Add frontend for allpayment
continuous-integration/drone/push Build is passing Details

This commit is contained in:
philipp lang 2022-12-14 23:20:05 +01:00
parent 8af0e2a16e
commit 785f9e5689
10 changed files with 35 additions and 15 deletions

View File

@ -22,6 +22,7 @@ class Subscription extends Model
*/
public $casts = [
'split' => 'boolean',
'for_promise' => 'boolean',
];
public function getAmount(): int

View File

@ -41,8 +41,10 @@ class SubscriptionController extends Controller
'name' => 'required|max:255',
'split' => 'present|boolean',
'fee_id' => 'required|exists:fees,id',
'for_promise' => 'present|boolean',
], [], [
'fee_id' => 'Nami-Beitrag',
'for_promise' => 'Für Versprechen benutzen',
]);
$children = $request->validate([
@ -75,8 +77,10 @@ class SubscriptionController extends Controller
'name' => 'required|max:255',
'split' => 'present|boolean',
'fee_id' => 'required|exists:fees,id',
'for_promise' => 'present|boolean',
], [], [
'fee_id' => 'Nami-Beitrag',
'for_promise' => 'Für Versprechen benutzen',
]);
$subscription->update($subscriptionParams);
$children = $request->validate([

View File

@ -27,6 +27,7 @@ class SubscriptionResource extends JsonResource
'amount' => $this->getAmount(),
'split' => $this->split,
'children' => SubscriptionChildResource::collection($this->whenLoaded('children')),
'for_promise' => $this->for_promise,
];
}
}

View File

@ -1,28 +1,29 @@
<template>
<form class="p-6 grid gap-4 justify-start" @submit.prevent="submit">
<f-text id="year" v-model="inner.year" label="Jahr" required></f-text>
<f-switch id="for_promise" label="Versprechen einbeziehen" v-model="inner.for_promise" size="sm"></f-switch>
<button type="submit" class="btn btn-primary">Absenden</button>
</form>
</template>
<script>
export default {
data: function() {
data: function () {
return {
inner: {},
inner: {
for_promise: false,
},
};
},
props: {
},
props: {},
methods: {
submit() {
this.$inertia.post(`/allpayment`, this.inner)
}
}
this.$inertia.post(`/allpayment`, this.inner);
},
},
};
</script>

View File

@ -14,6 +14,12 @@
required
></f-select>
<f-switch id="split" label="Rechnung aufsplitten" v-model="inner.split" size="sm"></f-switch>
<f-switch
id="for_promise"
label="Für Versprechen benutzen"
v-model="inner.for_promise"
size="sm"
></f-switch>
</div>
</box>
<box heading="Positionen">

View File

@ -28,7 +28,7 @@ return [
'string' => ':attribute muss zwischen :min & :max Zeichen lang sein.',
'array' => ':attribute muss zwischen :min & :max Elemente haben.',
],
'boolean' => ":attribute muss entweder 'true' oder 'false' sein.",
'boolean' => ':attribute muss ein Wahrheitswert sein.',
'confirmed' => ':attribute stimmt nicht mit der Bestätigung überein.',
'date' => ':attribute muss ein gültiges Datum sein.',
'date_equals' => ':attribute muss ein Datum gleich :date sein.',

View File

@ -15,7 +15,7 @@ class EditTest extends TestCase
public function testItReturnsChildren(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
$subscription = Subscription::factory()->name('hi')->for(Fee::factory())->children([
$subscription = Subscription::factory()->name('hi')->forPromise()->for(Fee::factory())->children([
new Child('a', 1400),
new Child('b', 1500),
])->create(['split' => true]);
@ -30,6 +30,7 @@ class EditTest extends TestCase
'name' => 'hi',
'id' => $subscription->id,
'split' => true,
'for_promise' => true,
], $response, 'data');
}
}

View File

@ -22,7 +22,7 @@ class StoreTest extends TestCase
'/subscription',
SubscriptionRequestFactory::new()->fee($fee)->name('lorem')->children([
new Child('ch', 2500),
])->create(['split' => true])
])->create(['split' => true, 'for_promise' => true])
);
$response->assertRedirect('/subscription');
@ -31,6 +31,7 @@ class StoreTest extends TestCase
'fee_id' => $fee->id,
'name' => 'lorem',
'split' => true,
'for_promise' => true,
]);
$this->assertDatabaseHas('subscription_children', [
'name' => 'ch',
@ -52,6 +53,7 @@ class StoreTest extends TestCase
$this->assertErrors([
'fee_id' => 'Nami-Beitrag ist nicht vorhanden.',
'name' => 'Name ist erforderlich.',
'for_promise' => 'Für Versprechen benutzen muss ein Wahrheitswert sein.',
], $response);
}
}

View File

@ -16,12 +16,12 @@ class UpdateTest extends TestCase
public function testItUpdatesASubscription(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
$subscription = Subscription::factory()->name('hi')->for(Fee::factory())->create(['split' => true]);
$subscription = Subscription::factory()->name('hi')->for(Fee::factory())->create(['split' => true, 'for_promise' => false]);
$fee = Fee::factory()->create();
$response = $this->from("/subscription/{$subscription->id}")->patch(
"/subscription/{$subscription->id}",
SubscriptionRequestFactory::new()->amount(2500)->fee($fee)->name('lorem')->create(['split' => false])
SubscriptionRequestFactory::new()->amount(2500)->fee($fee)->name('lorem')->create(['split' => false, 'for_promise' => true])
);
$response->assertRedirect('/subscription');
@ -30,6 +30,7 @@ class UpdateTest extends TestCase
'fee_id' => $fee->id,
'name' => 'Lorem',
'split' => false,
'for_promise' => true,
]);
}
@ -70,6 +71,7 @@ class UpdateTest extends TestCase
$this->assertErrors([
'fee_id' => 'Nami-Beitrag ist nicht vorhanden.',
'name' => 'Name ist erforderlich.',
'for_promise' => 'Für Versprechen benutzen muss ein Wahrheitswert sein.',
], $response);
}
}

View File

@ -8,7 +8,7 @@ use Worksome\RequestFactories\RequestFactory;
class SubscriptionRequestFactory extends RequestFactory
{
/**
* @return array{fee_id: int, name: string, split: bool, children: array<int, array{amount: int, name: string}>}
* @return array{fee_id: int, name: string, split: bool, for_promise: bool, children: array<int, array{amount: int, name: string}>}
*/
public function definition(): array
{
@ -17,6 +17,7 @@ class SubscriptionRequestFactory extends RequestFactory
'name' => $this->faker->words(5, true),
'split' => $this->faker->boolean(),
'children' => [],
'for_promise' => $this->faker->boolean(),
];
}
@ -40,6 +41,7 @@ class SubscriptionRequestFactory extends RequestFactory
return $this->state([
'fee_id' => 9999,
'name' => '',
'for_promise' => 'A',
]);
}