Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions lib/Fhp/Action/SendSEPATransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class SendSEPATransfer extends BaseAction
private $painMessage;
/** @var string */
private $xmlSchema;
/** @var bool */
private $singleBookingRequested = false;

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

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

/**
* Request individual bookings instead of a batch booking on the bank statement.
* Only applicable for batch transfers (Sammelüberweisung).
*
* @param bool $singleBookingRequested If true, each transaction appears separately on the statement.
* @return $this
*/
public function setSingleBookingRequested(bool $singleBookingRequested): self
{
$this->singleBookingRequested = $singleBookingRequested;
return $this;
}

/**
* @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
*/
Expand All @@ -59,7 +74,7 @@ public function __serialize(): array
{
return [
parent::__serialize(),
$this->account, $this->painMessage, $this->xmlSchema,
$this->account, $this->painMessage, $this->xmlSchema, $this->singleBookingRequested,
];
}

Expand All @@ -78,7 +93,7 @@ public function __unserialize(array $serialized): void
{
list(
$parentSerialized,
$this->account, $this->painMessage, $this->xmlSchema,
$this->account, $this->painMessage, $this->xmlSchema, $this->singleBookingRequested,
) = $serialized;

is_array($parentSerialized) ?
Expand Down Expand Up @@ -144,6 +159,16 @@ protected function createRequest(BPD $bpd, ?UPD $upd)
$segment->kontoverbindungInternational = Kti::fromAccount($this->account);
$segment->sepaDescriptor = $this->xmlSchema;
$segment->sepaPainMessage = new Bin($this->painMessage);

// For batch transfers: set einzelbuchungGewuenscht if bank allows it
if ($numberOfTransactions > 1) {
$paramSegmentId = $hasReqdExDates ? 'HICMES' : 'HICCMS';
$paramSegment = $bpd->getLatestSupportedParameters($paramSegmentId);
if ($paramSegment !== null && $paramSegment->getParameter()->einzelbuchungErlaubt) {
$segment->einzelbuchungGewuenscht = $this->singleBookingRequested;
}
}

return $segment;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Fhp/Segment/CCM/HICCMSv1.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class HICCMSv1 extends BaseGeschaeftsvorfallparameter
{
public ParameterSEPASammelueberweisungV1 $parameter;

public function getParameter()
public function getParameter(): ParameterSEPASammelueberweisungV1
{
return $this->parameter;
}
Expand Down
5 changes: 5 additions & 0 deletions lib/Fhp/Segment/CME/HICMESv1.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@
class HICMESv1 extends BaseGeschaeftsvorfallparameter
{
public ParameterTerminierteSEPASammelueberweisungEinreichenV1 $parameter;

public function getParameter(): ParameterTerminierteSEPASammelueberweisungEinreichenV1
{
return $this->parameter;
}
}