Umsetzung der Warenwirtschafts-/Produktmanagement-Erweiterung gemaess Entwicklungsplan V4.0: - AP-00: Regressionsbasis fuer 5.1-Features (ProductPhase51Test) - AP-01: URL-Bugfixes B1/B2 (suppliers/packaging-items, breitere url-Spalten) - AP-04/04.1: iPad-taugliche, vereinheitlichte Tabellen-Aktionen - AP-05: Einstellungen "Allgemein" mit UST-Saetzen (tax_rates) und Lieferzeit-Vorlagen (delivery_times, inkl. Tage-Feld) - AP-06: Lieferanten um Bestellweg, Bestell-Mail/-URL und Lieferzeit erweitert - AP-07/07.1: INCI um Lieferanten-Mehrfachwahl, UST und Lieferzeit erweitert; Lieferanten-Detailansicht im Modal mit pflegbaren INCI-/Verpackungslisten - AP-08: Einkauf um UST-Snapshot, Netto/Brutto-Automatik und Duplizieren erweitert Entwicklungsplan aktualisiert: alle Klaerungspunkte (§5) vom Kunden beantwortet und in die jeweiligen APs eingearbeitet (AP-02/03/09/13/15), neues AP-18 (Hinweise-Doku unter Einstellungen) ergaenzt. Naechster Schritt eindeutig markiert: AP-09 (Produktion auf Hersteller-Rezeptur, kein Fallback, Warnung).
111 lines
3.6 KiB
PHP
111 lines
3.6 KiB
PHP
<?php
|
|
|
|
use App\Models\TaxRate;
|
|
use App\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class, RefreshDatabase::class);
|
|
|
|
function taxRateUser(int $adminLevel = 8): User
|
|
{
|
|
$user = User::query()->create([
|
|
'email' => uniqid('tax_', true).'@test.example',
|
|
'password' => bcrypt('password'),
|
|
]);
|
|
$user->forceFill([
|
|
'admin' => $adminLevel,
|
|
'confirmed' => true,
|
|
'active' => true,
|
|
'wizard' => 100,
|
|
'blocked' => false,
|
|
])->save();
|
|
|
|
return $user->fresh();
|
|
}
|
|
|
|
test('allgemein-seite rendert und zeigt umsatzsteuersaetze', function () {
|
|
$this->actingAs(taxRateUser(8), 'user');
|
|
|
|
TaxRate::create(['name' => 'Standard', 'percent' => 19.00, 'active' => true, 'pos' => 0]);
|
|
|
|
$response = $this->get(route('admin.inventory.general'));
|
|
|
|
$response->assertSuccessful();
|
|
$response->assertSee('Umsatzsteuersätze', false);
|
|
$response->assertSee('Standard');
|
|
$response->assertSee(route('admin.inventory.tax-rates.create'), false);
|
|
});
|
|
|
|
test('superadmin legt umsatzsteuersatz an', function () {
|
|
$this->actingAs(taxRateUser(8), 'user');
|
|
|
|
$this->get(route('admin.inventory.tax-rates.create'))->assertSuccessful();
|
|
|
|
$this->post(route('admin.inventory.tax-rates.store'), [
|
|
'name' => 'Standard',
|
|
'percent' => '19',
|
|
'active' => '1',
|
|
'pos' => 0,
|
|
])->assertRedirect(route('admin.inventory.general'));
|
|
|
|
$taxRate = TaxRate::query()->where('name', 'Standard')->firstOrFail();
|
|
expect((float) $taxRate->percent)->toBe(19.00);
|
|
expect($taxRate->active)->toBeTrue();
|
|
});
|
|
|
|
test('umsatzsteuersatz kann bearbeitet und deaktiviert werden', function () {
|
|
$this->actingAs(taxRateUser(8), 'user');
|
|
|
|
$taxRate = TaxRate::create(['name' => 'Ermäßigt', 'percent' => 7.00, 'active' => true, 'pos' => 1]);
|
|
|
|
$this->get(route('admin.inventory.tax-rates.edit', $taxRate))->assertSuccessful();
|
|
|
|
$this->put(route('admin.inventory.tax-rates.update', $taxRate), [
|
|
'name' => 'Ermäßigt (alt)',
|
|
'percent' => '7',
|
|
'pos' => 1,
|
|
])->assertRedirect(route('admin.inventory.general'));
|
|
|
|
$taxRate->refresh();
|
|
expect($taxRate->name)->toBe('Ermäßigt (alt)');
|
|
expect($taxRate->active)->toBeFalse();
|
|
});
|
|
|
|
test('umsatzsteuersatz kann geloescht werden', function () {
|
|
$this->actingAs(taxRateUser(8), 'user');
|
|
|
|
$taxRate = TaxRate::create(['name' => 'Steuerfrei', 'percent' => 0.00, 'active' => true, 'pos' => 2]);
|
|
|
|
$this->delete(route('admin.inventory.tax-rates.destroy', $taxRate))
|
|
->assertRedirect(route('admin.inventory.general'));
|
|
|
|
expect(TaxRate::query()->whereKey($taxRate->id)->exists())->toBeFalse();
|
|
});
|
|
|
|
test('prozentsatz ist pflicht und muss numerisch sein', function () {
|
|
$this->actingAs(taxRateUser(8), 'user');
|
|
|
|
$this->post(route('admin.inventory.tax-rates.store'), [
|
|
'name' => 'Ohne Satz',
|
|
'percent' => '',
|
|
])->assertSessionHasErrors('percent');
|
|
|
|
$this->post(route('admin.inventory.tax-rates.store'), [
|
|
'name' => 'Zu hoch',
|
|
'percent' => '150',
|
|
])->assertSessionHasErrors('percent');
|
|
});
|
|
|
|
test('nur aktive saetze ueber active-scope', function () {
|
|
TaxRate::create(['name' => 'Aktiv', 'percent' => 19.00, 'active' => true, 'pos' => 0]);
|
|
TaxRate::create(['name' => 'Inaktiv', 'percent' => 16.00, 'active' => false, 'pos' => 1]);
|
|
|
|
expect(TaxRate::query()->active()->pluck('name')->all())->toBe(['Aktiv']);
|
|
});
|
|
|
|
test('nicht-superadmin hat keinen zugriff auf allgemein-seite', function () {
|
|
$this->actingAs(taxRateUser(7), 'user');
|
|
|
|
$this->get(route('admin.inventory.general'))->assertRedirect('/home');
|
|
});
|