Count billing materials without a billing month in reports
Materials created before billing months existed have no period, so the profitability report left out what they billed. Their month is now the month they were created in, as in the export repository. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -99,6 +99,22 @@ it('reports billing, costs and margins by job and service unit', function () {
|
||||
->toContain(';-12000');
|
||||
});
|
||||
|
||||
it('counts a fixed price billed by a material without a billing month in the month it was created', function () {
|
||||
$job = profitJob(['name' => 'Tarra', 'payment_basis' => 'fixed_quote', 'quoted_amount_cents' => 40000, 'status' => JobStatus::Done], [$this->video->id]);
|
||||
profitHours($job, 1, '2026-11-20');
|
||||
|
||||
$exportId = app(OpenBillingDraft::class)->execute($this->manager->id);
|
||||
app(AddJobToDraft::class)->execute($exportId, $job->id);
|
||||
app(FinalizeBillingExport::class)->execute($exportId, $this->manager->id);
|
||||
DB::table('billing_exports')->where('id', $exportId)->update(['period' => null, 'created_at' => '2026-11-24 11:03:07']);
|
||||
|
||||
$november = Livewire::withQueryParams(['alku' => '2026-11-01', 'loppu' => '2026-11-30'])->test('reports::profitability')->instance()->report();
|
||||
$december = Livewire::withQueryParams(['alku' => '2026-12-01', 'loppu' => '2026-12-31'])->test('reports::profitability')->instance()->report();
|
||||
|
||||
expect($november->jobs[0]->profit->workCents)->toBe(40000)
|
||||
->and($december->jobs)->toBe([]);
|
||||
});
|
||||
|
||||
it('asks for the internal hourly cost before showing margins', function () {
|
||||
profitHours(profitJob(['name' => 'Tuntityö', 'payment_basis' => 'hourly'], [$this->video->id]), 2, '2026-11-03');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user