Management builds the monthly billing material (laskuaineisto) as a draft: done jobs are added as invoices of their own, combined when the customer, billing unit and reference allow it, and their billable hours are set per work type. Creating the material checks the jobs again, marks the approved hours and billable expenses billed, forms invoice lines with price and VAT snapshots and moves the jobs to "Lasku luotu". Fixed price jobs bill their quoted amount once. Billed hours keep their approval and billed expenses can no longer change. The Fennoa export and monthly fee lines come later. Co-Authored-By: Claude Opus 5.5 <[email protected]>
66 lines
2.1 KiB
PHP
66 lines
2.1 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
|
|
* @property int|null $billing_export_id
|
|
*/
|
|
#[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',
|
|
];
|
|
}
|
|
}
|