Task calendar (/jobs/calendar) replaces per-unit task Kanban columns (K34): a two-week Gantt of tasks per person. Bars move, resize and change person by dragging or through a keyboard dialog. Each task's estimate is booked evenly over working days into task_bookings, and what exceeds the daily maximum (jobs.daily_capacity_hours, 8 h) moves to the next working day. Tasks get planned_from/planned_to on the form. Holidays (/settings/holidays): Finnish public holidays calculated per year, which the admin can take out of use, plus company days off. Also includes the earlier uncommitted work: workflow templates with adding tasks from a template, and removing customers no module refers to. Co-Authored-By: Claude Opus 5.5 <[email protected]>
61 lines
2.1 KiB
PHP
61 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Customers\Infrastructure\Persistence\Repositories;
|
|
|
|
use App\Modules\Customers\Domain\Contracts\BillingUnitRepository;
|
|
use App\Modules\Customers\Domain\Entities\BillingUnit;
|
|
use App\Modules\Customers\Domain\ValueObjects\BillingUnitName;
|
|
use App\Modules\Customers\Domain\ValueObjects\EInvoiceAddress;
|
|
use App\Modules\Customers\Infrastructure\Persistence\Eloquent\BillingUnitModel;
|
|
|
|
class EloquentBillingUnitRepository implements BillingUnitRepository
|
|
{
|
|
public function findForCustomer(int $customerId, int $billingUnitId): ?BillingUnit
|
|
{
|
|
$model = BillingUnitModel::query()->where('customer_id', $customerId)->find($billingUnitId);
|
|
|
|
return $model === null ? null : $this->toEntity($model);
|
|
}
|
|
|
|
public function save(BillingUnit $billingUnit): BillingUnit
|
|
{
|
|
$model = $billingUnit->id() === null
|
|
? new BillingUnitModel
|
|
: BillingUnitModel::query()->findOrFail($billingUnit->id());
|
|
|
|
$model->fill([
|
|
'customer_id' => $billingUnit->customerId(),
|
|
'name' => $billingUnit->name()->value,
|
|
'billing_address' => $billingUnit->billingAddress(),
|
|
'e_invoice_address' => $billingUnit->eInvoiceAddress()?->value,
|
|
'e_invoice_operator' => $billingUnit->eInvoiceOperator(),
|
|
'reference' => $billingUnit->reference(),
|
|
])->save();
|
|
|
|
return $this->toEntity($model);
|
|
}
|
|
|
|
public function delete(BillingUnit $billingUnit): void
|
|
{
|
|
BillingUnitModel::query()->whereKey($billingUnit->id())->delete();
|
|
}
|
|
|
|
public function existsForCustomer(int $customerId): bool
|
|
{
|
|
return BillingUnitModel::query()->where('customer_id', $customerId)->exists();
|
|
}
|
|
|
|
private function toEntity(BillingUnitModel $model): BillingUnit
|
|
{
|
|
return BillingUnit::reconstitute(
|
|
$model->id,
|
|
$model->customer_id,
|
|
new BillingUnitName($model->name),
|
|
$model->billing_address,
|
|
$model->e_invoice_address === null ? null : new EInvoiceAddress($model->e_invoice_address),
|
|
$model->e_invoice_operator,
|
|
$model->reference,
|
|
);
|
|
}
|
|
}
|