-
Notifications
You must be signed in to change notification settings - Fork 380
[Subcontracting] Add feature mechanism for subcontracting app #8436
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
base: main
Are you sure you want to change the base?
Changes from all commits
42ce514
3655f42
58d9905
895a6b2
8bf534d
8f7282d
3219254
374f29d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // ------------------------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // ------------------------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespace Microsoft.Manufacturing.Subcontracting; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. File uses CRLF line endings inconsistentlyThe diff for this file shows Recommendation:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using Microsoft.Manufacturing.Setup; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| codeunit 99001569 "Subc. Feature Flag Handler" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| procedure IsSubcontractingEnabled(): Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feature flag issues DB read on every call
Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ManufacturingSetup: Record "Manufacturing Setup"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ManufacturingSetup.SetLoadFields("Legacy Subcontracting"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if not ManufacturingSetup.Get() then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit(false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit(not ManufacturingSetup."Legacy Subcontracting"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,12 +9,15 @@ codeunit 99001500 "Subc. Session State" | |||||||||||||||||||||||||||||||
| SingleInstance = true; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| var | ||||||||||||||||||||||||||||||||
| SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; | ||||||||||||||||||||||||||||||||
| CodeDictionary: Dictionary of [Text, Code[1024]]; | ||||||||||||||||||||||||||||||||
| DateDictionary: Dictionary of [Text, Date]; | ||||||||||||||||||||||||||||||||
| RecordIDDictionary: Dictionary of [Text, RecordId]; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| procedure ClearAllDictionariesForKey(StoredKey: Text) | ||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||
| if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SingleInstance cache defeated by per-call DB reads
Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||||||||||||||||||||||||
| exit; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if CodeDictionary.ContainsKey(StoredKey) then | ||||||||||||||||||||||||||||||||
| CodeDictionary.Remove(StoredKey); | ||||||||||||||||||||||||||||||||
|
|
@@ -28,6 +31,9 @@ codeunit 99001500 "Subc. Session State" | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| procedure SetCode(KeyToStore: Text; CodeToStore: Code[1024]) | ||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||
| if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then | ||||||||||||||||||||||||||||||||
| exit; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if CodeDictionary.ContainsKey(KeyToStore) then | ||||||||||||||||||||||||||||||||
| CodeDictionary.Set(KeyToStore, CodeToStore) | ||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||
|
|
@@ -36,6 +42,9 @@ codeunit 99001500 "Subc. Session State" | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| procedure SetDate(KeyToStore: Text; DateToStore: Date) | ||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||
| if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then | ||||||||||||||||||||||||||||||||
| exit; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if DateDictionary.ContainsKey(KeyToStore) then | ||||||||||||||||||||||||||||||||
| DateDictionary.Set(KeyToStore, DateToStore) | ||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||
|
|
@@ -44,6 +53,9 @@ codeunit 99001500 "Subc. Session State" | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| procedure SetRecordID(KeyToStore: Text; RecordIDToStore: RecordId) | ||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||
| if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then | ||||||||||||||||||||||||||||||||
| exit; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if RecordIDDictionary.ContainsKey(KeyToStore) then | ||||||||||||||||||||||||||||||||
| RecordIDDictionary.Set(KeyToStore, RecordIDToStore) | ||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||
|
|
@@ -52,18 +64,27 @@ codeunit 99001500 "Subc. Session State" | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| procedure GetCode(StoredKey: Text): Code[1024] | ||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||
| if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then | ||||||||||||||||||||||||||||||||
| exit; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if CodeDictionary.ContainsKey(StoredKey) then | ||||||||||||||||||||||||||||||||
| exit(CodeDictionary.Get(StoredKey)); | ||||||||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| procedure GetDate(StoredKey: Text): Date | ||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||
| if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then | ||||||||||||||||||||||||||||||||
| exit; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if DateDictionary.ContainsKey(StoredKey) then | ||||||||||||||||||||||||||||||||
| exit(DateDictionary.Get(StoredKey)); | ||||||||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| procedure GetRecordID(StoredKey: Text; var ReturnRecordID: RecordId) | ||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||
| if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then | ||||||||||||||||||||||||||||||||
| exit; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| Clear(ReturnRecordID); | ||||||||||||||||||||||||||||||||
| if RecordIDDictionary.ContainsKey(StoredKey) then | ||||||||||||||||||||||||||||||||
| ReturnRecordID := RecordIDDictionary.Get(StoredKey); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,21 @@ | ||||||||||||||
| // ------------------------------------------------------------------------------------------------ | ||||||||||||||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||||||||||||||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||||||||||||||
| // ------------------------------------------------------------------------------------------------ | ||||||||||||||
| namespace Microsoft.Manufacturing.Subcontracting; | ||||||||||||||
| using System.Upgrade; | ||||||||||||||
|
|
||||||||||||||
| codeunit 99001570 "Subc. Upgrade Tag Def. Ext." | ||||||||||||||
| { | ||||||||||||||
| [EventSubscriber(ObjectType::Codeunit, Codeunit::"Upgrade Tag", 'OnGetPerCompanyUpgradeTags', '', false, false)] | ||||||||||||||
| local procedure RegisterPerCompanyTags(var PerCompanyUpgradeTags: List of [Code[250]]) | ||||||||||||||
| begin | ||||||||||||||
| PerCompanyUpgradeTags.Add(GetSubcontractingUpgradeTag()); | ||||||||||||||
| end; | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| internal procedure GetSubcontractingUpgradeTag(): Code[250] | ||||||||||||||
| begin | ||||||||||||||
| exit('MS-406123-Subcontracting-20260601'); | ||||||||||||||
| end; | ||||||||||||||
| } | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. File missing newline at endThe new Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,9 @@ | |||||||||||||||||||||||||||||||||||||||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||||||||||||||||||||||||||||||||||||||||
| // ------------------------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| namespace Microsoft.Manufacturing.Subcontracting; | ||||||||||||||||||||||||||||||||||||||||
| using Microsoft.Manufacturing.Setup; | ||||||||||||||||||||||||||||||||||||||||
| using System.Upgrade; | ||||||||||||||||||||||||||||||||||||||||
| using Microsoft.Upgrade; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| codeunit 99001501 "Subcontracting Install" | ||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -36,6 +39,7 @@ codeunit 99001501 "Subcontracting Install" | |||||||||||||||||||||||||||||||||||||||
| SubcontractingCompInit: Codeunit "Subcontracting Comp. Init."; | ||||||||||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||||||||||
| SubcontractingCompInit.CreateBasicSubcontractingMgtSetup(); | ||||||||||||||||||||||||||||||||||||||||
| SetSubcontractingFeatureOnInstall(); | ||||||||||||||||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| local procedure HandleReinstallPerCompany() | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -52,4 +56,20 @@ codeunit 99001501 "Subcontracting Install" | |||||||||||||||||||||||||||||||||||||||
| local procedure HandleReinstallPerDatabase() | ||||||||||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| local procedure SetSubcontractingFeatureOnInstall() | ||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Upgrade path skips feature-flag initialisation
Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||||||||||||||||||||||||||||||||
| var | ||||||||||||||||||||||||||||||||||||||||
| ManufacturingSetup: Record "Manufacturing Setup"; | ||||||||||||||||||||||||||||||||||||||||
| UpgradeTag: Codeunit "Upgrade Tag"; | ||||||||||||||||||||||||||||||||||||||||
| SubcApplicationAreaHandler: Codeunit "Subc. Application Area Handler"; | ||||||||||||||||||||||||||||||||||||||||
| SubcUpgradeTagDefExt: Codeunit "Subc. Upgrade Tag Def. Ext."; | ||||||||||||||||||||||||||||||||||||||||
| UpgradeTagDefinitions: Codeunit "Upgrade Tag Definitions"; | ||||||||||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||||||||||
| if UpgradeTag.HasUpgradeTag(SubcUpgradeTagDefExt.GetSubcontractingUpgradeTag()) then | ||||||||||||||||||||||||||||||||||||||||
| exit; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| SubcApplicationAreaHandler.UpdateApplicationArea(); | ||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Install does not set Legacy Subcontracting default
Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| UpgradeTag.SetUpgradeTag(SubcUpgradeTagDefExt.GetSubcontractingUpgradeTag()); | ||||||||||||||||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The field "Legacy Subcontracting" is marked as obsolete 29, this code should follow the same and all the references to this as well