-
Notifications
You must be signed in to change notification settings - Fork 387
Bug 638464: Remove Subc. Detailed Calculation report; extend BaseApp report via event #8673
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
6c24397
cf101af
f11ad1c
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 | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,8 +4,10 @@ | |||||||||||||||||||||||||
| // ------------------------------------------------------------------------------------------------ | ||||||||||||||||||||||||||
| namespace Microsoft.Manufacturing.Subcontracting; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| using Microsoft.Foundation.Enums; | ||||||||||||||||||||||||||
| using Microsoft.Manufacturing.Reports; | ||||||||||||||||||||||||||
| using System.Environment; | ||||||||||||||||||||||||||
| using Microsoft.Manufacturing.Routing; | ||||||||||||||||||||||||||
| using Microsoft.Manufacturing.WorkCenter; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| codeunit 99001512 "Subc. Reporting Triggers Ext" | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
|
|
@@ -27,4 +29,43 @@ codeunit 99001512 "Subc. Reporting Triggers Ext" | |||||||||||||||||||||||||
| if ReportId = Report::"Detailed Calculation" then | ||||||||||||||||||||||||||
| NewReportId := Report::"Subc. Detailed Calculation"; | ||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| [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 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, | ||||||||||||||||||||||||||
|
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. Hardcoded QtyUoM/ProdQtyPerUom/QtyBase bypass UOM conversionThe call to Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||||||||||||||||||
| 1, | ||||||||||||||||||||||||||
| 1); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| IsHandled := true; | ||||||||||||||||||||||||||
|
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. IsHandled guard missing in event subscriberThe event subscriber does not check whether Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -92,6 +92,5 @@ permissionset 99001501 "Subcontract. - Objs" | |||||||||
| report "Subc. Calculate Subcontracts" = X, | ||||||||||
| report "Subc. Create Transf. Order" = X, | ||||||||||
| report "Subc. Create SubCReturnOrder" = X, | ||||||||||
| report "Subc. Detailed Calculation" = X, | ||||||||||
|
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. Base report not added to permission setThe custom Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||
| report "Subc. Dispatching List" = X; | ||||||||||
| } | ||||||||||
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.
WorkCenter.Get called without prior type guard on routing line
The guard
if RoutingLine.Type <> RoutingLine.Type::"Work Center" then exit;is correct, butWorkCenter.Getis then called unconditionally for every routing line in the report dataset. In a production routing with many work-center operations, each line triggers an extra database read even for work centers with no subcontractor configured.Recommendation:
CalcFieldsselectively. At minimum ensure the existing guard at line 46 (WorkCenter."Subcontractor No." = '') short-circuits quickly, which it does — the current code is acceptable but should be noted for routing headers with many lines.👍 useful · ❤️ especially valuable · 👎 wrong - reply with why