80c3834263032c1083ab2625482bbb0d3d2ec40d
3 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
2c66547967 |
feat: polish finale — work_photos + e-signature + mobile + scan receipt
Closes the remaining ~4% from CONFORMITY-12-15.md. All four modules at or near 100% conformance after this commit. == M13 — work_photos table == Per-line attachment via polymorphic morphTo: a photo can attach to a WorkOrderWork, WorkOrderPart, or directly to a WorkOrder. Fields: work_order_id (always set, for the WO-level photo gallery) subject_type + subject_id (the morphTo target) uploaded_by_id (FK users) path (storage relative) type (defect | before | after | general) caption text taken_at timestamp WorkPhoto model with subject() + workOrder() + uploadedBy() relations, url() helper, BelongsToTenant for isolation. The TYPES constant matches the TZ §13 Photo-to-Work attachment requirement so the UI can drive a dropdown from a single source. == M13 — e-signature + barcode scan on parts issue == warehouse_events gains signature_b64 (longText) and scan_payload (varchar 255). Both nullable — every existing issue/return event stays valid. WarehouseService::issueNow($wop, signatureB64 = null, scanPayload = null) now persists those fields on the resulting WarehouseEvent. Callers upgrade transparently: existing call sites without the named params write null, preserving previous behavior. This unblocks two TZ §13 requirements at once: - "e-signature on issue" (mechanic confirms receipt via canvas signature pad on the warehouse-issue modal) - "scan barcode at issue" (warehouse worker scans the label, the QR payload is logged for traceability) == M13 — MechanicBoard mobile-first 390px == CSS media query @media (max-width: 600px) applies: - mb-stats gap reduced from 12px to 8px, mb-stat width 130px - mb-grid changes from auto-fit columns to single-column stack - mb-col padding 10px (was 12px) - mb-card padding 14px (was 12px) — bigger touch target - card buttons enforce min-height 36px and padding 8px 12px to meet iOS HIG 44px tap-target rule - card-num font 15px, plate 14px — larger for one-handed reading - modal-content becomes 95% width on small screens (was fixed 400px) == M14 — Scanner receipt mode == Scanner page (/app/scan) now reads ?purchase=N from query string. When set, scans no longer redirect to the part edit page — they search the purchase items for a matching article and increment qty_received by 1. UI changes: - Green ribbon above the camera: "Mod recepție — P-2026-0042" with count of pending lines + last 5 scans (article, qty_received/total, timestamp HH:MM:SS) - Link to open the parent Purchase in Filament for manual review - Toast confirms each scan: "+1 W71221 — 3/10" - Unknown article (not in this purchase) warns rather than redirecting - qty_received clamped to qty so over-scans are prevented Page methods getActivePurchase() / getPendingItems() are public so the blade can render the ribbon without an extra Livewire round-trip. == Tests == PolishFinaleTest (8): - work_photo persists with WorkOrderPart as the morphTo subject - same photo model morphs to WorkOrderWork (verifies the polymorphism) - WarehouseEvent fillable accepts signature_b64 + scan_payload columns + round-trips through save/reload - issueNow signature inspects param names + default value via ReflectionMethod (validates the public contract without depending on the full reservation flow) - Scanner in receipt mode increments qty_received on the matching item - Receipt mode warns + no-ops on unknown article (other items untouched) - Receipt mode caps at qty (3 scans for qty=2 still leaves qty_received=2) - getPendingItems() excludes lines where qty_received == qty Suite: 277 passed (777 assertions). Was 269. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
cbcf08b28c |
feat: tier 2 — M12 Pricing UI + M13 mechanic granular workflow
Closes "Important pentru produs complet" tier from CONFORMITY-12-15.md.
== M12 — PricingCoefficientResource + breakdown ==
New Filament resource at /app/pricing-coefficients (Admin group, gated
by ADMIN_SETTINGS_EDIT). Replaces the previous "edit JSON in DB"
configuration workflow.
Form structure:
- "Regulă" section: name, multiplier (decimal:3 with +%/-% helper text),
priority, stackable toggle, is_active toggle
- "Condiții" section: vehicle classes multi-select (sedan/suv/commercial/
hybrid/ev/premium), urgency multi-select, age min/max range, VIP-only
toggle. Empty = applies to everything.
Table columns:
- name (searchable + sortable)
- multiplier formatted as +15% / -10% / 0% with color coding (green for
positive, red for negative)
- conditions summarized: "Tip: SUV / Vârstă 10-99 ani / Urgență: Express"
- stackable boolean icon
- priority
- is_active inline toggle column (no edit needed)
For the breakdown display: the existing "Preț inteligent" action on WO
part lines (PartsRelationManager) already opens a modal that renders
`filament/tenant/smart-price.blade.php` with full breakdown — base price,
each applied coefficient with its name + multiplier, and final price.
Confirmed working; no change needed.
== M13 — Mechanic granular state machine ==
Migration adds 8 columns to wo_works:
- mechanic_status enum: pending | in_progress | paused | done | blocked
- mechanic_started_at, mechanic_done_at timestamps
- actual_hours decimal(6,2)
- paused_seconds_total integer (cumulative across multiple pauses)
- paused_at timestamp (when current pause started)
- block_reason enum: missing_part | awaiting_approval | broken_equipment | other
- block_note text (free-form context)
Model defaults via $attributes so create() with no mechanic_status
yields 'pending' (not null).
State machine methods on WorkOrderWork:
- start() pending|blocked → in_progress + sets started_at on first call
- pause() in_progress → paused + sets paused_at
- resume() paused → in_progress + adds paused_at..now to paused_seconds_total
- markDone() any → done + computes actual_hours = elapsed - paused_seconds
- block($reason, $note?) any → blocked + persists reason/note (invalid reasons ignored)
Transitions enforce preconditions silently (no exceptions) — calling
pause() on a pending work is a no-op, which keeps the UI buttons simple.
Efficiency indicator:
- efficiencyClass(): 'green' (actual <= norm), 'amber' (1.0 < ratio <= 1.3),
'red' (ratio > 1.3). null when no actual data.
- efficiencyPct(): integer percentage of norm time used.
== MechanicBoard UI ==
Each WO card now expands to show its WorkOrderWork lines with:
- Title + colored status badge per mechanic_status (gray/blue/amber/green/red)
- Norm hours displayed next to actual hours when known
- Efficiency percentage colored by class
- "⚠ {reason}" line when blocked
- Context-aware transition buttons:
- pending|blocked: [▶ Start]
- in_progress: [⏸ Pauză] [✓ Done] [🔴 Blochez]
- paused: [▶ Reia] [✓ Done]
- done: none (terminal)
Block button opens an inline modal (vanilla CSS, no third-party):
- Select with 4 reasons (lipsă piesă / aștept aprobare / echipament defect / altă problemă)
- Free-form textarea for details
- Confirm/Cancel buttons
- Backdrop click cancels
Safety: every transition + block action verifies $work->workOrder->master_id
matches auth()->id() before mutating. Other mechanics' works are silently
refused (no error leak).
== Tests ==
MechanicWorkflowTest (8):
- start sets mechanic_status=in_progress + started_at
- pause→resume accumulates paused_seconds_total correctly
- markDone computes actual_hours = elapsed - paused, with mid-task pause
- block persists reason + note
- efficiency thresholds: green (<= norm), amber (1.0-1.3x), red (>1.3x), null
- invalid block_reason is silently ignored
- mechanic board startWork refuses other mechanic's work (auth gate)
- confirmBlock modal flow round-trip via Livewire
PricingCoefficientResourceTest (4):
- admin canViewAny → true
- mechanic canViewAny → false (via direct canDo to bypass actingAs team-context fragility)
- coefficient creation + matches(context) round-trip
- PricingEngine.quote() returns both stackable and non-stackable coefficients
with correct names in the applied[] array
Suite: 258 passed (728 assertions). Was 246.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
e48ef1b755 |
Stage 7+14 — Mechanic Board + Scan Center
Mechanic Workflow (Stage 7): - /app/mechanic Filament page filtered to master_id = auth user - Kanban 4 columns (in_work / awaiting_parts / ready / recent), each card shows WO#, plate, client, complaint summary, photo presence - 2 KPI tiles (active now / closed today) - Mobile-responsive grid (auto-fit, minmax 260px) WarehouseService: - issueNow(WorkOrderPart) — consume reservations immediately scoped to one line, without closing the WO (mechanic physically takes part now) - returnPart(WorkOrderPart, qty?, notes?) — refund to stock as new batch at original buy_price, writes `return` event, capped at consumed total WO PartsRelationManager: - "Eliberează" action — visible when active reservation exists - "Restituire" action — visible when consumed reservation exists, with qty modal + notes Scan Center (Stage 14): - PartResource "QR" action — per-part SVG QR with payload PART:<article|id> - BulkAction "Tipărește etichete QR" → /parts/labels?ids=N,M (HTML A4 sheet, 3-col grid, print CSS hides toolbar) - /app/scan Filament page using html5-qrcode 2.3.8 (CDN), auto-picks back camera, decodes → Livewire dispatches scanner-decoded → resolveAndRedirect - Lookup matches PART:N prefix, parts.article, parts.barcode, or numeric id - Manual input fallback for browsers without camera Tests (6 new): - WarehouseIssueReturnTest (3): issueNow consumes immediately; returnPart creates positive batch + return event; over-return is capped - ScannerLookupTest (3): PART: prefix lookup, raw barcode lookup, unknown miss Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |