diff --git a/Prototyping/.vscode/launch.json b/Prototyping/.vscode/launch.json new file mode 100644 index 0000000..b1330a3 --- /dev/null +++ b/Prototyping/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + "version": "0.2.0", + "configurations": [ + { + //https://businesscentral.dynamics.com/2384b7c3-109e-4c22-8731-4394fb3aa627/QA_Feature?company=PrintVis%20Inc.&page=2500&dc=0&bookmark=18_zpQ1dwCRhyKkVlN-IUu7elgqmuaGXA + //https://businesscentral.dynamics.com/2384b7c3-109e-4c22-8731-4394fb3aa627/JH-Test + "name": "Microsoft cloud sandbox", + "request": "launch", + "type": "al", + "environmentType": "Sandbox", + "environmentName": "JH-Test", + "tenant": "2384b7c3-109e-4c22-8731-4394fb3aa627", + "startupObjectId": 22, + "startupObjectType": "Page", + "breakOnError": "All", + "launchBrowser": true, + "enableLongRunningSqlStatements": true, + "enableSqlInformationDebugger": true + } + ] +} \ No newline at end of file diff --git a/Prototyping/PVSJobItemMinReelWidth.Codeunit.al b/Prototyping/PVSJobItemMinReelWidth.Codeunit.al new file mode 100644 index 0000000..21e5b22 --- /dev/null +++ b/Prototyping/PVSJobItemMinReelWidth.Codeunit.al @@ -0,0 +1,67 @@ +codeunit 50103 "PVS Job Item Min Reel Width" +{ + [EventSubscriber(ObjectType::Table, Database::"PVS Job Item", 'OnAfterValidateEvent', 'Final Format Code', false, false)] + local procedure OnAfterValidateFormatCode(var Rec: Record "PVS Job Item"; var xRec: Record "PVS Job Item") + begin + CalcMinReelWidth(Rec); + end; + + [EventSubscriber(ObjectType::Table, Database::"PVS Job Item", 'OnAfterValidateEvent', 'Controlling Sheet Unit', false, false)] + local procedure OnAfterValidateControllingSheetUnit(var Rec: Record "PVS Job Item"; var xRec: Record "PVS Job Item") + begin + CalcMinReelWidth(Rec); + end; + + [EventSubscriber(ObjectType::Table, Database::"PVS Job Item", 'OnAfterValidateEvent', 'Imposition Type', false, false)] + local procedure OnAfterValidateImpositionType(var Rec: Record "PVS Job Item"; var xRec: Record "PVS Job Item") + begin + CalcMinReelWidth(Rec); + end; + + [EventSubscriber(ObjectType::Table, Database::"PVS Job Item", 'OnAfterValidateEvent', 'Front Overfold', false, false)] + local procedure OnAfterValidateFrontOverfold(var Rec: Record "PVS Job Item"; var xRec: Record "PVS Job Item") + begin + CalcMinReelWidth(Rec); + end; + + local procedure CalcMinReelWidth(var Rec: Record "PVS Job Item") + var + ImpositionRec: Record "PVS Imposition Code"; + Guard: Codeunit "PVS Min Reel Width Guard"; + LeavesWidth: Decimal; + begin + if Guard.IsCalcInProgress() then + exit; + + if not ComponentTypeIsInside(Rec."Component Type") then + exit; + + Rec.CalcFields("Controlling Sheet Unit"); + if (Rec."Final Format Code" = '') or (Rec."Controlling Sheet Unit" = '') or (Rec."Imposition Type" = '') then + exit; + + if not ImpositionRec.Get(Rec."Imposition Type") then + exit; + + LeavesWidth := ImpositionRec."Leaves Width"; + + Guard.SetCalcInProgress(true); + if TryApplyMinReelWidth(Rec, LeavesWidth) then; // errors silenced; execution always reaches the next line + Guard.SetCalcInProgress(false); + end; + + [TryFunction] + local procedure TryApplyMinReelWidth(var Rec: Record "PVS Job Item"; LeavesWidth: Decimal) + begin + // Direct assignment does not fire OnValidate; no recursion risk here + Rec."Minimum Reel Width" := + (LeavesWidth * Rec.Width) + + ((LeavesWidth / 2) * (Rec."Front Overfold" + Rec."Milling Depth")); + end; + + local procedure ComponentTypeIsInside(ComponentType: Code[10]): Boolean + begin + // Matches component types whose code contains 'INSIDE', consistent with the '*INSIDE*' filter in the spec + exit(StrPos(UpperCase(ComponentType), 'INSIDE') > 0); + end; +} diff --git a/Prototyping/PVSJobItemMinReelWidth.TableExt.al b/Prototyping/PVSJobItemMinReelWidth.TableExt.al new file mode 100644 index 0000000..c57aa49 --- /dev/null +++ b/Prototyping/PVSJobItemMinReelWidth.TableExt.al @@ -0,0 +1,26 @@ +tableextension 50100 "PVS Job Item Min Reel Width" extends "PVS Job Item" +{ + fields + { + field(50100; "Minimum Reel Width"; Decimal) + { + Caption = 'Minimum Reel Width'; + DataClassification = CustomerContent; + ToolTip = 'Minimum Reel Width in mm'; + + trigger OnValidate() + var + Diff: Decimal; + Guard: Codeunit "PVS Min Reel Width Guard"; + begin + if Guard.IsCalcInProgress() then + exit; + // xRec holds the pre-validate value; Diff is 0 when unchanged (e.g. first-time insert) + Diff := Rec."Minimum Reel Width" - xRec."Minimum Reel Width"; + if (Diff <> 0) and (xRec."Minimum Reel Width" <> 0) then + // Per spec: the difference (new - old) is added 1:1 to Front Overfold + Rec."Front Overfold" := Rec."Front Overfold" + Diff; + end; + } + } +} diff --git a/Prototyping/PVSJobItemsListPart.PageExt.al b/Prototyping/PVSJobItemsListPart.PageExt.al new file mode 100644 index 0000000..7baefb9 --- /dev/null +++ b/Prototyping/PVSJobItemsListPart.PageExt.al @@ -0,0 +1,15 @@ +pageextension 50101 "PVS Job Items ListPart Ext" extends "PVS Job Items ListPart" +{ + layout + { + addafter(ImpositionType) + { + field("Minimum Reel Width"; Rec."Minimum Reel Width") + { + ApplicationArea = All; + Caption = 'Minimum Reel Width'; + ToolTip = 'Minimum Reel Width in mm'; + } + } + } +} diff --git a/Prototyping/PVSMinReelWidthGuard.Codeunit.al b/Prototyping/PVSMinReelWidthGuard.Codeunit.al new file mode 100644 index 0000000..60586a1 --- /dev/null +++ b/Prototyping/PVSMinReelWidthGuard.Codeunit.al @@ -0,0 +1,17 @@ +codeunit 50101 "PVS Min Reel Width Guard" +{ + SingleInstance = true; + + var + CalcInProgress: Boolean; + + procedure SetCalcInProgress(Value: Boolean) + begin + CalcInProgress := Value; + end; + + procedure IsCalcInProgress(): Boolean + begin + exit(CalcInProgress); + end; +} diff --git a/Prototyping/Thirsday25App.code-workspace b/Prototyping/Thirsday25App.code-workspace new file mode 100644 index 0000000..e3e2fed --- /dev/null +++ b/Prototyping/Thirsday25App.code-workspace @@ -0,0 +1,10 @@ +{ + "folders": [ + { + "path": "Thirsday25App" + } + ], + "settings": { + "al.enableCodeAnalysis": false + } +} diff --git a/Prototyping/Thirsday25App/app.json b/Prototyping/Thirsday25App/app.json new file mode 100644 index 0000000..155b24c --- /dev/null +++ b/Prototyping/Thirsday25App/app.json @@ -0,0 +1,39 @@ +{ + "id": "2d9f26a9-f8e2-4695-9dc7-16f8ad2b28fe", + "name": "Thirsday25 app", + "publisher": "PrintVis", + "version": "1.0.0.0", + "brief": "", + "description": "", + "privacyStatement": "", + "EULA": "", + "help": "", + "url": "", + "logo": "", + "dependencies": [ + { + "id": "5452f323-059e-499a-9753-5d2c07eef904", + "name": "PrintVis", + "publisher": "PrintVis A/S", + "version": "28.0.0.0" + } + ], + "screenshots": [], + "platform": "1.0.0.0", + "application": "28.0.0.0", + "idRanges": [ + { + "from": 51000, + "to": 51999 + } + ], + "resourceExposurePolicy": { + "allowDebugging": true, + "allowDownloadingSource": true, + "includeSourceInSymbolFile": true + }, + "runtime": "16.0", + "features": [ + "NoImplicitWith" + ] +} \ No newline at end of file diff --git a/Prototyping/Thirsday25App/src/THRThursday25Install.Codeunit.al b/Prototyping/Thirsday25App/src/THRThursday25Install.Codeunit.al new file mode 100644 index 0000000..eea6e68 --- /dev/null +++ b/Prototyping/Thirsday25App/src/THRThursday25Install.Codeunit.al @@ -0,0 +1,8 @@ +codeunit 50102 "THR Thursday25 Install" +{ + Subtype = Install; + + trigger OnInstallAppPerCompany() + begin + end; +}