Files
ladill-care/app/Models/Bill.php
T
isaaccladandCursor 015a4cc7fe
Deploy Ladill Care / deploy (push) Successful in 1m45s
Wire Care lists into Ladill Queue workflows instead of reception panels.
When Queue integration is on, role pages issue tickets into their own
department queues and drive Call next → Serve → Complete on the native
lists. Integration off leaves existing UI unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 16:27:48 +00:00

84 lines
2.0 KiB
PHP

<?php
namespace App\Models;
use App\Models\Concerns\BelongsToOwner;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Str;
class Bill extends Model
{
use BelongsToOwner, SoftDeletes;
public const STATUS_DRAFT = 'draft';
public const STATUS_OPEN = 'open';
public const STATUS_PARTIAL = 'partial';
public const STATUS_PAID = 'paid';
public const STATUS_VOID = 'void';
protected $table = 'care_bills';
protected $fillable = [
'uuid', 'queue_ticket_uuid', 'queue_ticket_number', 'queue_ticket_status',
'owner_ref', 'organization_id', 'branch_id', 'visit_id', 'patient_id',
'invoice_number', 'status', 'subtotal_minor', 'discount_minor', 'tax_minor',
'total_minor', 'amount_paid_minor', 'balance_minor', 'notes', 'created_by', 'finalized_at',
];
protected function casts(): array
{
return ['finalized_at' => 'datetime'];
}
protected static function booted(): void
{
static::creating(function (Bill $bill) {
if (! $bill->uuid) {
$bill->uuid = (string) Str::uuid();
}
});
}
public function getRouteKeyName(): string
{
return 'uuid';
}
public function patient(): BelongsTo
{
return $this->belongsTo(Patient::class, 'patient_id');
}
public function visit(): BelongsTo
{
return $this->belongsTo(Visit::class, 'visit_id');
}
public function branch(): BelongsTo
{
return $this->belongsTo(Branch::class, 'branch_id');
}
public function organization(): BelongsTo
{
return $this->belongsTo(Organization::class, 'organization_id');
}
public function lineItems(): HasMany
{
return $this->hasMany(BillLineItem::class, 'bill_id');
}
public function payments(): HasMany
{
return $this->hasMany(Payment::class, 'bill_id');
}
}