Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No. Series: Ability to extend filters on finding No. Series Lines when getting new numbers #2361

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
NumberFormatErr: Label 'The number format in %1 must be the same as the number format in %2.', Comment = '%1=No. Series Code,%2=No. Series Code';
UnIncrementableStringErr: Label 'The value in the %1 field must have a number so that we can assign the next number in the series.', Comment = '%1 = New Field Name';
NumberLengthErr: Label 'The number %1 cannot be extended to more than 20 characters.', Comment = '%1=No.';
CodeFieldChangedErr: Label 'The filter on %1 was altered by an event subscriber. This is a programming error. Please contact your partner to resolve the issue.\Original %1: %2\Modified Filter: %3';

Check failure on line 18 in src/Business Foundation/App/NoSeries/src/Setup/NoSeriesSetupImpl.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build System Application Modules (Default) / System Application Modules (Default)

AA0470 Variable 'CodeFieldChangedErr' with placeholders should have a comment explaining their content.

Check failure on line 18 in src/Business Foundation/App/NoSeries/src/Setup/NoSeriesSetupImpl.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build Business Foundation (Translated) / Business Foundation (Translated)

AA0470 Variable 'CodeFieldChangedErr' with placeholders should have a comment explaining their content.

Check failure on line 18 in src/Business Foundation/App/NoSeries/src/Setup/NoSeriesSetupImpl.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build Business Foundation (Clean) / Business Foundation (Clean)

AA0470 Variable 'CodeFieldChangedErr' with placeholders should have a comment explaining their content.

Check failure on line 18 in src/Business Foundation/App/NoSeries/src/Setup/NoSeriesSetupImpl.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build Business Foundation (Default) / Business Foundation (Default)

AA0470 Variable 'CodeFieldChangedErr' with placeholders should have a comment explaining their content.

Check failure on line 18 in src/Business Foundation/App/NoSeries/src/Setup/NoSeriesSetupImpl.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build System Application Modules (Clean) / System Application Modules (Clean)

AA0470 Variable 'CodeFieldChangedErr' with placeholders should have a comment explaining their content.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the error below shows, whenever you add a label with placeholder, you must add a comment specifying what those placeholders are. These are necessary for translation teams to translate the string better. This is required for all strings with placeholders because some string can be very difficult for a translator to understand when they almost fully consist of these placeholders..


procedure SetImplementation(var NoSeries: Record "No. Series"; Implementation: Enum "No. Series Implementation")
var
Expand Down Expand Up @@ -98,9 +99,7 @@
#endif
begin
NoSeriesLine.Reset();
NoSeriesLine.SetCurrentKey("Series Code", "Starting Date");
NoSeriesLine.SetRange("Series Code", NoSeriesRec.Code);
NoSeriesLine.SetRange("Starting Date", 0D, WorkDate());
SetNoSeriesLineFilters(NoSeriesLine, NoSeriesRec.Code, WorkDate());
#if not CLEAN24
#pragma warning disable AL0432
NoSeriesManagement.RaiseObsoleteOnNoSeriesLineFilterOnBeforeFindLast(NoSeriesLine);
Expand Down Expand Up @@ -137,6 +136,22 @@
exit(NoSeriesSingle.MayProduceGaps());
end;

procedure SetNoSeriesLineFilters(var NoSeriesLine: Record "No. Series Line"; NoSeriesCode: Code[20]; StartingDate: Date)
var
NoSeries: Codeunit "No. Series";
NoSeriesLine2: Record "No. Series Line";

Check failure on line 142 in src/Business Foundation/App/NoSeries/src/Setup/NoSeriesSetupImpl.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build System Application Modules (Default) / System Application Modules (Default)

AA0021 Variable declarations should be ordered by type. Variables should be sorted like this: Record, Report, Codeunit, XmlPort, Page, Query, Notification, BigText, DateFormula, RecordId, RecordRef, FieldRef, and FilterPageBuilder. The rest of the variables are not sorted.

Check failure on line 142 in src/Business Foundation/App/NoSeries/src/Setup/NoSeriesSetupImpl.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build Business Foundation (Translated) / Business Foundation (Translated)

AA0021 Variable declarations should be ordered by type. Variables should be sorted like this: Record, Report, Codeunit, XmlPort, Page, Query, Notification, BigText, DateFormula, RecordId, RecordRef, FieldRef, and FilterPageBuilder. The rest of the variables are not sorted.

Check failure on line 142 in src/Business Foundation/App/NoSeries/src/Setup/NoSeriesSetupImpl.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build Business Foundation (Clean) / Business Foundation (Clean)

AA0021 Variable declarations should be ordered by type. Variables should be sorted like this: Record, Report, Codeunit, XmlPort, Page, Query, Notification, BigText, DateFormula, RecordId, RecordRef, FieldRef, and FilterPageBuilder. The rest of the variables are not sorted.

Check failure on line 142 in src/Business Foundation/App/NoSeries/src/Setup/NoSeriesSetupImpl.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build Business Foundation (Default) / Business Foundation (Default)

AA0021 Variable declarations should be ordered by type. Variables should be sorted like this: Record, Report, Codeunit, XmlPort, Page, Query, Notification, BigText, DateFormula, RecordId, RecordRef, FieldRef, and FilterPageBuilder. The rest of the variables are not sorted.

Check failure on line 142 in src/Business Foundation/App/NoSeries/src/Setup/NoSeriesSetupImpl.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build System Application Modules (Clean) / System Application Modules (Clean)

AA0021 Variable declarations should be ordered by type. Variables should be sorted like this: Record, Report, Codeunit, XmlPort, Page, Query, Notification, BigText, DateFormula, RecordId, RecordRef, FieldRef, and FilterPageBuilder. The rest of the variables are not sorted.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See errors below, basically the sorting of variables must be fixed, Record comes before codeunit.

begin
NoSeriesLine2.SetCurrentKey("Series Code", "Starting Date");
NoSeriesLine2.SetRange("Starting Date", 0D, StartingDate);
NoSeriesLine2.SetRange("Series Code", NoSeriesCode);
NoSeries.OnSetNoSeriesLineFilters(NoSeriesLine2);
if NoSeriesLine2.GetFilter("Series Code") <> NoSeriesCode then
Error(CodeFieldChangedErr, NoSeriesLine2.FieldCaption("Series Code"), NoSeriesCode, NoSeriesLine2.GetFilter("Series Code"));

NoSeriesLine.SetCurrentKey("Series Code", "Starting Date");
NoSeriesLine.CopyFilters(NoSeriesLine2);
end;

procedure CalculateOpen(NoSeriesLine: Record "No. Series Line"): Boolean
var
NoSeries: Codeunit "No. Series";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,14 @@ codeunit 310 "No. Series"
internal procedure OnAfterSetNoSeriesCurrentLineFilters(NoSeries: Record "No. Series"; var NoSeriesLine: Record "No. Series Line"; IsDrillDown: Boolean);
begin
end;

/// <summary>
/// Use this event to set additional filters on the No. Series Line record. These filters are used when searching the No. Series.
/// </summary>
/// <remarks>Changing the filter on the "Series Code" field is not allowed and will result in an error.</remarks>
/// <param name="NoSeriesLine">The No. Series Line to set filters on.</param>
PeterDurrer marked this conversation as resolved.
Show resolved Hide resolved
[IntegrationEvent(false, false)]
internal procedure OnSetNoSeriesLineFilters(var NoSeriesLine: Record "No. Series Line");
begin
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ codeunit 304 "No. Series - Impl."
NoSeriesRec: Record "No. Series";
NoSeriesLine2: Record "No. Series Line";
NoSeries: Codeunit "No. Series";
NoSeriesSetupImpl: Codeunit "No. Series - Setup Impl.";
NoSeriesErrorsImpl: Codeunit "No. Series - Errors Impl.";
#if not CLEAN24
#pragma warning disable AL0432
Expand All @@ -174,9 +175,7 @@ codeunit 304 "No. Series - Impl."

// Find the No. Series Line closest to the usage date
NoSeriesLine2.Reset();
NoSeriesLine2.SetCurrentKey("Series Code", "Starting Date");
NoSeriesLine2.SetRange("Series Code", NoSeriesCode);
NoSeriesLine2.SetRange("Starting Date", 0D, UsageDate);
NoSeriesSetupImpl.SetNoSeriesLineFilters(NoSeriesLine2, NoSeriesCode, UsageDate);
#if not CLEAN24
#pragma warning disable AL0432
NoSeriesManagement.RaiseObsoleteOnNoSeriesLineFilterOnBeforeFindLast(NoSeriesLine2);
Expand Down
Loading