Skip to content

Commit 0a3cd9a

Browse files
authored
Merge pull request #529 from timrasche/feature/single-booking-sepa-transfer
Add singleBookingRequested option to SendSEPATransfer
2 parents d1a75a2 + fb58bed commit 0a3cd9a

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

lib/Fhp/Action/SendSEPATransfer.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class SendSEPATransfer extends BaseAction
2626
private $painMessage;
2727
/** @var string */
2828
private $xmlSchema;
29+
/** @var bool */
30+
private $singleBookingRequested = false;
2931

3032
// There are no result fields. This action is simply marked as done to indicate that the transfer was executed.
3133

@@ -47,6 +49,19 @@ public static function create(SEPAAccount $account, string $painMessage): SendSE
4749
return $result;
4850
}
4951

52+
/**
53+
* Request individual bookings instead of a batch booking on the bank statement.
54+
* Only applicable for batch transfers (Sammelüberweisung).
55+
*
56+
* @param bool $singleBookingRequested If true, each transaction appears separately on the statement.
57+
* @return $this
58+
*/
59+
public function setSingleBookingRequested(bool $singleBookingRequested): self
60+
{
61+
$this->singleBookingRequested = $singleBookingRequested;
62+
return $this;
63+
}
64+
5065
/**
5166
* @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023
5267
*/
@@ -59,7 +74,7 @@ public function __serialize(): array
5974
{
6075
return [
6176
parent::__serialize(),
62-
$this->account, $this->painMessage, $this->xmlSchema,
77+
$this->account, $this->painMessage, $this->xmlSchema, $this->singleBookingRequested,
6378
];
6479
}
6580

@@ -78,7 +93,7 @@ public function __unserialize(array $serialized): void
7893
{
7994
list(
8095
$parentSerialized,
81-
$this->account, $this->painMessage, $this->xmlSchema,
96+
$this->account, $this->painMessage, $this->xmlSchema, $this->singleBookingRequested,
8297
) = $serialized;
8398

8499
is_array($parentSerialized) ?
@@ -144,6 +159,16 @@ protected function createRequest(BPD $bpd, ?UPD $upd)
144159
$segment->kontoverbindungInternational = Kti::fromAccount($this->account);
145160
$segment->sepaDescriptor = $this->xmlSchema;
146161
$segment->sepaPainMessage = new Bin($this->painMessage);
162+
163+
// For batch transfers: set einzelbuchungGewuenscht if bank allows it
164+
if ($numberOfTransactions > 1) {
165+
$paramSegmentId = $hasReqdExDates ? 'HICMES' : 'HICCMS';
166+
$paramSegment = $bpd->getLatestSupportedParameters($paramSegmentId);
167+
if ($paramSegment !== null && $paramSegment->getParameter()->einzelbuchungErlaubt) {
168+
$segment->einzelbuchungGewuenscht = $this->singleBookingRequested;
169+
}
170+
}
171+
147172
return $segment;
148173
}
149174

lib/Fhp/Segment/CCM/HICCMSv1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class HICCMSv1 extends BaseGeschaeftsvorfallparameter
1414
{
1515
public ParameterSEPASammelueberweisungV1 $parameter;
1616

17-
public function getParameter()
17+
public function getParameter(): ParameterSEPASammelueberweisungV1
1818
{
1919
return $this->parameter;
2020
}

lib/Fhp/Segment/CME/HICMESv1.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@
1313
class HICMESv1 extends BaseGeschaeftsvorfallparameter
1414
{
1515
public ParameterTerminierteSEPASammelueberweisungEinreichenV1 $parameter;
16+
17+
public function getParameter(): ParameterTerminierteSEPASammelueberweisungEinreichenV1
18+
{
19+
return $this->parameter;
20+
}
1621
}

0 commit comments

Comments
 (0)