@@ -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
0 commit comments