Add expenses on customer jobs
- New Expenses module: purchases (materials, other) with a description and cost, and mileage priced with the price list's mileage rate. - Who paid and whether the expense is billed are separate: an employee's own payments are reimbursed elsewhere. A billed expense has a markup and a billed amount, cost plus markup unless given. - A job's expenses page lists, adds, edits and removes them; amounts of others' expenses need the expenses permission, own ones always show. Done jobs lock their expenses. - The Kulut menu shows the user's own expenses by month. Management records subcontractors' expenses, which they see but cannot change. - The price list gets a default markup for new purchases. - Number fields that update a calculation now use wire:model.live.blur: in Livewire 4 plain .blur no longer sends the value to the server, which also fixes the product form's VAT calculation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Expenses\Application\DTOs;
|
||||
|
||||
use App\Modules\Expenses\Domain\Enums\ExpenseCategory;
|
||||
use App\Modules\Expenses\Domain\Enums\ExpensePayer;
|
||||
|
||||
/**
|
||||
* An expense's fields as the user typed them: amounts "12,50", kilometres
|
||||
* "12,5", markup "15". An empty billed amount means cost plus markup.
|
||||
*/
|
||||
final readonly class ExpenseData
|
||||
{
|
||||
/**
|
||||
* @param string $spentOn Date as Y-m-d.
|
||||
*/
|
||||
public function __construct(
|
||||
public int $userId,
|
||||
public ExpenseCategory $category,
|
||||
public ExpensePayer $paidBy,
|
||||
public string $spentOn,
|
||||
public string $description = '',
|
||||
public string $cost = '',
|
||||
public string $kilometers = '',
|
||||
public string $destination = '',
|
||||
public string $purpose = '',
|
||||
public bool $isBillable = true,
|
||||
public string $markup = '',
|
||||
public string $billedAmount = '',
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Expenses\Application\DTOs;
|
||||
|
||||
/**
|
||||
* A customer job as expenses see it: its number and name, and whether it is
|
||||
* done, which locks its expenses.
|
||||
*/
|
||||
final readonly class ExpenseJob
|
||||
{
|
||||
public function __construct(
|
||||
public int $id,
|
||||
public string $number,
|
||||
public string $name,
|
||||
public bool $isLocked,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* E.g. "2026-0005 Messuvideo".
|
||||
*/
|
||||
public function label(): string
|
||||
{
|
||||
return $this->number.' '.$this->name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Expenses\Application\DTOs;
|
||||
|
||||
use App\Modules\Expenses\Domain\Enums\ExpenseCategory;
|
||||
use App\Modules\Expenses\Domain\Enums\ExpensePayer;
|
||||
|
||||
/**
|
||||
* An expense for lists and forms. Amounts are in cents without VAT; pages
|
||||
* decide per row whether the viewer may see them.
|
||||
*/
|
||||
final readonly class ExpenseSummary
|
||||
{
|
||||
/**
|
||||
* @param string $spentOn Date as Y-m-d.
|
||||
*/
|
||||
public function __construct(
|
||||
public int $id,
|
||||
public ExpenseJob $job,
|
||||
public int $userId,
|
||||
public string $userName,
|
||||
public int $recordedBy,
|
||||
public string $recordedByName,
|
||||
public ExpenseCategory $category,
|
||||
public ExpensePayer $paidBy,
|
||||
public string $spentOn,
|
||||
public ?string $description,
|
||||
public int $costCents,
|
||||
public ?int $kilometerTenths,
|
||||
public ?string $destination,
|
||||
public ?string $purpose,
|
||||
public bool $isBillable,
|
||||
public ?int $markupBasisPoints,
|
||||
public ?int $billedAmountCents,
|
||||
) {}
|
||||
}
|
||||
Reference in New Issue
Block a user