create(['currency' => 'GBP']); $revision = ProjectRevision::factory()->for($project)->create(); $this->actingAs(User::factory()->create(['role' => 'admin']))->post(route('projects.cost-snapshots.store', $project), [ 'revision_id' => $revision->id, 'basis' => 'estimate', 'currency' => 'GBP', 'batch_units' => 4, 'lines' => [['category' => 'shipping', 'description' => 'Two units per parcel', 'quantity' => '1', 'quantity_unit' => 'parcel', 'unit_rate' => '5', 'units_per_parcel' => 2]], ])->assertRedirect(); $this->assertSame('10.0000', ProjectCostSnapshot::firstOrFail()->shipping_total); $this->assertSame('2.5000', ProjectCostSnapshot::firstOrFail()->perUnitGrandTotal()); } public function test_cost_currency_cannot_diverge_from_project(): void { $project = Project::factory()->create(['currency' => 'GBP']); $revision = ProjectRevision::factory()->for($project)->create(); $this->actingAs(User::factory()->create(['role' => 'admin']))->post(route('projects.cost-snapshots.store', $project), [ 'revision_id' => $revision->id, 'basis' => 'estimate', 'currency' => 'USD', 'batch_units' => 1, 'lines' => [['category' => 'filament', 'description' => 'PLA', 'quantity' => '10', 'quantity_unit' => 'g', 'unit_rate' => '20']], ])->assertSessionHasErrors('currency'); $this->assertDatabaseCount('project_cost_snapshots', 0); } public function test_costing_and_revert_have_usable_labeled_forms(): void { $project = Project::factory()->create(); $this->actingAs(User::factory()->create(['role' => 'admin']))->get(route('projects.show', $project))->assertOk() ->assertSee('Add cost line')->assertSee('Saleable batch yield')->assertSee('Units per parcel')->assertSee('Fusion document'); } }