Add keepdata to member form
This commit is contained in:
parent
24ed5d4ab9
commit
a897690e7a
|
@ -50,6 +50,7 @@ class InsertMemberAction
|
|||
'nationality_id' => Nationality::where('nami_id', $member->nationalityId)->firstOrFail()->id,
|
||||
'mitgliedsnr' => $member->memberId,
|
||||
'version' => $member->version,
|
||||
'keepdata' => $member->keepdata,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class NamiPutMemberAction
|
|||
'groupId' => $member->group->nami_id,
|
||||
'id' => $member->nami_id,
|
||||
'version' => $member->version,
|
||||
'keepdata' => false,
|
||||
'keepdata' => $member->keepdata,
|
||||
]);
|
||||
$response = $api->putMember($namiMember, $activity ? $activity->nami_id : null, $subactivity ? $subactivity->nami_id : null);
|
||||
Member::withoutEvents(function () use ($response, $member) {
|
||||
|
|
|
@ -58,7 +58,7 @@ class Member extends Model implements Geolocatable
|
|||
/**
|
||||
* @var array<int, string>
|
||||
*/
|
||||
public static array $namiFields = ['firstname', 'lastname', 'joined_at', 'birthday', 'send_newspaper', 'address', 'zip', 'location', 'nickname', 'other_country', 'further_address', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'gender_id', 'confession_id', 'region_id', 'country_id', 'fee_id', 'nationality_id', 'slug', 'subscription_id'];
|
||||
public static array $namiFields = ['firstname', 'lastname', 'joined_at', 'birthday', 'send_newspaper', 'address', 'zip', 'location', 'nickname', 'other_country', 'further_address', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'gender_id', 'confession_id', 'region_id', 'country_id', 'fee_id', 'nationality_id', 'slug', 'subscription_id', 'keepdata'];
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
|
@ -77,6 +77,7 @@ class Member extends Model implements Geolocatable
|
|||
'multiply_pv' => 'boolean',
|
||||
'multiply_more_pv' => 'boolean',
|
||||
'is_leader' => 'boolean',
|
||||
'keepdata' => 'boolean',
|
||||
'bill_kind' => BillKind::class,
|
||||
'mitgliedsnr' => 'integer',
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ class MemberRequest extends FormRequest
|
|||
'other_country' => '',
|
||||
'salutation' => '',
|
||||
'comment' => '',
|
||||
'keepdata' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -106,6 +106,7 @@ class MemberResource extends JsonResource
|
|||
'lat' => $this->lat,
|
||||
'lon' => $this->lon,
|
||||
'group_name' => $this->group->name,
|
||||
'keepdata' => $this->keepdata,
|
||||
'links' => [
|
||||
'membership_index' => route('member.membership.index', ['member' => $this->getModel()]),
|
||||
'invoiceposition_index' => route('member.invoice-position.index', ['member' => $this->getModel()]),
|
||||
|
@ -202,6 +203,7 @@ class MemberResource extends JsonResource
|
|||
'has_svk' => false,
|
||||
'multiply_pv' => false,
|
||||
'multiply_more_pv' => false,
|
||||
'keepdata' => false,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ class MemberFactory extends Factory
|
|||
'location' => $this->faker->city,
|
||||
'email' => $this->faker->safeEmail(),
|
||||
'recertified_at' => null,
|
||||
'keepdata' => false,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('members', function (Blueprint $table) {
|
||||
$table->boolean('keepdata')->after('email_parents')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('members', function (Blueprint $table) {
|
||||
$table->dropColumn('keepdata');
|
||||
});
|
||||
}
|
||||
};
|
|
@ -58,7 +58,8 @@
|
|||
<f-select id="subscription_id" v-model="inner.subscription_id" :options="meta.subscriptions" label="Beitrag" name="subscription_id" size="sm"></f-select>
|
||||
<f-switch id="has_nami" v-model="inner.has_nami" name="has_nami" size="sm" label="In Nami eintragen"></f-switch>
|
||||
<f-switch id="send_newspaper" v-model="inner.send_newspaper" name="send_newspaper" label="Mittendrin versenden" size="sm"></f-switch>
|
||||
<f-text id="joined_at" v-model="inner.joined_at" class="sm:col-span-2" type="date" label="Eintrittsdatum" size="sm" required></f-text>
|
||||
<f-switch id="keepdata" v-model="inner.keepdata" name="keepdata" label="Datenweiterverwendung" size="sm"></f-switch>
|
||||
<f-text id="joined_at" v-model="inner.joined_at" type="date" label="Eintrittsdatum" size="sm" required></f-text>
|
||||
<f-textarea id="comment" v-model="inner.comment" :rows="3" class="col-span-2" label="Kommentar" size="sm"></f-textarea>
|
||||
<div v-if="mode === 'create' || (original.has_nami === false && inner.has_nami === true)" class="contents">
|
||||
<f-select
|
||||
|
|
|
@ -32,6 +32,7 @@ class EditTest extends TestCase
|
|||
$this->assertInertiaHas('Biber', $response, "meta.formSubactivities.{$activity->id}.{$subactivity->id}");
|
||||
$this->assertInertiaHas('€ Mitglied', $response, "meta.formActivities.{$activity->id}");
|
||||
$this->assertInertiaHas('Max', $response, 'data.firstname');
|
||||
$this->assertInertiaHas(false, $response, 'data.keepdata');
|
||||
$this->assertInertiaHas('Doktor', $response, 'data.salutation');
|
||||
$this->assertInertiaHas('Lorem bla', $response, 'data.comment');
|
||||
$this->assertInertiaHas('edit', $response, 'mode');
|
||||
|
|
|
@ -17,12 +17,11 @@ use App\Region;
|
|||
use App\Subactivity;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Phake;
|
||||
use Tests\TestCase;
|
||||
use Zoomyboy\LaravelNami\Fakes\MemberFake;
|
||||
|
||||
uses(DatabaseTransactions::class);
|
||||
|
||||
it('testItPutsAMember', function () {
|
||||
it('testItPutsAMember', function (array $memberAttributes, array $storedAttributes) {
|
||||
Fee::factory()->create();
|
||||
$this->stubIo(PullMemberAction::class, fn ($mock) => $mock);
|
||||
$this->stubIo(PullMembershipsAction::class, fn ($mock) => $mock);
|
||||
|
@ -44,7 +43,7 @@ it('testItPutsAMember', function () {
|
|||
->for($nationality)
|
||||
->for($group)
|
||||
->emailBillKind()
|
||||
->create(['email_parents' => 'a@b.de']);
|
||||
->create($memberAttributes);
|
||||
|
||||
NamiPutMemberAction::run($member, $activity, $subactivity);
|
||||
|
||||
|
@ -52,11 +51,21 @@ it('testItPutsAMember', function () {
|
|||
'ersteTaetigkeitId' => 6,
|
||||
'ersteUntergliederungId' => 55,
|
||||
'konfessionId' => 567,
|
||||
'emailVertretungsberechtigter' => 'a@b.de',
|
||||
...$storedAttributes,
|
||||
]);
|
||||
$this->assertDatabaseHas('members', [
|
||||
'nami_id' => 993,
|
||||
]);
|
||||
Phake::verify(app(PullMemberAction::class))->handle(55, 993);
|
||||
Phake::verify(app(PullMembershipsAction::class))->handle($member);
|
||||
});
|
||||
})->with([
|
||||
[
|
||||
['email_parents' => 'a@b.de'], ['emailVertretungsberechtigter' => 'a@b.de'],
|
||||
],
|
||||
[
|
||||
['keepdata' => true], ['wiederverwendenFlag' => true],
|
||||
],
|
||||
[
|
||||
['keepdata' => false], ['wiederverwendenFlag' => false],
|
||||
],
|
||||
]);
|
||||
|
|
|
@ -11,26 +11,19 @@ use App\Nationality;
|
|||
use App\Payment\Subscription;
|
||||
use App\Region;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\TestCase;
|
||||
use Zoomyboy\LaravelNami\Fakes\MemberFake;
|
||||
|
||||
class PullMemberActionTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
uses(DatabaseTransactions::class);
|
||||
|
||||
beforeEach(function () {
|
||||
Subscription::factory()->name('test')->forFee(300)->create();
|
||||
Gender::factory()->inNami(303)->create();
|
||||
Country::factory()->inNami(302)->create();
|
||||
Nationality::factory()->inNami(1054)->create();
|
||||
$this->loginNami();
|
||||
}
|
||||
});
|
||||
|
||||
public function testFetchNormalMember(): void
|
||||
{
|
||||
it('testFetchNormalMember', function () {
|
||||
$this->loginNami();
|
||||
app(MemberFake::class)->shows(1000, 1001, [
|
||||
'vorname' => '::firstname::',
|
||||
'nachname' => '::lastname::',
|
||||
|
@ -78,24 +71,24 @@ class PullMemberActionTest extends TestCase
|
|||
'inner_name' => 'SG Wald',
|
||||
]);
|
||||
$this->assertEquals(1001, $member->nami_id);
|
||||
}
|
||||
});
|
||||
|
||||
public function testRegionIdIsSetToNull(): void
|
||||
{
|
||||
it('testFetchWiederverwendenFlag', function (array $memberAttributes, array $storedAttributes) {
|
||||
$this->loginNami();
|
||||
Region::factory()->inNami(999)->name('nicht-de')->create(['is_null' => true]);
|
||||
app(MemberFake::class)->shows(1000, 1001, [
|
||||
'regionId' => 999,
|
||||
]);
|
||||
app(MemberFake::class)->shows(1000, 1001, $memberAttributes);
|
||||
|
||||
app(PullMemberAction::class)->handle(1000, 1001);
|
||||
|
||||
$this->assertDatabaseHas('members', [
|
||||
'region_id' => null,
|
||||
$this->assertDatabaseHas('members', $storedAttributes);
|
||||
})->with([
|
||||
[['wiederverwendenFlag' => false], ['keepdata' => false]],
|
||||
[['wiederverwendenFlag' => true], ['keepdata' => true]],
|
||||
[['regionId' => 999], ['region_id' => null]]
|
||||
]);
|
||||
}
|
||||
|
||||
public function testItSetsFirstSubscriptionFromFee(): void
|
||||
{
|
||||
it('testItSetsFirstSubscriptionFromFee', function () {
|
||||
$this->loginNami();
|
||||
Region::factory()->inNami(999)->name('nicht-de')->create(['is_null' => true]);
|
||||
$should = Subscription::factory()->forFee(55)->create();
|
||||
app(MemberFake::class)->shows(1000, 1001, [
|
||||
|
@ -107,10 +100,10 @@ class PullMemberActionTest extends TestCase
|
|||
$this->assertDatabaseHas('members', [
|
||||
'subscription_id' => $should->id,
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
public function testItCreatesSubscriptionOnTheFly(): void
|
||||
{
|
||||
it('testItCreatesSubscriptionOnTheFly', function () {
|
||||
$this->loginNami();
|
||||
Region::factory()->inNami(999)->name('nicht-de')->create(['is_null' => true]);
|
||||
app(MemberFake::class)->shows(1000, 1001, [
|
||||
'beitragsartId' => 55,
|
||||
|
@ -133,10 +126,10 @@ class PullMemberActionTest extends TestCase
|
|||
$this->assertDatabaseHas('members', [
|
||||
'subscription_id' => $subscription->id,
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
public function testItPullsMemberWithNoSubscription(): void
|
||||
{
|
||||
it('testItPullsMemberWithNoSubscription', function () {
|
||||
$this->loginNami();
|
||||
Region::factory()->inNami(999)->name('nicht-de')->create(['is_null' => true]);
|
||||
app(MemberFake::class)->shows(1000, 1001, [
|
||||
'beitragsartId' => null,
|
||||
|
@ -148,5 +141,4 @@ class PullMemberActionTest extends TestCase
|
|||
$this->assertDatabaseHas('members', [
|
||||
'subscription_id' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -89,6 +89,35 @@ class StoreTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function testItStoresWiederverwendenFlag(): void
|
||||
{
|
||||
app(MemberFake::class)->stores(55, 103);
|
||||
Fee::factory()->create();
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$activity = Activity::factory()->inNami(89)->create();
|
||||
$subactivity = Subactivity::factory()->inNami(90)->create();
|
||||
$subscription = Subscription::factory()->forFee()->create();
|
||||
$confesstion = Confession::factory()->create(['is_null' => true]);
|
||||
PullMemberAction::shouldRun();
|
||||
PullMembershipsAction::shouldRun();
|
||||
|
||||
$this
|
||||
->from('/member/create')
|
||||
->post('/member', $this->attributes([
|
||||
'first_activity_id' => $activity->id,
|
||||
'first_subactivity_id' => $subactivity->id,
|
||||
'subscription_id' => $subscription->id,
|
||||
'keepdata' => true,
|
||||
]))->assertSessionHasNoErrors();
|
||||
|
||||
$this->assertDatabaseHas('members', [
|
||||
'keepdata' => true,
|
||||
]);
|
||||
app(MemberFake::class)->assertStored(55, [
|
||||
'wiederverwendenFlag' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function testItCanStoreAMemberWithoutNami(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
|
|
|
@ -77,6 +77,23 @@ class UpdateTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function testItUpdatesWiederverwendenFlag(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$member = $this->member();
|
||||
$this->fakeRequest();
|
||||
NamiPutMemberAction::allowToRun();
|
||||
|
||||
$this->patch("/member/{$member->id}", array_merge($member->getAttributes(), [
|
||||
'keepdata' => true,
|
||||
'has_nami' => true,
|
||||
]));
|
||||
|
||||
$this->assertDatabaseHas('members', [
|
||||
'keepdata' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function testItSetsLocationToNull(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
|
|
Loading…
Reference in New Issue