From 68b95b0f1e5c6359bd5e9f15509ad495aaa91e65 Mon Sep 17 00:00:00 2001 From: Finn Pedersen Date: Wed, 20 Dec 2023 10:57:21 +0100 Subject: [PATCH] Fixed remaning Rulesets --- .vscode/AfterConversion.ruleset.json | 4 +-- App/NextPeriodeCalcBatch.Report.al | 6 ++-- App/QtyToShipCalcBatch.Report.al | 6 ++-- .../SubscriptionOrder.PageExt.al | 12 +++---- Tests/TestSubscriptionApp.Codeunit.al | 33 ++++++++++--------- 5 files changed, 32 insertions(+), 29 deletions(-) diff --git a/.vscode/AfterConversion.ruleset.json b/.vscode/AfterConversion.ruleset.json index c736db0..7c737ff 100644 --- a/.vscode/AfterConversion.ruleset.json +++ b/.vscode/AfterConversion.ruleset.json @@ -159,7 +159,7 @@ }, { "id": "AA0072", - "action": "None", + "action": "Error", "justification": "The name of variables and parameters must be suffixed with the type or object name. BEST PRACTICES." }, { @@ -169,7 +169,7 @@ }, { "id": "AA0217", - "action": "None", + "action": "Error", "justification": "Use a text constant or label for format string in StrSubstNo. BEST PRACTICES." }, { diff --git a/App/NextPeriodeCalcBatch.Report.al b/App/NextPeriodeCalcBatch.Report.al index 6587673..7c7ad90 100644 --- a/App/NextPeriodeCalcBatch.Report.al +++ b/App/NextPeriodeCalcBatch.Report.al @@ -21,8 +21,8 @@ report 50140 "Next Periode Calc Batch" Counter := Counter + 1; WindowDialog.Update(1, "No."); WindowDialog.Update(2, ROUND(Counter / CounterTotal * 10000, 1)); - Clear(FPFrSubscriptionManagement); - FPFrSubscriptionManagement.CalculateNextSubscriptionPeriodOne("Sales Header"); + Clear(SubscriptionManagement); + SubscriptionManagement.CalculateNextSubscriptionPeriodOne("Sales Header"); CounterOK := CounterOK + 1; if MarkedOnly then Mark(false); @@ -63,7 +63,7 @@ report 50140 "Next Periode Calc Batch" } var - FPFrSubscriptionManagement: Codeunit "Subscription Management"; + SubscriptionManagement: Codeunit "Subscription Management"; UpdatingBlanketOrdersLbl: label 'Updating Blanket Orders #1########## @2@@@@@@@@@@@@@', Comment = '%1 = Order Number; %2 = Counter'; CounterLbl: label '%1 blanket orders out of a total of %2 have now been evaluated.', Comment = '%1 = Counter; %2 = Counter Total'; WindowDialog: Dialog; diff --git a/App/QtyToShipCalcBatch.Report.al b/App/QtyToShipCalcBatch.Report.al index 729c9fc..10fe1de 100644 --- a/App/QtyToShipCalcBatch.Report.al +++ b/App/QtyToShipCalcBatch.Report.al @@ -21,8 +21,8 @@ report 50141 "Qty to Ship Calc Batch" Counter := Counter + 1; WindowDialog.Update(1, "No."); WindowDialog.Update(2, ROUND(Counter / CounterTotal * 10000, 1)); - Clear(FPFrSubscriptionManagement); - FPFrSubscriptionManagement.CalculateQuantityToShipOne("Sales Header"); + Clear(SubscriptionManagement); + SubscriptionManagement.CalculateQuantityToShipOne("Sales Header"); CounterOK := CounterOK + 1; if MarkedOnly then Mark(false); @@ -63,7 +63,7 @@ report 50141 "Qty to Ship Calc Batch" } var - FPFrSubscriptionManagement: Codeunit "Subscription Management"; + SubscriptionManagement: Codeunit "Subscription Management"; UpdatingBlanketOrdersLbl: label 'Updating Blanket Orders #1########## @2@@@@@@@@@@@@@', Comment = '%1 = Order Number; %2 = Counter'; CounterLbl: label '%1 blanket orders out of a total of %2 have now been evaluated.', Comment = '%1 = Counter; %2 = Counter Total'; WindowDialog: Dialog; diff --git a/App/StandardPageExtensions/SubscriptionOrder.PageExt.al b/App/StandardPageExtensions/SubscriptionOrder.PageExt.al index 9201e6a..2b8604b 100644 --- a/App/StandardPageExtensions/SubscriptionOrder.PageExt.al +++ b/App/StandardPageExtensions/SubscriptionOrder.PageExt.al @@ -20,9 +20,9 @@ pageextension 50143 "Subscription Order" extends "Blanket Sales Order" trigger OnAction() var - FPFrSubscriptionManagement: Codeunit "Subscription Management"; + SubscriptionManagement: Codeunit "Subscription Management"; begin - FPFrSubscriptionManagement.CalculateQuantityToShipYN(Rec); + SubscriptionManagement.CalculateQuantityToShipYN(Rec); end; } action(MakeOrders) @@ -34,9 +34,9 @@ pageextension 50143 "Subscription Order" extends "Blanket Sales Order" trigger OnAction() var - FPFrSubscriptionManagement: Codeunit "Subscription Management"; + SubscriptionManagement: Codeunit "Subscription Management"; begin - FPFrSubscriptionManagement.MakeOrderYN(Rec); + SubscriptionManagement.MakeOrderYN(Rec); end; } action("Calculate Next Subscription Period") @@ -48,9 +48,9 @@ pageextension 50143 "Subscription Order" extends "Blanket Sales Order" trigger OnAction() var - FPFrSubscriptionManagement: Codeunit "Subscription Management"; + SubscriptionManagement: Codeunit "Subscription Management"; begin - FPFrSubscriptionManagement.CalculateNextSubscriptionPeriodYN(Rec); + SubscriptionManagement.CalculateNextSubscriptionPeriodYN(Rec); end; } } diff --git a/Tests/TestSubscriptionApp.Codeunit.al b/Tests/TestSubscriptionApp.Codeunit.al index 7a85dd6..ea3dee6 100644 --- a/Tests/TestSubscriptionApp.Codeunit.al +++ b/Tests/TestSubscriptionApp.Codeunit.al @@ -11,7 +11,7 @@ codeunit 50144 "Test Subscription App" var StandardLibrary: Codeunit "Standard Library"; Assert: Codeunit Assert; - FPFrEventSubscribers: Codeunit "Event Subscribers"; + EventSubscribers: Codeunit "Event Subscribers"; @@ -23,7 +23,7 @@ codeunit 50144 "Test Subscription App" [Test] procedure TestXMLFormatEnum() var - FPFrSubscriptionEnum: Enum "Subscription Enum"; + SubscriptionEnum: Enum "Subscription Enum"; begin // [SCENARIO #001] Formating Enum @@ -31,9 +31,9 @@ codeunit 50144 "Test Subscription App" // [WHEN] formating // [THEN] correct XML string - Assert.AreEqual('0', StandardLibrary.XMLFormat(FPFrSubscriptionEnum::" "), ''); - Assert.AreEqual('1', StandardLibrary.XMLFormat(FPFrSubscriptionEnum::Recurring), ''); - Assert.AreEqual('2', StandardLibrary.XMLFormat(FPFrSubscriptionEnum::Stop), ''); + Assert.AreEqual('0', StandardLibrary.XMLFormat(SubscriptionEnum::" "), ''); + Assert.AreEqual('1', StandardLibrary.XMLFormat(SubscriptionEnum::Recurring), ''); + Assert.AreEqual('2', StandardLibrary.XMLFormat(SubscriptionEnum::Stop), ''); end; @@ -47,7 +47,7 @@ codeunit 50144 "Test Subscription App" SalesHeader: Record "Sales Header"; SalesLine1: Record "Sales Line"; SalesLine2: Record "Sales Line"; - FPFrSubscriptionMgt: Codeunit "Subscription Management"; + SubscriptionManagement: Codeunit "Subscription Management"; DateExpression: DateFormula; ThisDay: Date; LineNumber: Integer; @@ -62,7 +62,7 @@ codeunit 50144 "Test Subscription App" // [THEN] correct XML string DebuggingMode := true; - BindSubscription(FPFrEventSubscribers); + BindSubscription(EventSubscribers); ThisDay := DMY2Date(1, 1, 2024); WorkDate(ThisDay); @@ -104,7 +104,7 @@ codeunit 50144 "Test Subscription App" SalesLine1.Init(); SalesLine1.Validate("Document Type", SalesHeader."Document Type"); SalesLine1.Validate("Document No.", SalesHeader."No."); - LineNumber := FPFrSubscriptionMgt.GetNextLineNumber(SalesHeader); + LineNumber := SubscriptionManagement.GetNextLineNumber(SalesHeader); SalesLine1.Validate("Line No.", LineNumber); SalesLine1.Insert(true); SalesLine1.Validate(Type, SalesLine1.Type::Item); @@ -122,7 +122,7 @@ codeunit 50144 "Test Subscription App" SalesLine2.Init(); SalesLine2.Validate("Document Type", SalesHeader."Document Type"); SalesLine2.Validate("Document No.", SalesHeader."No."); - LineNumber := FPFrSubscriptionMgt.GetNextLineNumber(SalesHeader); + LineNumber := SubscriptionManagement.GetNextLineNumber(SalesHeader); SalesLine2.Validate("Line No.", LineNumber); SalesLine2.Insert(true); SalesLine2.Validate(Type, SalesLine2.Type::Item); @@ -150,21 +150,21 @@ codeunit 50144 "Test Subscription App" BlanketOrderStatus := SalesHeaderStatus(SalesHeader); for Counter := 1 to 10 do begin - FPFrSubscriptionMgt.CalculateQuantityToShipYN(SalesHeader); + SubscriptionManagement.CalculateQuantityToShipYN(SalesHeader); BlanketOrderStatus := SalesHeaderStatus(SalesHeader); - FPFrSubscriptionMgt.MakeOrderYN(SalesHeader); + SubscriptionManagement.MakeOrderYN(SalesHeader); SimulatePosting(SalesHeader); BlanketOrderStatus := SalesHeaderStatus(SalesHeader); - FPFrSubscriptionMgt.CalculateNextSubscriptionPeriodYN(SalesHeader); + SubscriptionManagement.CalculateNextSubscriptionPeriodYN(SalesHeader); BlanketOrderStatus := SalesHeaderStatus(SalesHeader); ThisDay := CalcDate('<1D>', ThisDay); WorkDate(ThisDay); end; - UnbindSubscription(FPFrEventSubscribers); + UnbindSubscription(EventSubscribers); end; procedure SimulatePosting(SalesHeader: Record "Sales Header") @@ -187,6 +187,8 @@ codeunit 50144 "Test Subscription App" var SalesLine: Record "Sales Line"; String: Text; + StatusTxt: Label 'Line %1, Date %2, Qty %3, To Ship %4, To inv %5, Shipped %6, Invoiced %7', + Comment = '%1 = Line No., %2 = Date, %3 = Quantity, %4 = Qty. to Ship, %5 = Qty. to Invoice, %6 = Quantity Shipped, %7 = Quantity Invoiced)'; begin // String := StrSubstNo('%1 %2 %3\', Format(SalesHeader."Document Type"), SalesHeader."No.", SalesHeader."Document Date"); SalesLine.SetRange("Document Type", SalesHeader."Document Type"); @@ -194,14 +196,15 @@ codeunit 50144 "Test Subscription App" if SalesLine.FindSet() then repeat String := String + - StrSubstNo('Line %1, Date %2, Qty %3, To Ship %4, To inv %5, Shipped %6, Invoiced %7\', + StrSubstNo(StatusTxt, SalesLine."Line No.", Format(SalesLine."Shipment Date", 0, 9), SalesLine.Quantity, SalesLine."Qty. to Ship", SalesLine."Qty. to Invoice", SalesLine."Quantity Shipped", - SalesLine."Quantity Invoiced"); + SalesLine."Quantity Invoiced") + + '\'; until SalesLine.Next() = 0; exit(String); end;