- New Expenses module: purchases (materials, other) with a description and cost, and mileage priced with the price list's mileage rate. - Who paid and whether the expense is billed are separate: an employee's own payments are reimbursed elsewhere. A billed expense has a markup and a billed amount, cost plus markup unless given. - A job's expenses page lists, adds, edits and removes them; amounts of others' expenses need the expenses permission, own ones always show. Done jobs lock their expenses. - The Kulut menu shows the user's own expenses by month. Management records subcontractors' expenses, which they see but cannot change. - The price list gets a default markup for new purchases. - Number fields that update a calculation now use wire:model.live.blur: in Livewire 4 plain .blur no longer sends the value to the server, which also fixes the product form's VAT calculation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
65 lines
2.0 KiB
PHP
65 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Expenses\Infrastructure\Persistence\Eloquent;
|
|
|
|
use App\Modules\Expenses\Domain\Enums\ExpenseCategory;
|
|
use App\Modules\Expenses\Domain\Enums\ExpensePayer;
|
|
use Database\Factories\ExpenseFactory;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Attributes\Table;
|
|
use Illuminate\Database\Eloquent\Attributes\UseFactory;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
/**
|
|
* Persistence model, used only inside the Expenses Infrastructure layer.
|
|
*
|
|
* @property int $id
|
|
* @property int $customer_job_id
|
|
* @property int $user_id
|
|
* @property int $recorded_by
|
|
* @property ExpenseCategory $category
|
|
* @property ExpensePayer $paid_by
|
|
* @property Carbon $spent_on
|
|
* @property string|null $description
|
|
* @property int $cost_cents
|
|
* @property string|null $kilometers
|
|
* @property string|null $destination
|
|
* @property string|null $purpose
|
|
* @property bool $is_billable
|
|
* @property int|null $markup_basis_points
|
|
* @property int|null $billed_amount_cents
|
|
*/
|
|
#[Table('expenses')]
|
|
#[Fillable([
|
|
'customer_job_id', 'user_id', 'recorded_by', 'category', 'paid_by', 'spent_on', 'description', 'cost_cents',
|
|
'kilometers', 'destination', 'purpose', 'is_billable', 'markup_basis_points', 'billed_amount_cents',
|
|
])]
|
|
#[UseFactory(ExpenseFactory::class)]
|
|
class ExpenseModel extends Model
|
|
{
|
|
/** @use HasFactory<ExpenseFactory> */
|
|
use HasFactory;
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'customer_job_id' => 'integer',
|
|
'user_id' => 'integer',
|
|
'recorded_by' => 'integer',
|
|
'category' => ExpenseCategory::class,
|
|
'paid_by' => ExpensePayer::class,
|
|
'spent_on' => 'date',
|
|
'cost_cents' => 'integer',
|
|
'kilometers' => 'decimal:1',
|
|
'is_billable' => 'boolean',
|
|
'markup_basis_points' => 'integer',
|
|
'billed_amount_cents' => 'integer',
|
|
];
|
|
}
|
|
}
|