From 8299a7c55782cfd07b84cab4bee9eee1a976daa0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Jun 2026 12:47:24 +0000 Subject: [PATCH 1/5] Add Minimum Reel Width field to PVS Job Item with calculation logic --- .../PVSJobItemMinReelWidth.Codeunit.al | 52 +++++++++++++++++++ .../PVSJobItemMinReelWidth.TableExt.al | 21 ++++++++ Prototyping/PVSJobItemsListPart.PageExt.al | 16 ++++++ 3 files changed, 89 insertions(+) create mode 100644 Prototyping/PVSJobItemMinReelWidth.Codeunit.al create mode 100644 Prototyping/PVSJobItemMinReelWidth.TableExt.al create mode 100644 Prototyping/PVSJobItemsListPart.PageExt.al diff --git a/Prototyping/PVSJobItemMinReelWidth.Codeunit.al b/Prototyping/PVSJobItemMinReelWidth.Codeunit.al new file mode 100644 index 0000000..369e2a3 --- /dev/null +++ b/Prototyping/PVSJobItemMinReelWidth.Codeunit.al @@ -0,0 +1,52 @@ +codeunit 50100 "PVS Job Item Min Reel Width" +{ + [EventSubscriber(ObjectType::Table, Database::"PVS Job Item", 'OnAfterValidateEvent', '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"; + LeavesWidth: Decimal; + begin + if not ComponentTypeIsInside(Rec."Component Type") then + exit; + + if (Rec."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"; + + Rec."Minimum Reel Width" := + (LeavesWidth * Rec.Width) + + ((LeavesWidth / 2) * (Rec."Front Overfold" + Rec."Milling Depth")); + end; + + local procedure ComponentTypeIsInside(ComponentType: Code[10]): Boolean + begin + exit(StrPos(ComponentType, 'INSIDE') > 0); + end; +} diff --git a/Prototyping/PVSJobItemMinReelWidth.TableExt.al b/Prototyping/PVSJobItemMinReelWidth.TableExt.al new file mode 100644 index 0000000..bdbb4c8 --- /dev/null +++ b/Prototyping/PVSJobItemMinReelWidth.TableExt.al @@ -0,0 +1,21 @@ +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; + begin + Diff := Rec."Minimum Reel Width" - xRec."Minimum Reel Width"; + if Diff <> 0 then + 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..be75dc4 --- /dev/null +++ b/Prototyping/PVSJobItemsListPart.PageExt.al @@ -0,0 +1,16 @@ +pageextension 50101 "PVS Job Items ListPart Ext" extends "PVS Job Items ListPart" +{ + layout + { + addafter("Imposition Type") + { + field("Minimum Reel Width"; Rec."Minimum Reel Width") + { + ApplicationArea = All; + Caption = 'Minimum Reel Width'; + ToolTip = 'Minimum Reel Width in mm'; + Editable = true; + } + } + } +} From a3cfa196fa8d047f29b9fd3a272639b34df13c7e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Jun 2026 12:49:38 +0000 Subject: [PATCH 2/5] Fix recursion guard, case sensitivity, and redundant Editable property --- Prototyping/PVSJobItemMinReelWidth.Codeunit.al | 8 +++++++- Prototyping/PVSJobItemMinReelWidth.TableExt.al | 3 +++ Prototyping/PVSJobItemsListPart.PageExt.al | 1 - Prototyping/PVSMinReelWidthGuard.Codeunit.al | 17 +++++++++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 Prototyping/PVSMinReelWidthGuard.Codeunit.al diff --git a/Prototyping/PVSJobItemMinReelWidth.Codeunit.al b/Prototyping/PVSJobItemMinReelWidth.Codeunit.al index 369e2a3..40ecfcd 100644 --- a/Prototyping/PVSJobItemMinReelWidth.Codeunit.al +++ b/Prototyping/PVSJobItemMinReelWidth.Codeunit.al @@ -27,8 +27,12 @@ codeunit 50100 "PVS Job Item Min Reel Width" 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; @@ -40,13 +44,15 @@ codeunit 50100 "PVS Job Item Min Reel Width" LeavesWidth := ImpositionRec."Leaves Width"; + Guard.SetCalcInProgress(true); Rec."Minimum Reel Width" := (LeavesWidth * Rec.Width) + ((LeavesWidth / 2) * (Rec."Front Overfold" + Rec."Milling Depth")); + Guard.SetCalcInProgress(false); end; local procedure ComponentTypeIsInside(ComponentType: Code[10]): Boolean begin - exit(StrPos(ComponentType, 'INSIDE') > 0); + exit(StrPos(UpperCase(ComponentType), 'INSIDE') > 0); end; } diff --git a/Prototyping/PVSJobItemMinReelWidth.TableExt.al b/Prototyping/PVSJobItemMinReelWidth.TableExt.al index bdbb4c8..326ea21 100644 --- a/Prototyping/PVSJobItemMinReelWidth.TableExt.al +++ b/Prototyping/PVSJobItemMinReelWidth.TableExt.al @@ -11,7 +11,10 @@ tableextension 50100 "PVS Job Item Min Reel Width" extends "PVS Job Item" trigger OnValidate() var Diff: Decimal; + Guard: Codeunit "PVS Min Reel Width Guard"; begin + if Guard.IsCalcInProgress() then + exit; Diff := Rec."Minimum Reel Width" - xRec."Minimum Reel Width"; if Diff <> 0 then Rec."Front Overfold" := Rec."Front Overfold" + Diff; diff --git a/Prototyping/PVSJobItemsListPart.PageExt.al b/Prototyping/PVSJobItemsListPart.PageExt.al index be75dc4..37d4115 100644 --- a/Prototyping/PVSJobItemsListPart.PageExt.al +++ b/Prototyping/PVSJobItemsListPart.PageExt.al @@ -9,7 +9,6 @@ pageextension 50101 "PVS Job Items ListPart Ext" extends "PVS Job Items ListPart ApplicationArea = All; Caption = 'Minimum Reel Width'; ToolTip = 'Minimum Reel Width in mm'; - Editable = true; } } } 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; +} From 3cb168cc0ee184ff53d30d4b810ff0079a5492b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Jun 2026 12:51:16 +0000 Subject: [PATCH 3/5] Use TryFunction for safe guard reset and add spec comment --- Prototyping/PVSJobItemMinReelWidth.Codeunit.al | 9 ++++++++- Prototyping/PVSJobItemMinReelWidth.TableExt.al | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Prototyping/PVSJobItemMinReelWidth.Codeunit.al b/Prototyping/PVSJobItemMinReelWidth.Codeunit.al index 40ecfcd..8d2a5ef 100644 --- a/Prototyping/PVSJobItemMinReelWidth.Codeunit.al +++ b/Prototyping/PVSJobItemMinReelWidth.Codeunit.al @@ -45,14 +45,21 @@ codeunit 50100 "PVS Job Item Min Reel Width" LeavesWidth := ImpositionRec."Leaves Width"; Guard.SetCalcInProgress(true); + TryApplyMinReelWidth(Rec, LeavesWidth); + Guard.SetCalcInProgress(false); + end; + + [TryFunction] + local procedure TryApplyMinReelWidth(var Rec: Record "PVS Job Item"; LeavesWidth: Decimal) + begin Rec."Minimum Reel Width" := (LeavesWidth * Rec.Width) + ((LeavesWidth / 2) * (Rec."Front Overfold" + Rec."Milling Depth")); - Guard.SetCalcInProgress(false); 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 index 326ea21..13ca429 100644 --- a/Prototyping/PVSJobItemMinReelWidth.TableExt.al +++ b/Prototyping/PVSJobItemMinReelWidth.TableExt.al @@ -15,6 +15,7 @@ tableextension 50100 "PVS Job Item Min Reel Width" extends "PVS Job Item" begin if Guard.IsCalcInProgress() then exit; + // Per spec: the difference (new - old) is added 1:1 to Front Overfold Diff := Rec."Minimum Reel Width" - xRec."Minimum Reel Width"; if Diff <> 0 then Rec."Front Overfold" := Rec."Front Overfold" + Diff; From e051a4bc4ef8b9443390bca0cb1458ded8b2a724 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Jun 2026 12:53:53 +0000 Subject: [PATCH 4/5] Improve guard safety, add TryFunction comments, guard against insert scenario --- Prototyping/PVSJobItemMinReelWidth.Codeunit.al | 3 ++- Prototyping/PVSJobItemMinReelWidth.TableExt.al | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Prototyping/PVSJobItemMinReelWidth.Codeunit.al b/Prototyping/PVSJobItemMinReelWidth.Codeunit.al index 8d2a5ef..24d2bde 100644 --- a/Prototyping/PVSJobItemMinReelWidth.Codeunit.al +++ b/Prototyping/PVSJobItemMinReelWidth.Codeunit.al @@ -45,13 +45,14 @@ codeunit 50100 "PVS Job Item Min Reel Width" LeavesWidth := ImpositionRec."Leaves Width"; Guard.SetCalcInProgress(true); - TryApplyMinReelWidth(Rec, LeavesWidth); + 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")); diff --git a/Prototyping/PVSJobItemMinReelWidth.TableExt.al b/Prototyping/PVSJobItemMinReelWidth.TableExt.al index 13ca429..c57aa49 100644 --- a/Prototyping/PVSJobItemMinReelWidth.TableExt.al +++ b/Prototyping/PVSJobItemMinReelWidth.TableExt.al @@ -15,9 +15,10 @@ tableextension 50100 "PVS Job Item Min Reel Width" extends "PVS Job Item" begin if Guard.IsCalcInProgress() then exit; - // Per spec: the difference (new - old) is added 1:1 to Front Overfold + // 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 then + 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; } From 9b4aa7875d83ef1e0bac868adfa6e05e5b6b7747 Mon Sep 17 00:00:00 2001 From: JH-PV Date: Fri, 26 Jun 2026 14:54:12 +0200 Subject: [PATCH 5/5] Latest changes to Reel width --- Prototyping/.vscode/launch.json | 21 ++++++++++ .../PVSJobItemMinReelWidth.Codeunit.al | 7 ++-- Prototyping/PVSJobItemsListPart.PageExt.al | 2 +- Prototyping/Thirsday25App.code-workspace | 10 +++++ Prototyping/Thirsday25App/app.json | 39 +++++++++++++++++++ .../src/THRThursday25Install.Codeunit.al | 8 ++++ 6 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 Prototyping/.vscode/launch.json create mode 100644 Prototyping/Thirsday25App.code-workspace create mode 100644 Prototyping/Thirsday25App/app.json create mode 100644 Prototyping/Thirsday25App/src/THRThursday25Install.Codeunit.al 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 index 24d2bde..21e5b22 100644 --- a/Prototyping/PVSJobItemMinReelWidth.Codeunit.al +++ b/Prototyping/PVSJobItemMinReelWidth.Codeunit.al @@ -1,6 +1,6 @@ -codeunit 50100 "PVS Job Item Min Reel Width" +codeunit 50103 "PVS Job Item Min Reel Width" { - [EventSubscriber(ObjectType::Table, Database::"PVS Job Item", 'OnAfterValidateEvent', 'Format Code', false, false)] + [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); @@ -36,7 +36,8 @@ codeunit 50100 "PVS Job Item Min Reel Width" if not ComponentTypeIsInside(Rec."Component Type") then exit; - if (Rec."Format Code" = '') or (Rec."Controlling Sheet Unit" = '') or (Rec."Imposition Type" = '') then + 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 diff --git a/Prototyping/PVSJobItemsListPart.PageExt.al b/Prototyping/PVSJobItemsListPart.PageExt.al index 37d4115..7baefb9 100644 --- a/Prototyping/PVSJobItemsListPart.PageExt.al +++ b/Prototyping/PVSJobItemsListPart.PageExt.al @@ -2,7 +2,7 @@ pageextension 50101 "PVS Job Items ListPart Ext" extends "PVS Job Items ListPart { layout { - addafter("Imposition Type") + addafter(ImpositionType) { field("Minimum Reel Width"; Rec."Minimum Reel Width") { 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; +}