Bug 638464: Remove Subc. Detailed Calculation report; extend BaseApp report via event#8673
Bug 638464: Remove Subc. Detailed Calculation report; extend BaseApp report via event#8673ChethanT wants to merge 2 commits into
Conversation
…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>
| report "Subc. Calculate Subcontracts" = X, | ||
| report "Subc. Create Transf. Order" = X, | ||
| report "Subc. Create SubCReturnOrder" = X, | ||
| report "Subc. Detailed Calculation" = X, |
There was a problem hiding this comment.
Base report not added to permission set
The custom Subc. Detailed Calculation report (99001500) was removed from the permission set without adding the base Detailed Calculation report (99000756) in its place. Users assigned only the Subcontracting permission set will be unable to run the Detailed Calculation report after this change.
Recommendation:
- Add
report "Detailed Calculation" = Xto the permission set so subcontracting users retain access to the replaced report.
| report "Subc. Detailed Calculation" = X, | |
| report "Subc. Create SubCReturnOrder" = X, | |
| report "Detailed Calculation" = X, | |
| report "Subc. Dispatching List" = X; |
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| 1, | ||
| 1); | ||
|
|
||
| IsHandled := true; |
There was a problem hiding this comment.
IsHandled guard missing in event subscriber
The event subscriber does not check whether IsHandled is already true before executing. If another extension has already handled the event, this code will still run and override the earlier handler's result, silently suppressing its work.
Recommendation:
- Add an early exit at the start of the procedure when
IsHandledis alreadytrue.
| IsHandled := true; | |
| begin | |
| if IsHandled then | |
| exit; | |
| if RoutingLine.Type <> RoutingLine.Type::"Work Center" then | |
| exit; |
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| // [WHEN] Run the "Detailed Calculation" report (BaseApp 99000756) for this item. | ||
| Commit(); | ||
| Item.SetRecFilter(); | ||
| DetailedCalculation.SetTableView(Item); |
There was a problem hiding this comment.
Test missing negative/fallback coverage
The new test only verifies the happy path where a subcontractor price exists and is picked up. There is no test case verifying that when a work center has a Subcontractor No. but no matching subcontractor price record exists, the report correctly falls back to the work center's own direct unit cost rather than outputting zero or an uninitialized value.
Recommendation:
- Add a second test procedure that creates a work center with a subcontractor but no
SubcontractorPricerecord, and asserts thatProdUnitCostequals the work center'sDirect Unit Cost.
| DetailedCalculation.SetTableView(Item); | |
| [Test] | |
| procedure DetailedCalculationReportFallsBackToWorkCenterCostWhenNoPriceExists() | |
| // ... arrange: work center with Subcontractor No., no SubcontractorPrice record | |
| // ... assert: ProdUnitCost = WorkCenterDirectCost | |
| begin | |
| end; |
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
Summary
Root Cause
\SubcReportingTriggersExt\ subscribed to \SubstituteReport\ but checked \if ReportId = Report::"Subc. Detailed Calculation"\ and set \NewReportId\ to itself (99001500 → 99001500). This was a no-op — it should have been substituting the BaseApp report (99000756).
Fix
Test
Added \DetailedCalculationReportUsesSubcontractorPricing\ in codeunit 139982 "Subc. Pricing Test" — [SCENARIO 638464].
Fixes AB#638464
🤖 Generated with GitHub Copilot