Bakery POS - Phase 6 Production Management
==========================================

IMPORTANT
---------
1. Back up your current /bakery/ folder.
2. Back up the engrgolk_bakery database.
3. Import ONLY sql/007_phase6_production.sql into engrgolk_bakery.
4. Then upload the updated application files.

DO NOT import sql/001_master_schema.sql into the current live database.
That file is only the consolidated schema for a future clean installation.

OPTION A - FULL INTEGRATED BUILD
--------------------------------
Upload/extract bakery_full_phase6_updated.zip over your current bakery folder.
The package was produced from the exact Bakery ZIP supplied for Phase 6.
For security, config/database.php is intentionally omitted from the downloadable full ZIP.
When extracting over your current /bakery/ folder, your existing database credentials file remains untouched.

OPTION B - UPDATE ONLY
----------------------
Replace/add only these files:

NEW
/app/Services/ProductionService.php
/assets/js/phase6.js
/bakery/production.php
/bakery/production-edit.php
/bakery/production-view.php
/sql/007_phase6_production.sql

REPLACE
/app/Support/layout.php
/config/app.php
/assets/css/app.css
/service-worker.js
/bakery/index.php
/sql/001_master_schema.sql   (future clean-install reference only)

NOT CHANGED
-----------
Authentication / Email OTP
Registration / Password reset
Database credentials
Phase 4 purchasing / supplier payment logic
Phase 5 product / barcode / recipe logic
RawMaterialService.php
ProductRecipeService.php

PHASE 6 WORKFLOW
----------------
DRAFT
 -> PLANNED
 -> RELEASED (materials reserved using FEFO where expiry exists)
 -> IN_PRODUCTION (material issue begins)
 -> PARTIAL (actual output recorded)
 -> COMPLETED

Cancellation is supported before completion. Unissued reservations are released.
If materials were issued, physically unused quantities should be returned first.
On cancellation, any issued quantity not returned or already identified as raw-material
wastage is recorded as CANCELLED_PRODUCTION material loss for traceability.

FIRST TEST
----------
1. Open Bakery > Production.
2. Create a small production batch using a manufactured product that has an ACTIVE recipe.
3. Save & Mark Planned.
4. Open the batch and review calculated raw-material requirements.
5. Release / Reserve Materials.
6. Review the FEFO reservations.
7. Issue the required materials.
8. If necessary, return unused issued material.
9. Record actual Good Output and any Wastage.
10. Complete Production.
11. Check Raw Materials / Stock History to confirm ISSUE / RETURN / RESERVE / RELEASE movements.
12. The good output will exist in bpos_finished_product_batches and bpos_product_stock_ledger
    ready for the future Finished Goods / Transfer phase.

COST NOTE
---------
Phase 6 uses the recipe/raw-material estimated material unit cost as the provisional
finished-product batch cost. Phase 7 will add labour, electricity/gas, packaging,
transport/other costs, markup/margin and final pricing.
