Skip to content
Merged
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
21 changes: 18 additions & 3 deletions src/Action/SendSEPADirectDebit.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class SendSEPADirectDebit extends BaseAction
protected $tryToUseControlSumForSingleTransactions = false;
/** @var string */
private $coreType;
private bool $singleBookingRequested = false;

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

Expand Down Expand Up @@ -82,6 +83,20 @@ public static function create(SEPAAccount $account, string $painMessage, bool $t
return $result;
}

/**
* Request individual bookings instead of a batch booking on the bank statement.
* Only applicable for batch direct debits (Sammellastschrift).
*
* @param bool $singleBookingRequested If true, each transaction appears separately on the statement.
* @return $this
*/
public function setSingleBookingRequested(bool $singleBookingRequested): self

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that PHP8 supports named arguments, have you considered using a create() parameter rather than adding a new setter? I believe this would be the only case in this library so far where a setter is used on an action.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I initially considered that as well, but then decided against it because I adopted the approach from SEPATransfer, as I didn't want to have two different logics for the two similar cases. I just adapted it from SEPATransfer. Therefore, we should either switch both cases to named arguments, or leave it as it is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah you're right, I overlooked that we have a setter there already, and even for exactly the same kind of property.

{
$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 @@ -94,7 +109,7 @@ public function __serialize(): array
{
return [
parent::__serialize(),
$this->singleDirectDebit, $this->tryToUseControlSumForSingleTransactions, $this->ctrlSum, $this->coreType, $this->painMessage, $this->painNamespace, $this->account,
$this->singleDirectDebit, $this->tryToUseControlSumForSingleTransactions, $this->ctrlSum, $this->coreType, $this->painMessage, $this->painNamespace, $this->account, $this->singleBookingRequested,
];
}

Expand All @@ -113,7 +128,7 @@ public function __unserialize(array $serialized): void
{
list(
$parentSerialized,
$this->singleDirectDebit, $this->tryToUseControlSumForSingleTransactions, $this->ctrlSum, $this->coreType, $this->painMessage, $this->painNamespace, $this->account,
$this->singleDirectDebit, $this->tryToUseControlSumForSingleTransactions, $this->ctrlSum, $this->coreType, $this->painMessage, $this->painNamespace, $this->account, $this->singleBookingRequested,
) = $serialized;

is_array($parentSerialized) ?
Expand Down Expand Up @@ -172,7 +187,7 @@ protected function createRequest(BPD $bpd, ?UPD $upd)

if (!$useSingleDirectDebit) {
if ($hidxes->getParameter()->einzelbuchungErlaubt) {
$hkdxe->einzelbuchungGewuenscht = false;
$hkdxe->einzelbuchungGewuenscht = $this->singleBookingRequested;
}

/* @var HIDMESv1 $hidxes */
Expand Down
Loading