-
Notifications
You must be signed in to change notification settings - Fork 412
Expand file tree
/
Copy pathJobsMultipleCustomers.Codeunit.al
More file actions
2250 lines (1804 loc) · 96.2 KB
/
Copy pathJobsMultipleCustomers.Codeunit.al
File metadata and controls
2250 lines (1804 loc) · 96.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
codeunit 136323 "Jobs - Multiple Customers"
{
Subtype = Test;
TestPermissions = Disabled;
trigger OnRun()
begin
// [FEATURE] [Projects] [Multiple Customers]
Initialized := false
end;
var
LibraryJob: Codeunit "Library - Job";
LibraryERM: Codeunit "Library - ERM";
LibrarySales: Codeunit "Library - Sales";
LibraryDimension: Codeunit "Library - Dimension";
LibraryInventory: Codeunit "Library - Inventory";
LibraryUtility: Codeunit "Library - Utility";
LibraryTestInitialize: Codeunit "Library - Test Initialize";
LibraryVariableStorage: Codeunit "Library - Variable Storage";
LibraryPriceCalculation: Codeunit "Library - Price Calculation";
LibraryRandom: Codeunit "Library - Random";
JobCreateInvoice: Codeunit "Job Create-Invoice";
Assert: Codeunit Assert;
Initialized: Boolean;
CustomersAreNotEqualMsg: Label 'Customers on Project Task and %1 are not equal.', Comment = '%1 = Table caption';
LinesTransferedToInvoiceMsg: Label 'The lines were successfully transferred to an invoice.';
UpdateBillingMethodErr: Label 'You cannot select %1 in %2, because one or more Project Tasks exist for this %3.', Comment = '%1 = Caption of the Task Billing Method field value; %2 = Caption of the Task Billing Method field; %3 = Caption of the Project table';
AssociatedEntriesExistErr: Label 'You cannot change %1 because one or more entries are associated with this %2.', Comment = '%1 = Name of field used in the error; %2 = The name of the Project table';
TasksNotUpdatedMsg: Label 'You have changed %1 on the project, but it has not been changed on the existing project tasks.', Comment = '%1 = a Field Caption like Location Code';
UpdateTasksManuallyMsg: Label 'You must update the existing project tasks manually.';
SplitMessageTxt: Label '%1\%2', Comment = 'Some message text 1.\Some message text 2.', Locked = true;
OneInvoicesAreCreatedMsg: Label '1 invoice is created.';
PostJournalLineQst: Label 'Do you want to post the journal lines?';
PostedJournalLinesMsg: Label 'The journal lines were successfully posted.';
UpdateBillToCustMsg: Label 'You have changed a customer. Prices and costs needs to be updated on a related lines.\\Do you want to update related lines?';
MultipleInvoiceCreatedMsg: Label '%1 invoices are created.', Comment = '%1= Invoice count';
[Test]
procedure DefaultTaskBillingMethodIsPulledOnNewProject()
var
Job: Record Job;
begin
// [SCENARIO 348602] Default Task Billing Method is Pulled on new Project
Initialize();
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [WHEN] Create new Project
LibraryJob.CreateJob(Job);
// [THEN] Verify results
Assert.IsTrue(Job."Task Billing Method" = Job."Task Billing Method"::"Multiple customers", 'Task Billing Method is not Multiple Customers');
end;
[Test]
procedure CustomerControlsAreVisibleOnJobTaskSubformForMultiCustomerTaskBillingMethod()
var
Job: Record Job;
JobCard: TestPage "Job Card";
begin
// [SCENARIO 348602] Customer Controls are Visible on Job Task Subform for Multi-Customer Task Billing Method
Initialize();
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] Create new Project
LibraryJob.CreateJob(Job);
// [WHEN] Open Job Card
JobCard.OpenEdit();
JobCard.GoToRecord(Job);
// [THEN] Verify results
Assert.IsTrue(JobCard.JobTaskLines."Sell-to Customer No.".Visible(), 'Customer control is not visible for Multi Customer Billing Method');
Assert.IsTrue(JobCard.JobTaskLines."Bill-to Customer No.".Visible(), 'Customer control is not visible for Multi Customer Billing Method');
end;
[Test]
procedure CustomerIsInitializedOnJobTaskForMultiCustomerBillingMethod()
var
Job: Record Job;
JobTask: Record "Job Task";
begin
// [SCENARIO 348602] Customer is Initialized on Job Task for Multi-Customer Billing Method
Initialize();
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [WHEN] Create new Project and Project Task
CreateJobAndJobTask(Job, JobTask);
// [THEN] Verify results
Assert.AreEqual(Job."Sell-to Customer No.", JobTask."Sell-to Customer No.", StrSubstNo(CustomersAreNotEqualMsg, Job.TableCaption));
Assert.AreEqual(Job."Bill-to Customer No.", JobTask."Bill-to Customer No.", StrSubstNo(CustomersAreNotEqualMsg, Job.TableCaption));
end;
[Test]
procedure IsNotAllowedToReturnBillingMethodToOneCustomerIfJobTaskExist()
var
Job: Record Job;
JobTask: Record "Job Task";
RecRef: RecordRef;
FldRef: FieldRef;
begin
// [SCENARIO 348602] Is not Allowed to Return Billing Method to One Customer if Job Task Exist
Initialize();
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] Create new Project and Project Task
CreateJobAndJobTask(Job, JobTask);
// [WHEN] Try to set Billing Method to One Customer
asserterror Job.Validate("Task Billing Method", Job."Task Billing Method"::"One customer");
// [THEN] Verify results
RecRef.GetTable(Job);
FldRef := RecRef.Field(Job.FieldNo("Task Billing Method"));
Assert.ExpectedError(StrSubstNo(UpdateBillingMethodErr, FldRef.GetEnumValueCaption(Job."Task Billing Method".AsInteger()), Job.FieldCaption("Task Billing Method"), Job.TableCaption()));
end;
[Test]
procedure CheckCustomersDataOnJobAndJobTaskForMultiCustomersBillingOption()
var
Job: Record Job;
JobTask: Record "Job Task";
Customers: array[2] of Record Customer;
begin
// [SCENARIO 348602]
Initialize();
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] Create Customers with Address
LibrarySales.CreateCustomerWithAddress(Customers[1]);
LibrarySales.CreateCustomerWithAddress(Customers[2]);
// [GIVEN] Create Ship-to Address Customer
CreateShiptoAddrCustomer(Customers[1]."No.");
// [GIVEN] Set Bill-to Customer
Customers[1].Validate("Bill-to Customer No.", Customers[2]."No.");
Customers[1].Modify(true);
// [GIVEN] Create new Project
LibraryJob.CreateJob(Job, Customers[1]."No.");
// [WHEN] Create new Project Task
LibraryJob.CreateJobTask(Job, JobTask);
// [THEN] Verify results
Assert.AreEqual(Job."Sell-to Customer No.", JobTask."Sell-to Customer No.", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Sell-to Customer Name", JobTask."Sell-to Customer Name", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Sell-to Customer Name 2", JobTask."Sell-to Customer Name 2", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Sell-to Address", JobTask."Sell-to Address", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Sell-to Address 2", JobTask."Sell-to Address 2", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Sell-to City", JobTask."Sell-to City", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Sell-to Contact", JobTask."Sell-to Contact", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Sell-to Post Code", JobTask."Sell-to Post Code", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Sell-to County", JobTask."Sell-to County", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Sell-to Country/Region Code", JobTask."Sell-to Country/Region Code", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Sell-to Contact No.", JobTask."Sell-to Contact No.", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Bill-to Customer No.", JobTask."Bill-to Customer No.", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Bill-to Name", JobTask."Bill-to Name", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Bill-to Address", JobTask."Bill-to Address", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Bill-to Address 2", JobTask."Bill-to Address 2", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Bill-to City", JobTask."Bill-to City", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Bill-to County", JobTask."Bill-to County", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Bill-to Post Code", JobTask."Bill-to Post Code", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Bill-to Country/Region Code", JobTask."Bill-to Country/Region Code", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Bill-to Name 2", JobTask."Bill-to Name 2", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Bill-to Contact No.", JobTask."Bill-to Contact No.", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Bill-to Contact", JobTask."Bill-to Contact", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Ship-to Code", JobTask."Ship-to Code", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Ship-to Name", JobTask."Ship-to Name", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Ship-to Name 2", JobTask."Ship-to Name 2", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Ship-to Address", JobTask."Ship-to Address", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Ship-to Address 2", JobTask."Ship-to Address 2", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Ship-to City", JobTask."Ship-to City", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Ship-to Contact", JobTask."Ship-to Contact", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Ship-to Post Code", JobTask."Ship-to Post Code", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Ship-to County", JobTask."Ship-to County", 'Customers data are not equal on Project and Project Task');
Assert.AreEqual(Job."Ship-to Country/Region Code", JobTask."Ship-to Country/Region Code", 'Customers data are not equal on Project and Project Task');
end;
[Test]
procedure InvoiceCurrencyCodeOnJobTaskIsNotEditableForJobWithCurrencyCode()
var
Job: Record Job;
JobTask: Record "Job Task";
Currency: Record Currency;
JobTaskCard: TestPage "Job Task Card";
begin
// [SCENARIO 348602] Invoice Currency Code on Job Task is not editable for Job with Currency Code
Initialize();
// [GIVEN] Create Currency
LibraryERM.CreateCurrency(Currency);
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] Create new Project and Project Task
CreateJobAndJobTask(Job, JobTask);
// [GIVEN] Set Currency Code on Project
Job.Validate("Currency Code", Currency.Code);
Job.Modify();
// [WHEN] Open Job Task card
JobTaskCard.OpenEdit();
JobTaskCard.GoToRecord(JobTask);
// [THEN] Verify results
Assert.IsFalse(JobTaskCard."Invoice Currency Code".Editable(), 'Invoice Currency Code is editable');
end;
[Test]
procedure JobTaskDimensionsAreRecalculatedOnUpdateCustomer()
var
Job: Record Job;
JobTask: Record "Job Task";
JobTaskDimension: Record "Job Task Dimension";
Customers: array[2] of Record Customer;
DimensionValues: array[2] of Record "Dimension Value";
begin
// [SCENARIO 348602] Job Task Dimensions are recalculated on Update Customer on Job Task
Initialize();
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] Create Customers with Dimensions
CreateCustomerwithDimension(Customers[1], DimensionValues[1]);
CreateCustomerwithDimension(Customers[2], DimensionValues[2]);
// [GIVEN] Create new Project
LibraryJob.CreateJob(Job, Customers[1]."No.");
// [GIVEN] Create new Project Task
LibraryJob.CreateJobTask(Job, JobTask);
// [WHEN] Find Job Task Dimensions
FindJobTaskDimension(JobTask, JobTaskDimension, DimensionValues[1]);
// [THEN] Verify Job Task Dimensions
Assert.AreEqual(JobTaskDimension."Dimension Value Code", DimensionValues[1].Code, 'Job Task Dimension is not equal to Customer Dimension');
// [GIVEN] Update Customer on Project Task
JobTask.Validate("Sell-to Customer No.", Customers[2]."No.");
JobTask.Modify(true);
// [WHEN] Find Job Task Dimensions
FindJobTaskDimension(JobTask, JobTaskDimension, DimensionValues[2]);
// [THEN] Verify results
Assert.AreEqual(JobTaskDimension."Dimension Value Code", DimensionValues[2].Code, 'Job Task Dimension is not equal to Customer Dimension');
end;
[Test]
[HandlerFunctions('ConfirmYesHandler')]
procedure SalesPriceIsPulledFromCustomerOnJobTask()
var
Item: Record Item;
Job: Record Job;
JobTask: Record "Job Task";
JobPlanningLine: Record "Job Planning Line";
PriceListHeader: Record "Price List Header";
PriceListLines: array[2] of Record "Price List Line";
Customers: array[2] of Record Customer;
begin
// [SCENARIO 348602] Sales Price is Pulled from Customer on Job Task
Initialize();
// [GIVEN] New pricing enabled
LibraryPriceCalculation.EnableExtendedPriceCalculation();
LibraryPriceCalculation.SetupDefaultHandler("Price Calculation Handler"::"Business Central (Version 16.0)");
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] Create new Item
LibraryInventory.CreateItem(Item);
// [GIVEN] Create Customers
LibrarySales.CreateCustomer(Customers[1]);
LibrarySales.CreateCustomer(Customers[2]);
// [GIVEN] Create Sales Prices for Item and Customers
CreatePriceLineForCustomer(PriceListHeader, PriceListLines[1], Customers[1]."No.", Item."No.");
CreatePriceLineForCustomer(PriceListHeader, PriceListLines[2], Customers[2]."No.", Item."No.");
// [GIVEN] Create new Project
LibraryJob.CreateJob(Job, Customers[1]."No.");
// [GIVEN] Create new Project Task
LibraryJob.CreateJobTask(Job, JobTask);
// [WHEN] Create Job Planning Line
CreateJobPlanningLineWithItem(JobPlanningLine, JobTask, JobPlanningLine."Line Type"::"Both Budget and Billable", Item."No.", 1);
// [THEN] Verify results
Assert.AreEqual(JobPlanningLine."Unit Price", PriceListLines[1]."Unit Price", 'Sales Price is not equal to Customer Sales Price');
// [GIVEN] Create new Project Task
LibraryJob.CreateJobTask(Job, JobTask);
// [GIVEN] Update Customer on Project Task
JobTask.Validate("Sell-to Customer No.", Customers[2]."No.");
JobTask.Modify(true);
// [WHEN] Create Job Planning Line
CreateJobPlanningLineWithItem(JobPlanningLine, JobTask, JobPlanningLine."Line Type"::"Both Budget and Billable", Item."No.", 1);
// [THEN] Verify results
Assert.AreEqual(JobPlanningLine."Unit Price", PriceListLines[2]."Unit Price", 'Sales Price is not equal to Customer Sales Price');
end;
[Test]
[HandlerFunctions('ConfirmYesHandler')]
procedure SalesPriceIsPulledFromCustomerOnJobTaskForJournalLine()
var
Item: Record Item;
Job: Record Job;
JobTask: Record "Job Task";
JobJournalLine: Record "Job Journal Line";
PriceListHeader: Record "Price List Header";
PriceListLines: array[2] of Record "Price List Line";
Customers: array[2] of Record Customer;
begin
// [SCENARIO 639857] The Job Journal Line price honors the task-level Bill-to Customer under Multiple customers billing.
Initialize();
// [GIVEN] New pricing enabled
LibraryPriceCalculation.EnableExtendedPriceCalculation();
LibraryPriceCalculation.SetupDefaultHandler("Price Calculation Handler"::"Business Central (Version 16.0)");
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] New Item and two Customers with distinct Sales Prices
LibraryInventory.CreateItem(Item);
LibrarySales.CreateCustomer(Customers[1]);
LibrarySales.CreateCustomer(Customers[2]);
CreatePriceLineForCustomer(PriceListHeader, PriceListLines[1], Customers[1]."No.", Item."No.");
CreatePriceLineForCustomer(PriceListHeader, PriceListLines[2], Customers[2]."No.", Item."No.");
// [GIVEN] Project billed to Customer 1 with a task inheriting the project customer
LibraryJob.CreateJob(Job, Customers[1]."No.");
LibraryJob.CreateJobTask(Job, JobTask);
// [WHEN] Creating a Job Journal Line for the task
CreateJobJournalLineWithItem(JobJournalLine, JobTask, Item."No.", 1);
// [THEN] The unit price is Customer 1's price
Assert.AreEqual(PriceListLines[1]."Unit Price", JobJournalLine."Unit Price", 'Sales Price is not equal to Customer Sales Price');
// [GIVEN] A second task billed to Customer 2
LibraryJob.CreateJobTask(Job, JobTask);
JobTask.Validate("Sell-to Customer No.", Customers[2]."No.");
JobTask.Modify(true);
// [WHEN] Creating a Job Journal Line for the second task
CreateJobJournalLineWithItem(JobJournalLine, JobTask, Item."No.", 1);
// [THEN] The unit price is Customer 2's price (task-level Bill-to Customer honored)
Assert.AreEqual(PriceListLines[2]."Unit Price", JobJournalLine."Unit Price", 'Sales Price is not equal to Customer Sales Price');
end;
[Test]
[HandlerFunctions('JobTransferToSalesInvoiceRequestPageHandler,MessageHandler')]
procedure SalesInvoiceIsCreatedForJobTaskCustomer()
var
Job: Record Job;
JobTask: Record "Job Task";
JobPlanningLine: Record "Job Planning Line";
SalesHeader: Record "Sales Header";
SalesLine: Record "Sales Line";
Customers: array[2] of Record Customer;
begin
// [SCENARIO 348602] Sales Invoice is Created for Job Task Customer
Initialize();
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] Create Customers
LibrarySales.CreateCustomer(Customers[1]);
LibrarySales.CreateCustomer(Customers[2]);
// [GIVEN] Create new Project
LibraryJob.CreateJob(Job, Customers[1]."No.");
// [GIVEN] Create new Project Task
LibraryJob.CreateJobTask(Job, JobTask);
// [GIVEN] Update Customer on Project Task
JobTask.Validate("Sell-to Customer No.", Customers[2]."No.");
JobTask.Modify(true);
// [GIVEN] Create Job Planning Line
LibraryJob.CreateJobPlanningLine(JobPlanningLine."Line Type"::Billable, JobPlanningLine.Type::Item, JobTask, JobPlanningLine);
Commit();
// [GIVEN] Enqueue data
LibraryVariableStorage.Enqueue(LinesTransferedToInvoiceMsg);
// [WHEN] Create Sales Invoice
JobCreateInvoice.CreateSalesInvoice(JobPlanningLine, false);
// [GIVEN] Find Sales Document
FindSalesLine(SalesLine, SalesLine."Document Type"::Invoice, SalesLine.Type::Item, JobPlanningLine."Job No.");
SalesHeader.Get(SalesLine."Document Type", SalesLine."Document No.");
// [THEN] Verify results
Assert.AreEqual(SalesHeader."Sell-to Customer No.", Customers[2]."No.", StrSubstNo(CustomersAreNotEqualMsg, SalesHeader.TableCaption));
end;
[Test]
[HandlerFunctions('ConfirmYesHandler')]
procedure AllowChangeCustomerOnJobWithRelatedPlanningLine()
var
Item: Record Item;
Job: Record Job;
JobTask: Record "Job Task";
JobPlanningLine: Record "Job Planning Line";
PriceListHeader: Record "Price List Header";
PriceListLines: array[2] of Record "Price List Line";
Customers: array[2] of Record Customer;
begin
// [SCENARIO 433788] Allow Change Customer on Job with Related Planning Line
Initialize();
// [GIVEN] Set One Customer billing method on Project Setup
SetOneCustomerBillingMethodOnProjectSetup();
// [GIVEN] New pricing enabled
LibraryPriceCalculation.EnableExtendedPriceCalculation();
LibraryPriceCalculation.SetupDefaultHandler("Price Calculation Handler"::"Business Central (Version 16.0)");
// [GIVEN] Create new Item
LibraryInventory.CreateItem(Item);
// [GIVEN] Create Customers
LibrarySales.CreateCustomer(Customers[1]);
LibrarySales.CreateCustomer(Customers[2]);
// [GIVEN] Create Sales Prices for Item and Customers
CreatePriceLineForCustomer(PriceListHeader, PriceListLines[1], Customers[1]."No.", Item."No.");
CreatePriceLineForCustomer(PriceListHeader, PriceListLines[2], Customers[2]."No.", Item."No.");
// [GIVEN] Create new Project
LibraryJob.CreateJob(Job, Customers[1]."No.");
// [GIVEN] Create new Project Task
LibraryJob.CreateJobTask(Job, JobTask);
// [WHEN] Create Job Planning Line
CreateJobPlanningLineWithItem(JobPlanningLine, JobTask, JobPlanningLine."Line Type"::"Both Budget and Billable", Item."No.", 1);
// [THEN] Verify results
Assert.AreEqual(JobPlanningLine."Unit Price", PriceListLines[1]."Unit Price", 'Sales Price is not equal to Customer Sales Price');
// [WHEN] Update Customer on Project
Job.Validate("Sell-to Customer No.", Customers[2]."No.");
Job.Modify(true);
// [THEN] Verify results
JobPlanningLine.Find('=');
Assert.AreEqual(JobPlanningLine."Unit Price", PriceListLines[2]."Unit Price", 'Sales Price is not equal to Customer Sales Price');
end;
[Test]
[HandlerFunctions('ConfirmYesHandler')]
procedure AllowChangeBillToCustomerOnJobWithRelatedPlanningLine()
var
Item: Record Item;
Job: Record Job;
JobTask: Record "Job Task";
JobPlanningLine: Record "Job Planning Line";
PriceListHeader: Record "Price List Header";
PriceListLines: array[2] of Record "Price List Line";
Customers: array[2] of Record Customer;
begin
// [SCENARIO 433788] Allow Change Bill-to Customer on Job with Related Planning Line
Initialize();
// [GIVEN] Set One Customer billing method on Project Setup
SetOneCustomerBillingMethodOnProjectSetup();
// [GIVEN] New pricing enabled
LibraryPriceCalculation.EnableExtendedPriceCalculation();
LibraryPriceCalculation.SetupDefaultHandler("Price Calculation Handler"::"Business Central (Version 16.0)");
// [GIVEN] Create new Item
LibraryInventory.CreateItem(Item);
// [GIVEN] Create Customers
LibrarySales.CreateCustomer(Customers[1]);
LibrarySales.CreateCustomer(Customers[2]);
// [GIVEN] Create Sales Prices for Item and Customers
CreatePriceLineForCustomer(PriceListHeader, PriceListLines[1], Customers[1]."No.", Item."No.");
CreatePriceLineForCustomer(PriceListHeader, PriceListLines[2], Customers[2]."No.", Item."No.");
// [GIVEN] Create new Project
LibraryJob.CreateJob(Job, Customers[1]."No.");
// [GIVEN] Create new Project Task
LibraryJob.CreateJobTask(Job, JobTask);
// [WHEN] Create Job Planning Line
CreateJobPlanningLineWithItem(JobPlanningLine, JobTask, JobPlanningLine."Line Type"::"Both Budget and Billable", Item."No.", 1);
// [THEN] Verify results
Assert.AreEqual(JobPlanningLine."Unit Price", PriceListLines[1]."Unit Price", 'Sales Price is not equal to Customer Sales Price');
// [WHEN] Update Customer on Project
Job.Validate("Bill-to Customer No.", Customers[2]."No.");
Job.Modify(true);
// [THEN] Verify results
JobPlanningLine.Find('=');
Assert.AreEqual(JobPlanningLine."Unit Price", PriceListLines[2]."Unit Price", 'Sales Price is not equal to Customer Sales Price');
end;
[Test]
[HandlerFunctions('JobTransferToSalesInvoiceRequestPageHandler,MessageHandler')]
procedure CustomerUpdateIsNotAllowedForJobWithPostedSalesInvoice()
var
Job: Record Job;
JobTask: Record "Job Task";
JobPlanningLine: Record "Job Planning Line";
SalesHeader: Record "Sales Header";
SalesLine: Record "Sales Line";
Customers: array[2] of Record Customer;
begin
// [SCENARIO 433788] Customer Update is not Allowed for Job with Posted Sales Invoice
Initialize();
// [GIVEN] Set One Customer billing method on Project Setup
SetOneCustomerBillingMethodOnProjectSetup();
// [GIVEN] Create Customers
LibrarySales.CreateCustomer(Customers[1]);
LibrarySales.CreateCustomer(Customers[2]);
// [GIVEN] Create new Project
LibraryJob.CreateJob(Job, Customers[1]."No.");
// [GIVEN] Create new Project Task
LibraryJob.CreateJobTask(Job, JobTask);
// [GIVEN] Create Job Planning Line
LibraryJob.CreateJobPlanningLine(JobPlanningLine."Line Type"::Billable, JobPlanningLine.Type::Item, JobTask, JobPlanningLine);
Commit();
// [GIVEN] Enqueue data
LibraryVariableStorage.Enqueue(LinesTransferedToInvoiceMsg);
// [GIVEN] Create Sales Invoice
JobCreateInvoice.CreateSalesInvoice(JobPlanningLine, false);
// [GIVEN] Find Sales Document
FindSalesLine(SalesLine, SalesLine."Document Type"::Invoice, SalesLine.Type::Item, JobPlanningLine."Job No.");
SalesHeader.Get(SalesLine."Document Type", SalesLine."Document No.");
// [GIVEN] Post Sales Invoice
LibrarySales.PostSalesDocument(SalesHeader, true, true);
// [WHEN] Update Customer on Project
asserterror Job.Validate("Sell-to Customer No.", Customers[2]."No.");
// [THEN] Verify results
Assert.ExpectedError(StrSubstNo(AssociatedEntriesExistErr, Job.FieldCaption("Sell-to Customer No."), Job.TableCaption()));
end;
[Test]
[HandlerFunctions('ConfirmYesHandler')]
procedure AllowChangeCustomerOnJobTaskWithRelatedPlanningLine()
var
Item: Record Item;
Job: Record Job;
JobTask: Record "Job Task";
JobPlanningLine: Record "Job Planning Line";
PriceListHeader: Record "Price List Header";
PriceListLines: array[2] of Record "Price List Line";
Customers: array[2] of Record Customer;
begin
// [SCENARIO 433788] Allow Change Customer on Job Task with Related Planning Line
Initialize();
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] New pricing enabled
LibraryPriceCalculation.EnableExtendedPriceCalculation();
LibraryPriceCalculation.SetupDefaultHandler("Price Calculation Handler"::"Business Central (Version 16.0)");
// [GIVEN] Create new Item
LibraryInventory.CreateItem(Item);
// [GIVEN] Create Customers
LibrarySales.CreateCustomer(Customers[1]);
LibrarySales.CreateCustomer(Customers[2]);
// [GIVEN] Create Sales Prices for Item and Customers
CreatePriceLineForCustomer(PriceListHeader, PriceListLines[1], Customers[1]."No.", Item."No.");
CreatePriceLineForCustomer(PriceListHeader, PriceListLines[2], Customers[2]."No.", Item."No.");
// [GIVEN] Create new Project
LibraryJob.CreateJob(Job, Customers[1]."No.");
// [GIVEN] Create new Project Task
LibraryJob.CreateJobTask(Job, JobTask);
// [WHEN] Create Job Planning Line
CreateJobPlanningLineWithItem(JobPlanningLine, JobTask, JobPlanningLine."Line Type"::"Both Budget and Billable", Item."No.", 1);
// [THEN] Verify results
Assert.AreEqual(JobPlanningLine."Unit Price", PriceListLines[1]."Unit Price", 'Sales Price is not equal to Customer Sales Price');
// [WHEN] Update Customer on Project Task
JobTask.Validate("Sell-to Customer No.", Customers[2]."No.");
JobTask.Modify(true);
// [THEN] Verify results
JobPlanningLine.Find('=');
Assert.AreEqual(JobPlanningLine."Unit Price", PriceListLines[2]."Unit Price", 'Sales Price is not equal to Customer Sales Price');
end;
[Test]
[HandlerFunctions('ConfirmYesHandler')]
procedure AllowChangeBillToCustomerOnJobTaskWithRelatedPlanningLine()
var
Item: Record Item;
Job: Record Job;
JobTask: Record "Job Task";
JobPlanningLine: Record "Job Planning Line";
PriceListHeader: Record "Price List Header";
PriceListLines: array[2] of Record "Price List Line";
Customers: array[2] of Record Customer;
begin
// [SCENARIO 433788] Allow Change Bill-to Customer on Job Task with Related Planning Line
Initialize();
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] New pricing enabled
LibraryPriceCalculation.EnableExtendedPriceCalculation();
LibraryPriceCalculation.SetupDefaultHandler("Price Calculation Handler"::"Business Central (Version 16.0)");
// [GIVEN] Create new Item
LibraryInventory.CreateItem(Item);
// [GIVEN] Create Customers
LibrarySales.CreateCustomer(Customers[1]);
LibrarySales.CreateCustomer(Customers[2]);
// [GIVEN] Create Sales Prices for Item and Customers
CreatePriceLineForCustomer(PriceListHeader, PriceListLines[1], Customers[1]."No.", Item."No.");
CreatePriceLineForCustomer(PriceListHeader, PriceListLines[2], Customers[2]."No.", Item."No.");
// [GIVEN] Create new Project
LibraryJob.CreateJob(Job, Customers[1]."No.");
// [GIVEN] Create new Project Task
LibraryJob.CreateJobTask(Job, JobTask);
// [WHEN] Create Job Planning Line
CreateJobPlanningLineWithItem(JobPlanningLine, JobTask, JobPlanningLine."Line Type"::"Both Budget and Billable", Item."No.", 1);
// [THEN] Verify results
Assert.AreEqual(JobPlanningLine."Unit Price", PriceListLines[1]."Unit Price", 'Sales Price is not equal to Customer Sales Price');
// [WHEN] Update Customer on Project Task
JobTask.Validate("Bill-to Customer No.", Customers[2]."No.");
JobTask.Modify(true);
// [THEN] Verify results
JobPlanningLine.Find('=');
Assert.AreEqual(JobPlanningLine."Unit Price", PriceListLines[2]."Unit Price", 'Sales Price is not equal to Customer Sales Price');
end;
[Test]
[HandlerFunctions('JobTransferToSalesInvoiceRequestPageHandler,MessageHandler')]
procedure CustomerUpdateIsNotAllowedForJobTaskWithPostedSalesInvoice()
var
Job: Record Job;
JobTask: Record "Job Task";
JobPlanningLine: Record "Job Planning Line";
SalesHeader: Record "Sales Header";
SalesLine: Record "Sales Line";
Customers: array[2] of Record Customer;
begin
// [SCENARIO 433788] Customer Update is not Allowed for Job Task with Posted Sales Invoice
Initialize();
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] Create Customers
LibrarySales.CreateCustomer(Customers[1]);
LibrarySales.CreateCustomer(Customers[2]);
// [GIVEN] Create new Project
LibraryJob.CreateJob(Job, Customers[1]."No.");
// [GIVEN] Create new Project Task
LibraryJob.CreateJobTask(Job, JobTask);
// [GIVEN] Create Job Planning Line
LibraryJob.CreateJobPlanningLine(JobPlanningLine."Line Type"::Billable, JobPlanningLine.Type::Item, JobTask, JobPlanningLine);
Commit();
// [GIVEN] Enqueue data
LibraryVariableStorage.Enqueue(LinesTransferedToInvoiceMsg);
// [GIVEN] Create Sales Invoice
JobCreateInvoice.CreateSalesInvoice(JobPlanningLine, false);
// [GIVEN] Find Sales Document
FindSalesLine(SalesLine, SalesLine."Document Type"::Invoice, SalesLine.Type::Item, JobPlanningLine."Job No.");
SalesHeader.Get(SalesLine."Document Type", SalesLine."Document No.");
// [GIVEN] Post Sales Invoice
LibrarySales.PostSalesDocument(SalesHeader, true, true);
// [WHEN] Update Customer on Project
asserterror JobTask.Validate("Sell-to Customer No.", Customers[2]."No.");
// [THEN] Verify results
Assert.ExpectedError(StrSubstNo(AssociatedEntriesExistErr, JobTask.FieldCaption("Sell-to Customer No."), JobTask.TableCaption()));
end;
[Test]
procedure InvoiceCurrencyCodeOnJobTaskIsClearedOnValidateCurrencyCodeOnJob()
var
Job: Record Job;
JobTask: Record "Job Task";
Currency: array[2] of Record Currency;
begin
// [SCENARIO 498974] Invoice Currency Code on Job Task is cleared on Validate Currency Code on Job
Initialize();
// [GIVEN] Create Currencies
LibraryERM.CreateCurrency(Currency[1]);
LibraryERM.CreateCurrency(Currency[2]);
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] Create new Project and Project Task
CreateJobAndJobTask(Job, JobTask);
// [GIVEN] Set Invoice Currency Code on Project Task
JobTask.Validate("Invoice Currency Code", Currency[1].Code);
JobTask.Modify();
// [WHEN] Set Currency Code on Project
Job.Validate("Currency Code", Currency[2].Code);
Job.Modify();
// [THEN] Verify results
JobTask.Find('=');
Assert.AreEqual(JobTask."Invoice Currency Code", '', 'Invoice Currency Code is not cleared');
end;
[Test]
[HandlerFunctions('JobTaskMessageHandler')]
procedure ShowWarningMessageAboutJobChangesThatJobTaskWillNotBeUpdated()
var
Job: Record Job;
JobTask: Record "Job Task";
PaymentMethod: Record "Payment Method";
PaymentTerms: Record "Payment Terms";
Currency: Record Currency;
begin
// [SCENARIO 498976] Show Warning Message about Job Changes that Job Task will not be Updated
Initialize();
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] Create new Project and Project Task
CreateJobAndJobTask(Job, JobTask);
// [GIVEN] Create Payment Method
LibraryERM.CreatePaymentMethod(PaymentMethod);
// [WHEN] Update Payment Method Code on Project
LibraryVariableStorage.Enqueue(JobTask.FieldCaption("Payment Method Code"));
Job.Validate("Payment Method Code", PaymentMethod.Code);
// [THEN] Verify results
// [GIVEN] Create Payment Terms
LibraryERM.CreatePaymentTerms(PaymentTerms);
// [WHEN] Update Payment Terms Code on Project
LibraryVariableStorage.Enqueue(JobTask.FieldCaption("Payment Terms Code"));
Job.Validate("Payment Terms Code", PaymentTerms.Code);
// [THEN] Verify results
// [GIVEN] Create Currency
LibraryERM.CreateCurrency(Currency);
// [WHEN] Update Invoice Currency Code on Project
LibraryVariableStorage.Enqueue(JobTask.FieldCaption("Invoice Currency Code"));
Job.Validate("Invoice Currency Code", Currency.Code);
// [THEN] Verify results
end;
[Test]
procedure ClearJobTaskCustomerDataOnCopyJobForOneCustomerTaskBillingOptionOnTargetJob()
var
JobTasks: array[2] of Record "Job Task";
Jobs: array[2] of Record Job;
Customers: array[2] of Record Customer;
CopyJob: Codeunit "Copy Job";
begin
// [SCENARIO 498973] Clear Job Task Customer Data on Copy Job for One Customer Task Billing Option on Target Job
Initialize();
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] Create Customer
LibrarySales.CreateCustomer(Customers[1]);
LibrarySales.CreateCustomer(Customers[2]);
// [GIVEN] Create new Project
LibraryJob.CreateJob(Jobs[1], Customers[1]."No.");
// [GIVEN] Create new Project Task
LibraryJob.CreateJobTask(Jobs[1], JobTasks[1]);
// [GIVEN] Create new Project
LibraryJob.CreateJob(Jobs[2], Customers[2]."No.");
// [GIVEN] Set One Customer billing method on Project
Jobs[2].Validate("Task Billing Method", Jobs[2]."Task Billing Method"::"One customer");
Jobs[2].Modify(true);
// [WHEN] Copy Project Tasks
CopyJob.CopyJobTasks(Jobs[1], Jobs[2]);
// [THEN] Verify results
JobTasks[2].Get(Jobs[2]."No.", JobTasks[1]."Job Task No.");
JobTasks[2].TestField("Sell-to Customer No.", '');
JobTasks[2].TestField("Bill-to Customer No.", '');
end;
[Test]
procedure InitializeJobTaskCustomerDataOnCopyJobForMultipleCustomerTaskBillingOptionOnTargetJob()
var
JobTasks: array[2] of Record "Job Task";
Jobs: array[2] of Record Job;
Customers: array[2] of Record Customer;
CopyJob: Codeunit "Copy Job";
begin
// [SCENARIO 498973] Initialize Job Task Customer Data on Copy Job for Multiple Customer Task Billing Option on Target Job
Initialize();
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] Create Customer
LibrarySales.CreateCustomer(Customers[1]);
LibrarySales.CreateCustomer(Customers[2]);
// [GIVEN] Create new Project
LibraryJob.CreateJob(Jobs[1], Customers[1]."No.");
// [GIVEN] Create new Project Task
LibraryJob.CreateJobTask(Jobs[1], JobTasks[1]);
// [GIVEN] Create new Project
LibraryJob.CreateJob(Jobs[2], Customers[2]."No.");
// [WHEN] Copy Project Tasks
CopyJob.CopyJobTasks(Jobs[1], Jobs[2]);
// [THEN] Verify results
JobTasks[2].Get(Jobs[2]."No.", JobTasks[1]."Job Task No.");
JobTasks[2].TestField("Sell-to Customer No.", Customers[2]."No.");
JobTasks[2].TestField("Bill-to Customer No.", Customers[2]."No.");
end;
[Test]
[HandlerFunctions('GetJobPlanLines')]
procedure AllowCreatingSalesInvoiceLineOutsideOfProjectForMultipleCustomersBillingMethod()
var
Job: Record Job;
JobTask: Record "Job Task";
SalesHeader: Record "Sales Header";
SalesLine: Record "Sales Line";
JobPlanningLine: Record "Job Planning Line";
Customers: array[2] of Record Customer;
Qty: Decimal;
begin
// [SCENARIO 500367] Allow Creating Sales Invoice Line Outside of Project for Multiple Customers Billing Method
Initialize();
Qty := LibraryRandom.RandInt(10);
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] Create Customer
LibrarySales.CreateCustomer(Customers[1]);
LibrarySales.CreateCustomer(Customers[2]);
// [GIVEN] Create new Project
LibraryJob.CreateJob(Job, Customers[1]."No.");
// [GIVEN] Create new Project Task
LibraryJob.CreateJobTask(Job, JobTask);
// [GIVEN] Update Customer on Project Task
JobTask.Validate("Sell-to Customer No.", Customers[2]."No.");
JobTask.Modify(true);
// [GIVEN] Create Job Planning Line with Qty to Transfer to Invoice
CreateJobPlanningLineWithQtyToTransferToInvoice(JobPlanningLine, JobTask, Qty, Qty);
// [GIVEN] Create Sales Invoice
LibrarySales.CreateSalesHeader(SalesHeader, SalesHeader."Document Type"::Invoice, Customers[2]."No.");
// [GIVEN] Create Sales Line
CreateSimpleSalesLine(SalesLine, SalesHeader);
// [WHEN] Get Job Planning Lines
// [HANDLER] [GetJobPlanLines] Get Job Plan Lines
Codeunit.Run(Codeunit::"Job-Process Plan. Lines", SalesLine);
// [THEN] Verify Job Info on Sales Line
SalesLine.Get(SalesLine."Document Type", SalesLine."Document No.", SalesLine."Line No.");
SalesLine.TestField("Job No.", JobTask."Job No.");
SalesLine.TestField("Job Task No.", JobTask."Job Task No.");
SalesLine.TestField("Job Contract Entry No.", JobPlanningLine."Job Contract Entry No.");
end;
[Test]
[HandlerFunctions('GetJobPlanLines')]
procedure CheckInvoicedQtyOnJobPlanningLinesAfterSalesInvoiceCreatedFromJobPlanningLineIsPostedForMultipleCustomersBillingMethod()
var
Job: Record Job;
JobTask: Record "Job Task";
SalesHeader: Record "Sales Header";
SalesLine: Record "Sales Line";
JobPlanningLine: Record "Job Planning Line";
Customers: array[2] of Record Customer;
begin
// [SCENARIO 500367] Check Invoiced Qty. on Job Planning Line after Sales Invoice created from Job Planning Line is posted for Multiple Customers Billing Method
Initialize();
// [GIVEN] Set Multiple Customers on Project Setup
SetMultiupleCustomersOnProjectSetup();
// [GIVEN] Create Customer
LibrarySales.CreateCustomer(Customers[1]);
LibrarySales.CreateCustomer(Customers[2]);
// [GIVEN] Create new Project
LibraryJob.CreateJob(Job, Customers[1]."No.");
// [GIVEN] Create new Project Task
LibraryJob.CreateJobTask(Job, JobTask);
// [GIVEN] Update Customer on Project Task
JobTask.Validate("Sell-to Customer No.", Customers[2]."No.");
JobTask.Modify(true);
// [GIVEN] Create Job Planning Line with Qty to Transfer to Invoice
LibraryJob.CreateJobPlanningLine(LibraryJob.PlanningLineTypeContract(), LibraryJob.ItemType(), JobTask, JobPlanningLine);
// [GIVEN] Create Sales Invoice
LibrarySales.CreateSalesHeader(SalesHeader, SalesHeader."Document Type"::Invoice, Customers[2]."No.");
// [GIVEN] Create Sales Line
CreateSimpleSalesLine(SalesLine, SalesHeader);
// [GIVEN] Get Job Planning Lines
// [HANDLER] [GetPJobPlanLines] Get Job Plan Lines
Codeunit.Run(Codeunit::"Job-Process Plan. Lines", SalesLine);
// [WHEN] Post Sales Invoice
LibrarySales.PostSalesDocument(SalesHeader, false, true);
// [THEN] Verify Qty. Invoiced and Qty. Transferred to Invoice on Job Planning Line