Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
39 changes: 39 additions & 0 deletions AvoidSameSorting/PTEAvoidSameSorting.Codeunit.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Codeunit 80421 "PTE Avoid Same Sorting"
{
SingleInstance = true;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"PVS Planning Units Generate ", 'OnAfterFind_Create_TempPlanUnit', '', false, false)]
local procedure OnAfterFind_Create_TempPlanUnit(in_CapacityCode: Code[20];
in_SheetID: Integer;
in_ProcessID: Integer;
in_Is_Created: Boolean;
in_SetupRec: Record "PVS Calculation Unit Setup";
var out_JobItemRec_Tmp: Record "PVS Job Item" temporary;
var out_CalcUnitTMP: Record "PVS Job Calculation Unit" temporary;
var out_PlanUnitTmp: Record "PVS Job Planning Unit" temporary)
var
PlanUnitTmp: Record "PVS Job Planning Unit" temporary;
begin
if not in_Is_Created then
exit;

if in_SheetID <> 0 then
exit;

PlanUnitTmp.Copy(out_PlanUnitTmp, true);
PlanUnitTmp.Reset();
PlanUnitTmp.SetCurrentKey("Simulation Version", ID, Job, "Sorting Order");
PlanUnitTmp.SetRange("Simulation Version", out_PlanUnitTmp."Simulation Version");
PlanUnitTmp.SetRange(ID, out_PlanUnitTmp.ID);
PlanUnitTmp.SetRange(Job, out_PlanUnitTmp.Job);
PlanUnitTmp.SetRange(Unit, out_PlanUnitTmp.Unit);
PlanUnitTmp.SetRange("Capacity Unit", out_PlanUnitTmp."Capacity Unit");
PlanUnitTmp.SetRange("Sorting Order", out_PlanUnitTmp."Sorting Order");
PlanUnitTmp.SetRange("Sheet ID", 0);
PlanUnitTmp.SetFilter("Plan ID", '<>%1', PlanUnitTmp."Plan ID");
if PlanUnitTmp.Findlast then begin
out_PlanUnitTmp."Sorting Order" := PlanUnitTmp."Sorting Order" + 1;
out_PlanUnitTmp.modify();
end;
end;
}
8 changes: 8 additions & 0 deletions AvoidSameSorting/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Avoid same planning sorting
Whenever a new planning unit is created (for sheet 0), this codeunit ensures its Sorting Order doesn't collide with an existing planning unit that shares the same Unit and Capacity Unit, bumping the order up by 1 if a conflict is found.


# What this extension includes:

- An event subscriber (codeunit 80421) that check a potential sorting conflict after a new Planning Unit Record has been inserted.

39 changes: 39 additions & 0 deletions AvoidSameSorting/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"id": "bf1ceb67-67a4-4889-9f85-2148fb148ca4",
"name": "Avoid Same Sorting",
"publisher": "PrintVis Open Source",
"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": "24.0.0.0"
}
],
"screenshots": [],
"platform": "1.0.0.0",
"application": "27.0.0.0",
"idRanges": [
{
"from": 80421,
"to": 80421
}
],
"resourceExposurePolicy": {
"allowDebugging": true,
"allowDownloadingSource": true,
"includeSourceInSymbolFile": true
},
"runtime": "16.0",
"features": [
"NoImplicitWith"
]
}
Loading