# CHANGELOG

## Stock Receipt preview + Returns product source — 2026-08-23

- Added parsed STR item review and explicit Quick Accept before final Stock Receipt confirmation.
- Return/RMA lookup now includes valid discontinued/out-of-catalog master products while preserving checkout eligibility and historical invoice snapshots.

## Direct Van to RMA — 2026-08-24

- Renamed and clarified Opening RMA as `Move from Van to RMA`, added required reason and paired-operation audit details, explicit completed/no-approval API result, own-van 403 protection, and an admin-reviewable movement history. Customer Return approvals remain unchanged.

## Stock Receipts v1 — 2026-08-16

- Added private warehouse STR upload and deterministic multi-page parsing using supplied documents 12920 and 12921.
- Added duplicate protection, exact SKU/barcode matching, explicit request linking, resumable/idempotent counting, and variance review.
- Added atomic accepted-only confirmation with direct receipt movement traceability and duplicate-post protection.
- Added Laravel admin and Flutter one-hand receipt flows.

## Customer account unification and profile completion — 2026-08-16

- Normalized non-QA operational customers to ON_ACCOUNT without changing historical invoices or snapshots.
- Made ON ACCOUNT/CASH an explicit per-invoice choice, defaulting to ON ACCOUNT.
- Added permission-safe profile completion, deterministic completeness, and private document expiry/version metadata.
- Verified production desktop/mobile Laravel navigation and physical SM X135G checkout/profile flows; QA draft cleanup left stock untouched.

## Invoice / Checkout Stabilization — 2026-08-16

- Fixed valid active-list and physical-van products being reported as nonexistent when their master lifecycle status is discontinued.
- Added order preflight and structured affected-item failures.
- Standardized `product_id` as `products.id` across catalog API, Flutter Cart persistence, and checkout; removed catalog-row-ID fallback.
- Preserved current source pricing, Cash/On Account rules, quantities, and stock deductions.

## 2026-08-15 — Stock Replenishment

- Closed the variance selector state defect by binding each item to its persisted reason and note.
- Added optional structured Delivery Note Number, Driver and Vehicle persistence, direct dispatch fields in Laravel and Flutter, and retained combined timeline notes.
- Added dispatch metadata to the Receiving PDF and completed production visual QA for both operational PDFs.
- Hid the dashboard Stock Requests shortcut from unauthorized salesmen and retained server-side 403 enforcement.
- Added regression coverage for all four variance reasons, dispatch form visibility/persistence, and salesman API authorization.
- Added normalized requests, items, events, receipts, receipt items and private attachments.
- Added permanent SR numbering, two admin reviews, preparation, dispatch and discrepancy receiving.
- Added idempotent additive `warehouse_receipt` movements for Accepted Qty only.
- Added Laravel operations UI, mobile API and white A4 Stock Request PDF.
- Added private prepared-photo, dispatch-receipt, and receipt-line discrepancy evidence with protected streaming and preserved history.
- Added nullable receipt/receipt-item audit links for discrepancy attachments.
- Added authenticated Warehouse Preparation and Receiving PDFs with quantity differences, reasons, receipt metadata, and Accepted Qty stock wording.
- Added completion/security/stock matrix tests; existing stock movement arithmetic is unchanged.
- Physical Android QA fixed the extended New Request shape and ensured Save Draft remains visible above the keyboard.
- Added the temporary QA dataset architecture, exact owner isolation, QA catalog/customer records, Code 39 scanner labels, protected reset/cleanup command, QA PDF warnings and append-only QA stock audit markers.
- Corrected receipt replay ordering so an already completed identical receipt remains idempotent.

## 2026-08-09

- Fixed customer order data isolation in the mobile API.
- Added audited onboarding, territory enforcement, private versioned documents, duplicate warnings and admin review.
- Added Cash/On Account rules, configurable cash discount/VAT, Clearance exclusion and immutable invoice snapshots.

## Version 0.8.0 - Mobile API v1

### Added

- Mobile token authentication.
- Mobile login endpoint.
- Mobile logout endpoint.
- Mobile user profile endpoint.
- Mobile dashboard endpoint.
- Mobile van boxes endpoint.
- Mobile box items endpoint.
- Mobile barcode product lookup endpoint.

### Technical

- Added mobile_tokens table.
- Added MobileToken model.
- Added MobileAuth middleware.
- Added routes/api.php.
- Added API documentation.

### Next

- Connect Flutter login to Laravel API.
- Save token in Flutter secure storage.
- Load dashboard from API.
- Load van boxes from API.

## Version 0.8.2 - Mobile Van Stock API

### Added

- Mobile van stock endpoint.
- Search support for SKU, barcode, name, and category.

## Version 0.8.4 - Van Stock API Improvements

### Fixed

- Removed repeated products in Mobile My Van API by grouping stock rows.
- Added product image URL to van stock API.
- Added van meta data for mobile screen title.

## Version 0.8.6 - Van Stock Quantity Fix

### Fixed

- Mobile My Van now reads only the latest van stock import.
- Prevented old imports from increasing displayed quantities.

## Version 0.8.11 - Mobile Inventory Check API

### Added

- Mobile inventory check current endpoint.
- Mobile inventory check start endpoint.
- Mobile inventory check mark endpoint.
- Mobile inventory check finish endpoint.
- API documentation for inventory check.

## Version 0.9.4 - Shipment Parser Fix

### Fixed

- Shipment parser now supports new WIWU shipment Excel format.
- Supported columns: Item, Barcode 1, Description, Item Category Name, Qty.
- Shipment upload now auto-parses after upload.
- PDF generation now attempts parsing if shipment items are empty.

## Version 0.9.5 - Smart Price Import

### Added

- Smart price import command.
- Auto-detection for SKU, barcode, Van Sales, Wholesale, and RRP price columns.
- Price update from uploaded price list files.

### Behavior

- Current Van Sales is used first.
- If Van Sales is missing, Wholesale is used.
- If Wholesale is missing, RRP is used.

## Version 0.9.6 - Laravel Smart Price Upload

### Added

- Price list upload now smart-parses automatically from Laravel UI.
- Smart parser detects SKU, Barcode, RRP, Wholesale, and Van Sales columns.
- Product prices are updated during parsing.
- Price import items are saved for review in Laravel.

### Behavior

- Current Van Sales is used first.
- If Van Sales is missing, Wholesale is used.
- If Wholesale is missing, RRP is used.
- Matched products are updated immediately after upload.

## Version 0.9.7 - Import Center v1

### Added

- Import Center module.
- Upload file to Import Center.
- Smart file type detection.
- Detection Review step.
- User confirmation before analysis.
- Analyze preview page.
- Import sessions database table.

### Flow

Upload File
→ System Suggestion
→ User Confirms Type
→ Analyze Preview
→ Final Import later

## Version 0.9.8 - Import Center Final Import

### Added

- Import Now button in Import Center preview.
- Import Center can now import confirmed Shipment files.
- Import Center can now import confirmed Price List files.
- Import Center can now import confirmed SOH files.
- Import sessions now update status to imported or failed.

### Pending

- Van Stock import from Import Center needs salesman/van selection.

## Version 0.9.9 - Smart Import Preview

### Added

- Smart preview for shipment files.
- Smart preview for price list files.
- Matched and not matched product status.
- Product photo preview.
- Shipment quantity and estimated value preview.
- Price old/new comparison preview.
- Ignored rows section for total rows.

## Version 0.9.10 - Import Center Van Stock

### Added

- Van Stock support in Import Center.
- Salesman / van selection before analysis.
- Smart Van Stock preview.
- Final Van Stock import from Import Center.
- Auto generated salesman van catalog after import.

### Behavior

- Upload file.
- Confirm as Van Stock.
- Select salesman / van.
- Analyze preview.
- Import Now.

## Version 0.9.11 - Price Sync Without Replacing Main Catalog

### Fixed

- Price List import no longer replaces the Regular Main Catalog.
- Price List import now updates products and existing active catalog item prices.
- Public portal ignores empty active Regular/Clearance catalogs.
- Empty active main catalogs are archived during the repair step.

### Added

- Catalog item price update tracking.
- UPDATED badge on customer catalog items when price was updated.
- Old price tracking for updated catalog items.

## Version 0.9.12 - Permanent Catalog Architecture

### Added

- Permanent catalog fields.
- Permanent Main Catalog.
- Permanent Clearance Catalog.
- Permanent Salesman Van Catalogs.
- Catalog repair command.
- Salesman van quantity badge inside customer catalog.
- Permanent catalog documentation.

### Changed

- Public portal now prefers protected permanent catalogs.
- Price updates no longer create or replace permanent catalogs.

## Version 0.9.13 - Permanent Catalog Safety Lock

### Added

- Safety lock command for permanent catalogs.
- Van Stock imports now reuse the permanent salesman catalog.
- Old non-permanent van stock catalogs are archived safely.
- Permanent catalogs are never archived by Van Stock import.

### Command

php artisan catalogs:safety-lock

<!-- SNYT_CHANGELOG_DOCS_V2_START -->

## Documentation Hub v2 - 2026-08-08

### Added

- Laravel + Flutter combined internal Developer Documentation Hub.
- Synchronized Flutter documentation snapshot support.
- Cross-project search.
- Shared Business Rules page.
- Shared Development Workflow page.
- Shared Architecture Map page.
- Previous / Next page navigation.
- Reading progress indicator.
- Copy buttons for code blocks.
- Responsive documentation layout.

### Changed

- `/docs` is the internal entry point for Laravel and Flutter technical documentation.
- Existing Markdown documentation remains the source of truth.
- Laravel baseline documentation now reflects the current field-sales, mobile, order, inventory, reporting, chat, and operations foundations.
- Approved RMA, stock receiving, invoice pricing, invoice editing, and release automation work is recorded as planned rather than implemented.

### Business Rules Recorded

- Displayed prices include VAT.
- Current intended Cash discount default is 5% and is controlled by Laravel.
- On Account invoices do not receive the automatic Cash discount.
- Clearance products are excluded from the automatic Cash discount.
- RMA stock must never appear as sellable customer-catalog stock.
- Historical invoices preserve their original pricing rules.

<!-- SNYT_CHANGELOG_DOCS_V2_END -->

<!-- SNYT_RETURNS_RMA_CHANGELOG_V1_START -->
## Returns / RMA Module v1 - 2026-08-08

### Added

- Full Returns module with Customer Return / Resellable and RMA / Defective return types.
- Dedicated non-sellable RMA stock bucket.
- Optional return photos.
- SKU / barcode product lookup and van availability.
- Direct exchange from salesman van stock.
- Opening RMA stock reclassification.
- Accountant pricing and financial settlement recording.
- Warehouse handover batches, confirmation, rejected-item return flow, and A4 PDF.
- Flutter Returns navigation, screens, customer history integration, and global dark SNYT UI foundation.
- English Returns / RMA workflow graphic in `/docs`.

### Stock Safety

- Resellable returns remain non-sellable until accountant approval.
- RMA stock is isolated from customer-visible stock.
- Direct exchange deducts only the replacement quantity from sellable stock.
- Stock edits and warehouse rejection flows remain recorded in `van_stock_movements`.
<!-- SNYT_RETURNS_RMA_CHANGELOG_V1_END -->

## 2026-08-08 - Returns / RMA v1 QA Baseline

- Returns / RMA v1 Flutter integration completed.
- Final analyzer cleanup completed.
- `flutter analyze`: No issues found.
- `flutter test`: 9 tests passed.
- Returns module is ready for device and backend integration QA.
## 2026-08-09 — Returns production hardening

- Required explicit `item_ids` for warehouse handover preparation.
- Required a saved customer for standard returns.
- Added strict return-item ownership and complete settlement checks to accounting review.
- Prevented applying a return to an invoice belonging to another customer.
## 2026-08-09 — Explicit Return workflow

- Added Draft, explicit Submit, Approve, and Reject transitions.
- Added submitter/rejector audit fields and required rejection reasons.
- Preserved RMA stock on rejection and excluded drafts/rejected returns from handover.
- Made duplicate resellable approval stock-safe and froze submitted returns for salesman editing.
## 2026-08-09 — Dedicated RMA Stock

- Added `GET /api/mobile/rma-stock` with search, salesman scoping, admin filtering, and balance summaries.
- Derived ready/prepared/in-transit state from existing RMA and handover records without duplicating inventory.
- Added explicit HTTP 403 guards to approve, reject, and accounting-review actions for normal salesmen.
## 2026-08-09 — Returns / RMA validation fixes

- Validated Returns/RMA in an isolated SQLite environment: 16 related tests and 100 assertions passed.
- Fixed Opening RMA financial initialization referencing an undefined variable.
- Removed the computed handover remaining quantity from model attributes before saving the Return item.
- Added automated coverage for the 21 agreed scenarios, stock invariants, movement audit, financial settlements, and authorization.

## 2026-08-09 — Warehouse handover movement traceability

- Added nullable `van_stock_movements.return_handover_id` linked to `return_handover_batches`.
- New `rma_handover` and `rma_handover_rejected` movements record their exact handover batch without changing stock behavior.
- Left historical movement references `NULL`; no uncertain backfill was attempted.
- Returns/RMA isolated suite: 16 tests, 106 assertions, all passed; all 21 scenarios remain covered and passing.
- Full Laravel suite: 51 passed and one pre-existing, unrelated `PriceImportWorkflowTest` failure.

## 2026-08-09 — SNYT Enterprise UI v1 foundation

- Added centralized dark enterprise CSS tokens and reusable Blade card, metric, status, header, button, empty-state, and form-field components.
- Migrated the global authenticated/guest layouts, desktop sidebar, responsive drawer/topbar, and Dashboard only.
- Standardized semantic status colors across Laravel and Flutter.
- Preserved practical web tables and added contained horizontal scrolling on mobile.
- Verified production Blade compilation, Dashboard route, authenticated rendering, desktop/mobile responsiveness, and browser console with no errors.

## 2026-08-09 — Enterprise UI foundation polish

- Separated Dashboard quick-link context, action title, and arrow into a responsive hierarchy.
- Added compact card hover treatment and mobile-safe padding without changing any destination or business behavior.

## 2026-08-09 — SNYT Enterprise UI v1: Full Laravel Visual Consistency Pass

- Inventoried 97 Blade views and visually opened 57 unique safe Laravel pages/states using authenticated production data.
- Standardized legacy product and customer text, inputs, selects, badges, cards, and semantic utility colors against the centralized dark enterprise tokens.
- Removed the obsolete light-only Customers theme and preserved all customer routes, forms, filters, and validation behavior.
- Fixed full-page mobile overflow on Price Import details and Return details while keeping wide tables inside contained horizontal scrollers.
- Verified desktop 1440px, tablet 768px, and mobile 390px layouts with no remaining page-level horizontal overflow in the representative route set.
- Verified the responsive navigation drawer interaction and browser console with no relevant errors or warnings.
- PHP syntax, Blade compilation, and the 291-route production route list passed.
- Isolated Laravel validation passed: 18 tests and 144 assertions, including all static web-page smoke checks and the complete Returns/RMA suites.
- Added representative screenshots under `docs/screenshots/full-laravel-qa/` and synchronized them with live `/docs`.

## 2026-08-09 — SNYT Enterprise UI v1 cross-platform consistency completed

- Compared Laravel and Flutter design tokens and representative Dashboard, product, customer, order, Return/RMA, handover, form, and system-state surfaces.
- Corrected Laravel Draft order presentation from amber to neutral.
- Added state-aware Return financial/operational and warehouse-handover badges.
- Standardized legacy Laravel badges on the same translucent neutral, amber, green, cyan, red, and purple enterprise treatments used by Flutter.
- Preserved every existing status value, route, workflow, permission, API, stock rule, and pricing rule.
- Production PHP syntax, Blade compilation, route sanity, browser console, and representative mobile/desktop rendering passed.
- Isolated Laravel validation passed: 18 tests and 144 assertions.
## 2026-08-09 — Customer onboarding and invoice QA

- Recorded the Customer + Cash/On Account validation results from the isolated PHPUnit environment.
- Focused Customer/Pricing: 10 tests and 31 assertions passed. Returns/RMA regression: 16 tests and 106 assertions passed.
- Full suite: 61 passed; the sole failure remains the pre-existing empty fake PDF case in `PriceImportWorkflowTest`, intentionally untouched.
- No production data or business logic was changed.
## 2026-08-09 — Customer + Pricing QA hardening

- Added focused coverage for private document uploads, authorization, customer isolation, VAT/TRN, Cash/On Account approval and pricing, maximum-order boundaries, snapshots, suspension, duplicates, maps and invoice render data.
- Fixed missing TRN enforcement for VAT-registered customer submission and deployed the proven service fix after backup.
- Fixed the PDF line total to use the already-net stored value instead of subtracting Cash discount twice.
- Customer/Pricing suite: 19 tests / 129 assertions passed; Returns/RMA: 16 / 106 passed.
- Full suite: 70 passed; only the excluded pre-existing `PriceImportWorkflowTest` fake-PDF failure remains.

## 2026-08-09 — Security Cheque completion

- Added nullable dated/undated cheque metadata to customer applications while reusing private `customer_documents` storage for the image.
- Enforced the On Account requirements and conditional cheque date in Laravel.
- Added complete metadata to mobile/admin review payloads and protected admin document streaming.
- Added six focused feature tests; Customer/Pricing 25 / 160 and Returns/RMA 11 / 77 passed.
- Full suite: 76 passed / 401 assertions; the known unrelated `PriceImportWorkflowTest` failure is unchanged.

## 2026-08-09 — Customer onboarding workflow completion

- Added Customer Applications queue, complete onboarding details, protected documents and clear review actions.
- Added server-backed resumable drafts and complete mobile restore payloads.
- Separated requested account type from explicit final admin account type and cleared stale Cash credit metadata.
- Added four focused tests with 33 assertions; Customer/Pricing 29 / 193 and Returns/RMA 11 / 77 passed.
- Full suite: 80 passed / 434 assertions; the known PriceImport fake-PDF failure remains unrelated.

## 2026-08-11 — Opening RMA repair

- Fixed undefined `$existing` in the mobile Opening RMA validator.
- Made Opening RMA an idempotent atomic stock-bucket reclassification with no synthetic Customer Return.
- Added direct balanced movement audit rows and fresh authoritative balance response.
- Added barcode/API and invariant coverage; 22 Returns/RMA tests / 144 assertions pass.
- Completed production Stock Replenishment E2E QA with the isolated QA dataset, receipt replay protection, short-preparation review and protected damaged-item evidence.
- Added discoverable Laravel admin links for Stock Requests, Warehouse Preparation, Awaiting Release, Receiving Issues and QA Dataset, plus a dashboard Stock Requests entry point.
- Restricted Flutter stock workflow action buttons to the role that Laravel already authorizes.
# 2026-08-16 — Import Center stabilization

- Made Import Center the only operational uploader for price lists, shipments, and Salesman Van Stock; historical pages remain available.
- Added staged type confirmation, duplicate comparison/resolution, bulk actions, inline correction, row skipping, partial completion, and change previews.
- Added atomic versioned Main/Clearance replacement and non-replacing Price Update semantics with replay protection.
- Corrected the PriceImportWorkflow fake-PDF regression by preventing the legacy endpoint from invoking a parser and directing uploads to Import Center.
- Isolated suite: 113 tests / 647 assertions, all passing, including centralized Shipment and Van Stock regression.

## Async analysis repair

- Removed PhpSpreadsheet analysis from the upload and type-confirmation HTTP requests.
- Added queued, persisted analysis states, reloadable progress/failure UX, and UUID request idempotency.
- Added a persistent cPanel cron worker using the existing database queue and `flock` overlap protection.
- Reproduced the 79,444,200-byte failure as origin HTTP 500 after the web-SAPI 30-second limit; queued analysis completed in 36 seconds.
- Full isolated Laravel suite: 115 tests / 661 assertions, all passing.

## 2026-08-16 — Laravel route and sidebar audit

- Audited all registered web routes and classified operational, detail, form, action, download, authentication, internal, admin, salesman, legacy, and API routes.
- Added discoverable Returns navigation for admin and salesman, RMA Handovers in the appropriate operational groups, and admin-only Developer Docs.
- Preserved Returns as the Laravel landing page for customer return/RMA work; no duplicate web RMA-stock page was introduced.
- Added active-page accessibility markers and focused navigation/authorization coverage.
- Added a supervisor navigation map matching the existing operations authorization while keeping administrator-only modules hidden.
- Added contextual back-links on Return, RMA Handover, and Stock Request details, plus filtered Orders and Returns links on Customer details.
# 2026-08-26 — Visits, Daily Route and DWR v1

- Added authoritative resumable work days, multiple break intervals, manually ordered daily routes, planned/unplanned visits, optional GPS capture fields and one-active-visit safety.
- Linked qualifying orders and customer returns to the active customer visit without changing their existing workflows.
- Added operational Visit Collections v1 with idempotency and an explicit no-ledger/no-credit contract.
- Added system-derived WhatsApp DWR generation, persisted narrative fields, Copy and native Share actions, previous-date loading, customer visit history, Dashboard/More access and Laravel operational pages.
