Files
Toiminnanohjaus/app/Modules/Jobs/Infrastructure/Persistence/Eloquent/CustomerJobModel.php
T
petriandClaude Opus 5.5 6de5d9bef1 Add quick sales with cash days, credits and PDF receipts
Quick sales (pikamyynti) of active consumer products at the counter, in a
new Sales module:

- Product buttons add one to the sale's list per press; quantities can be
  lowered, raised or removed. Payment by cash or card, optional customer.
- Product durations are booked as the seller's hours on the yearly
  "Pikamyynnit" job (internal customer, not billed) through Jobs'
  ProvideQuickSaleTask and TimeTracking's AddTaskHours. The sale stands
  even when the hours cannot be booked, and the seller is told.
- Sales are never deleted: a credit records the lines negated on today's
  cash day, once per sale, by the seller or management.
- Closing a cash day stores its balance by payment method and VAT rate and
  stops sales on it; only management reopens a day.
- A printable A5 PDF receipt (barryvdh/laravel-dompdf) with the company's
  details, business ID, VAT number, lines and VAT breakdown.

Company details are kept in the settings and edited by the admin only on
the new Yritystiedot page. BusinessId moves from Customers to Shared so
both use the same check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 12:33:46 +02:00

89 lines
3.2 KiB
PHP

<?php
namespace App\Modules\Jobs\Infrastructure\Persistence\Eloquent;
use App\Modules\Jobs\Domain\Enums\JobKind;
use App\Modules\Jobs\Domain\Enums\JobStatus;
use App\Modules\Jobs\Domain\Enums\PaymentBasis;
use App\Modules\Jobs\Domain\Enums\Priority;
use Carbon\CarbonImmutable;
use Database\Factories\CustomerJobFactory;
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;
/**
* Persistence model of a customer job, used only inside the Jobs
* Infrastructure layer. Service units, members, tags and links are in
* their own tables, read and written by the repository.
*
* @property int $id
* @property string $number
* @property string $name
* @property string|null $description
* @property int $customer_id
* @property CarbonImmutable|null $starts_on
* @property CarbonImmutable|null $due_on
* @property CarbonImmutable|null $planned_from
* @property CarbonImmutable|null $planned_to
* @property JobKind $kind
* @property JobStatus $status
* @property Priority $priority
* @property PaymentBasis|null $payment_basis
* @property string|null $estimated_hours
* @property string|null $customer_reference
* @property string|null $instructions
* @property int $responsible_user_id
* @property int|null $contact_user_id
* @property int|null $customer_contact_id
* @property int|null $biller_user_id
* @property int|null $billing_unit_id
* @property int $created_by
* @property int|null $quoted_amount_cents
* @property CarbonImmutable|null $completed_at
* @property int|null $quick_sale_year
* @property CarbonImmutable $created_at
*/
#[Table('customer_jobs')]
#[Fillable([
'number', 'name', 'description', 'customer_id', 'starts_on', 'due_on', 'planned_from', 'planned_to',
'kind', 'status', 'priority', 'payment_basis', 'estimated_hours', 'quoted_amount_cents', 'customer_reference', 'instructions',
'responsible_user_id', 'contact_user_id', 'customer_contact_id', 'biller_user_id', 'billing_unit_id', 'created_by', 'completed_at',
])]
#[UseFactory(CustomerJobFactory::class)]
class CustomerJobModel extends Model
{
/** @use HasFactory<CustomerJobFactory> */
use HasFactory;
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'customer_id' => 'integer',
'quoted_amount_cents' => 'integer',
'quick_sale_year' => 'integer',
'completed_at' => 'immutable_datetime',
'starts_on' => 'immutable_date',
'due_on' => 'immutable_date',
'planned_from' => 'immutable_date',
'planned_to' => 'immutable_date',
'kind' => JobKind::class,
'status' => JobStatus::class,
'priority' => Priority::class,
'payment_basis' => PaymentBasis::class,
'responsible_user_id' => 'integer',
'contact_user_id' => 'integer',
'customer_contact_id' => 'integer',
'biller_user_id' => 'integer',
'billing_unit_id' => 'integer',
'created_by' => 'integer',
'created_at' => 'immutable_datetime',
];
}
}