Files
petriandClaude Opus 5.5 b4f2f1cfaa Add the task calendar, holidays, workflow templates and customer removal
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]>
2026-11-24 18:13:11 +02:00

71 lines
3.5 KiB
PHP

<?php
use App\Modules\Customers\Application\Services\CustomerRemoval;
use App\Modules\Customers\Application\UseCases\RemoveCustomer;
use App\Modules\Customers\Domain\Entities\BillingUnit;
use App\Modules\Customers\Domain\Entities\Customer;
use App\Modules\Customers\Domain\Entities\CustomerContact;
use App\Modules\Customers\Domain\Enums\CustomerType;
use App\Modules\Customers\Domain\Exceptions\CustomerInUse;
use App\Modules\Customers\Domain\Exceptions\CustomerNotFound;
use App\Modules\Customers\Domain\Exceptions\InternalCustomerCannotBeRemoved;
use App\Modules\Customers\Domain\ValueObjects\BillingUnitName;
use App\Modules\Customers\Domain\ValueObjects\ContactName;
use App\Modules\Customers\Domain\ValueObjects\CustomerName;
use Tests\Fakes\FakeCustomerReferences;
use Tests\Fakes\FakeTransactionManager;
use Tests\Fakes\InMemoryBillingUnitRepository;
use Tests\Fakes\InMemoryCustomerContactRepository;
use Tests\Fakes\InMemoryCustomerRepository;
beforeEach(function () {
$this->customers = new InMemoryCustomerRepository;
$this->contacts = new InMemoryCustomerContactRepository;
$this->billingUnits = new InMemoryBillingUnitRepository;
$this->references = new FakeCustomerReferences;
$this->removal = new CustomerRemoval($this->customers, $this->contacts, $this->billingUnits, $this->references);
$this->removeCustomer = new RemoveCustomer($this->customers, $this->removal, new FakeTransactionManager);
$this->customerId = $this->customers->save(Customer::register(new CustomerName('Mainos Oy'), CustomerType::Company))->id();
});
it('removes a customer that has nothing but its name', function () {
expect($this->removal->canRemove($this->customerId))->toBeTrue();
$this->removeCustomer->execute($this->customerId);
expect($this->customers->findById($this->customerId))->toBeNull()
->and($this->removal->canRemove($this->customerId))->toBeFalse();
});
it('does not remove an unknown customer', function () {
$this->removeCustomer->execute(999);
})->throws(CustomerNotFound::class);
it('does not remove the internal customer', function () {
$internalId = $this->customers->save(Customer::reconstitute(50, new CustomerName('Oma Oy'), CustomerType::Company, null, null, true))->id();
expect($this->removal->canRemove($internalId))->toBeFalse()
->and(fn () => $this->removeCustomer->execute($internalId))->toThrow(InternalCustomerCannotBeRemoved::class)
->and($this->customers->findById($internalId))->not->toBeNull();
});
it('does not remove a customer that has a contact or a billing unit', function (string $row) {
match ($row) {
'contact' => $this->contacts->save(CustomerContact::create($this->customerId, new ContactName('Maija'))),
'billing unit' => $this->billingUnits->save(BillingUnit::create($this->customerId, new BillingUnitName('Mainos Oy'))),
};
expect($this->removal->canRemove($this->customerId))->toBeFalse()
->and(fn () => $this->removeCustomer->execute($this->customerId))->toThrow(CustomerInUse::class)
->and($this->customers->findById($this->customerId))->not->toBeNull();
})->with(['contact', 'billing unit']);
it('does not remove a customer that other modules refer to', function () {
$this->references->referencedIds = [$this->customerId];
expect($this->removal->canRemove($this->customerId))->toBeFalse()
->and(fn () => $this->removeCustomer->execute($this->customerId))->toThrow(CustomerInUse::class)
->and($this->customers->findById($this->customerId))->not->toBeNull();
});