Remove split payments
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
acf280346f
commit
11fe883b5c
|
@ -15,15 +15,7 @@ class Subscription extends Model
|
|||
/**
|
||||
* @var array<int, string>
|
||||
*/
|
||||
public $fillable = ['name', 'fee_id', 'split', 'for_promise'];
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public $casts = [
|
||||
'split' => 'boolean',
|
||||
'for_promise' => 'boolean',
|
||||
];
|
||||
public $fillable = ['name', 'fee_id'];
|
||||
|
||||
public function getAmount(): int
|
||||
{
|
||||
|
|
|
@ -39,12 +39,9 @@ class SubscriptionController extends Controller
|
|||
{
|
||||
$subscriptionParams = $request->validate([
|
||||
'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([
|
||||
|
@ -76,12 +73,9 @@ class SubscriptionController extends Controller
|
|||
{
|
||||
$subscriptionParams = $request->validate([
|
||||
'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([
|
||||
|
|
|
@ -26,11 +26,9 @@ class SubscriptionResource extends JsonResource
|
|||
'name' => $this->name,
|
||||
'fee_id' => $this->fee_id,
|
||||
'fee_name' => $this->fee->name,
|
||||
'amount_human' => number_format($this->getAmount() / 100, 2, ',', '.').' €',
|
||||
'amount_human' => number_format($this->getAmount() / 100, 2, ',', '.') . ' €',
|
||||
'amount' => $this->getAmount(),
|
||||
'split' => $this->split,
|
||||
'children' => SubscriptionChildResource::collection($this->whenLoaded('children')),
|
||||
'for_promise' => $this->for_promise,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ class SubscriptionFactory extends Factory
|
|||
return [
|
||||
'name' => $this->faker->word,
|
||||
'fee_id' => Fee::factory()->createOne()->id,
|
||||
'for_promise' => false,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -42,9 +41,4 @@ class SubscriptionFactory extends Factory
|
|||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function forPromise(): self
|
||||
{
|
||||
return $this->state(['for_promise' => true]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,6 +92,11 @@ return new class extends Migration
|
|||
}
|
||||
|
||||
Schema::dropIfExists('payments');
|
||||
|
||||
Schema::table('subscriptions', function (Blueprint $table) {
|
||||
$table->dropColumn('split');
|
||||
$table->dropColumn('for_promise');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,7 +106,17 @@ return new class extends Migration
|
|||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('subscriptions', function (Blueprint $table) {
|
||||
$table->boolean('split')->default(false);
|
||||
$table->boolean('for_promise')->default(false);
|
||||
});
|
||||
Schema::dropIfExists('invoice_positions');
|
||||
Schema::dropIfExists('invoices');
|
||||
Schema::create('payments', function ($table) {
|
||||
$table->id();
|
||||
$table->string('nr');
|
||||
$table->integer('subscription_id');
|
||||
$table->json('invoice_data');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -10,21 +10,23 @@
|
|||
<ui-box heading="Beitrag">
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<f-text id="name" v-model="inner.name" label="Name" size="sm" required></f-text>
|
||||
<f-select id="fee_id" name="fee_id" :options="fees" v-model="inner.fee_id" label="Nami-Beitrag" size="sm" 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>
|
||||
<f-select id="fee_id" v-model="inner.fee_id" name="fee_id" :options="fees" label="Nami-Beitrag"
|
||||
size="sm" required></f-select>
|
||||
</div>
|
||||
</ui-box>
|
||||
<ui-box heading="Positionen">
|
||||
<div class="flex flex-col space-y-4">
|
||||
<div v-for="(pos, index) in inner.children" :key="index" class="flex space-x-2 items-end">
|
||||
<f-text :id="`name-${index}`" v-model="pos.name" label="Name" size="sm" required></f-text>
|
||||
<f-text :id="`amount-${index}`" v-model="pos.amount" label="Beitrag" size="sm" mode="area" required></f-text>
|
||||
<a href="#" @click.prevent="inner.children.splice(index, 1)" class="btn btn-sm btn-danger icon flex-none">
|
||||
<f-text :id="`amount-${index}`" v-model="pos.amount" label="Beitrag" size="sm" mode="area"
|
||||
required></f-text>
|
||||
<a href="#" class="btn btn-sm btn-danger icon flex-none"
|
||||
@click.prevent="inner.children.splice(index, 1)">
|
||||
<ui-sprite src="trash" class="w-5 h-5"></ui-sprite>
|
||||
</a>
|
||||
</div>
|
||||
<a href="#" @click.prevent="inner.children.push({name: '', amount: 0})" class="btn btn-sm flex btn-primary flex self-start mt-4">
|
||||
<a href="#" class="btn btn-sm flex btn-primary flex self-start mt-4"
|
||||
@click.prevent="inner.children.push({ name: '', amount: 0 })">
|
||||
<ui-sprite src="plus" class="w-5 h-5"></ui-sprite>
|
||||
Position hinzufügen
|
||||
</a>
|
||||
|
@ -36,11 +38,6 @@
|
|||
|
||||
<script>
|
||||
export default {
|
||||
data: function () {
|
||||
return {
|
||||
inner: {...this.data},
|
||||
};
|
||||
},
|
||||
|
||||
props: {
|
||||
data: {},
|
||||
|
@ -48,6 +45,11 @@ export default {
|
|||
mode: {},
|
||||
meta: {},
|
||||
},
|
||||
data: function () {
|
||||
return {
|
||||
inner: { ...this.data },
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
submit() {
|
||||
|
|
|
@ -126,8 +126,6 @@ class PullMemberActionTest extends TestCase
|
|||
$this->assertDatabaseHas('subscriptions', [
|
||||
'fee_id' => $fee->id,
|
||||
'name' => 'Lala',
|
||||
'split' => false,
|
||||
'for_promise' => false,
|
||||
]);
|
||||
$this->assertDatabaseHas('subscription_children', [
|
||||
'name' => 'Lala',
|
||||
|
|
|
@ -15,10 +15,10 @@ class EditTest extends TestCase
|
|||
public function testItReturnsChildren(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$subscription = Subscription::factory()->name('hi')->forPromise()->for(Fee::factory())->children([
|
||||
$subscription = Subscription::factory()->name('hi')->for(Fee::factory())->children([
|
||||
new Child('a', 1400),
|
||||
new Child('b', 1500),
|
||||
])->create(['split' => true]);
|
||||
])->create();
|
||||
|
||||
$response = $this->get("/subscription/{$subscription->id}/edit");
|
||||
|
||||
|
@ -29,8 +29,6 @@ class EditTest extends TestCase
|
|||
],
|
||||
'name' => 'hi',
|
||||
'id' => $subscription->id,
|
||||
'split' => true,
|
||||
'for_promise' => true,
|
||||
], $response, 'data');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class StoreTest extends TestCase
|
|||
'/subscription',
|
||||
SubscriptionRequestFactory::new()->fee($fee)->name('lorem')->children([
|
||||
new Child('ch', 2500),
|
||||
])->create(['split' => true, 'for_promise' => true])
|
||||
])->create()
|
||||
);
|
||||
|
||||
$response->assertRedirect('/subscription');
|
||||
|
@ -30,8 +30,6 @@ class StoreTest extends TestCase
|
|||
$this->assertDatabaseHas('subscriptions', [
|
||||
'fee_id' => $fee->id,
|
||||
'name' => 'lorem',
|
||||
'split' => true,
|
||||
'for_promise' => true,
|
||||
]);
|
||||
$this->assertDatabaseHas('subscription_children', [
|
||||
'name' => 'ch',
|
||||
|
@ -43,7 +41,7 @@ class StoreTest extends TestCase
|
|||
public function testItValidatesSubscription(): void
|
||||
{
|
||||
$this->login()->loginNami();
|
||||
$fee = Fee::factory()->create();
|
||||
Fee::factory()->create();
|
||||
|
||||
$response = $this->post(
|
||||
'/subscription',
|
||||
|
@ -53,7 +51,6 @@ 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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, 'for_promise' => false]);
|
||||
$subscription = Subscription::factory()->name('hi')->for(Fee::factory())->create();
|
||||
$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, 'for_promise' => true])
|
||||
SubscriptionRequestFactory::new()->amount(2500)->fee($fee)->name('lorem')->create()
|
||||
);
|
||||
|
||||
$response->assertRedirect('/subscription');
|
||||
|
@ -29,8 +29,6 @@ class UpdateTest extends TestCase
|
|||
'id' => $subscription->id,
|
||||
'fee_id' => $fee->id,
|
||||
'name' => 'Lorem',
|
||||
'split' => false,
|
||||
'for_promise' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -71,7 +69,6 @@ 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,16 +8,14 @@ use Worksome\RequestFactories\RequestFactory;
|
|||
class SubscriptionRequestFactory extends RequestFactory
|
||||
{
|
||||
/**
|
||||
* @return array{fee_id: int, name: string, split: bool, for_promise: bool, children: array<int, array{amount: int, name: string}>}
|
||||
* @return array{fee_id: int, name: string, children: array<int, array{amount: int, name: string}>}
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'fee_id' => Fee::factory()->create()->id,
|
||||
'name' => $this->faker->words(5, true),
|
||||
'split' => $this->faker->boolean(),
|
||||
'children' => [],
|
||||
'for_promise' => $this->faker->boolean(),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -41,7 +39,6 @@ class SubscriptionRequestFactory extends RequestFactory
|
|||
return $this->state([
|
||||
'fee_id' => 9999,
|
||||
'name' => '',
|
||||
'for_promise' => 'A',
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue