idata 0.1.33 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -24
- data/README2.md +37 -0
- data/bin/ivalidate2 +426 -0
- data/full-pg-lawson.sh +707 -0
- data/full-pg.sh +153 -155
- data/full.sh +75 -5
- data/lib/idata/version.rb +1 -1
- data/sample.sh +13 -10
- metadata +18 -14
data/full-pg.sh
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# SHARED VARIABLES
|
4
4
|
# ---------------------------------------------------------------------------------
|
5
5
|
# Database to store data tables
|
6
|
-
ORGNAME="
|
6
|
+
ORGNAME="tiff20140805"
|
7
7
|
|
8
8
|
# ENV variables used by the validation command
|
9
9
|
export HOST="localhost"
|
@@ -16,13 +16,12 @@ export LISTEN=7432
|
|
16
16
|
OUTPUT_DIR="/tmp/$ORGNAME" && test -e $OUTPUT_DIR || mkdir $OUTPUT_DIR
|
17
17
|
|
18
18
|
# Input files and correspondings names
|
19
|
-
FCONTRACTO="
|
20
|
-
FVENDOR="
|
19
|
+
FCONTRACTO="ContractMaster.csv"
|
20
|
+
FVENDOR="VendorMaster.csv"
|
21
21
|
FITEM="ItemMaster.csv"
|
22
22
|
FINVOICE="InvoiceHistory.csv"
|
23
23
|
FMFR="MfrMaster.csv"
|
24
|
-
FPO="
|
25
|
-
FPO2="PurchaseOrder.csv"
|
24
|
+
FPO="PurchaseOrder.csv"
|
26
25
|
FUSER="User.csv"
|
27
26
|
FLOCATION="Location.csv"
|
28
27
|
FITEMCOST="ItemCostCenterAcctExceptions.csv"
|
@@ -38,7 +37,6 @@ ITEM="items"
|
|
38
37
|
INVOICE="invoices"
|
39
38
|
MFR="manufacturers"
|
40
39
|
PO="purchase_orders"
|
41
|
-
PO2="second_purchase_orders"
|
42
40
|
USER="users"
|
43
41
|
LOCATION="locations"
|
44
42
|
ITEMCOST="item_costs"
|
@@ -67,10 +65,8 @@ iload -i "$FITEM" -t "$ITEM" -f csv
|
|
67
65
|
#iload -i "$FINVOICE" -t "$INVOICE" -f csv
|
68
66
|
iload -i "$FMFR" -t "$MFR" -f csv
|
69
67
|
iload -i "$FPO" -t "$PO" -f csv
|
70
|
-
iload -i "$FPO2" -t "$PO2" -f csv
|
71
68
|
iload -i "$FUSER" -t "$USER" -f csv
|
72
69
|
iload -i "$FLOCATION" -t "$LOCATION" -f csv
|
73
|
-
#iload -i "$FITEMCOST" -t "$ITEMCOST" -f csv
|
74
70
|
iload -i "$FREQ" -t "$REQ" -f csv
|
75
71
|
iload -i "$FGL" -t "$GL" -f csv
|
76
72
|
iload -i "$FINVENTORY" -t "$INVENTORY" -f csv
|
@@ -100,22 +96,10 @@ UPDATE $ITEM set active = '1' where active = 'Y';
|
|
100
96
|
UPDATE items set active = '3' where active = 'N';
|
101
97
|
"
|
102
98
|
|
103
|
-
ipatch -q "
|
104
|
-
-- Extract FIRST_NAME, LAST_NAME from NAME
|
105
|
-
--ALTER TABLE $USER ADD COLUMN first_name varchar;
|
106
|
-
--ALTER TABLE $USER ADD COLUMN last_name varchar;
|
107
|
-
--UPDATE $USER SET username = trim(regexp_replace(username, '\s+', ' ', 'g'));
|
108
|
-
--UPDATE $USER SET first_name = username, last_name = username
|
109
|
-
--WHERE array_length(string_to_array(username, ' '), 1) = 1;
|
110
|
-
--UPDATE $USER SET first_name = substring(username, '^[^\s]+'),
|
111
|
-
-- last_name = regexp_replace(username, '^[^\s]+\s', '', 'g')
|
112
|
-
--WHERE array_length(string_to_array(username, ' '), 1) >= 2;
|
113
|
-
"
|
114
|
-
|
115
99
|
ipatch -q "
|
116
100
|
-- ADD EMAIL COLUMN
|
117
|
-
|
118
|
-
|
101
|
+
ALTER TABLE $USER ADD COLUMN email VARCHAR;
|
102
|
+
UPDATE $USER SET email = LOGIN_ID;
|
119
103
|
"
|
120
104
|
|
121
105
|
ipatch -q "
|
@@ -149,9 +133,15 @@ UPDATE $LOCATION SET stockless_ind = 'N' WHERE stockless_ind IS NULL OR LENGTH(t
|
|
149
133
|
# Convert A2A2A2 to A2-A2-A2
|
150
134
|
# Manual check and comment out the following to speed up validating
|
151
135
|
# @todo IEVAL performance is very poor, avoid using it (use IPATCH instead) unless there is no better way
|
136
|
+
ipatch -q "
|
137
|
+
alter table $GL add column old_fq_acct_no varchar;
|
138
|
+
update $GL set old_fq_acct_no = fq_acct_no;
|
139
|
+
"
|
140
|
+
|
152
141
|
ieval -t $GL --eval="
|
153
142
|
if item.corp_acct_fmt && item.corp_acct_fmt[/^[A-Z][0-9][A-Z][0-9][A-Z][0-9]$/]
|
154
143
|
item.corp_acct_fmt = item.corp_acct_fmt.unpack('a2a2a2').join('-')
|
144
|
+
item.fq_acct_no = item.fq_acct_no.unpack('a2a5a5').join('-')
|
155
145
|
end
|
156
146
|
"
|
157
147
|
|
@@ -163,7 +153,7 @@ ivalidate --case-insensitive --pretty -t $VENDOR \
|
|
163
153
|
--log-to=validation_errors \
|
164
154
|
--not-null="vendor_code" \
|
165
155
|
--not-null="vendor_name" \
|
166
|
-
--unique="vendor_code,vendor_name" \
|
156
|
+
--unique="vendor_code, vendor_name" \
|
167
157
|
--match="vendor_code/[a-zA-Z0-9]/" \
|
168
158
|
--match="vendor_name/[a-zA-Z0-9]/" \
|
169
159
|
--consistent-by="vendor_code|vendor_name" \
|
@@ -176,9 +166,11 @@ ivalidate --case-insensitive --pretty -t $MFR \
|
|
176
166
|
--log-to=validation_errors \
|
177
167
|
--not-null="mfr_number" \
|
178
168
|
--not-null="mfr_name" \
|
169
|
+
--unique="mfr_number, mfr_name" \
|
179
170
|
--match="mfr_number/[a-zA-Z0-9]/" \
|
180
171
|
--match="mfr_name/[a-zA-Z0-9]/" \
|
181
172
|
--consistent-by="mfr_name|mfr_number" \
|
173
|
+
--consistent-by="mfr_number|mfr_name" \
|
182
174
|
--consistent-by="country_code|country_name" \
|
183
175
|
--consistent-by="country_name|country_code"
|
184
176
|
|
@@ -201,19 +193,22 @@ ivalidate --case-insensitive --pretty -t $GL \
|
|
201
193
|
--match="exp_acct_no/[a-zA-Z0-9]/" \
|
202
194
|
--not-null=exp_acct_name \
|
203
195
|
--match="exp_acct_name/[a-zA-Z0-9]/" \
|
196
|
+
--not-null=fq_acct_no \
|
197
|
+
--unique=fq_acct_no \
|
198
|
+
--rquery="(fq_acct_no IS NOT NULL AND corp_acct_fmt IS NOT NULL AND fq_acct_no !~ ('^' || regexp_replace(replace(corp_acct_fmt, '-', '}-'), '(?=[abcABC])[A-Z]', '[0-9]{', 'g') || '}$')) -- Invalid fq_acct_no" \
|
204
199
|
--consistent-by="corp_acct_no|corp_acct_name" \
|
205
200
|
--consistent-by="corp_acct_name|corp_acct_no" \
|
206
201
|
--consistent-by="exp_acct_no|corp_acct_no, corp_acct_name, cc_acct_no, cc_acct_name, exp_acct_name" \
|
207
202
|
--consistent-by="exp_acct_name|corp_acct_no, corp_acct_name, cc_acct_no, cc_acct_name, exp_acct_no" \
|
208
|
-
--consistent-by="cc_acct_no|corp_acct_no, corp_acct_name, cc_acct_name" \
|
209
|
-
--consistent-by="cc_acct_name|corp_acct_no, corp_acct_name, cc_acct_no" \
|
203
|
+
--consistent-by="cc_acct_no|corp_acct_no, corp_acct_name, cc_acct_name, exp_acct_no, exp_acct_name" \
|
204
|
+
--consistent-by="cc_acct_name|corp_acct_no, corp_acct_name, cc_acct_no, exp_acct_no, exp_acct_name" \
|
210
205
|
--not-null=exp_acct_type \
|
211
206
|
--match="exp_acct_type/^(1|2|3|4|5|Asset|Liability|Equity|Income\sStatement|Expense|Income)$/"
|
212
207
|
|
213
208
|
# validate LOCATION
|
214
209
|
ivalidate --case-insensitive --pretty -t $LOCATION \
|
215
210
|
--log-to=validation_errors \
|
216
|
-
--not-null=loc_id \
|
211
|
+
--not-null="loc_id" \
|
217
212
|
--match="loc_id/[a-zA-Z0-9]/" \
|
218
213
|
--not-null="name" \
|
219
214
|
--match="name/[a-zA-Z0-9]/" \
|
@@ -221,35 +216,31 @@ ivalidate --case-insensitive --pretty -t $LOCATION \
|
|
221
216
|
--match="facility_code/[a-zA-Z0-9]/" \
|
222
217
|
--not-null=facility_desc \
|
223
218
|
--match="facility_desc/[a-zA-Z0-9]/" \
|
224
|
-
--match="ship_to_ind/^(Y|N)$/" \
|
225
|
-
--match="bill_to_ind/^(Y|N)$/" \
|
226
|
-
--match="stockless_ind/^(Y|N)$/" \
|
227
|
-
--not-null=loc_type \
|
219
|
+
--match="ship_to_ind/^(Y|N|y|n)$/" \
|
220
|
+
--match="bill_to_ind/^(Y|N|y|n)$/" \
|
221
|
+
--match="stockless_ind/^(Y|N|y|n)$/" \
|
222
|
+
--not-null="loc_type" \
|
228
223
|
--match="loc_type/^(C|S|LOC_TYPE_SUPPLY|LOC_TYPE_CONSUME)$/" \
|
229
|
-
--not-null=inventory_path_name \
|
230
|
-
--not-null=inventory_location_name \
|
231
|
-
--query="(route_no is null or route_no = '' or regexp_replace(route_no, '[,\.]', '', 'g') ~ '^[1-9][0-9]+$') -- invalid route_no" \
|
232
224
|
--rquery="(loc_type ~* '^(LOC_TYPE_SUPPLY|S)$' and (corp_acct_no is null or corp_name is null or corp_id is null)) -- either corp id/name or corp_acct_no is null" \
|
233
|
-
--not-null=active \
|
234
|
-
--match="active/^(Y|N)$/" \
|
235
|
-
--not-null=corp_acct_no \
|
225
|
+
--not-null="active" \
|
226
|
+
--match="active/^(Y|N|1|2|3)$/" \
|
236
227
|
--match="corp_acct_no/[a-zA-Z0-9]/" \
|
237
|
-
--
|
238
|
-
--
|
239
|
-
--match="route_no
|
228
|
+
--rquery="((inventory_path_name != '' AND inventory_path_name IS NOT NULL AND lower(inventory_path_name) != 'default') AND (inventory_loc_seq_no IS NULL OR inventory_loc_seq_no = '')) -- [inventory_loc_seq_no] is null" \
|
229
|
+
--rquery="((inventory_path_name != '' AND inventory_path_name IS NOT NULL AND lower(inventory_path_name) != 'default') AND (inventory_location_name IS NULL OR inventory_location_name = '')) -- [inventory_location_name] is null" \
|
230
|
+
--match="route_no/[a-zA-Z0-9]/" \
|
240
231
|
--match="route_name/[a-zA-Z0-9]/" \
|
241
232
|
--match="corp_name/[a-zA-Z0-9]/" \
|
242
233
|
--consistent-by="corp_name|corp_id" \
|
243
234
|
--consistent-by="corp_id|corp_name" \
|
244
235
|
--consistent-by="name|facility_code, loc_id" \
|
245
236
|
--consistent-by="loc_id|facility_code, name" \
|
246
|
-
--cross-reference="inventory_path_name|$LOCATION.name" \
|
247
237
|
--cross-reference="inventory_location_name|$LOCATION.name" \
|
248
238
|
--cross-reference="corp_id|$GL.corp_acct_no" \
|
249
239
|
--cross-reference="corp_name|$GL.corp_acct_name"
|
250
240
|
|
251
241
|
|
252
242
|
# validate CONTRACTS ORIGINAL
|
243
|
+
# @note Check unique keyset with item_id included for MSCM only
|
253
244
|
ivalidate --case-insensitive --pretty -t $CONTRACTO \
|
254
245
|
--log-to=validation_errors \
|
255
246
|
--not-null=contract_number \
|
@@ -259,16 +250,21 @@ ivalidate --case-insensitive --pretty -t $CONTRACTO \
|
|
259
250
|
--not-null=mfr_item_id \
|
260
251
|
--not-null=mfr_name \
|
261
252
|
--not-null=item_uom \
|
253
|
+
--not-null=corp_id \
|
254
|
+
--not-null=item_descr \
|
262
255
|
--not-null=item_qoe \
|
263
256
|
--not-null=contract_price \
|
264
|
-
--not-null=
|
257
|
+
--not-null=contract_gpo_id \
|
265
258
|
--match="contract_number/[a-zA-Z0-9]/" \
|
259
|
+
--match="contract_gpo_name/[a-zA-Z0-9]/" \
|
260
|
+
--match="corp_id/[a-zA-Z0-9]/" \
|
266
261
|
--match="corp_name/[a-zA-Z0-9]/" \
|
267
262
|
--match="vendor_item_id/[a-zA-Z0-9]/" \
|
268
263
|
--match="vendor_name/[a-zA-Z0-9]/" \
|
269
264
|
--match="mfr_item_id/[a-zA-Z0-9]/" \
|
270
265
|
--match="mfr_name/[a-zA-Z0-9]/" \
|
271
|
-
--
|
266
|
+
--rquery="(lower(mfr_name) = 'unknown' AND mfr_number IS NULL) -- Unknown mfr_name" \
|
267
|
+
--query="to_date(contract_end, 'YYYY-MM-DD') >= to_date(contract_start, 'YYYY-MM-DD') -- [contract_end] comes before [contract_start]" \
|
272
268
|
--match="contract_status/^(1|2|3|A|I|Inactive|Active|Y)$/" \
|
273
269
|
--match="item_status/^(1|2|3|A|I|Inactive|Active|Y)$/" \
|
274
270
|
--consistent-by="corp_id|corp_name" \
|
@@ -283,7 +279,7 @@ ivalidate --case-insensitive --pretty -t $CONTRACTO \
|
|
283
279
|
--match="contract_price/^[0-9]+(\.{0,1}[0-9]+|[0-9]*)$/" \
|
284
280
|
--match="item_qoe/^[0-9]+(\.{0,1}[0-9]+|[0-9]*)$/" \
|
285
281
|
--rquery="(item_uom NOT IN (SELECT code FROM uomstd) AND item_uom !~ '^[a-zA-Z0-9]{1,3}$') -- invalid item_uom" \
|
286
|
-
--unique="contract_gpo_name, contract_number, contract_start, contract_end, vendor_name, mfr_item_id, mfr_name, item_uom, corp_id" \
|
282
|
+
--unique="contract_gpo_name, contract_number, contract_start, contract_end, vendor_name, mfr_item_id, mfr_name, item_uom, corp_id, item_id" \
|
287
283
|
|
288
284
|
# validate ITEM
|
289
285
|
# Accepted:
|
@@ -312,6 +308,8 @@ ivalidate --case-insensitive --pretty -t $ITEM \
|
|
312
308
|
--match="mfr_number/[a-zA-Z0-9]/" \
|
313
309
|
--match="mfr_name/[a-zA-Z0-9]/" \
|
314
310
|
--match="active/^(1|2|3|A|I)$/" \
|
311
|
+
--rquery="(lower(mfr_name) = 'unknown' AND mfr_number IS NULL) -- Unknown mfr_name" \
|
312
|
+
--unique="item_id, corp_id, vendor_code, item_uom" \
|
315
313
|
--cross-reference="vendor_code|$VENDOR.vendor_code" \
|
316
314
|
--cross-reference="vendor_name|$VENDOR.vendor_name" \
|
317
315
|
--cross-reference="mfr_number|$MFR.mfr_number" \
|
@@ -331,82 +329,38 @@ ivalidate --case-insensitive --pretty -t $ITEM \
|
|
331
329
|
# validate PO
|
332
330
|
ivalidate --case-insensitive --pretty -t $PO \
|
333
331
|
--log-to=validation_errors \
|
334
|
-
--not-null=po_no \
|
335
|
-
--match="po_no/[a-zA-Z0-9]/" \
|
336
|
-
--not-null=po_date \
|
337
|
-
--not-null=corp_id \
|
338
|
-
--match="corp_id/[a-zA-Z0-9]/" \
|
339
|
-
--not-null=corp_name \
|
340
|
-
--match="corp_name/[a-zA-Z0-9]/" \
|
341
|
-
--not-null=Paragon_Cost_Center_Acct \
|
342
|
-
--match="Paragon_Cost_Center_Acct/[a-zA-Z0-9]/" \
|
343
|
-
--not-null=cost_center_name \
|
344
|
-
--match="cost_center_name/[a-zA-Z0-9]/" \
|
345
|
-
--not-null=PO_Line_No \
|
346
|
-
--match="PO_Line_No/^[1-9][0-9]*$/" \
|
347
|
-
--not-null=item_id \
|
348
|
-
--match="item_id/[a-zA-Z0-9]/" \
|
349
|
-
--not-null=vendor_name \
|
350
|
-
--match="vendor_name/[a-zA-Z0-9]/" \
|
351
|
-
--not-null=Paragon_Vendor_Code \
|
352
|
-
--match="Paragon_Vendor_Code/[a-zA-Z0-9]/" \
|
353
|
-
--match="mfr_name/[a-zA-Z0-9]/" \
|
354
|
-
--not-null=mfr_number \
|
355
|
-
--match="mfr_number/[a-zA-Z0-9]/" \
|
356
|
-
--not-null=item_descr \
|
357
|
-
--consistent-by="corp_id|corp_name" \
|
358
|
-
--consistent-by="corp_name|corp_id" \
|
359
|
-
--consistent-by="Paragon_Vendor_Code|vendor_name" \
|
360
|
-
--consistent-by="vendor_name|Paragon_Vendor_Code" \
|
361
|
-
--consistent-by="mfr_name|mfr_number" \
|
362
|
-
--unique="po_no, PO_Line_No" \
|
363
|
-
--rquery="(item_id not like '%~%' and item_id not in (select item_id from items)) -- item_id does not reference items.item_id" \
|
364
|
-
--cross-reference="Paragon_Vendor_Code|$VENDOR.vendor_code" \
|
365
|
-
--cross-reference="vendor_name|$VENDOR.vendor_name" \
|
366
|
-
--cross-reference="mfr_number|$MFR.mfr_number" \
|
367
|
-
--cross-reference="mfr_name|$MFR.mfr_name" \
|
368
|
-
--cross-reference="corp_id|$GL.corp_acct_no" \
|
369
|
-
--cross-reference="corp_name|$GL.corp_acct_name" \
|
370
|
-
--cross-reference="Paragon_Cost_Center_Acct|$GL.cc_acct_no" \
|
371
|
-
--cross-reference="cost_center_name|$GL.cc_acct_name" \
|
372
|
-
--rquery="(purchase_uom NOT IN (SELECT code FROM uomstd) AND purchase_uom !~ '^[a-zA-Z0-9]{1,3}$') -- invalid purchase_uom" \
|
373
|
-
--rquery="(item_id IS NOT NULL AND (Paragon_Vendor_Code IS NOT NULL OR vendor_name IS NOT NULL) AND vendor_item_id IS NULL) -- vendor_item_id is null" \
|
374
|
-
--match="purchase_price/^[0-9]+(\.{0,1}[0-9]+|[0-9]*)$/" \
|
375
|
-
--match="purchase_qoe/^[0-9]+(\.{0,1}[0-9]+|[0-9]*)$/"
|
376
|
-
|
377
|
-
ivalidate --case-insensitive --pretty -t $PO2 \
|
378
|
-
--log-to=validation_errors \
|
379
|
-
--not-null=po_no \
|
332
|
+
--not-null="po_no" \
|
380
333
|
--match="po_no/[a-zA-Z0-9]/" \
|
381
|
-
--not-null=po_date \
|
382
|
-
--not-null=corp_id \
|
334
|
+
--not-null="po_date" \
|
335
|
+
--not-null="corp_id" \
|
383
336
|
--match="corp_id/[a-zA-Z0-9]/" \
|
384
|
-
--not-null=corp_name \
|
337
|
+
--not-null="corp_name" \
|
385
338
|
--match="corp_name/[a-zA-Z0-9]/" \
|
386
|
-
--not-null=cost_center_id \
|
339
|
+
--not-null="cost_center_id" \
|
387
340
|
--match="cost_center_id/[a-zA-Z0-9]/" \
|
388
|
-
--not-null=cost_center_name \
|
341
|
+
--not-null="cost_center_name" \
|
389
342
|
--match="cost_center_name/[a-zA-Z0-9]/" \
|
390
|
-
--not-null=
|
391
|
-
--match="
|
392
|
-
--not-null=item_id \
|
343
|
+
--not-null="po_line_number" \
|
344
|
+
--match="po_line_number/^[1-9][0-9]*$/" \
|
345
|
+
--not-null="item_id" \
|
393
346
|
--match="item_id/[a-zA-Z0-9]/" \
|
394
|
-
--not-null=vendor_name \
|
347
|
+
--not-null="vendor_name" \
|
395
348
|
--match="vendor_name/[a-zA-Z0-9]/" \
|
396
|
-
--not-null=vendor_code \
|
349
|
+
--not-null="vendor_code" \
|
397
350
|
--match="vendor_code/[a-zA-Z0-9]/" \
|
398
|
-
--not-null=mfr_name \
|
351
|
+
--not-null="mfr_name" \
|
399
352
|
--match="mfr_name/[a-zA-Z0-9]/" \
|
400
|
-
--not-null=mfr_number \
|
353
|
+
--not-null="mfr_number" \
|
401
354
|
--match="mfr_number/[a-zA-Z0-9]/" \
|
402
|
-
--not-null=item_descr \
|
355
|
+
--not-null="item_descr" \
|
403
356
|
--consistent-by="corp_id|corp_name" \
|
404
357
|
--consistent-by="corp_name|corp_id" \
|
405
358
|
--consistent-by="vendor_code|vendor_name" \
|
406
359
|
--consistent-by="vendor_name|vendor_code" \
|
407
360
|
--consistent-by="mfr_name|mfr_number" \
|
408
|
-
--unique="po_no,
|
409
|
-
--rquery="(
|
361
|
+
--unique="po_no, po_line_number" \
|
362
|
+
--rquery="(lower(mfr_name) = 'unknown' AND mfr_number IS NULL) -- Unknown mfr_name" \
|
363
|
+
--rquery="(item_id not like '%~%' and item_id not in (select item_id from items)) -- [item_id] does not reference [items.item_id]" \
|
410
364
|
--cross-reference="vendor_code|$VENDOR.vendor_code" \
|
411
365
|
--cross-reference="vendor_name|$VENDOR.vendor_name" \
|
412
366
|
--cross-reference="mfr_number|$MFR.mfr_number" \
|
@@ -415,12 +369,16 @@ ivalidate --case-insensitive --pretty -t $PO2 \
|
|
415
369
|
--cross-reference="corp_name|$GL.corp_acct_name" \
|
416
370
|
--cross-reference="cost_center_id|$GL.cc_acct_no" \
|
417
371
|
--cross-reference="cost_center_name|$GL.cc_acct_name" \
|
418
|
-
--rquery="(purchase_uom NOT IN (SELECT code FROM uomstd) AND purchase_uom !~ '^[a-zA-Z0-9]{1,3}$') -- invalid purchase_uom" \
|
419
|
-
--rquery="(item_id IS
|
372
|
+
--rquery="(purchase_uom NOT IN (SELECT code FROM uomstd) AND purchase_uom !~ '^[a-zA-Z0-9]{1,3}$') -- invalid [purchase_uom]" \
|
373
|
+
--rquery="((item_id IS NULL OR item_id !~ '[a-zA-Z0-9]') AND (vendor_item_id IS NULL OR vendor_item_id !~ '[a-zA-Z0-9]')) -- [vendor_item_id] is either null or invalid" \
|
420
374
|
--match="purchase_price/^[0-9]+(\.{0,1}[0-9]+|[0-9]*)$/" \
|
421
375
|
--match="purchase_qoe/^[0-9]+(\.{0,1}[0-9]+|[0-9]*)$/"
|
422
376
|
|
377
|
+
# do not check --match="item_descr/[a-zA-Z0-9]/" \
|
378
|
+
|
423
379
|
# validate Req
|
380
|
+
# --consistent-by="corp_id|corp_name" \
|
381
|
+
# --consistent-by="corp_name|corp_id" \
|
424
382
|
ivalidate --case-insensitive --pretty -t $REQ \
|
425
383
|
--log-to=validation_errors \
|
426
384
|
--not-null="req_no" \
|
@@ -431,6 +389,8 @@ ivalidate --case-insensitive --pretty -t $REQ \
|
|
431
389
|
--match="corp_id/[a-zA-Z0-9]/" \
|
432
390
|
--not-null="corp_name" \
|
433
391
|
--match="corp_name/[a-zA-Z0-9]/" \
|
392
|
+
--not-null="costcenter_id" \
|
393
|
+
--match="costcenter_id/[a-zA-Z0-9]/" \
|
434
394
|
--not-null="req_line_number" \
|
435
395
|
--match="req_line_number/^[1-9][0-9]*$/" \
|
436
396
|
--not-null="item_id" \
|
@@ -439,13 +399,7 @@ ivalidate --case-insensitive --pretty -t $REQ \
|
|
439
399
|
--match="vendor_name/[a-zA-Z0-9]/" \
|
440
400
|
--not-null="vendor_code" \
|
441
401
|
--match="vendor_code/[a-zA-Z0-9]/" \
|
442
|
-
--
|
443
|
-
--match="mfr_name/[a-zA-Z0-9]/" \
|
444
|
-
--not-null="item_descr" \
|
445
|
-
--match="item_descr/[a-zA-Z0-9]/" \
|
446
|
-
--consistent-by="corp_id|corp_name" \
|
447
|
-
--consistent-by="corp_name|corp_id" \
|
448
|
-
--rquery="(item_id not like '%~[%' and item_id not in (select item_id from items)) -- item_id does not reference items.item_id" \
|
402
|
+
--rquery="(item_id not like '%~%' and item_id not in (select item_id from items)) -- item_id does not reference items.item_id" \
|
449
403
|
--cross-reference="corp_id|$GL.corp_acct_no" \
|
450
404
|
--cross-reference="corp_name|$GL.corp_acct_name" \
|
451
405
|
--cross-reference="vendor_name|$VENDOR.vendor_name" \
|
@@ -460,20 +414,8 @@ ivalidate --case-insensitive --pretty -t $USER \
|
|
460
414
|
--log-to=validation_errors \
|
461
415
|
--not-null="email" \
|
462
416
|
--unique="email" \
|
463
|
-
--
|
464
|
-
|
465
|
-
# validate
|
466
|
-
#ivalidate --case-insensitive --pretty -t $ITEMCOST \
|
467
|
-
# --log-to=validation_errors \
|
468
|
-
# --not-null="corp_acct_no" \
|
469
|
-
# --match="corp_acct_no/[a-zA-Z0-9]/" \
|
470
|
-
# --not-null="item_no" \
|
471
|
-
# --match="item_no/[a-zA-Z0-9]/" \
|
472
|
-
# --not-null="excp_type" \
|
473
|
-
# --match="excp_type/^(A|R)$/" \
|
474
|
-
# --cross-reference="corp_acct_no|$GL.corp_acct_no" \
|
475
|
-
# --cross-reference="item_no|$ITEM.item_id" \
|
476
|
-
# --cross-reference="exp_acct_no|$GL.exp_acct_no"
|
417
|
+
--match="lower(email)/[a-z0-9][a-z0-9_\.]+@[a-z0-9][a-z0-9_\.\-]+\.[a-z0-9_\.\-]+/"
|
418
|
+
|
477
419
|
|
478
420
|
# validate INVENTORY
|
479
421
|
ivalidate --case-insensitive --pretty -t $INVENTORY \
|
@@ -484,15 +426,11 @@ ivalidate --case-insensitive --pretty -t $INVENTORY \
|
|
484
426
|
--match="loc_id/[a-zA-Z0-9]/" \
|
485
427
|
--not-null="vendor_code" \
|
486
428
|
--match="vendor_code/[a-zA-Z0-9]/" \
|
487
|
-
--not-null="vendor_name" \
|
488
|
-
--match="vendor_name/[a-zA-Z0-9]/" \
|
489
429
|
--not-null="corp_id" \
|
490
|
-
--match="
|
491
|
-
--not-null="location_name" \
|
430
|
+
--match="corp_id/[a-zA-Z0-9]/" \
|
492
431
|
--match="location_name/[a-zA-Z0-9]/" \
|
493
432
|
--not-null="item_id" \
|
494
|
-
--match="
|
495
|
-
--match="inventory_status/^(Active|Pending Inactive|Inactive)$/" \
|
433
|
+
--match="inventory_status/^(Active|Pending Inactive|Inactive|1|2|3)$/" \
|
496
434
|
--cross-reference="item_id|$ITEM.item_id" \
|
497
435
|
--cross-reference="location_name|$LOCATION.name" \
|
498
436
|
--cross-reference="vendor_code|$VENDOR.vendor_code" \
|
@@ -502,7 +440,7 @@ ivalidate --case-insensitive --pretty -t $INVENTORY \
|
|
502
440
|
|
503
441
|
ivalidate --case-insensitive --pretty -t $ULPR \
|
504
442
|
--log-to=validation_errors \
|
505
|
-
--match="Default_Indicator/^(Y|N|y|n)$/" \
|
443
|
+
--match="Default_Indicator/^(Y|N|y|n|Y|N)$/" \
|
506
444
|
--not-null="email" \
|
507
445
|
--cross-reference="email|$USER.email" \
|
508
446
|
--cross-reference="loc_id|$LOCATION.loc_id" \
|
@@ -515,7 +453,7 @@ ivalidate --case-insensitive --pretty -t $LPR \
|
|
515
453
|
--not-null="Default_Inventory_Location_Name" \
|
516
454
|
--cross-reference="Default_Inventory_Location_Name|$LOCATION.Inventory_Location_Name" \
|
517
455
|
--match="loc_type/^(C|LOC_TYPE_CONSUME)$/" \
|
518
|
-
--match="active/^(1|2|3|A|I)$/" \
|
456
|
+
--match="active/^(1|2|3|A|I|Y|N)$/" \
|
519
457
|
--cross-reference="item_id|$ITEM.item_id" \
|
520
458
|
--cross-reference="corp_acct_no|$GL.corp_acct_no" \
|
521
459
|
--cross-reference="corp_name|$GL.corp_acct_name" \
|
@@ -528,14 +466,6 @@ ivalidate --case-insensitive --pretty -t $LPR \
|
|
528
466
|
# Create report file for every table (extract 1000 records for every error)
|
529
467
|
# These file will then be used for the Validation Report
|
530
468
|
####################################################
|
531
|
-
|
532
|
-
#iexport -t $ITEMCOST \
|
533
|
-
# -o "$OUTPUT_DIR/$ITEMCOST.csv" -f csv --no-quote-empty --quotes --headers \
|
534
|
-
# --query="select * from (select ROW_NUMBER() OVER (PARTITION BY error) AS group_index, *
|
535
|
-
# FROM ( select unnest(string_to_array(validation_errors, ' || ')) as error, * from
|
536
|
-
# $ITEMCOST order by id ) as main) as tmp
|
537
|
-
# where group_index <= 1000" \
|
538
|
-
# --exclude="id, validation_errors, group_index"
|
539
469
|
|
540
470
|
iexport -t $CONTRACTO \
|
541
471
|
-o "$OUTPUT_DIR/$CONTRACTO.csv" -f csv --no-quote-empty --quotes --headers \
|
@@ -577,14 +507,6 @@ iexport -t $PO \
|
|
577
507
|
where group_index <= 1000" \
|
578
508
|
--exclude="id, validation_errors, group_index"
|
579
509
|
|
580
|
-
iexport -t $PO2 \
|
581
|
-
-o "$OUTPUT_DIR/$PO2.csv" -f csv --no-quote-empty --quotes --headers \
|
582
|
-
--query="select * from (select ROW_NUMBER() OVER (PARTITION BY error) AS group_index, *
|
583
|
-
FROM ( select unnest(string_to_array(validation_errors, ' || ')) as error, * from
|
584
|
-
$PO2 order by id ) as main) as tmp
|
585
|
-
where group_index <= 1000" \
|
586
|
-
--exclude="id, validation_errors, group_index"
|
587
|
-
|
588
510
|
iexport -t $INVENTORY \
|
589
511
|
-o "$OUTPUT_DIR/$INVENTORY.csv" -f csv --no-quote-empty --quotes --headers \
|
590
512
|
--query="select * from (select ROW_NUMBER() OVER (PARTITION BY error) AS group_index, *
|
@@ -651,11 +573,9 @@ iexport --output="$OUTPUT_DIR/summary.csv" -f csv --no-quote-empty --quotes --he
|
|
651
573
|
(select 'ReqHistoryLoad' as input_file, unnest(string_to_array(validation_errors, ' || ')) as error, count(*), round((count(*) * 100)::numeric / (select count(*) from $REQ), 2)::varchar || '%' as percentage from $REQ group by error order by error) union
|
652
574
|
(select 'MfrMaster' as input_file, unnest(string_to_array(validation_errors, ' || ')) as error, count(*), round((count(*) * 100)::numeric / (select count(*) from $MFR), 2)::varchar || '%' as percentage from $MFR group by error order by error) union
|
653
575
|
(select 'PurchaseOrder' as input_file, unnest(string_to_array(validation_errors, ' || ')) as error, count(*), round((count(*) * 100)::numeric / (select count(*) from $PO), 2)::varchar || '%' as percentage from $PO group by error order by error) union
|
654
|
-
(select 'PurchaseOrder2' as input_file, unnest(string_to_array(validation_errors, ' || ')) as error, count(*), round((count(*) * 100)::numeric / (select count(*) from $PO2), 2)::varchar || '%' as percentage from $PO2 group by error order by error) union
|
655
576
|
(select 'Inventory' as input_file, unnest(string_to_array(validation_errors, ' || ')) as error, count(*), round((count(*) * 100)::numeric / (select count(*) from $INVENTORY), 2)::varchar || '%' as percentage from $INVENTORY group by error order by error) union
|
656
577
|
(select 'User' as input_file, unnest(string_to_array(validation_errors, ' || ')) as error, count(*), round((count(*) * 100)::numeric / (select count(*) from $USER), 2)::varchar || '%' as percentage from $USER group by error order by error) union
|
657
578
|
(select 'Location' as input_file, unnest(string_to_array(validation_errors, ' || ')) as error, count(*), round((count(*) * 100)::numeric / (select count(*) from $LOCATION), 2)::varchar || '%' as percentage from $LOCATION group by error order by error) union
|
658
|
-
--(select 'ItemCost' as input_file, unnest(string_to_array(validation_errors, ' || ')) as error, count(*), round((count(*) * 100)::numeric / (select count(*) from $ITEMCOST), 2)::varchar || '%' as percentage from $ITEMCOST group by error order by error) union
|
659
579
|
(select 'GLAccount' as input_file, unnest(string_to_array(validation_errors, ' || ')) as error, count(*), round((count(*) * 100)::numeric / (select count(*) from $GL), 2)::varchar || '%' as percentage from $GL group by error order by error) union
|
660
580
|
(select 'UserLocationProfile' as input_file, unnest(string_to_array(validation_errors, ' || ')) as error, count(*), round((count(*) * 100)::numeric / (select count(*) from $ULPR), 2)::varchar || '%' as percentage from $ULPR group by error order by error) union
|
661
581
|
(select 'LocationProfile' as input_file, unnest(string_to_array(validation_errors, ' || ')) as error, count(*), round((count(*) * 100)::numeric / (select count(*) from $LPR), 2)::varchar || '%' as percentage from $LPR group by error order by error)"
|
@@ -667,8 +587,8 @@ imerge --output=$OUTPUT_DIR/$ORGNAME.xls \
|
|
667
587
|
--input="ContractMaster:$OUTPUT_DIR/$CONTRACTO.csv" \
|
668
588
|
--input="ItemMaster:$OUTPUT_DIR/$ITEM.csv" \
|
669
589
|
--input="MfrMaster:$OUTPUT_DIR/$MFR.csv" \
|
590
|
+
--input="VendorMaster:$OUTPUT_DIR/$VENDOR.csv" \
|
670
591
|
--input="PurchaseOrder:$OUTPUT_DIR/$PO.csv" \
|
671
|
-
--input="PurchaseOrder2:$OUTPUT_DIR/$PO2.csv" \
|
672
592
|
--input="User:$OUTPUT_DIR/$USER.csv" \
|
673
593
|
--input="Location:$OUTPUT_DIR/$LOCATION.csv" \
|
674
594
|
--input="ReqHistoryLoad:$OUTPUT_DIR/$REQ.csv" \
|
@@ -677,4 +597,82 @@ imerge --output=$OUTPUT_DIR/$ORGNAME.xls \
|
|
677
597
|
--input="$ULPR:$OUTPUT_DIR/$ULPR.csv" \
|
678
598
|
--input="$LPR:$OUTPUT_DIR/$LPR.csv"
|
679
599
|
|
680
|
-
|
600
|
+
####################################################
|
601
|
+
# EXPORT FOR UPLOADING
|
602
|
+
####################################################
|
603
|
+
|
604
|
+
ipatch -q "
|
605
|
+
DELETE FROM purchase_orders where validation_errors ilike '%[po_no, po_line_number] is not unique%';
|
606
|
+
DELETE FROM purchase_orders where validation_errors ilike '%[item_id] does not reference [items.item_id]%';
|
607
|
+
|
608
|
+
DELETE FROM users where validation_errors ilike '%email is null%';
|
609
|
+
DELETE FROM user_location_profiles where validation_errors ilike '%email is null%';
|
610
|
+
"
|
611
|
+
|
612
|
+
|
613
|
+
|
614
|
+
iexport -t $ITEMCOST \
|
615
|
+
-o "$OUTPUT_DIR/$ITEMCOST.csv" -f csv --no-quote-empty --no-quotes --headers --delim=$'\t' \
|
616
|
+
--exclude="id, validation_errors"
|
617
|
+
|
618
|
+
iexport -t $CONTRACTO \
|
619
|
+
-o "$OUTPUT_DIR/$CONTRACTO.csv" -f csv --no-quote-empty --no-quotes --headers --delim=$'\t' \
|
620
|
+
--exclude="id, validation_errors"
|
621
|
+
|
622
|
+
iexport -t $VENDOR \
|
623
|
+
-o "$OUTPUT_DIR/$VENDOR.csv" -f csv --no-quote-empty --quotes --headers --delim=$'\t' \
|
624
|
+
--exclude="id, validation_errors"
|
625
|
+
|
626
|
+
iexport -t $MFR \
|
627
|
+
-o "$OUTPUT_DIR/$MFR.csv" -f csv --no-quote-empty --quotes --headers --delim=$'\t' \
|
628
|
+
--exclude="id, validation_errors"
|
629
|
+
|
630
|
+
iexport -t $GL \
|
631
|
+
-o "$OUTPUT_DIR/$GL.csv" -f csv --no-quote-empty --quotes --headers --delim=$'\t' \
|
632
|
+
--exclude="id, validation_errors"
|
633
|
+
|
634
|
+
iexport -t $PO \
|
635
|
+
-o "$OUTPUT_DIR/$PO.csv" -f csv --no-quote-empty --no-quotes --headers --delim=$'\t' \
|
636
|
+
--exclude="id, validation_errors"
|
637
|
+
|
638
|
+
iexport -t $INVENTORY \
|
639
|
+
-o "$OUTPUT_DIR/$INVENTORY.csv" -f csv --no-quote-empty --quotes --headers --delim=$'\t' \
|
640
|
+
--exclude="id, validation_errors"
|
641
|
+
|
642
|
+
iexport -t $REQ \
|
643
|
+
-o "$OUTPUT_DIR/$REQ.csv" -f csv --no-quote-empty --quotes --headers --delim=$'\t' \
|
644
|
+
--exclude="id, validation_errors"
|
645
|
+
|
646
|
+
iexport -t $ITEM \
|
647
|
+
-o "$OUTPUT_DIR/$ITEM.csv" -f csv --no-quote-empty --no-quotes --headers --delim=$'\t' \
|
648
|
+
--query="select item_id, item_descr,vendor_name,vendor_code,vendor_item_id,mfr_name,mfr_number,mfr_item_id,corp_id,corp_name, active, array_to_string(array_agg(item_uom), ',') item_uom, array_to_string(array_agg(item_qoe),',') item_qoe,array_to_string(array_agg(item_price),',') item_price
|
649
|
+
from
|
650
|
+
(
|
651
|
+
select * from items order by item_id, item_descr,vendor_name,vendor_code,vendor_item_id,mfr_name,mfr_number,mfr_item_id,corp_id,corp_name, active, item_qoe::float desc
|
652
|
+
) abc
|
653
|
+
group by item_id, item_descr,vendor_name,vendor_code,vendor_item_id,mfr_name,mfr_number,mfr_item_id,corp_id,corp_name, active
|
654
|
+
" \
|
655
|
+
--exclude="id, validation_errors, group_index"
|
656
|
+
|
657
|
+
|
658
|
+
ipatch -q "
|
659
|
+
update users set phone = regexp_replace(phone, '[^0123456789]', '', 'g');
|
660
|
+
update users set phone = '1234567890' where phone is null or length(phone) < 10;
|
661
|
+
update users set first_name = username where length(first_name) < 2;
|
662
|
+
update users set last_name = username where length(last_name) < 2;
|
663
|
+
"
|
664
|
+
iexport -t $USER \
|
665
|
+
-o "$OUTPUT_DIR/$USER.csv" -f csv --no-quote-empty --no-quotes --no-headers --delim=',' \
|
666
|
+
--query="select first_name, last_name, phone, 0 as tmp1, -1 as tmp2, -1 as tmp3, -1 as tmp4, -1 as tmp5, email, '12345678' as passwd, 'Analyst' as tmp6 from users WHERE email IS NOT NULL AND length(email) > 0"
|
667
|
+
|
668
|
+
iexport -t $LOCATION \
|
669
|
+
-o "$OUTPUT_DIR/$LOCATION.csv" -f csv --no-quote-empty --quotes --headers --delim=$'\t' \
|
670
|
+
--exclude="id, validation_errors"
|
671
|
+
|
672
|
+
iexport -t $LPR \
|
673
|
+
-o "$OUTPUT_DIR/$LPR.csv" -f csv --no-quote-empty --quotes --headers --delim=$'\t' \
|
674
|
+
--exclude="id, validation_errors"
|
675
|
+
|
676
|
+
iexport -t $ULPR \
|
677
|
+
-o "$OUTPUT_DIR/$ULPR.csv" -f csv --no-quote-empty --quotes --headers --delim=$'\t' \
|
678
|
+
--exclude="id, validation_errors"
|