Describe the issue
Report 790 "Calculate Inventory", procedure CreateDimFromDefault(), filters Default Dimension with two independent OR-filters:
DefaultDimension.SetFilter("No.", '%1|%2', TempQuantityOnHandBuffer."Item No.", TempQuantityOnHandBuffer."Location Code");
DefaultDimension.SetFilter("Table ID", '%1|%2', DATABASE::Item, DATABASE::Location);
Because "No." and "Table ID" are filtered independently, the combinations are never paired per table. If an Item's No. happens to equal the Code of some unrelated Location (for example both are 10), that unrelated Location's default dimensions pass both filters and leak onto the counting journal line, even when the inventory is calculated for a completely different location.
Verified still present in current main: src/Layers/W1/BaseApp/Inventory/Counting/Journal/CalculateInventory.Report.al, CreateDimFromDefault().
The fix is to replace the cross-product filter with two scoped reads: one for ("Table ID" = Database::Item, "No." = Item No.) and one for ("Table ID" = Database::Location, "No." = Location Code).
Expected behavior
Only the default dimensions of the counted Item and of the Location actually being counted are applied to the physical inventory journal line. A Location that merely shares its Code with the Item's No. must not contribute dimensions.
Steps to reproduce
- Create Item with No. = 10.
- Create Location with Code = 10 and add default dimensions to it.
- Post some inventory for Item 10 on a different location (e.g. BLUE).
- Run Calculate Inventory (report 790) for location BLUE.
- The journal line receives the default dimensions of Location 10, which has nothing to do with the count.
Additional context
This is a copy of microsoft/BusinessCentralApps#1542 (reported by Karel Koncel, labeled Approved/SCM in the contribution pilot). It was being fixed in microsoft/BusinessCentralApps#1908, which was reviewed (a regression test was requested and added) but was closed unmerged when the repository was retired. Re-filing here per the retirement notice to re-submit the fix against BCApps.
I will provide a fix for a bug
Describe the issue
Report 790 "Calculate Inventory", procedure
CreateDimFromDefault(), filters Default Dimension with two independent OR-filters:Because
"No."and"Table ID"are filtered independently, the combinations are never paired per table. If an Item'sNo.happens to equal theCodeof some unrelated Location (for example both are10), that unrelated Location's default dimensions pass both filters and leak onto the counting journal line, even when the inventory is calculated for a completely different location.Verified still present in current main:
src/Layers/W1/BaseApp/Inventory/Counting/Journal/CalculateInventory.Report.al,CreateDimFromDefault().The fix is to replace the cross-product filter with two scoped reads: one for
("Table ID" = Database::Item, "No." = Item No.)and one for("Table ID" = Database::Location, "No." = Location Code).Expected behavior
Only the default dimensions of the counted Item and of the Location actually being counted are applied to the physical inventory journal line. A Location that merely shares its Code with the Item's No. must not contribute dimensions.
Steps to reproduce
Additional context
This is a copy of microsoft/BusinessCentralApps#1542 (reported by Karel Koncel, labeled Approved/SCM in the contribution pilot). It was being fixed in microsoft/BusinessCentralApps#1908, which was reviewed (a regression test was requested and added) but was closed unmerged when the repository was retired. Re-filing here per the retirement notice to re-submit the fix against BCApps.
I will provide a fix for a bug