Add: Update kontoverbindung

This commit is contained in:
philipp lang 2025-03-29 03:03:12 +01:00
parent fa12646ead
commit ff34c23032
4 changed files with 39 additions and 4 deletions

View File

@ -153,7 +153,6 @@ class Api
if ($member->id) {
$existing = $this->rawMember($member->groupId, $member->id);
$payload = array_merge($existing, $member->toNami());
$payload['kontoverbindung'] = json_encode(data_get($payload, 'kontoverbindung', []));
$url = $this->url . '/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/' . $member->groupId . '/' . $member->id;
$response = $this->http()->put($url, $payload);
$this->assertOk($response, $url, 'Update failed');

View File

@ -37,12 +37,12 @@ class BankAccount extends Data
/**
* @return array<string, mixed>
*/
public function toNami(): string
public function toNami(?int $memberId = null): string
{
return json_encode([
'id' => $this->id ?: '',
'zahlungsKonditionId' => $this->conditionId,
'mitgliedsNummer' => $this->memberId,
'mitgliedsNummer' => $memberId !== null ? $memberId : $this->memberId,
'institut' => $this->bankName ?: '',
'kontoinhaber' => $this->person ?: '',
'kontonummer' => $this->accountNumber ?: '',

View File

@ -159,7 +159,7 @@ class Member extends Data
'nameZusatz' => $this->furtherAddress,
'version' => $this->version,
'eintrittsdatum' => $this->joinedAt->format('Y-m-d 00:00:00'),
'kontoverbindung' => $this->bankAccount->toNami(),
'kontoverbindung' => $this->bankAccount->toNami($this->memberId),
];
}

View File

@ -133,6 +133,42 @@ class PutMemberTest extends TestCase
]);
}
public function testItUpdatesKontoverbindung(): void
{
app(MemberFake::class)
->updatesSuccessfully(103, 16)
->shows(103, 16);
$member = Member::toFactory()
->withBankAccount(BankAccount::toFactory()->state([
'id' => 555,
'zahlungsKonditionId' => 1,
'institut' => 'institut',
'kontoinhaber' => 'kontoinhaber',
'kontonummer' => 'kontonummer',
'bankleitzahl' => 'bankleitzahl',
'iban' => 'iban',
'bic' => 'bic',
]))
->toMember(['groupId' => 103, 'id' => 16, 'mitgliedsNummer' => 18]);
$response = $this->login()->putMember($member);
$this->assertEquals(16, $response);
app(MemberFake::class)->assertUpdated(103, 16, [
'kontoverbindung' => json_encode([
'id' => 555,
'zahlungsKonditionId' => 1,
'mitgliedsNummer' => 18,
'institut' => 'institut',
'kontoinhaber' => 'kontoinhaber',
'kontonummer' => 'kontonummer',
'bankleitzahl' => 'bankleitzahl',
'iban' => 'iban',
'bic' => 'bic',
]),
]);
}
public function testUpdateAMemberWithForeignAttributes(): void
{
app(MemberFake::class)