Add: Update kontoverbindung
This commit is contained in:
parent
fa12646ead
commit
ff34c23032
|
@ -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');
|
||||
|
|
|
@ -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 ?: '',
|
||||
|
|
|
@ -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),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue