From 6c24397ca5ff59bc591e81bed9c8d4cea9fbc7ee Mon Sep 17 00:00:00 2001 From: Chethan Thopaiah Date: Thu, 18 Jun 2026 21:59:40 +0200 Subject: [PATCH] Bug 638464: Remove Subc. Detailed Calculation report; extend BaseApp report via event - Remove Report 99001500 (Subc. Detailed Calculation) which was a full copy of BaseApp Report 99000756 - Rewrite SubcReportingTriggersExt to subscribe to new BaseApp event OnAfterGetRecordRoutingLineOnBeforeCalcRoutingCostPerUnit - Event subscriber applies subcontractor pricing when Work Center has a subcontractor - Remove report from permission set - Add test verifying BaseApp report uses subcontractor pricing via event This eliminates duplicate Tell Me entries, preserves extensibility, and fixes the no-op report substitution (which checked ReportId = 99001500 and set NewReportId = 99001500). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../SubcontractObjs.PermissionSet.al | 1 - .../SubcReportingTriggersExt.Codeunit.al | 45 +- .../Rep99001500.SubcDetailedCalculation.rdl | 5957 ----------------- .../Reports/SubcDetailedCalculation.Report.al | 489 -- .../Tests/SubcPricingTest.Codeunit.al | 63 + 5 files changed, 103 insertions(+), 6452 deletions(-) delete mode 100644 src/Apps/W1/Subcontracting/App/src/Process/Reports/Rep99001500.SubcDetailedCalculation.rdl delete mode 100644 src/Apps/W1/Subcontracting/App/src/Process/Reports/SubcDetailedCalculation.Report.al diff --git a/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractObjs.PermissionSet.al b/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractObjs.PermissionSet.al index fbfc1d4d58..bb866a6fcf 100644 --- a/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractObjs.PermissionSet.al +++ b/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractObjs.PermissionSet.al @@ -81,6 +81,5 @@ permissionset 99001501 "Subcontract. - Objs" // Reports report "Subc. Create Transf. Order" = X, report "Subc. Create SubCReturnOrder" = X, - report "Subc. Detailed Calculation" = X, report "Subc. Dispatching List" = X; } \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/Extensions/SubcReportingTriggersExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/Extensions/SubcReportingTriggersExt.Codeunit.al index 9c37237ef3..6298874bba 100644 --- a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/Extensions/SubcReportingTriggersExt.Codeunit.al +++ b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/Extensions/SubcReportingTriggersExt.Codeunit.al @@ -4,14 +4,49 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.Manufacturing.Subcontracting; -using System.Environment; +using Microsoft.Foundation.Enums; +using Microsoft.Manufacturing.Reports; +using Microsoft.Manufacturing.Routing; +using Microsoft.Manufacturing.WorkCenter; codeunit 99001512 "Subc. Reporting Triggers Ext" { - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Reporting Triggers", SubstituteReport, '', false, false)] - local procedure SubstituteDetailedCalculation(ReportId: Integer; var NewReportId: Integer) + [EventSubscriber(ObjectType::Report, Report::"Detailed Calculation", OnAfterGetRecordRoutingLineOnBeforeCalcRoutingCostPerUnit, '', false, false)] + local procedure OnAfterGetRecordRoutingLineOnBeforeCalcCost(var RoutingLine: Record "Routing Line"; ItemNo: Code[20]; BaseUnitOfMeasure: Code[10]; StandardTaskCode: Code[10]; CalculationDate: Date; var DirectUnitCost: Decimal; var IndirectCostPct: Decimal; var OverheadRate: Decimal; var ProdUnitCost: Decimal; var UnitCostCalculation: Enum "Unit Cost Calculation Type"; var IsHandled: Boolean) + var + SubcontractorPrice: Record "Subcontractor Price"; + WorkCenter: Record "Work Center"; + SubcPriceManagement: Codeunit "Subc. Price Management"; begin - if ReportId = Report::"Subc. Detailed Calculation" then - NewReportId := Report::"Subc. Detailed Calculation"; + if RoutingLine.Type <> RoutingLine.Type::"Work Center" then + exit; + + if not WorkCenter.Get(RoutingLine."Work Center No.") then + exit; + + if WorkCenter."Subcontractor No." = '' then + exit; + + SubcontractorPrice."Vendor No." := WorkCenter."Subcontractor No."; + SubcontractorPrice."Item No." := ItemNo; + SubcontractorPrice."Standard Task Code" := StandardTaskCode; + SubcontractorPrice."Work Center No." := WorkCenter."No."; + SubcontractorPrice."Variant Code" := ''; + SubcontractorPrice."Unit of Measure Code" := BaseUnitOfMeasure; + SubcontractorPrice."Starting Date" := CalculationDate; + SubcontractorPrice."Currency Code" := ''; + SubcPriceManagement.SetRoutingPriceListCost( + SubcontractorPrice, + WorkCenter, + DirectUnitCost, + IndirectCostPct, + OverheadRate, + ProdUnitCost, + UnitCostCalculation, + 1, + 1, + 1); + + IsHandled := true; end; } \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Reports/Rep99001500.SubcDetailedCalculation.rdl b/src/Apps/W1/Subcontracting/App/src/Process/Reports/Rep99001500.SubcDetailedCalculation.rdl deleted file mode 100644 index f0ad93b76b..0000000000 --- a/src/Apps/W1/Subcontracting/App/src/Process/Reports/Rep99001500.SubcDetailedCalculation.rdl +++ /dev/null @@ -1,5957 +0,0 @@ - - - 0 - - - - SQL - - - None - 76c8b53c-5c88-4136-be7b-4e803ebab26d - - - - - - - - - - - 1.16906cm - - - 1.40236cm - - - 2.22494cm - - - 1.45001cm - - - 1.5873cm - - - 1.12222cm - - - 1.65001cm - - - 1.95001cm - - - 1.7873cm - - - 1.5873cm - - - 0.95237cm - - - 1.26985cm - - - - - 0.35278cm - - - - - true - true - - - - - =First(Fields!ItemFilterCaption.Value) - - - - - - - Textbox1 - - - 12 - - - - - - - - - - - - - - - - - 0.35278cm - - - - - true - true - - - - - - - - - - - - Textbox2 - - - - - - - - true - true - - - - - - - - - - - - Textbox3 - - - - - - - - true - true - - - - - - - - - - - - Textbox4 - - - - - - - - true - true - - - - - - - - - - - - Textbox5 - - - - - - - - true - true - - - - - - - - - - - - Textbox6 - - - - - - - - true - true - - - - - - - - - - - - - - - - true - true - - - - - - - - - - - - Textbox8 - - - - - - - - true - true - - - - - - - - - - - - Textbox9 - - - - - - - - true - true - - - - - - - - - - - - Textbox10 - - - - - - - - true - true - - - - - - - - - - - - Textbox11 - - - - - - - - true - true - - - - - - - - - - - - Textbox12 - - - - - - - - true - true - - - - - - - - - - - - Textbox13 - - - - - - - - 0.35278cm - - - - - true - true - - - - - =Parameters!No_ItemCaption.Value - - - - - - - Textbox14 - - - 2 - - - - - - - true - true - - - - - - - - - - - - Textbox15 - - - - - - - - true - true - - - - - =Fields!No_Item.Value - - - - - - - Textbox16 - - - Bottom - 5pt - 5pt - - - 5 - - - - - - - - - - true - true - - - - - - - - - - - - Textbox17 - - - - - - - - true - true - - - - - - - - - - - - Textbox18 - - - - - - - - true - true - - - - - - - - - - - - Textbox19 - - - - - - - - true - true - - - - - - - - - - - - Textbox20 - - - - - - - - 0.4064cm - - - - - true - true - - - - - =Parameters!Description_ItemCaption.Value - - - - - - - Textbox21 - - - 3 - - - - - - - - true - true - - - - - =Fields!Description_Item.Value - - - - - - - Textbox22 - - - 6 - - - - - - - - - - - true - true - - - - - - - - - - - - Textbox23 - - - - - - - - true - true - - - - - - - - - - - - Textbox24 - - - - - - - - true - true - - - - - - - - - - - - Textbox25 - - - - - - - - 0.35278cm - - - - - true - true - - - - - =Parameters!ProductionBOMNo_ItemCaption.Value - - - - - - - Textbox26 - - - 3 - - - - - - - - true - true - - - - - =Fields!ProductionBOMNo_Item.Value - - - - - - - Textbox27 - - - 2 - - - - - - - true - true - - - - - =Fields!PBOMVersionCode1.Value - - - - - - - Textbox28 - - - 2 - - - - - - - true - true - - - - - - - - - - - - Textbox29 - - - - - - - - true - true - - - - - - - - - - - - Textbox30 - - - - - - - - true - true - - - - - - - - - - - - Textbox32 - - - - - - - - true - true - - - - - - - - - - - - Textbox34 - - - - - - - - true - true - - - - - - - - - - - - Textbox35 - - - - - - - - 0.35278cm - - - - - true - true - - - - - =Parameters!LotSize_ItemCaption.Value - - - - - - - Textbox36 - - - 3 - - - - - - - - true - true - - - - - =Fields!LotSize_Item.Value - - - - - - - Textbox37 - - - 2 - - - - - - - true - true - - - - - =Fields!BaseUnitOfMeasure_Item.Value - - - - - - 2 - - - - - - - true - true - - - - - - - - - - - - - - - - true - true - - - - - - - - - - - - Textbox40 - - - - - - - - true - true - - - - - - - - - - - - Textbox41 - - - - - - - - true - true - - - - - - - - - - - - Textbox42 - - - - - - - - true - true - - - - - - - - - - - - Textbox43 - - - - - - - - 0.35278cm - - - - - true - true - - - - - =Parameters!RoutingNo_ItemCaption.Value - - - - - - - Textbox44 - - - 3 - - - - - - - - true - true - - - - - =Fields!RoutingNo_Item.Value - - - - - - - Textbox45 - - - 2 - - - - - - - true - true - - - - - =Fields!RtngVersionCode.Value - - - - - - - Textbox46 - - - 2 - - - - - - - true - true - - - - - - - - - - - - Textbox47 - - - - - - - - true - true - - - - - - - - - - - - Textbox48 - - - - - - - - true - true - - - - - - - - - - - - Textbox49 - - - - - - - - true - true - - - - - - - - - - - - Textbox50 - - - - - - - - true - true - - - - - - - - - - - - Textbox51 - - - - - - - - 0.35278cm - - - - - true - true - - - - - - - - - - - - Textbox52 - - - 12 - - - - - - - - - - - - - - - - - 0.35278cm - - - - - true - true - - - - - =Parameters!OperationNo_RtngLineCaption.Value - - - - - - - Textbox53 - - - 2 - - - - - - - true - true - - - - - =Parameters!Type_RtngLineCaption.Value - - - - - - - Textbox54 - - - - - - - - true - true - - - - - =Parameters!No_RtngLineCaption.Value - - - - - - - Textbox55 - - - - - - - - true - true - - - - - =Parameters!Description_ItemCaption.Value - - - - - - - Textbox56 - - - 2 - - - - - - - true - true - - - - - =Parameters!SetupTime_RtngLineCaption.Value - - - - - - - Textbox57 - - - - - - - - true - true - - - - - =Parameters!RunTime_RtngLineCaption.Value - - - - - - - Textbox58 - - - - - - - - true - true - - - - - =Fields!CostTimeCaption.Value - - - - - - - Textbox59 - - - - - - - - true - true - - - - - =Fields!UnitCostCaption.Value - - - - - - - Textbox60 - - - - - - - - true - true - - - - - =Fields!TotalCostCaption.Value - - - - - - - Textbox62 - - - 2 - - - - - - - 0.17638cm - - - - - true - true - - - - - - - - - - - - Textbox63 - - - 12 - - - - - - - - - - - - - - - - - 0.17638cm - - - - - true - true - - - - - - - - - - - - Textbox64 - - - - - - Bottom - 5pt - - - 12 - - - - - - - - - - - - - - - - - 0.35278cm - - - - - true - true - - - - - =Fields!TypeCaption.Value - - - - - - - Textbox65 - - - - - - - - true - true - - - - - =Fields!NoCaption.Value - - - - - - - Textbox66 - - - - - - - - true - true - - - - - =Fields!DescriptionCaption.Value - - - - - - - Textbox67 - - - 2 - - - - - - - true - true - - - - - =Fields!QuantityCaption.Value - - - - - - - Textbox68 - - - - - - - - true - true - - - - - =Fields!BaseUnitOfMeasureCaption.Value - - - - - - - Textbox69 - - - 2 - - - - - - - true - true - - - - - =Fields!UnitCostCaption.Value - - - - - - - Textbox70 - - - - - - - - true - true - - - - - =Fields!TotalCost1Caption.Value - - - - - - - Textbox71 - - - - - - - - true - true - - - - - - - - - - - - Textbox72 - - - - - - - - true - true - - - - - - - - - - - - Textbox73 - - - - - - - - true - true - - - - - - - - - - - - Textbox74 - - - - - - - - 0.17638cm - - - - - true - true - - - - - - - - - - - - Textbox75 - - - 12 - - - - - - - - - - - - - - - - - 0.17638cm - - - - - true - true - - - - - - - - - - - - Textbox77 - - - - - - Bottom - 5pt - - - 12 - - - - - - - - - - - - - - - - - 0.35278cm - - - - - true - true - - - - - =Fields!OperationNo_RtngLine.Value - - - - - - - Textbox78 - - - 2 - - - - - - - true - true - - - - - =Fields!Type_RtngLine.Value - - - - - - - Textbox79 - - - - - - - - true - true - - - - - =Fields!No_RtngLine.Value - - - - - - - Textbox80 - - - - - - - - true - true - - - - - =Fields!Description_RtngLine.Value - - - - - - - Textbox81 - - - 2 - - - - - - - true - true - - - - - =Fields!SetupTime_RtngLine.Value - - - - - - - Textbox82 - - - - - - - - true - true - - - - - =Fields!RunTime_RtngLine.Value - - - - - - - Textbox83 - - - - - - - - true - true - - - - - =Fields!CostTime.Value - - - - - - - Textbox84 - - - - - - - - true - true - - - - - =Fields!ProdUnitCost.Value - - - - - - - Textbox85 - - - - - - - - true - true - - - - - =Fields!ProdTotalCost.Value - - - - - - - Textbox86 - - - 2 - - - - - - - 0.35278cm - - - - - true - true - - - - - =Fields!ProdBOMLineLevelType.Value - - - - - - - Textbox87 - - - - - - - - true - true - - - - - =Fields!ProdBOMLineLevelNo.Value - - - - - - - Textbox88 - - - - - - - - true - true - - - - - =Fields!ProdBOMLineLevelDesc.Value - - - - - - - Textbox89 - - - 2 - - - - - - - true - true - - - - - =Fields!ProdBOMLineLevelQuantity.Value - - - - - - - Textbox90 - - - - - - - - true - true - - - - - =Fields!CompItemBaseUOM.Value - - - - - - - Textbox91 - - - 2 - - - - - - - true - true - - - - - =Fields!CompItemUnitCost.Value - - - - - - - Textbox92 - - - - - - - - true - true - - - - - =Fields!CostTotal.Value - - - - - - - Textbox93 - - - - - - - - true - true - - - - - - - - - - - - Textbox94 - - - - - - - - true - true - - - - - - - - - - - - Textbox95 - - - - - - - - true - true - - - - - - - - - - - - Textbox96 - - - - - - - - 0.17638cm - - - - - true - true - - - - - - - - - - - - Textbox97 - - - 12 - - - - - - - - - - - - - - - - - 0.17638cm - - - - - true - true - - - - - - - - - - - - Textbox98 - - - 8 - - - - - - - - - - - - - true - true - - - - - - - - - - - - Textbox99 - - - - - - Top - 5pt - - - - - - - - true - true - - - - - - - - - - - - Textbox100 - - - 3 - - - - - - - - 0.35278cm - - - - - true - true - - - - - - - - - - - - Textbox101 - - - - - - - - true - true - - - - - - - - - - - - Textbox102 - - - - - - - - true - true - - - - - - - - - - - - Textbox103 - - - - - - - - true - true - - - - - - - - - - - - Textbox104 - - - - - - - - true - true - - - - - - - - - - - - Textbox105 - - - - - - - - true - true - - - - - =Fields!TotalCost1Caption.Value - - - - - - - Textbox106 - - - 3 - - - - - - - - true - true - - - - - =Sum(Fields!CostTotal.Value) - - - - - - - Textbox107 - - - - - - - - true - true - - - - - - - - - Textbox108 - - - - - - - - true - true - - - - - - - - - - - - Textbox109 - - - - - - - - true - true - - - - - - - - - - - - Textbox110 - - - - - - - - 0.17638cm - - - - - true - true - - - - - - - - - - - - Textbox111 - - - - - - - - true - true - - - - - - - - - - - - Textbox112 - - - - - - - - true - true - - - - - - - - - - - - Textbox113 - - - - - - - - true - true - - - - - - - - - - - - Textbox114 - - - - - - - - true - true - - - - - - - - - - - - Textbox115 - - - - - - - - true - true - - - - - - - - - - - - - - - - true - true - - - - - - - - - - - - Textbox117 - - - - - - - - true - true - - - - - - - - - - - - Textbox118 - - - - - - - - true - true - - - - - - - - - - - - Textbox119 - - - - - - - - true - true - - - - - - - - - - - - Textbox120 - - - - - - - - true - true - - - - - - - - - - - - Textbox121 - - - - - - - - true - true - - - - - - - - - - - - Textbox122 - - - - - - - - 0.17638cm - - - - - true - true - - - - - - - - - - - - Textbox123 - - - 11 - - - - - - - - - - - - - - - - true - true - - - - - - - - - - - - Textbox124 - - - - - - Top - 5pt - - - - - - - - 0.35278cm - - - - - true - true - - - - - - - - - Textbox125 - - - 7 - - - - - - - - - - - - true - true - - - - - =First(Fields!TotalCostCaption.Value) - - - - - - - Textbox126 - - - 4 - - - - - - - - - true - true - - - - - =Sum(Fields!ProdTotalCost.Value) - - - - - - - Textbox127 - - - - - - - - 0.35278cm - - - - - true - true - - - - - - - - - Textbox128 - - - 7 - - - - - - - - - - - - true - true - - - - - - - - - Textbox129 - - - - - - - - true - true - - - - - - - - - Textbox130 - - - - - - - - true - true - - - - - - - - - Textbox131 - - - - - - - - true - true - - - - - - - - - Textbox132 - - - - - - - - true - true - - - - - - - - - - - - Textbox133 - - - - - - - - 0.35278cm - - - - - true - true - - - - - - - - - - - - Textbox134 - - - 7 - - - - - - - - - - - - true - true - - - - - =Last(Fields!CostOfProductionCaption.Value) - - - - - - - Textbox135 - - - 4 - - - - - - - - - true - true - - - - - =Sum(Fields!FooterProdTotalCost.Value) - - - - - - - Textbox136 - - - - - - - - 0.35278cm - - - - - true - true - - - - - - - - - - - - Textbox137 - - - 7 - - - - - - - - - - - - true - true - - - - - =Last(Fields!CostOfComponentsCaption.Value) - - - - - - - Textbox138 - - - 4 - - - - - - - - - true - true - - - - - =Sum(Fields!FooterCostTotal.Value) - - - - - - - Textbox139 - - - - - - - - 0.35278cm - - - - - true - true - - - - - - - - - - - - Textbox140 - - - 7 - - - - - - - - - - - - true - true - - - - - =Last(Fields!SingleLevelMfgOverheadCostCaption.Value) - - - - - - - Textbox141 - - - 4 - - - - - - - - - true - true - - - - - =Sum(Fields!SingleLevelMfgOvhd.Value) - - - - - - - Textbox142 - - - - - - - - 0.17638cm - - - - - true - true - - - - - - - - - - - - Textbox143 - - - 7 - - - - - - - - - - - - true - true - - - - - - - - - Textbox144 - - - - - - - - true - true - - - - - - - - - - - - Textbox145 - - - - - - - - true - true - - - - - - - - - Textbox146 - - - - - - - - true - true - - - - - - - - - Textbox147 - - - - - - - - true - true - - - - - - - - - - - - Textbox148 - - - - - - - - 0.17638cm - - - - - true - true - - - - - - - - - - - - Textbox149 - - - 11 - - - - - - - - - - - - - - - - true - true - - - - - - - - - - - - Textbox150 - - - - - - Top - 5pt - - - - - - - - 0.35278cm - - - - - true - true - - - - - - - - - - - - Textbox151 - - - 7 - - - - - - - - - - - - true - true - - - - - - - - - Textbox152 - - - - - - - - true - true - - - - - =Last(Fields!UnitCostCaption.Value) - - - - - - - Textbox153 - - - 3 - - - - - - - - true - true - - - - - =Sum(Fields!UnitCost_Item.Value) - - - - - - - Textbox154 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - =iif(Fields!ItemFilter.Value = "",true,false) - - After - true - - - - =iif(Fields!ItemFilter.Value = "",true,false) - - After - true - - - - - =Fields!No_Item.Value - - - End - - - - - After - true - - - After - true - - - After - true - - - After - true - - - After - true - - - After - true - - - - - =Fields!InRouting.Value - - - - - - =iif(Fields!InRouting.Value,false,true) - - After - true - - - - =iif(Fields!InRouting.Value,false,true) - - After - true - - - - =iif(Fields!InRouting.Value,false,true) - - After - - - - - =Fields!InBOM.Value - - - - - - =iif(Fields!InBOM.Value,false,true) - - After - true - - - - =iif(Fields!InBOM.Value,false,true) - - After - true - - - - =iif(Fields!InBOM.Value,false,true) - - After - - - - Detail - - - - - =iif(Fields!OperationNo_RtngLine.Value = "",true,false) - - - - - =iif(Fields!ShowLine.Value,false,true) - - - - Detail_Collection - Output - true - - - - =iif(Fields!TotalCost1Caption.Value = "",true,false) - - Before - - - - =iif(Fields!TotalCost1Caption.Value = "",true,false) - - Before - - - - =iif(Fields!TotalCost1Caption.Value = "",true,false) - - Before - true - - - - =iif(Fields!TotalCostCaption.Value = "",true,false) - - Before - true - - - - =iif(Fields!TotalCostCaption.Value = "",true,false) - - Before - - - - - - =iif(First(Fields!TotalCostCaption.Value) = "",true,false) - - Before - true - - - - =iif(First(Fields!TotalCostCaption.Value) = "",true,false) - - Before - true - - - - - Before - true - - - Before - true - - - Before - true - - - Before - true - - - Before - - - Before - true - - - - - - DataSet_Result - 8.52024cm - 18.15273cm - - - - - - - true - - - - - =Fields!PageNoCaption.Value - - - - - - - 0.3595cm - 12.57817cm - 11pt - 5.10758cm - 1 - - - - true - - - - - =Fields!CalculateDate.Value - - - - - - - true - - - - - =Fields!CompanyName.Value - - - - - - - true - - - - - =Fields!TodayFormatted.Value - - - - - - - 12.50762cm - 11pt - 5.64511cm - 4 - - - - true - true - - - - - =User!UserID - - - - - - - 0.75075cm - 14.41376cm - 11pt - 3.73896cm - 5 - - =iif(Fields!DetailedCalculationCaption.Value = "",true,false) - - NoOutput - - - - - - - - 29.7cm - 21cm - 1.76389cm - 1.05833cm - 1.05833cm - 1.48167cm - 1.27cm -