Fixed: Dont update subscription from nami if fee id already matches
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
011e414848
commit
056b8f9ed6
|
@ -22,7 +22,8 @@ class InsertMemberAction
|
|||
{
|
||||
$region = Region::firstWhere('nami_id', $member->regionId ?: -1);
|
||||
|
||||
return Member::updateOrCreate(['nami_id' => $member->id], [
|
||||
|
||||
$payload = [
|
||||
'firstname' => $member->firstname,
|
||||
'lastname' => $member->lastname,
|
||||
'joined_at' => $member->joinedAt,
|
||||
|
@ -51,7 +52,16 @@ class InsertMemberAction
|
|||
'mitgliedsnr' => $member->memberId,
|
||||
'version' => $member->version,
|
||||
'keepdata' => $member->keepdata,
|
||||
]);
|
||||
];
|
||||
|
||||
// Dont update subscription if fee id of existing member's subscription is already the same
|
||||
if ($existing = Member::nami($member->id)) {
|
||||
if ($existing->subscription && $existing->subscription->fee->nami_id === $member->feeId) {
|
||||
$payload['subscription_id'] = $existing->subscription->id;
|
||||
}
|
||||
}
|
||||
|
||||
return Member::updateOrCreate(['nami_id' => $member->id], $payload);
|
||||
}
|
||||
|
||||
public function getSubscription(NamiMember $member): ?Subscription
|
||||
|
|
|
@ -7,6 +7,7 @@ use App\Country;
|
|||
use App\Fee;
|
||||
use App\Gender;
|
||||
use App\Group;
|
||||
use App\Member\Member;
|
||||
use App\Nationality;
|
||||
use App\Payment\Subscription;
|
||||
use App\Region;
|
||||
|
@ -142,3 +143,20 @@ it('testItPullsMemberWithNoSubscription', function () {
|
|||
'subscription_id' => null,
|
||||
]);
|
||||
});
|
||||
|
||||
it('doesnt set first subscription if fee matches', function () {
|
||||
$this->loginNami();
|
||||
Subscription::factory()->forFee(55)->create();
|
||||
$otherSubscription = Subscription::factory()->forFee(55)->create();
|
||||
$member = Member::factory()->defaults()->inNami(1001)->create(['subscription_id' => $otherSubscription->id]);
|
||||
app(MemberFake::class)->shows(1000, 1001, [
|
||||
'beitragsartId' => 55,
|
||||
]);
|
||||
|
||||
app(PullMemberAction::class)->handle(1000, 1001);
|
||||
|
||||
$this->assertDatabaseHas('members', [
|
||||
'subscription_id' => $otherSubscription->id,
|
||||
'id' => $member->id,
|
||||
]);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue