Skip to content

[Subcontracting] Fix subcontracting order opening wrong purchase order after creation#9396

Open
6CRIPT wants to merge 15 commits into
mainfrom
bugs/639381-subcontracting-order-opens-old-purchase-order
Open

[Subcontracting] Fix subcontracting order opening wrong purchase order after creation#9396
6CRIPT wants to merge 15 commits into
mainfrom
bugs/639381-subcontracting-order-opens-old-purchase-order

Conversation

@6CRIPT

@6CRIPT 6CRIPT commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Fixes AB#639381

Problem

When a subcontracting operation already had a received purchase order and the production order quantity was increased, clicking Create Subcontracting Order again created a new PO for the delta quantity but opened the old, already-received PO instead of the newly created one. The user had to manually navigate to find the correct order.

Root cause

ShowCreatedPurchaseOrder re-derived which PO to open by filtering purchase lines (Prod. Order No. + Operation No. + Routing Reference No.). That filter matched both the old and the new lines, so FindFirst returned the lowest Document No. (the old one). The code never tracked which document was actually created during the current run.

Fix

We now capture the purchase order(s) actually created/affected in the current invocation: we snapshot the existing subcontracting POs before Carry Out and Mark the newly created (or updated) header afterwards, then open only the marked set. Filtering was aligned with PurchLineExists (open, unreceived lines), the confirmation count/branching is derived from the marked headers, and a fallback keeps working when Carry Out updates an existing open PO instead of creating a new one. Added two integration tests covering the delta-PO and updated-open-PO scenarios.

6CRIPT and others added 15 commits June 25, 2026 08:51
…tstanding Amount

- SalesDocTotalsSalesEntryUI: disable Foundation app area to prevent auto invoice discount calculation
- PurchDocTotalsSalesEntryUI: same fix for purchase doc totals tests
- ERMSalesPurchaseDocument (CA): use Amount Including VAT for customer GL entry ACY calculation
- SalesPurchaseReports (CA): use Outstanding Amount (includes tax) for report verification"
@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Copilot PR Review

Iteration 2 · Outcome: completed

Knowledge source: https://github.com/microsoft/BCQuality@186d8a131465475c79244d994acb872cd5c0d4bf

Orchestrator pre-filter (2 file(s) excluded)

  • layer-disabled (knowledge) : 2 file(s)

Findings produced by the AL review agent v1.7.3. Reply 👎 on any inline comment to flag false positives.

@6CRIPT

6CRIPT commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Im getting infra failures not releated to my PR:

Message (ArgumentNullException): EventSignature failure: SubScriber assy = Microsoft.Dynamics.Nav.BusinessApplication.Codeunit20419, COD_20419_BBB61F7289C7A1E6E85D8B7F47D00B251CDC80D98511F646D58B5A0B9B1476ED, Version=29.0.51074.0, Culture=neutral, PublicKeyToken=null, target assy = Microsoft.Dynamics.Nav.BusinessApplication.Codeunit20419, COD_20419_BBB61F7289C7A1E6E85D8B7F47D00B251CDC80D98511F646D58B5A0B9B1476ED, Version=29.0.51074.0, Culture=neutral, PublicKeyToken=null, Subscriber signature = 'System.Threading.Tasks.ValueTask Microsoft.Dynamics.Nav.BusinessApplication.Codeunit20419.InitializeChecklistOnAfterLogIn()', target signature = 'Microsoft.Dynamics.Nav.BusinessApplication.Codeunit20419Qlty. Guided Experience[ID=20419]()' 2026-07-14T08:39:52.2939328Z RootException: ArgumentNullException (HResult: 0x80004003) 2026-07-14T08:39:52.2940028Z Value cannot be null. (Parameter 'encoder') 2026-07-14T08:39:52.2940528Z ExceptionStackTrace: 2026-07-14T08:39:52.2941507Z at System.Drawing.CoreImageExtensions.Save(IImage image, Stream stream, Guid encoder, Guid format, EncoderParameters* encoderParameters) 2026-07-14T08:39:52.2942856Z at System.Drawing.Image.Save(Stream stream, ImageFormat format) 2026-07-14T08:39:52.2944002Z at Microsoft.Dynamics.Nav.Runtime.Media.NavMediaImage.BytesAsync(CancellationToken cancellationToken) 2026-07-14T08:39:52.2944853Z at Microsoft.Dynamics.Nav.Runtime.Media.NavMediaImage.Bytes() 2026-07-14T08:39:52.2945160Z 2026-07-14T08:39:52.2945425Z Run-TestsInBcContainer Telemetry Correlation Id: 77a1298b-02b7-460c-bbf8-6c93ddc78e18 2026-07-14T08:39:52.2946160Z Run-TestsInBcContainer Telemetry Correlation Id: 77a1298b-02b7-460c-bbf8-6c93ddc78e18 2026-07-14T08:39:52.2947937Z Exception occurred while running tests: Cannot open page 130455. You might need to import the test toolkit to the container and/or remove the folder C:\ProgramData\BcContainerHelper\Extensions\bcbuildprojectsTestAppsCH29313723281\PsTestTool and retry. You might also have URL or Company name wrong. / 2026-07-14T08:39:52.2950070Z Exception occurred while running tests: Cannot open page 130455. You might need to import the test toolkit to the container and/or remove the folder C:\ProgramData\BcContainerHelper\Extensions\bcbuildprojectsTestAppsCH29313723281\PsTestTool and retry. You might also have URL or Company name wrong. / 2026-07-14T08:39:52.2951505Z Tests failed after 1 attempts.

Note Cannot open page 130455. You might need to import the test toolkit to the container

@Dynamics365
Could you please help me with this one? I've tried to pull from main, re-run jobs and so on several times and nothing works.

Thanks!

@6CRIPT 6CRIPT self-assigned this Jul 16, 2026
@JesperSchulz JesperSchulz added the SCM GitHub request for SCM area label Jul 16, 2026
@6CRIPT 6CRIPT added the Subcontracting Subcontracting related activities label Jul 17, 2026
@6CRIPT
6CRIPT enabled auto-merge July 17, 2026 12:13
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Stale Status Check Deleted

The Pull Request Build workflow run for this PR was older than 72 hours and has been deleted.

📋 Why was it deleted?

Status checks that are too old may no longer reflect the current state of the target branch. To ensure this PR is validated against the latest code and passes up-to-date checks, a fresh build is required.


🔄 How to trigger a new status check:

  1. 📤 Push a new commit to the PR branch, or
  2. 🔁 Close and reopen the PR

This will automatically trigger a new Pull Request Build workflow run.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Stale Status Check Deleted

The Pull Request Build workflow run for this PR was older than 72 hours and has been deleted.

📋 Why was it deleted?

Status checks that are too old may no longer reflect the current state of the target branch. To ensure this PR is validated against the latest code and passes up-to-date checks, a fresh build is required.


🔄 How to trigger a new status check:

  1. 📤 Push a new commit to the PR branch, or
  2. 🔁 Close and reopen the PR

This will automatically trigger a new Pull Request Build workflow run.

@6CRIPT 6CRIPT closed this Jul 20, 2026
auto-merge was automatically disabled July 20, 2026 07:11

Pull request was closed

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 SCM GitHub request for SCM area Subcontracting Subcontracting related activities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants