51a0bab39e
Schema:
- users + specialization, color, hourly_rate (pentru maistri)
- labors: catalog manopere standard cu category/ore/preț (RO+RU)
- work_orders: nr unique per tenant, status workflow (9 stări),
pay_status (3 stări), client/vehicle/master/deal/appointment refs,
complaint/diagnosis/recommendations, total auto-calculat
- wo_works: manopere per fișă, recalc auto la save/delete
- wo_parts: piese per fișă (free-text deocamdată), discount/total auto
Filament resources (group Service):
- LaborResource: CRUD + grupare pe categorie + filter active
- WorkOrderResource: form complex în 4 secțiuni (antet, diagnostic, plată)
+ 2 RelationManagers (Works, Parts)
- MasterResource: vedere User filtrată role=mechanic, edit specializare/
culoare calendar/tarif oră
Conversie auto: la adaugare manoperă din catalog Labor,
form populează numele + ore + preț/oră derivat (price/hours).
Number generator pentru WO: format WO-{YY}-{NNNN} per tenant per an,
calculat în CreateWorkOrder via WorkOrder::generateNumber().
Seed extins:
- 3 mecanici (Vasile/Andrei/Nicolae) cu culori + specializări
- 10 manopere standard din prototipul AutoCRM.html
- 1 fișă demo (BMW X5 plăcuțe Brembo) cu 1 manoperă + 1 piesă, total auto
53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Tenant;
|
|
|
|
use App\Models\Concerns\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class WorkOrderPart extends Model
|
|
{
|
|
use BelongsToTenant;
|
|
|
|
protected $table = 'wo_parts';
|
|
|
|
public const STATUSES = [
|
|
'needed' => 'Necesară',
|
|
'ordered' => 'Comandată',
|
|
'delivered' => 'Sosită',
|
|
'installed' => 'Montată',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'company_id', 'work_order_id',
|
|
'name', 'article', 'brand',
|
|
'qty', 'unit', 'buy_price', 'sell_price',
|
|
'discount_pct', 'total', 'status', 'notes',
|
|
];
|
|
|
|
protected $casts = [
|
|
'qty' => 'decimal:2',
|
|
'buy_price' => 'decimal:2',
|
|
'sell_price' => 'decimal:2',
|
|
'discount_pct' => 'decimal:2',
|
|
'total' => 'decimal:2',
|
|
];
|
|
|
|
public function workOrder(): BelongsTo
|
|
{
|
|
return $this->belongsTo(WorkOrder::class);
|
|
}
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::saving(function (self $row) {
|
|
$sub = (float) $row->qty * (float) $row->sell_price;
|
|
$disc = (float) $row->discount_pct;
|
|
$row->total = round($sub * (1 - $disc / 100), 2);
|
|
});
|
|
static::saved(fn (self $row) => $row->workOrder?->recalcTotal());
|
|
static::deleted(fn (self $row) => $row->workOrder?->recalcTotal());
|
|
}
|
|
}
|