diff --git a/app/Payment/Subscription.php b/app/Payment/Subscription.php
index d0ff7267..c707d684 100644
--- a/app/Payment/Subscription.php
+++ b/app/Payment/Subscription.php
@@ -22,6 +22,7 @@ class Subscription extends Model
*/
public $casts = [
'split' => 'boolean',
+ 'for_promise' => 'boolean',
];
public function getAmount(): int
diff --git a/app/Payment/SubscriptionController.php b/app/Payment/SubscriptionController.php
index 05c4fbf9..816f0546 100644
--- a/app/Payment/SubscriptionController.php
+++ b/app/Payment/SubscriptionController.php
@@ -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([
diff --git a/app/Payment/SubscriptionResource.php b/app/Payment/SubscriptionResource.php
index 2d1d6293..cfd4395a 100644
--- a/app/Payment/SubscriptionResource.php
+++ b/app/Payment/SubscriptionResource.php
@@ -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,
];
}
}
diff --git a/resources/js/views/allpayment/VForm.vue b/resources/js/views/allpayment/VForm.vue
index 8cb705bf..eab372da 100644
--- a/resources/js/views/allpayment/VForm.vue
+++ b/resources/js/views/allpayment/VForm.vue
@@ -1,28 +1,29 @@
diff --git a/resources/js/views/subscription/SubscriptionForm.vue b/resources/js/views/subscription/SubscriptionForm.vue
index b4bb4232..b05c9a8d 100644
--- a/resources/js/views/subscription/SubscriptionForm.vue
+++ b/resources/js/views/subscription/SubscriptionForm.vue
@@ -14,6 +14,12 @@
required
>
+
diff --git a/resources/lang/de/validation.php b/resources/lang/de/validation.php
index d496fada..cd234141 100644
--- a/resources/lang/de/validation.php
+++ b/resources/lang/de/validation.php
@@ -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.',
diff --git a/tests/Feature/Subscription/EditTest.php b/tests/Feature/Subscription/EditTest.php
index d14bf19e..209da11b 100644
--- a/tests/Feature/Subscription/EditTest.php
+++ b/tests/Feature/Subscription/EditTest.php
@@ -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');
}
}
diff --git a/tests/Feature/Subscription/StoreTest.php b/tests/Feature/Subscription/StoreTest.php
index 7230c323..ae6e5125 100644
--- a/tests/Feature/Subscription/StoreTest.php
+++ b/tests/Feature/Subscription/StoreTest.php
@@ -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);
}
}
diff --git a/tests/Feature/Subscription/UpdateTest.php b/tests/Feature/Subscription/UpdateTest.php
index f12815eb..11d4711e 100644
--- a/tests/Feature/Subscription/UpdateTest.php
+++ b/tests/Feature/Subscription/UpdateTest.php
@@ -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);
}
}
diff --git a/tests/RequestFactories/SubscriptionRequestFactory.php b/tests/RequestFactories/SubscriptionRequestFactory.php
index c7dd0dc4..a808d85f 100644
--- a/tests/RequestFactories/SubscriptionRequestFactory.php
+++ b/tests/RequestFactories/SubscriptionRequestFactory.php
@@ -8,7 +8,7 @@ use Worksome\RequestFactories\RequestFactory;
class SubscriptionRequestFactory extends RequestFactory
{
/**
- * @return array{fee_id: int, name: string, split: bool, children: array}
+ * @return array{fee_id: int, name: string, split: bool, for_promise: bool, children: array}
*/
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',
]);
}