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,55 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Modules\Catalog\Application\UseCases\SetMileageRate;
|
||||
use App\Modules\Expenses\Infrastructure\Persistence\Eloquent\ExpenseModel;
|
||||
use App\Modules\Jobs\Domain\Enums\JobStatus;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\CustomerJobModel;
|
||||
use App\Modules\Shared\Application\Contracts\Settings;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
$this->user = User::factory()->employee()->create();
|
||||
$this->actingAs($this->user);
|
||||
app(Settings::class)->put(SetMileageRate::SETTING_KEY, '59');
|
||||
$this->job = CustomerJobModel::factory()->create(['name' => 'Messuvideo', 'status' => JobStatus::Order]);
|
||||
$this->purchase = ExpenseModel::factory()->create(['customer_job_id' => $this->job->id, 'user_id' => $this->user->id, 'description' => 'Tulostuspaperi', 'spent_on' => now()->toDateString()]);
|
||||
$this->mileage = ExpenseModel::factory()->mileage()->create(['customer_job_id' => $this->job->id, 'user_id' => $this->user->id, 'spent_on' => now()->toDateString()]);
|
||||
ExpenseModel::factory()->create(['customer_job_id' => $this->job->id, 'description' => 'Kollegan hankinta']);
|
||||
});
|
||||
|
||||
it('has no accessibility issues on the expense pages and no sideways scrolling', function (string $page, string $device, string $colorScheme) {
|
||||
$url = match ($page) {
|
||||
'job expenses' => route('expenses.job', $this->job->id),
|
||||
'new expense' => route('expenses.create', $this->job->id),
|
||||
'edit mileage' => route('expenses.edit', $this->mileage->id),
|
||||
'own expenses' => route('expenses.mine'),
|
||||
};
|
||||
|
||||
$visit = visit($url);
|
||||
$visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop();
|
||||
$visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode();
|
||||
|
||||
$visit->assertSee('Messuvideo')
|
||||
->assertNoJavaScriptErrors()
|
||||
->assertNoAccessibilityIssues(level: 2);
|
||||
})->with(['job expenses', 'new expense', 'edit mileage', 'own expenses'])->with([
|
||||
'desktop, light' => ['desktop', 'light'],
|
||||
'desktop, dark' => ['desktop', 'dark'],
|
||||
'mobile, light' => ['mobile', 'light'],
|
||||
'mobile, dark' => ['mobile', 'dark'],
|
||||
]);
|
||||
|
||||
it('works out the cost of kilometres as they are typed', function () {
|
||||
$field = '[wire\\:model\\.live\\.blur="form.kilometers"]';
|
||||
|
||||
visit(route('expenses.edit', $this->mileage->id))
|
||||
->clear($field)
|
||||
->type($field, '100')
|
||||
->keys($field, 'Tab')
|
||||
->assertSee('100 km × 0,59')
|
||||
->assertSee('59,00')
|
||||
->assertNoAccessibilityIssues(level: 2);
|
||||
});
|
||||
Reference in New Issue
Block a user