e8078f157a
Schema: - subcontractors (specialty, rating, contact) - subcontract_jobs (work_order link, cost, markup_pct, client_price, status workflow, sent_at/eta/returned_at, paid_to_sub) Models: - SubcontractJob: auto number (SC-YY-NNNN), client_price = cost×(1+markup/100) when markup>0 (else manual), margin() helper, recalcs parent WO on save/delete - WorkOrder.recalcTotal now includes non-cancelled subcontract job client_price Filament (new "Subcontractare" nav group): - SubcontractorResource (specialty/rating CRUD) - SubcontractJobResource board with cost/client/margin columns + status filters, nav badge = open jobs - SubcontractJobsRelationManager on WorkOrder Tests (7 new): - client_price from markup; manual price without markup; auto number; WO total includes jobs; cancelled excluded; delete recalcs; tenant isolation Closes roadmap to 16/18 stages (only Stage 10 Bodyshop remains). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
33 lines
776 B
PHP
33 lines
776 B
PHP
<?php
|
|
|
|
namespace App\Models\Tenant;
|
|
|
|
use App\Models\Concerns\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Subcontractor extends Model
|
|
{
|
|
use BelongsToTenant, SoftDeletes;
|
|
|
|
public const SPECIALTIES = [
|
|
'Turbo', 'Cutie viteze', 'Variator', 'Casetă direcție',
|
|
'PDR', 'Vopsitorie', 'Electronică', 'Injectoare', 'Altele',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'company_id', 'name', 'specialty', 'phone', 'email',
|
|
'rating', 'is_active', 'notes',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_active' => 'boolean',
|
|
];
|
|
|
|
public function jobs(): HasMany
|
|
{
|
|
return $this->hasMany(SubcontractJob::class);
|
|
}
|
|
}
|