sepa-sdd-xml-generator
sepa-sdd-xml-generator copied to clipboard
controlSum floating point precision error
public function addTransaction(SEPADirectDebitTransaction $transaction) { $this->transactions[] = $transaction; $this->numberOfTransactions++; $this->controlSum += $transaction->getInstructedAmount(); }
The addition of the controlSum can generate floating point precision errors, resulting in controlsums like 9471.4899999999.
@Churro We're experiencing this issue also. How to solve this? @Daddaaff how did you fix this?
I'd need a demo or quick reproduction to test a potential fix against
@Churro see below
<?php
$debtorIban = '------A-VALID-IBAN-GOES-HERE------';
$creditorIban = '------A-VALID-IBAN-GOES-HERE------';
$creditorBic = '------A-VALID-BIC-GOES-HERE------';
## ------------ ##
$message = new SEPAMessage('urn:iso:std:iso:20022:tech:xsd:pain.008.001.02');
$groupHeader = new SEPAGroupHeader();
$groupHeader->setMessageIdentification('SEPA-' . time());
$groupHeader->setInitiatingPartyName('Baz');
$message->setGroupHeader($groupHeader);
$paymentInfo = new SEPAPaymentInfo();
$paymentInfo->setPaymentInformationIdentification(md5('SEPA-RCUR-' . time()));
$paymentInfo->setBatchBooking('true');
$paymentInfo->setLocalInstrumentCode('CORE');
$paymentInfo->setSequenceType('RCUR');
$paymentInfo->setRequestedCollectionDate('2024-06-01');
$paymentInfo->setCreditorName('FooBar');
$paymentInfo->setCreditorAccountIBAN($creditorIban);
$paymentInfo->setCreditorAgentBIC($creditorBic);
$paymentInfo->setCreditorSchemeIdentification('1234567890');
$amounts = [
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
38.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
24.95,
26.95,
26.95,
26.95,
26.95,
24.95,
52.39,
24.95,
54.05,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
15.62,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
26.95,
26.95,
39.95,
24.95,
26.95,
26.95,
26.95,
40.88,
24.95,
24.95,
38.95,
33.53,
24.95,
24.95,
24.95,
24.02,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
5.00,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
24.95,
26.95,
26.95,
24.95,
26.95,
26.95,
26.95,
24.95,
46.90,
26.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
26.95,
24.95,
46.56,
26.95,
69.90,
26.95,
35.24,
48.24,
49.06,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
26.95,
26.95,
24.95,
24.95,
24.95,
26.95,
24.95,
40.88,
32.83,
32.83,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
32.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
26.95,
26.95,
24.95,
26.95,
26.95,
26.95,
26.95,
24.95,
49.06,
24.95,
21.95,
24.95,
24.95,
24.02,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
24.95,
26.95,
24.95,
26.95,
26.95,
26.95,
24.95,
46.90,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
26.95,
26.95,
26.95,
24.95,
26.95,
35.24,
24.95,
24.95,
21.95,
38.95,
46.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
26.95,
26.95,
26.95,
24.95,
26.95,
26.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
26.95,
26.95,
26.95,
24.95,
26.95,
24.95,
24.95,
24.95,
47.80,
24.95,
32.95,
38.95,
24.95,
24.95,
24.95,
24.95,
46.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
32.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
26.95,
26.95,
24.95,
26.95,
26.95,
24.95,
26.95,
26.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
32.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
26.95,
24.95,
24.95,
26.95,
26.95,
24.95,
26.95,
24.95,
24.95,
24.95,
21.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
46.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
26.95,
26.95,
26.95,
24.95,
24.95,
26.95,
26.95,
34.44,
24.95,
24.95,
24.95,
24.95,
32.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
26.95,
24.95,
26.95,
24.95,
24.95,
26.95,
24.95,
26.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
15.29,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
26.95,
26.95,
26.95,
26.95,
26.95,
24.95,
24.95,
35.24,
24.95,
24.95,
24.95,
21.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
24.95,
26.95,
24.95,
24.95,
24.95,
26.95,
24.95,
26.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
32.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
34.92,
24.95,
26.95,
26.95,
24.95,
24.95,
24.95,
37.66,
24.95,
24.95,
24.95,
32.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
21.52,
16.55,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
26.95,
26.95,
24.95,
26.95,
24.95,
24.95,
50.72,
24.95,
24.95,
21.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
15.62,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
26.95,
24.95,
26.95,
26.95,
24.95,
24.95,
26.95,
24.95,
24.95,
24.95,
29.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
24.95,
26.95,
26.95,
26.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
57.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
24.95,
26.95,
24.95,
26.95,
26.95,
26.95,
24.95,
37.66,
39.95,
34.44,
38.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
44.90,
26.95,
26.95,
26.95,
26.95,
52.39,
24.95,
26.95,
32.83,
26.95,
26.95,
32.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
53.95,
24.95,
24.95,
24.95,
5.00,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
24.95,
26.95,
43.15,
26.95,
24.95,
26.95,
34.44,
24.95,
24.95,
24.95,
24.95,
32.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
24.95,
26.95,
26.95,
26.95,
26.95,
24.95,
24.95,
24.95,
41.68,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
17.48,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
24.95,
26.95,
26.95,
24.95,
46.90,
26.95,
46.90,
26.95,
26.95,
24.95,
32.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
26.95,
26.95,
24.95,
24.95,
26.95,
39.95,
24.95,
24.95,
24.95,
24.95,
38.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
46.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
16.55,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
26.95,
26.95,
24.95,
26.95,
46.90,
26.95,
36.85,
24.95,
49.06,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
54.88,
24.95,
24.95,
26.95,
24.95,
24.95,
26.95,
26.95,
26.95,
24.95,
32.83,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
53.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
32.52,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
26.95,
26.95,
26.95,
26.95,
26.95,
39.95,
24.95,
26.95,
24.95,
34.44,
24.95,
24.95,
24.95,
46.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
21.68,
15.29,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
26.95,
24.95,
26.95,
46.90,
26.95,
24.95,
24.95,
24.95,
32.02,
24.95,
24.95,
21.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
68.95,
24.95,
21.68,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
33.63,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
24.95,
39.95,
26.95,
26.95,
26.95,
26.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
38.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
24.95,
26.95,
26.95,
26.95,
26.95,
24.95,
26.95,
26.95,
24.95,
26.95,
49.90,
26.95
];
foreach ($amounts as $key => $amount) {
$transaction = new SEPADirectDebitTransaction();
$transaction->setEndToEndIdentification('Foo-' . $key);
$transaction->setInstructedAmount($amount);
$transaction->setMandateIdentification('Bar-' . $key);
$transaction->setDateOfSignature('2024-01-01');
$transaction->setAmendmentIndicator('false');
$transaction->setDebtorName('Baz'.$key);
$transaction->setDebtorIban($debtorIban);
$transaction->setRemittanceInformation('Foo-'.$key);
$paymentInfo->addTransaction($transaction);
}
$message->addPaymentInfo($paymentInfo);
header('Content-type: text/xml');
$sFileName = 'test';
header('Content-Disposition: attachment; filename="' . $sFileName . '.xml"');
echo $message->printXML();
Any updates on this? Best regards
I had no time to look at this yet but if you figure out a workaround in the meantime, please feel welcome to create a PR.
Resolved by https://github.com/w2c/sepa-sdd-xml-generator/commit/30da7115e00cca05a68fa8c0ee0d47aaa28b2e6f.