@@ -12,6 +12,17 @@ codeunit 139662 "GP Item Tests"
12
12
ItemDataMigrationFacade: Codeunit "Item Data Migration Facade";
13
13
GPItemMigrator: Codeunit "GP Item Migrator";
14
14
GPTestHelperFunctions: Codeunit "GP Test Helper Functions";
15
+ ItemNoSashBrshTok: Label ' 1 1/2\"SASH BRSH' , Locked = true;
16
+ ItemNoStepLadderTok: Label ' 4'' STEPLADDER' , Locked = true;
17
+ ItemNoKitComponentInvTok: Label ' KIT COMPONENT INV' , Locked = true;
18
+ ItemNoKitComponentSvcTok: Label ' KIT COMPONENT SVC' , Locked = true;
19
+ ItemNoKitTok: Label ' KIT' , Locked = true;
20
+ ItemNo12345ITEMNUMBERTok: Label ' 12345ITEMNUMBER!@#$%' , Locked = true;
21
+ ItemNumberItemInactiveTok: Label ' ITEM INACTIVE' , Locked = true;
22
+ ItemNoItemDiscontinuedTok: Label ' ITEM DISCONTINUED' , Locked = true;
23
+ ItemClassesIdTest1Tok: Label ' TEST-1' , Locked = true;
24
+ ItemClassIdTest2Tok: Label ' TEST-2' , Locked = true;
25
+ PostingGroupGPTok: Label ' GP' , Locked = true;
15
26
16
27
[Test]
17
28
[TransactionModel ( TransactionModel ::AutoRollback) ]
@@ -50,11 +61,10 @@ codeunit 139662 "GP Item Tests"
50
61
HelperFunctions. CreatePostMigrationData() ;
51
62
52
63
// [THEN] An Item is created for all configured staging table entries
53
- Assert. RecordCount( Item, 7 ) ;
54
64
Assert. AreEqual( Item. Count () , HelperFunctions. GetNumberOfItems() , ' Wrong number of Items calculated' ) ;
55
65
56
66
// [THEN] Items are created with correct settings
57
- GPItem. Get( ' 1 1/2\"SASH BRSH ' ) ;
67
+ GPItem. Get( ItemNoSashBrshTok ) ;
58
68
Item. Get( GPItem. No) ;
59
69
Assert. AreEqual( GPItem. No, Item. "No.", ' Item No. not set' ) ;
60
70
Assert. AreEqual( 0.00 , Item. "Unit Price", ' Unit Price set' ) ;
@@ -67,7 +77,7 @@ codeunit 139662 "GP Item Tests"
67
77
Assert. AreEqual( GPItem. SearchDescription, Item. "Search Description", ' Search Description not set.' ) ;
68
78
Assert. AreEqual( GPItem. PurchUnitOfMeasure, Item. "Purch. Unit of Measure", ' Purch. Unit of Measure not set.' ) ;
69
79
70
- GPItem. Get( ' 4 '' STEPLADDER ' ) ;
80
+ GPItem. Get( ItemNoStepLadderTok ) ;
71
81
Item. Get( GPItem. No) ;
72
82
Assert. AreEqual( GPItem. No, Item. "No.", ' Item No. not set' ) ;
73
83
Assert. AreEqual( 0.00 , Item. "Unit Price", ' Unit Price set' ) ;
@@ -147,7 +157,7 @@ codeunit 139662 "GP Item Tests"
147
157
until GPItem. Next() = 0 ;
148
158
149
159
// [then] Then the Inventory Posting Groups will NOT be migrated
150
- InventoryPostingGroup. SetFilter( "Code", ' %1|%2' , ' TEST-1 ' , ' TEST-2 ' ) ;
160
+ InventoryPostingGroup. SetFilter( "Code", ' %1|%2' , ItemClassesIdTest1Tok, ItemClassIdTest2Tok ) ;
151
161
Assert. RecordCount( InventoryPostingGroup, 0 ) ;
152
162
end ;
153
163
@@ -180,43 +190,43 @@ codeunit 139662 "GP Item Tests"
180
190
Assert. RecordCount( GPIV00101, 8 ) ;
181
191
Assert. RecordCount( GPIV40400, 2 ) ;
182
192
183
- Assert. IsTrue( GPIV00101. Get( ' 1 1/2\"SASH BRSH ' ) , ' Could not locate item.' ) ;
184
- Assert. AreEqual( ' TEST-1 ' , GPIV00101. ITMCLSCD, ' Incorrect class Id' ) ;
185
- Assert. IsTrue( GPIV40400. Get( ' TEST-1 ' ) , ' Could not class Id.' ) ;
193
+ Assert. IsTrue( GPIV00101. Get( ItemNoSashBrshTok ) , ' Could not locate item.' ) ;
194
+ Assert. AreEqual( ItemClassesIdTest1Tok , GPIV00101. ITMCLSCD, ' Incorrect class Id' ) ;
195
+ Assert. IsTrue( GPIV40400. Get( ItemClassesIdTest1Tok ) , ' Could not class Id.' ) ;
186
196
187
197
GPItem. FindSet() ;
188
198
repeat
189
199
Migrate( GPItem) ;
190
200
until GPItem. Next() = 0 ;
191
201
192
202
// [THEN] The Inventory Posting Groups will be migrated
193
- Item. SetFilter( "No.", ' %1|%2|%3' , ' 1 1/2\"SASH BRSH ' , ' 12345ITEMNUMBER!@#$% ' , ' 4 '' STEPLADDER ' ) ;
203
+ Item. SetFilter( "No.", ' %1|%2|%3' , ItemNoSashBrshTok, ItemNo12345ITEMNUMBERTok, ItemNoStepLadderTok ) ;
194
204
Assert. IsFalse( Item. IsEmpty() , ' Could not find Items by code.' ) ;
195
205
196
- InventoryPostingGroup. SetFilter( "Code", ' %1|%2|%3' , ' TEST-1 ' , ' TEST-2 ' , ' GP ' ) ;
206
+ InventoryPostingGroup. SetFilter( "Code", ' %1|%2|%3' , ItemClassesIdTest1Tok, ItemClassIdTest2Tok, PostingGroupGPTok ) ;
197
207
Assert. IsFalse( InventoryPostingGroup. IsEmpty() , ' Could not find Inventory Posting Groups by code.' ) ;
198
208
Assert. RecordCount( InventoryPostingGroup, 3 ) ;
199
209
200
210
// [THEN] Fields for the first Inventory Posting Setup will be correct
201
- InventoryPostingSetup. SetRange( "Invt. Posting Group Code", ' TEST-1 ' ) ;
211
+ InventoryPostingSetup. SetRange( "Invt. Posting Group Code", ItemClassesIdTest1Tok ) ;
202
212
Assert. IsTrue( InventoryPostingSetup. FindFirst() , ' Could not find Inventory Posting Setup by code.' ) ;
203
- Assert. AreEqual( ' TEST-1 ' , InventoryPostingSetup. "Invt. Posting Group Code", ' Invt. Posting Group Code of InventoryPostingSetup is incorrect.' ) ;
213
+ Assert. AreEqual( ItemClassesIdTest1Tok , InventoryPostingSetup. "Invt. Posting Group Code", ' Invt. Posting Group Code of InventoryPostingSetup is incorrect.' ) ;
204
214
Assert. AreEqual( ' 1' , InventoryPostingSetup. "Inventory Account", ' Inventory Account of InventoryPostingSetup is incorrect.' ) ;
205
215
206
- InventoryPostingSetup. SetRange( "Invt. Posting Group Code", ' TEST-2 ' ) ;
216
+ InventoryPostingSetup. SetRange( "Invt. Posting Group Code", ItemClassIdTest2Tok ) ;
207
217
Assert. IsTrue( InventoryPostingSetup. FindFirst() , ' Could not find Inventory Posting Setup by code.' ) ;
208
- Assert. AreEqual( ' TEST-2 ' , InventoryPostingSetup. "Invt. Posting Group Code", ' Invt. Posting Group Code of InventoryPostingSetup is incorrect.' ) ;
218
+ Assert. AreEqual( ItemClassIdTest2Tok , InventoryPostingSetup. "Invt. Posting Group Code", ' Invt. Posting Group Code of InventoryPostingSetup is incorrect.' ) ;
209
219
Assert. AreEqual( ' ' , InventoryPostingSetup. "Inventory Account", ' Inventory Account of InventoryPostingSetup is incorrect.' ) ;
210
220
211
221
// [THEN] The correct Inventory Posting Groups are set
212
- Item. Get( ' 1 1/2\"SASH BRSH ' ) ;
213
- Assert. AreEqual( ' TEST-1 ' , Item. "Inventory Posting Group", ' Inventory Posting Group of migrated Item is incorrect.' ) ;
222
+ Item. Get( ItemNoSashBrshTok ) ;
223
+ Assert. AreEqual( ItemClassesIdTest1Tok , Item. "Inventory Posting Group", ' Inventory Posting Group of migrated Item is incorrect.' ) ;
214
224
215
- Item. Get( ' 12345ITEMNUMBER!@#$% ' ) ;
216
- Assert. AreEqual( ' TEST-1 ' , Item. "Inventory Posting Group", ' Inventory Posting Group of migrated Item is incorrect.' ) ;
225
+ Item. Get( ItemNo12345ITEMNUMBERTok ) ;
226
+ Assert. AreEqual( ItemClassesIdTest1Tok , Item. "Inventory Posting Group", ' Inventory Posting Group of migrated Item is incorrect.' ) ;
217
227
218
- Item. Get( ' 4 '' STEPLADDER ' ) ;
219
- Assert. AreEqual( ' TEST-2 ' , Item. "Inventory Posting Group", ' Inventory Posting Group of migrated Item is incorrect.' ) ;
228
+ Item. Get( ItemNoStepLadderTok ) ;
229
+ Assert. AreEqual( ItemClassIdTest2Tok , Item. "Inventory Posting Group", ' Inventory Posting Group of migrated Item is incorrect.' ) ;
220
230
end ;
221
231
222
232
[Test]
@@ -259,7 +269,7 @@ codeunit 139662 "GP Item Tests"
259
269
260
270
// [THEN] Inactive items will not be migrated
261
271
Assert. IsTrue( Item. Count () > 0 , ' Items were not migrated.' ) ;
262
- Item. SetRange( "No.", ' ITEM INACTIVE ' ) ;
272
+ Item. SetRange( "No.", ItemNumberItemInactiveTok ) ;
263
273
Assert. IsTrue( Item. IsEmpty() , ' Inactive item should not have been migrated.' ) ;
264
274
end ;
265
275
@@ -303,10 +313,10 @@ codeunit 139662 "GP Item Tests"
303
313
304
314
// [THEN] Discontinued items will not be migrated
305
315
Assert. IsTrue( Item. Count () > 0 , ' Items were not migrated.' ) ;
306
- Item. SetRange( "No.", ' ITEM INACTIVE ' ) ;
316
+ Item. SetRange( "No.", ItemNumberItemInactiveTok ) ;
307
317
Assert. IsTrue( Item. FindFirst() , ' Inactive item should have been migrated.' ) ;
308
318
309
- Item. SetRange( "No.", ' ITEM DISCONTINUED ' ) ;
319
+ Item. SetRange( "No.", ItemNoItemDiscontinuedTok ) ;
310
320
Assert. IsTrue( Item. IsEmpty() , ' Discontinued item should have been migrated.' ) ;
311
321
end ;
312
322
@@ -351,25 +361,25 @@ codeunit 139662 "GP Item Tests"
351
361
Assert. RecordCount( Item, 8 ) ;
352
362
Assert. AreEqual( Item. Count () , HelperFunctions. GetNumberOfItems() , ' Wrong number of Items calculated' ) ;
353
363
354
- Item. Get( ' KIT COMPONENT INV ' ) ;
364
+ Item. Get( ItemNoKitComponentInvTok ) ;
355
365
Assert. AreEqual( Item. Type ::Inventory, Item. Type , ' Type is incorrect (INV).' ) ;
356
366
357
- Item. Get( ' KIT COMPONENT SVC ' ) ;
367
+ Item. Get( ItemNoKitComponentSvcTok ) ;
358
368
Assert. AreEqual( Item. Type ::"Non-Inventory", Item. Type , ' Type is incorrect (SVC).' ) ;
359
369
360
370
// [THEN] Kit item components are created with correct settings
361
- BOMComponent. SetRange( "Parent Item No.", ' KIT ' ) ;
371
+ BOMComponent. SetRange( "Parent Item No.", ItemNoKitTok ) ;
362
372
Assert. RecordCount( BOMComponent, 2 ) ;
363
373
364
- BOMComponent. SetRange( "No.", ' KIT COMPONENT INV ' ) ;
374
+ BOMComponent. SetRange( "No.", ItemNoKitComponentInvTok ) ;
365
375
BOMComponent. FindFirst() ;
366
376
Assert. AreEqual( 10000 , BOMComponent. "Line No.", ' Line No. is incorrect' ) ;
367
377
Assert. AreEqual( BOMComponent. Type ::Item, BOMComponent. Type , ' Type is incorrect.' ) ;
368
378
Assert. AreEqual( ' Kit Component Inventory' , BOMComponent. Description, ' Description is incorrect.' ) ;
369
379
Assert. AreEqual( ' EACH' , BOMComponent. "Unit of Measure Code", ' Unit of Measure Code is incorrect.' ) ;
370
380
Assert. AreEqual( 1 , BOMComponent. "Quantity per", ' Quantity per is incorrect.' ) ;
371
381
372
- BOMComponent. SetRange( "No.", ' KIT COMPONENT SVC ' ) ;
382
+ BOMComponent. SetRange( "No.", ItemNoKitComponentSvcTok ) ;
373
383
BOMComponent. FindFirst() ;
374
384
Assert. AreEqual( 20000 , BOMComponent. "Line No.", ' Line No. is incorrect' ) ;
375
385
Assert. AreEqual( BOMComponent. Type ::Item, BOMComponent. Type , ' Type is incorrect.' ) ;
@@ -396,8 +406,8 @@ codeunit 139662 "GP Item Tests"
396
406
GPIV40400. DeleteAll() ;
397
407
DataMigrationEntity. DeleteAll() ;
398
408
399
- if not GenBusPostingGroup. Get( ' GP ' ) then begin
400
- GenBusPostingGroup. Validate( GenBusPostingGroup. Code , ' GP ' ) ;
409
+ if not GenBusPostingGroup. Get( PostingGroupGPTok ) then begin
410
+ GenBusPostingGroup. Validate( GenBusPostingGroup. Code , PostingGroupGPTok ) ;
401
411
GenBusPostingGroup. Insert( true) ;
402
412
end ;
403
413
end ;
@@ -417,10 +427,10 @@ codeunit 139662 "GP Item Tests"
417
427
GPIV00104: Record "GP IV00104";
418
428
begin
419
429
Clear( GPItem) ;
420
- GPItem. No := ' 1 1/2\"SASH BRSH ' ;
421
- GPItem. Description := ' 1 1/2\"SASH BRSH ' ;
430
+ GPItem. No := ItemNoSashBrshTok ;
431
+ GPItem. Description := ItemNoSashBrshTok ;
422
432
GPItem. SearchDescription := ' Craftsman Brush 1 1/2\" Sash' ;
423
- GPItem. ShortName := ' 1 1/2\"SASH BRSH ' ;
433
+ GPItem. ShortName := ItemNoSashBrshTok ;
424
434
GPItem. BaseUnitOfMeasure := ' Each' ;
425
435
GPItem. ItemType := 0 ;
426
436
GPItem. CostingMethod := ' 0' ;
@@ -435,7 +445,7 @@ codeunit 139662 "GP Item Tests"
435
445
GPItem. Insert() ;
436
446
437
447
Clear( GPItem) ;
438
- GPItem. No := ' 12345ITEMNUMBER!@#$% ' ;
448
+ GPItem. No := ItemNo12345ITEMNUMBERTok ;
439
449
GPItem. Description := ' 12345ITEMNUMBER!@#$%1234567890' ;
440
450
GPItem. SearchDescription := ' Item Description !@#123456789012345678901234567890' ;
441
451
GPItem. ShortName := ' 12345ITEMNUMBER!@#$%1234567890' ;
@@ -453,10 +463,10 @@ codeunit 139662 "GP Item Tests"
453
463
GPItem. Insert() ;
454
464
455
465
Clear( GPItem) ;
456
- GPItem. No := ' 4 '' STEPLADDER ' ;
457
- GPItem. Description := ' 4 '' STEPLADDER ' ;
458
- GPItem. SearchDescription := ' 4 '' Stepladder ' ;
459
- GPItem. ShortName := ' 4 '' STEPLADDER ' ;
466
+ GPItem. No := ItemNoStepLadderTok ;
467
+ GPItem. Description := ItemNoStepLadderTok ;
468
+ GPItem. SearchDescription := ItemNoStepLadderTok ;
469
+ GPItem. ShortName := ItemNoStepLadderTok ;
460
470
GPItem. BaseUnitOfMeasure := ' Each' ;
461
471
GPItem. ItemType := 0 ;
462
472
GPItem. CostingMethod := ' 0' ;
@@ -471,7 +481,7 @@ codeunit 139662 "GP Item Tests"
471
481
GPItem. Insert() ;
472
482
473
483
Clear( GPItem) ;
474
- GPItem. No := ' ITEM INACTIVE ' ;
484
+ GPItem. No := ItemNumberItemInactiveTok ;
475
485
GPItem. Description := ' Inactive item' ;
476
486
GPItem. SearchDescription := ' inactive' ;
477
487
GPItem. ShortName := ' Inactive item' ;
@@ -495,7 +505,7 @@ codeunit 139662 "GP Item Tests"
495
505
#pragma warning restore AA0139
496
506
497
507
Clear( GPItem) ;
498
- GPItem. No := ' ITEM DISCONTINUED ' ;
508
+ GPItem. No := ItemNoItemDiscontinuedTok ;
499
509
GPItem. Description := ' Discontinued item' ;
500
510
GPItem. SearchDescription := ' discontinued' ;
501
511
GPItem. ShortName := ' Discontinued item' ;
@@ -520,10 +530,10 @@ codeunit 139662 "GP Item Tests"
520
530
521
531
// Kit and its components
522
532
Clear( GPItem) ;
523
- GPItem. No := ' KIT ' ;
524
- GPItem. Description := ' Kit ' ;
525
- GPItem. SearchDescription := ' Kit ' ;
526
- GPItem. ShortName := ' Kit ' ;
533
+ GPItem. No := ItemNoKitTok ;
534
+ GPItem. Description := ItemNoKitTok ;
535
+ GPItem. SearchDescription := ItemNoKitTok ;
536
+ GPItem. ShortName := ItemNoKitTok ;
527
537
GPItem. BaseUnitOfMeasure := ' Each' ;
528
538
GPItem. ItemType := 2 ;
529
539
GPItem. CostingMethod := ' 0' ;
@@ -537,12 +547,12 @@ codeunit 139662 "GP Item Tests"
537
547
GPItem. Insert() ;
538
548
539
549
Clear( GPIV00101) ;
540
- GPIV00101. ITEMNMBR := ' KIT ' ;
550
+ GPIV00101. ITEMNMBR := ItemNoKitTok ;
541
551
GPIV00101. ITEMTYPE := 3 ;
542
552
GPIV00101. Insert() ;
543
553
544
554
Clear( GPItem) ;
545
- GPItem. No := ' KIT COMPONENT INV ' ;
555
+ GPItem. No := ItemNoKitComponentInvTok ;
546
556
GPItem. Description := ' Kit Component Inventory' ;
547
557
GPItem. SearchDescription := ' Kit component inventory' ;
548
558
GPItem. ShortName := ' Kit Component Inventory' ;
@@ -559,12 +569,12 @@ codeunit 139662 "GP Item Tests"
559
569
GPItem. Insert() ;
560
570
561
571
Clear( GPIV00101) ;
562
- GPIV00101. ITEMNMBR := ' KIT COMPONENT INV ' ;
572
+ GPIV00101. ITEMNMBR := ItemNoKitComponentInvTok ;
563
573
GPIV00101. ITEMTYPE := 1 ;
564
574
GPIV00101. Insert() ;
565
575
566
576
Clear( GPItem) ;
567
- GPItem. No := ' KIT COMPONENT SVC ' ;
577
+ GPItem. No := ItemNoKitComponentSvcTok ;
568
578
GPItem. Description := ' Kit Component Service' ;
569
579
GPItem. SearchDescription := ' Kit component service' ;
570
580
GPItem. ShortName := ' Kit Component SVC' ;
@@ -581,24 +591,24 @@ codeunit 139662 "GP Item Tests"
581
591
GPItem. Insert() ;
582
592
583
593
Clear( GPIV00101) ;
584
- GPIV00101. ITEMNMBR := ' KIT COMPONENT SVC ' ;
594
+ GPIV00101. ITEMNMBR := ItemNoKitComponentSvcTok ;
585
595
GPIV00101. ITEMTYPE := 5 ;
586
596
GPIV00101. Insert() ;
587
597
588
598
Clear( GPIV00104) ;
589
- GPIV00104. ITEMNMBR := ' KIT ' ;
599
+ GPIV00104. ITEMNMBR := ItemNoKitTok ;
590
600
GPIV00104. SEQNUMBR := 1 ;
591
- GPIV00104. CMPTITNM := ' KIT COMPONENT INV ' ;
601
+ GPIV00104. CMPTITNM := ItemNoKitComponentInvTok ;
592
602
GPIV00104. CMPITUOM := ' Each' ;
593
603
GPIV00104. CMPITQTY := 1 ;
594
604
GPIV00104. CMPSERNM := false;
595
605
GPIV00104. DEX_ROW_ID := 1 ;
596
606
GPIV00104. Insert() ;
597
607
598
608
Clear( GPIV00104) ;
599
- GPIV00104. ITEMNMBR := ' KIT ' ;
609
+ GPIV00104. ITEMNMBR := ItemNoKitTok ;
600
610
GPIV00104. SEQNUMBR := 1 ;
601
- GPIV00104. CMPTITNM := ' KIT COMPONENT SVC ' ;
611
+ GPIV00104. CMPTITNM := ItemNoKitComponentSvcTok ;
602
612
GPIV00104. CMPITUOM := ' Each' ;
603
613
GPIV00104. CMPITQTY := 1 ;
604
614
GPIV00104. CMPSERNM := false;
@@ -640,30 +650,30 @@ codeunit 139662 "GP Item Tests"
640
650
GLAccount. Insert() ;
641
651
642
652
GPIV40400. Init() ;
643
- GPIV40400. ITMCLSCD := ' TEST-1 ' ;
653
+ GPIV40400. ITMCLSCD := ItemClassesIdTest1Tok ;
644
654
GPIV40400. ITMCLSDC := ' Test class 1' ;
645
655
GPIV40400. IVIVINDX := 1 ;
646
656
GPIV40400. Insert() ;
647
657
648
658
GPIV40400. Init() ;
649
- GPIV40400. ITMCLSCD := ' TEST-2 ' ;
659
+ GPIV40400. ITMCLSCD := ItemClassIdTest2Tok ;
650
660
GPIV40400. ITMCLSDC := ' Test class 2' ;
651
661
GPIV40400. IVIVINDX := 0 ;
652
662
GPIV40400. Insert() ;
653
663
654
664
GPIV00101. Init() ;
655
- GPIV00101. ITEMNMBR := ' 1 1/2\"SASH BRSH ' ;
656
- GPIV00101. ITMCLSCD := ' TEST-1 ' ;
665
+ GPIV00101. ITEMNMBR := ItemNoSashBrshTok ;
666
+ GPIV00101. ITMCLSCD := ItemClassesIdTest1Tok ;
657
667
GPIV00101. Insert() ;
658
668
659
669
GPIV00101. Init() ;
660
- GPIV00101. ITEMNMBR := ' 12345ITEMNUMBER!@#$% ' ;
661
- GPIV00101. ITMCLSCD := ' TEST-1 ' ;
670
+ GPIV00101. ITEMNMBR := ItemNo12345ITEMNUMBERTok ;
671
+ GPIV00101. ITMCLSCD := ItemClassesIdTest1Tok ;
662
672
GPIV00101. Insert() ;
663
673
664
674
GPIV00101. Init() ;
665
- GPIV00101. ITEMNMBR := ' 4 '' STEPLADDER ' ;
666
- GPIV00101. ITMCLSCD := ' TEST-2 ' ;
675
+ GPIV00101. ITEMNMBR := ItemNoStepLadderTok ;
676
+ GPIV00101. ITMCLSCD := ItemClassIdTest2Tok ;
667
677
GPIV00101. Insert() ;
668
678
end ;
669
679
}
0 commit comments