# Indirect Goods Upgrade — Phase 5 Supplier Direct Delivery Completion

Completed: 11 July 2026

## Outcome

Indirect goods can now be fulfilled by a supplier delivering directly to a project through the shared Material Issue screen. The transaction creates a dedicated indirect direct-delivery document and fulfillment provenance without increasing normal indirect warehouse inventory.

## Enabled workflow

The Phase 5 feature gate `direct_delivery_enabled` is enabled.

For every indirect direct-delivery line the shared form now captures:

- supplier;
- LPO number;
- delivery note number;
- delivery and invoice dates;
- invoice number;
- receiver;
- project and per-line division;
- quantity;
- unit price;
- batch;
- production and expiry dates;
- supporting document and notes.

Different selected divisions are split into separate delivery headers so that each delivery has an unambiguous division ledger.

## Transaction behavior

`IndirectGoodsDirectDeliveryService::createAndComplete()` now atomically:

1. validates request-line ownership and remaining balance;
2. creates an `IGDD-YYYYMMDD-NNNN` delivery header;
3. creates accepted delivery lines;
4. calculates subtotal, VAT and total;
5. completes the delivery;
6. adds accepted quantity directly to indirect project inventory;
7. creates direct-delivery fulfillment and allocation rows;
8. creates supplier-to-project movement history;
9. updates request released/balance/status fields;
10. rebuilds indirect division summaries.

Normal `indirect_goods_inventory` is never updated by this workflow. Rejected quantity is validated and never stocked.

## New operational pages

- Indirect direct-delivery listing
- Delivery details
- Printable Indirect Goods Direct Delivery Note

The listing provides same-line print and view actions.

## Verification

### Static checks

- Models, services and controllers pass PHP syntax checks.
- Three direct-delivery routes are registered.
- All Blade views compile successfully.
- Domain invariant tests: 5 passed.

### Rolled-back end-to-end smoke test

A one-unit delivery at AED 25.00 was created and completed inside an outer transaction.

Verified during the transaction:

- delivery number: `IGDD-20260711-0001`;
- status: completed;
- subtotal: AED 25.00;
- VAT: AED 1.25;
- total: AED 26.25;
- fulfillment type: `direct_delivery`;
- fulfillment quantity: 1.0000;
- warehouse quantity change: 0.00;
- project quantity change: +1.00;
- released quantity change: +1.00;
- movement source: supplier;
- movement destination: project;
- reconciliation variance during delivery: 0.0000.

After rollback, baseline quantities and delivery/fulfillment counts returned to their prior values.

## Phase gate

Phase 5 is complete. Phase 6 may enable indirect FOC inventory and FOC issue. Indirect returns remain disabled until Phase 7.
