Add frontend for allpayment
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
8af0e2a16e
commit
785f9e5689
|
@ -22,6 +22,7 @@ class Subscription extends Model
|
||||||
*/
|
*/
|
||||||
public $casts = [
|
public $casts = [
|
||||||
'split' => 'boolean',
|
'split' => 'boolean',
|
||||||
|
'for_promise' => 'boolean',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getAmount(): int
|
public function getAmount(): int
|
||||||
|
|
|
@ -41,8 +41,10 @@ class SubscriptionController extends Controller
|
||||||
'name' => 'required|max:255',
|
'name' => 'required|max:255',
|
||||||
'split' => 'present|boolean',
|
'split' => 'present|boolean',
|
||||||
'fee_id' => 'required|exists:fees,id',
|
'fee_id' => 'required|exists:fees,id',
|
||||||
|
'for_promise' => 'present|boolean',
|
||||||
], [], [
|
], [], [
|
||||||
'fee_id' => 'Nami-Beitrag',
|
'fee_id' => 'Nami-Beitrag',
|
||||||
|
'for_promise' => 'Für Versprechen benutzen',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$children = $request->validate([
|
$children = $request->validate([
|
||||||
|
@ -75,8 +77,10 @@ class SubscriptionController extends Controller
|
||||||
'name' => 'required|max:255',
|
'name' => 'required|max:255',
|
||||||
'split' => 'present|boolean',
|
'split' => 'present|boolean',
|
||||||
'fee_id' => 'required|exists:fees,id',
|
'fee_id' => 'required|exists:fees,id',
|
||||||
|
'for_promise' => 'present|boolean',
|
||||||
], [], [
|
], [], [
|
||||||
'fee_id' => 'Nami-Beitrag',
|
'fee_id' => 'Nami-Beitrag',
|
||||||
|
'for_promise' => 'Für Versprechen benutzen',
|
||||||
]);
|
]);
|
||||||
$subscription->update($subscriptionParams);
|
$subscription->update($subscriptionParams);
|
||||||
$children = $request->validate([
|
$children = $request->validate([
|
||||||
|
|
|
@ -27,6 +27,7 @@ class SubscriptionResource extends JsonResource
|
||||||
'amount' => $this->getAmount(),
|
'amount' => $this->getAmount(),
|
||||||
'split' => $this->split,
|
'split' => $this->split,
|
||||||
'children' => SubscriptionChildResource::collection($this->whenLoaded('children')),
|
'children' => SubscriptionChildResource::collection($this->whenLoaded('children')),
|
||||||
|
'for_promise' => $this->for_promise,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<form class="p-6 grid gap-4 justify-start" @submit.prevent="submit">
|
<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-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>
|
<button type="submit" class="btn btn-primary">Absenden</button>
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
@ -11,18 +12,18 @@
|
||||||
export default {
|
export default {
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
inner: {},
|
inner: {
|
||||||
|
for_promise: false,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {},
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
submit() {
|
submit() {
|
||||||
this.$inertia.post(`/allpayment`, this.inner)
|
this.$inertia.post(`/allpayment`, this.inner);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -14,6 +14,12 @@
|
||||||
required
|
required
|
||||||
></f-select>
|
></f-select>
|
||||||
<f-switch id="split" label="Rechnung aufsplitten" v-model="inner.split" size="sm"></f-switch>
|
<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>
|
</div>
|
||||||
</box>
|
</box>
|
||||||
<box heading="Positionen">
|
<box heading="Positionen">
|
||||||
|
|
|
@ -28,7 +28,7 @@ return [
|
||||||
'string' => ':attribute muss zwischen :min & :max Zeichen lang sein.',
|
'string' => ':attribute muss zwischen :min & :max Zeichen lang sein.',
|
||||||
'array' => ':attribute muss zwischen :min & :max Elemente haben.',
|
'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.',
|
'confirmed' => ':attribute stimmt nicht mit der Bestätigung überein.',
|
||||||
'date' => ':attribute muss ein gültiges Datum sein.',
|
'date' => ':attribute muss ein gültiges Datum sein.',
|
||||||
'date_equals' => ':attribute muss ein Datum gleich :date sein.',
|
'date_equals' => ':attribute muss ein Datum gleich :date sein.',
|
||||||
|
|
|
@ -15,7 +15,7 @@ class EditTest extends TestCase
|
||||||
public function testItReturnsChildren(): void
|
public function testItReturnsChildren(): void
|
||||||
{
|
{
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$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('a', 1400),
|
||||||
new Child('b', 1500),
|
new Child('b', 1500),
|
||||||
])->create(['split' => true]);
|
])->create(['split' => true]);
|
||||||
|
@ -30,6 +30,7 @@ class EditTest extends TestCase
|
||||||
'name' => 'hi',
|
'name' => 'hi',
|
||||||
'id' => $subscription->id,
|
'id' => $subscription->id,
|
||||||
'split' => true,
|
'split' => true,
|
||||||
|
'for_promise' => true,
|
||||||
], $response, 'data');
|
], $response, 'data');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ class StoreTest extends TestCase
|
||||||
'/subscription',
|
'/subscription',
|
||||||
SubscriptionRequestFactory::new()->fee($fee)->name('lorem')->children([
|
SubscriptionRequestFactory::new()->fee($fee)->name('lorem')->children([
|
||||||
new Child('ch', 2500),
|
new Child('ch', 2500),
|
||||||
])->create(['split' => true])
|
])->create(['split' => true, 'for_promise' => true])
|
||||||
);
|
);
|
||||||
|
|
||||||
$response->assertRedirect('/subscription');
|
$response->assertRedirect('/subscription');
|
||||||
|
@ -31,6 +31,7 @@ class StoreTest extends TestCase
|
||||||
'fee_id' => $fee->id,
|
'fee_id' => $fee->id,
|
||||||
'name' => 'lorem',
|
'name' => 'lorem',
|
||||||
'split' => true,
|
'split' => true,
|
||||||
|
'for_promise' => true,
|
||||||
]);
|
]);
|
||||||
$this->assertDatabaseHas('subscription_children', [
|
$this->assertDatabaseHas('subscription_children', [
|
||||||
'name' => 'ch',
|
'name' => 'ch',
|
||||||
|
@ -52,6 +53,7 @@ class StoreTest extends TestCase
|
||||||
$this->assertErrors([
|
$this->assertErrors([
|
||||||
'fee_id' => 'Nami-Beitrag ist nicht vorhanden.',
|
'fee_id' => 'Nami-Beitrag ist nicht vorhanden.',
|
||||||
'name' => 'Name ist erforderlich.',
|
'name' => 'Name ist erforderlich.',
|
||||||
|
'for_promise' => 'Für Versprechen benutzen muss ein Wahrheitswert sein.',
|
||||||
], $response);
|
], $response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,12 @@ class UpdateTest extends TestCase
|
||||||
public function testItUpdatesASubscription(): void
|
public function testItUpdatesASubscription(): void
|
||||||
{
|
{
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$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();
|
$fee = Fee::factory()->create();
|
||||||
|
|
||||||
$response = $this->from("/subscription/{$subscription->id}")->patch(
|
$response = $this->from("/subscription/{$subscription->id}")->patch(
|
||||||
"/subscription/{$subscription->id}",
|
"/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');
|
$response->assertRedirect('/subscription');
|
||||||
|
@ -30,6 +30,7 @@ class UpdateTest extends TestCase
|
||||||
'fee_id' => $fee->id,
|
'fee_id' => $fee->id,
|
||||||
'name' => 'Lorem',
|
'name' => 'Lorem',
|
||||||
'split' => false,
|
'split' => false,
|
||||||
|
'for_promise' => true,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +71,7 @@ class UpdateTest extends TestCase
|
||||||
$this->assertErrors([
|
$this->assertErrors([
|
||||||
'fee_id' => 'Nami-Beitrag ist nicht vorhanden.',
|
'fee_id' => 'Nami-Beitrag ist nicht vorhanden.',
|
||||||
'name' => 'Name ist erforderlich.',
|
'name' => 'Name ist erforderlich.',
|
||||||
|
'for_promise' => 'Für Versprechen benutzen muss ein Wahrheitswert sein.',
|
||||||
], $response);
|
], $response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use Worksome\RequestFactories\RequestFactory;
|
||||||
class SubscriptionRequestFactory extends 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
|
public function definition(): array
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,7 @@ class SubscriptionRequestFactory extends RequestFactory
|
||||||
'name' => $this->faker->words(5, true),
|
'name' => $this->faker->words(5, true),
|
||||||
'split' => $this->faker->boolean(),
|
'split' => $this->faker->boolean(),
|
||||||
'children' => [],
|
'children' => [],
|
||||||
|
'for_promise' => $this->faker->boolean(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +41,7 @@ class SubscriptionRequestFactory extends RequestFactory
|
||||||
return $this->state([
|
return $this->state([
|
||||||
'fee_id' => 9999,
|
'fee_id' => 9999,
|
||||||
'name' => '',
|
'name' => '',
|
||||||
|
'for_promise' => 'A',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue