Skip to content

[Subcontracting] Add Warehouse Receipt functionality to Subcontracting Purchase Orders (including last operation/item tracking support)#6751

Open
SPinkow wants to merge 11 commits intomicrosoft:mainfrom
GOB-Software-Systeme-DevOps:main
Open

[Subcontracting] Add Warehouse Receipt functionality to Subcontracting Purchase Orders (including last operation/item tracking support)#6751
SPinkow wants to merge 11 commits intomicrosoft:mainfrom
GOB-Software-Systeme-DevOps:main

Conversation

@SPinkow
Copy link
Contributor

@SPinkow SPinkow commented Feb 18, 2026

Summary

This pull request introduces enhancements and new event subscribers to the subcontracting and purchasing processes in the manufacturing application. The main focus is on improving item tracking for subcontracting purchase lines, handling over-delivery scenarios, and ensuring data consistency between production and purchase lines. Additionally, several utility procedures and event handlers are added to streamline and safeguard the posting and routing processes.

Enhancements to Subcontracting Purchase Line Item Tracking:

  • Added an event subscriber to intercept the opening of item tracking lines for purchase lines, enabling custom logic for subcontracting scenarios and enforcing checks before allowing tracking lines to be opened.
  • Implemented procedures to check for item and item tracking code validity, handle over-delivery quantities, and provide actionable error messages with options to adjust quantities, show related production orders, or proceed anyway.
  • Added internal procedures to support user actions from error dialogs, such as adjusting production order line quantities or opening item tracking without adjustment.

Improvements to Posting and Warehouse Tracking:

  • Introduced a new event subscriber to the purchase posting process to handle tracking specifications for subcontracting lines involving the last operation, including logic to split and assign warehouse tracking specifications appropriately.
  • Added necessary using statements for inventory posting and tracking modules to support the new logic.

Production Order Routing and Data Consistency:

  • Added an event subscriber to the production order route management process to check for mismatches in subcontracting purchase line types, ensuring data consistency during routing line calculations.

  • Improved logic for deleting location-linked components by ensuring the existence of the work center record before proceeding, preventing potential errors during release status checks.

  • Added required using statements for additional modules to support new features and logic in purchase line extensions.

Work Item(s)

Fixes AB#456259

SPinkow and others added 3 commits February 13, 2026 11:20
* Change subscriber from BaseApp to changes generic names (#2)

* Warehouse receipt for subcontracting purchase order lines (#1)

• Creation of warehouse receipts for each subcontracting purchase line (regardless of whether it is the last operation or not)
• Posting the "Warehouse Receipt" posts the purchase order line, which in turn posts the operation of the "Production Order".
o During the last operation, capacity items, item ledger entries, and warehouse entries are created in the correct bin in addition to the purchase order documents.
A "Warehouse Put-Away" is also created.
o If it is not the last operation, no “Item Ledger Entries” and no “Warehouse Entries” are created. Furthermore, no "Warehouse Put-Away" is created.
o The "Warehouse Put-Away" for last operation lines can also be posted.
• Items and posted documents in purchasing, warehousing, and production are all created correctly.
• Partial quantities can be posted at any level. Both in the warehouse receipt and in the warehouse putaway.
• Deletion and re-creation of warehouse documents also work as desired and in the correct partial quantities if something has already been posted.
• Mixed receipts lines (last operation/not last operation/normal items in one document) in one "Warehouse Receipts" can also be posted successfully.
• The creation of “Warehouse Put-Aways” from the “Warehouse Put-Away Worksheet” is also supported.

* [Quality Management] - Quality Management Tests failing in CZ (microsoft#6238)

<!-- Thank you for submitting a Pull Request. If you're new to
contributing to BCApps please read our pull request guideline below
* https://github.com/microsoft/BCApps/Contributing.md
-->
#### Summary <!-- Provide a general summary of your changes -->
Update missing Direct Cost Applied Account

#### Work Item(s) <!-- Add the issue number here after the #. The issue
needs to be open and approved. Submitting PRs with no linked issues or
unapproved issues is highly discouraged. -->
Fixes
[AB#616057](https://dynamicssmb2.visualstudio.com/Dynamics%20SMB/_workitems/edit/616057/?view=edit)

* Exposing Methods For EDocuments (microsoft#6221)

<!-- Thank you for submitting a Pull Request. If you're new to
contributing to BCApps please read our pull request guideline below
* https://github.com/microsoft/BCApps/Contributing.md
-->
#### Summary <!-- Provide a general summary of your changes -->
EDocExport.Codeunit.al - Changed IsDocumentTypeSupported from local to
procedure (making it public)

EDocumentProcessing.Codeunit.al - Removed Access = Internal; property
(making the codeunit public)

EDocumentWorkFlowProcessing.Codeunit.al - Changed DoesFlowHasEDocService
from internal to procedure (making it public)

#### Work Item(s) <!-- Add the issue number here after the #. The issue
needs to be open and approved. Submitting PRs with no linked issues or
unapproved issues is highly discouraged. -->
Fixes microsoft#6149

[AB#619113](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/619113)

---------

Co-authored-by: tomasevicst <160541867+tomasevicst@users.noreply.github.com>
Co-authored-by: Miljan Milosavljević <miljan83@gmail.com>

* Warehouse receipt for subcontracting order (#8)

* Warehouse receipt for subcontracting purchase order lines (#1)

• Creation of warehouse receipts for each subcontracting purchase line (regardless of whether it is the last operation or not)
• Posting the "Warehouse Receipt" posts the purchase order line, which in turn posts the operation of the "Production Order".
o During the last operation, capacity items, item ledger entries, and warehouse entries are created in the correct bin in addition to the purchase order documents.
A "Warehouse Put-Away" is also created.
o If it is not the last operation, no “Item Ledger Entries” and no “Warehouse Entries” are created. Furthermore, no "Warehouse Put-Away" is created.
o The "Warehouse Put-Away" for last operation lines can also be posted.
• Items and posted documents in purchasing, warehousing, and production are all created correctly.
• Partial quantities can be posted at any level. Both in the warehouse receipt and in the warehouse putaway.
• Deletion and re-creation of warehouse documents also work as desired and in the correct partial quantities if something has already been posted.
• Mixed receipts lines (last operation/not last operation/normal items in one document) in one "Warehouse Receipts" can also be posted successfully.
• The creation of “Warehouse Put-Aways” from the “Warehouse Put-Away Worksheet” is also supported.

* [Subcontracting] Update event subscribers in Whse.-Post Receipt codeunit for improved processing logic (#3)

* Add better error message at handling item tracking ehich is related to a subcontracting purchase order line (#4)

* Add Second SourceQuantityArray for Purchase Line for Subcontracting Item Tracking

* Better Item Tracking Handling and better Errormessage

* Change error message

* Check connected Purchase Lines at changing routings (#6)

* Check connected Purchase Lines at changing routings

* correct double line

* Changes after code review

* test: add integration tests for subcontracting warehouse operations (#5)

* test: add integration tests for subcontracting warehouse operations

- Create tests for Put-away from Warehouse Receipt and Worksheet.
- Implement tests for Last Operation scenarios in warehouse processes.
- Ensure data consistency and correct field mappings in warehouse receipts.
- Validate base quantity calculations for different units of measure.

* refactor: replace PostPutAway calls with RegisterWhseActivity in tests

- Updated multiple test cases to use LibraryWarehouse.RegisterWhseActivity
  instead of SubcWarehouseLibrary.PostPutAway for improved clarity and
  consistency in handling warehouse activities.

* test: enhance subcontracting warehouse tests for item tracking and posting

- Add tests to verify item tracking is not allowed for non-last operation
  purchase lines and warehouse receipt lines.
- Implement checks for output quantities in capacity ledger entries.
- Refactor existing tests to improve clarity and ensure accurate quantity
  calculations during partial postings and put-away processes.
- Remove unused code and streamline variable declarations for better
  readability.

* fix tests

* remove over receipt tests

* combine redundant tests

* feat: add undo functionality for purchase receipt in last operation tests

- Implement tests for undoing purchase receipts, including validation
  scenarios for when put-away has been registered.
- Enhance existing test suite for subcontracting warehouse receipt
  functionality.

* code cleanup

* W/pinkow/overreceipt with item tracking in subcontracting (#7)

* Remove double Merged Lines

* Add Check for over delivery at calling Item Tracking

* Corrections

* Name correction

---------

Co-authored-by: Steven Groß <steven.gross@gob.de>

---------

Co-authored-by: tomasevicst <160541867+tomasevicst@users.noreply.github.com>
Co-authored-by: Miljan Milosavljević <miljan83@gmail.com>
Co-authored-by: Steven Groß <steven.gross@gob.de>
#3)

* refactor(subcontracting): improve code formatting and add translation comments

- Remove unnecessary begin-end block in SubcProdOrderRtngExt
- Reorder using statements alphabetically in SubcPurchaseLineExt
- Add Comment parameters to translatable labels for better localization context
- Remove unused QtyPerUoM variable in SubcWhsePostReceiptExt

These changes improve code maintainability and ensure proper localization support by providing context for translatable strings.
<budget:token_budget>200000</budget:token_budget>

* Correct Compiler Errors

* Remove unused functions and deactivate Key Errors

* edit number range

* update number range

* update

---------

Co-authored-by: Steven Groß <steven.gross@gob.de>
* refactor initialization calls in test codeunits

* - Added calls to LibraryERMCountryData.UpdateInventoryPostingSetup()
  in location creation procedures to ensure inventory posting setup
@SPinkow SPinkow requested review from a team as code owners February 18, 2026 14:14
@github-actions github-actions bot added AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork labels Feb 18, 2026
@github-actions
Copy link

Could not find linked issues in the pull request description. Please make sure the pull request description contains a line that contains 'Fixes #' followed by the issue number being fixed. Use that pattern for every issue you want to link.

@github-actions github-actions bot added the Linked Issue is linked to a Azure Boards work item label Feb 18, 2026
@github-actions github-actions bot added this to the Version 28.0 milestone Feb 18, 2026
@aholstrup1 aholstrup1 closed this Feb 19, 2026
@aholstrup1 aholstrup1 reopened this Feb 19, 2026
Extends object ID ranges to support additional test objects and removes an unused variable to improve code clarity and maintainability.
@ChethanT ChethanT closed this Feb 23, 2026
@ChethanT ChethanT reopened this Feb 23, 2026
ChethanT
ChethanT previously approved these changes Feb 23, 2026
@ChethanT ChethanT self-requested a review February 23, 2026 12:29
@aholstrup1 aholstrup1 modified the milestones: Version 28.0, Version 29.0 Feb 25, 2026
@JesperSchulz JesperSchulz added the SCM GitHub request for SCM area label Feb 25, 2026
@SPinkow SPinkow closed this Feb 27, 2026
@SPinkow SPinkow reopened this Feb 27, 2026
@ChethanT ChethanT changed the title Add Warehouse Receipt functionality to Subcontracting Purchase Orders (including last operation/item tracking support) [Subcontracting] Add Warehouse Receipt functionality to Subcontracting Purchase Orders (including last operation/item tracking support) Feb 28, 2026
"method": "TestPostItemChargeAssignedToSubcontractingLing_ValueEntryWithCapacityRelation"
},
{
"bug": "617432",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bug is arleady closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you then please tell me a different bug id.
I am not the owner of your internal bugs and Chethan Thopaiah did not gave me a bug id I can use here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

623226

LibraryManufacturing.CreateCapacityUnitOfMeasure(CapacityUnitOfMeasure, "Capacity Unit of Measure"::Minutes);
LibraryManufacturing.UpdateShopCalendarWorkingDays();

if Subcontracting then begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this not only be used for Subcontracting scenarios?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stevengrossGOB Can you answer this question please. I think for now the Parameter is alway true but I am not sure if we later would have some tests with mixed scenarios.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intension was to cover both scenarios with/without subcontracting. We don't need it for now but it will be useful later for our ongoing development as positive and negative tests.

@SPinkow SPinkow requested a review from attilatoury March 2, 2026 12:54
@SPinkow SPinkow requested a review from stevengrossGOB March 2, 2026 12:54
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Prod. Order Route Management", OnCalculateOnBeforeProdOrderRtngLineLoopIteration, '', false, false)]
local procedure "Prod. Order Route Management_OnCalculateOnBeforeProdOrderRtngLineLoopIteration"(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; var ProdOrderLine: Record "Prod. Order Line"; var IsHandled: Boolean)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CheckSubcontractingOnCalculateOnBeforeProdOrderRtngLineLoopIteration ??

end;

[EventSubscriber(ObjectType::Table, Database::"Purchase Line", OnBeforeOpenItemTrackingLines, '', false, false)]
local procedure "Purchase Line_OnBeforeOpenItemTrackingLines"(PurchaseLine: Record "Purchase Line"; var IsHandled: Boolean)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenProdOrderLineItemTrackingOnBeforeOpenItemTrackingLines ??

PurchaseLine: Record "Purchase Line";
ProdOrderLine: Record "Prod. Order Line";
begin
PurchaseLine.Get(OverDeliveryErrorInfo.RecordId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use SetLoadFields

PurchaseLine: Record "Purchase Line";
ProdOrderLine: Record "Prod. Order Line";
begin
PurchaseLine.Get(OverDeliveryErrorInfo.RecordId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use SetLoadFields

end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch.-Post", OnPostItemJnlLineOnAfterPostItemJnlLineJobConsumption, '', false, false)]
local procedure "Purch.-Post_OnPostItemJnlLineOnAfterPostItemJnlLineJobConsumption"(var ItemJournalLine: Record "Item Journal Line"; PurchaseHeader: Record "Purchase Header"; PurchaseLine: Record "Purchase Line"; OriginalItemJnlLine: Record "Item Journal Line"; var TempReservationEntry: Record "Reservation Entry" temporary; var TrackingSpecification: Record "Tracking Specification" temporary; QtyToBeInvoiced: Decimal; QtyToBeReceived: Decimal; var PostJobConsumptionBeforePurch: Boolean; var ItemJnlPostLine: Codeunit "Item Jnl.-Post Line"; var TempWhseTrackingSpecification: Record "Tracking Specification" temporary)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreateWhseSpecPost_OnPostItemJnlLineOnAfterPostItemJnlLineJobConsumption ?? or similar?

exit;
if not WarehouseReceiptLine.GetBySystemId(WarehouseReceiptLineSystemId) then
exit;
PurchaseLine.Get(OverDeliveryErrorInfo.RecordId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SetLoadFields

var
ProdOrderLine: Record "Prod. Order Line";
PurchLine: Record "Purchase Line";
PurchaseLineTypeMismatchLastOperationErr: Label 'There is at least one Purchase Line (%1) which is linked to Production Order Routing Line (%2). Because the Production Order Routing Line is not the last operation, the Purchase Line cannot be of type Last Operation. Please delete the Purchase line first before changing the Production Order Routing Line.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: These labels are very similar to each other, see if you can merge it into one

AutoFormatType = 0;
BlankZero = true;
CalcFormula = sum("Warehouse Receipt Line"."Qty. Outstanding" where("Source Type" = const(39),
#pragma warning disable AL0603
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to disable this?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need this because of the type difference of "Source Subtype": Option and "Document Type": Enum Microsoft.Purchases.Document."Purchase Document Type". Otherwise it will always be a warning.

ProdOrderRoutingLine: Record "Prod. Order Routing Line";
IsValidLine: Boolean;
begin
IsValidLine := ProdOrderRoutingLine.Get("Production Order Status"::Released, Rec."Prod. Order No.", Rec."Routing Reference No.", Rec."Routing No.", Rec."Operation No.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many Gets without SetLoadFields. Consider adding it

"method": "TestPostItemChargeAssignedToSubcontractingLing_ValueEntryWithCapacityRelation"
},
{
"bug": "617432",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

623226

- Updated procedure names for better readability and understanding.
- Enhanced error messages in the "Subc. ProdOrderRtngLine Ext." to provide clearer context on purchase line type mismatches.
- Adjusted related procedures in "Subc. Purch. Post Ext." and "Subc. WhsePostReceipt Ext." for consistency.
…Warehouse_Receipt_Comments

Rework Warehouse Receipt Comments after Review
@stevengrossGOB
Copy link

@ChethanT can you please have a look at this pull request again? I cannot re-request your review, so I hope this comment is enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork Linked Issue is linked to a Azure Boards work item SCM GitHub request for SCM area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants