Jobs billed by a fixed monthly fee get a monthly fee field, kept behind the quotes permission like the quoted amount. A billing material now has a billing month: a new draft adds every monthly fee job with something to bill, each on an invoice of its own, and bills one line for every unbilled month from the job's start up to the billing month (or its end or completion), so skipped months are caught up and no month is billed twice. Their expenses are billed alongside, their hours are covered by the fee and marked billed, and the job keeps running. Co-Authored-By: Claude Opus 5.5 <[email protected]>
57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Billing\Infrastructure\Persistence\Eloquent;
|
|
|
|
use App\Modules\Billing\Domain\Enums\LineKind;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Attributes\Table;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Persistence model, used only inside the Billing Infrastructure layer.
|
|
*
|
|
* @property int $id
|
|
* @property int $billing_invoice_id
|
|
* @property int $customer_job_id
|
|
* @property LineKind $kind
|
|
* @property int|null $work_type_id
|
|
* @property int|null $expense_id
|
|
* @property string|null $period Y-m
|
|
* @property string $description
|
|
* @property int|null $recorded_quarters
|
|
* @property int|null $quantity_quarters
|
|
* @property int $unit_price_cents
|
|
* @property int $vat_basis_points
|
|
* @property int $net_cents
|
|
* @property int $sort_order
|
|
*/
|
|
#[Table('billing_lines')]
|
|
#[Fillable([
|
|
'billing_invoice_id', 'customer_job_id', 'kind', 'work_type_id', 'expense_id', 'period', 'description',
|
|
'recorded_quarters', 'quantity_quarters', 'unit_price_cents', 'vat_basis_points', 'net_cents', 'sort_order',
|
|
])]
|
|
class BillingLineModel extends Model
|
|
{
|
|
public $timestamps = false;
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'billing_invoice_id' => 'integer',
|
|
'customer_job_id' => 'integer',
|
|
'kind' => LineKind::class,
|
|
'work_type_id' => 'integer',
|
|
'expense_id' => 'integer',
|
|
'recorded_quarters' => 'integer',
|
|
'quantity_quarters' => 'integer',
|
|
'unit_price_cents' => 'integer',
|
|
'vat_basis_points' => 'integer',
|
|
'net_cents' => 'integer',
|
|
'sort_order' => 'integer',
|
|
];
|
|
}
|
|
}
|