From b67c97e38251f17be042743fae4a873587c0c881 Mon Sep 17 00:00:00 2001 From: markcoenradie Date: Sun, 8 Oct 2017 22:18:40 +0200 Subject: [PATCH] Fix decimal mark by using F as type specifier in sprintf() (#13) * Use non-locale aware type specifier (i.e. always use period (.) as decimal mark) * Use non-locale aware type specifier (see previous commit) * Replace InstdAmt with non-locale aware string of amount --- src/Sephpa.php | 2 +- src/payment-collections/SepaCreditTransfer00100103.php | 4 ++-- src/payment-collections/SepaCreditTransfer00100203.php | 2 +- src/payment-collections/SepaCreditTransfer00100303.php | 2 +- src/payment-collections/SepaDirectDebit00800102.php | 4 ++-- src/payment-collections/SepaDirectDebit00800202.php | 4 ++-- src/payment-collections/SepaDirectDebit00800302.php | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Sephpa.php b/src/Sephpa.php index 54cd289..c0bf9be 100644 --- a/src/Sephpa.php +++ b/src/Sephpa.php @@ -134,7 +134,7 @@ public function generateXml($creDtTm = '') $grpHdr->addChild('MsgId', $this->msgId); $grpHdr->addChild('CreDtTm', $creDtTm); $grpHdr->addChild('NbOfTxs', $totalNumberOfTransaction); - $grpHdr->addChild('CtrlSum', sprintf('%01.2f', $this->getCtrlSum())); + $grpHdr->addChild('CtrlSum', sprintf('%01.2F', $this->getCtrlSum())); $grpHdr->addChild('InitgPty')->addChild('Nm', $this->initgPty); foreach($this->paymentCollections as $paymentCollection) diff --git a/src/payment-collections/SepaCreditTransfer00100103.php b/src/payment-collections/SepaCreditTransfer00100103.php index b81b989..9e8b968 100644 --- a/src/payment-collections/SepaCreditTransfer00100103.php +++ b/src/payment-collections/SepaCreditTransfer00100103.php @@ -156,7 +156,7 @@ public function generateCollectionXml(\SimpleXMLElement $pmtInf) if( !empty( $this->transferInfo['btchBookg'] ) ) $pmtInf->addChild('BtchBookg', $this->transferInfo['btchBookg']); $pmtInf->addChild('NbOfTxs', $this->getNumberOfTransactions()); - $pmtInf->addChild('CtrlSum', sprintf("%01.2f", $this->getCtrlSum())); + $pmtInf->addChild('CtrlSum', sprintf("%01.2F", $this->getCtrlSum())); $pmtTpInf = $pmtInf->addChild('PmtTpInf'); $pmtTpInf->addChild('InstrPrty', 'NORM'); @@ -200,7 +200,7 @@ public function generateCollectionXml(\SimpleXMLElement $pmtInf) private function generatePaymentXml(\SimpleXMLElement $cdtTrfTxInf, $payment, $ccy) { $cdtTrfTxInf->addChild('PmtId')->addChild('EndToEndId', $payment['pmtId']); - $cdtTrfTxInf->addChild('Amt')->addChild('InstdAmt', $payment['instdAmt']) + $cdtTrfTxInf->addChild('Amt')->addChild('InstdAmt', sprintf("%01.2F", $payment['instdAmt'])) ->addAttribute('Ccy', $ccy); if( !empty( $payment['bic'] ) ) $cdtTrfTxInf->addChild('CdtrAgt')->addChild('FinInstnId') diff --git a/src/payment-collections/SepaCreditTransfer00100203.php b/src/payment-collections/SepaCreditTransfer00100203.php index e60a08a..7759706 100644 --- a/src/payment-collections/SepaCreditTransfer00100203.php +++ b/src/payment-collections/SepaCreditTransfer00100203.php @@ -153,7 +153,7 @@ public function generateCollectionXml(\SimpleXMLElement $pmtInf) if( !empty( $this->transferInfo['btchBookg'] ) ) $pmtInf->addChild('BtchBookg', $this->transferInfo['btchBookg']); $pmtInf->addChild('NbOfTxs', $this->getNumberOfTransactions()); - $pmtInf->addChild('CtrlSum', sprintf('%01.2f', $this->getCtrlSum())); + $pmtInf->addChild('CtrlSum', sprintf('%01.2F', $this->getCtrlSum())); $pmtTpInf = $pmtInf->addChild('PmtTpInf'); $pmtTpInf->addChild('InstrPrty', 'NORM'); diff --git a/src/payment-collections/SepaCreditTransfer00100303.php b/src/payment-collections/SepaCreditTransfer00100303.php index cc1ad02..dd9307a 100644 --- a/src/payment-collections/SepaCreditTransfer00100303.php +++ b/src/payment-collections/SepaCreditTransfer00100303.php @@ -156,7 +156,7 @@ public function generateCollectionXml(\SimpleXMLElement $pmtInf) if( !empty( $this->transferInfo['btchBookg'] ) ) $pmtInf->addChild('BtchBookg', $this->transferInfo['btchBookg']); $pmtInf->addChild('NbOfTxs', $this->getNumberOfTransactions()); - $pmtInf->addChild('CtrlSum', sprintf("%01.2f", $this->getCtrlSum())); + $pmtInf->addChild('CtrlSum', sprintf("%01.2F", $this->getCtrlSum())); $pmtTpInf = $pmtInf->addChild('PmtTpInf'); $pmtTpInf->addChild('InstrPrty', 'NORM'); diff --git a/src/payment-collections/SepaDirectDebit00800102.php b/src/payment-collections/SepaDirectDebit00800102.php index a6553f0..8f29557 100644 --- a/src/payment-collections/SepaDirectDebit00800102.php +++ b/src/payment-collections/SepaDirectDebit00800102.php @@ -182,7 +182,7 @@ public function generateCollectionXml(\SimpleXMLElement $pmtInf) if( !empty( $this->debitInfo['btchBookg'] ) ) $pmtInf->addChild('BtchBookg', $this->debitInfo['btchBookg']); $pmtInf->addChild('NbOfTxs', $this->getNumberOfTransactions()); - $pmtInf->addChild('CtrlSum', sprintf('%01.2f', $this->getCtrlSum())); + $pmtInf->addChild('CtrlSum', sprintf('%01.2F', $this->getCtrlSum())); $pmtTpInf = $pmtInf->addChild('PmtTpInf'); $pmtTpInf->addChild('SvcLvl')->addChild('Cd', 'SEPA'); @@ -233,7 +233,7 @@ public function generateCollectionXml(\SimpleXMLElement $pmtInf) private function generatePaymentXml(\SimpleXMLElement $drctDbtTxInf, $payment, $ccy) { $drctDbtTxInf->addChild('PmtId')->addChild('EndToEndId', $payment['pmtId']); - $drctDbtTxInf->addChild('InstdAmt', sprintf('%01.2f', $payment['instdAmt'])) + $drctDbtTxInf->addChild('InstdAmt', sprintf('%01.2F', $payment['instdAmt'])) ->addAttribute('Ccy', $ccy); $mndtRltdInf = $drctDbtTxInf->addChild('DrctDbtTx')->addChild('MndtRltdInf'); diff --git a/src/payment-collections/SepaDirectDebit00800202.php b/src/payment-collections/SepaDirectDebit00800202.php index a05c3ef..0330634 100644 --- a/src/payment-collections/SepaDirectDebit00800202.php +++ b/src/payment-collections/SepaDirectDebit00800202.php @@ -164,7 +164,7 @@ public function generateCollectionXml(\SimpleXMLElement $pmtInf) if( !empty( $this->debitInfo['btchBookg'] ) ) $pmtInf->addChild('BtchBookg', $this->debitInfo['btchBookg']); $pmtInf->addChild('NbOfTxs', $this->getNumberOfTransactions()); - $pmtInf->addChild('CtrlSum', sprintf('%01.2f', $this->getCtrlSum())); + $pmtInf->addChild('CtrlSum', sprintf('%01.2F', $this->getCtrlSum())); $pmtTpInf = $pmtInf->addChild('PmtTpInf'); $pmtTpInf->addChild('SvcLvl')->addChild('Cd', 'SEPA'); @@ -211,7 +211,7 @@ public function generateCollectionXml(\SimpleXMLElement $pmtInf) private function generatePaymentXml(\SimpleXMLElement $drctDbtTxInf, $payment, $ccy) { $drctDbtTxInf->addChild('PmtId')->addChild('EndToEndId', $payment['pmtId']); - $drctDbtTxInf->addChild('InstdAmt', sprintf('%01.2f', $payment['instdAmt'])) + $drctDbtTxInf->addChild('InstdAmt', sprintf('%01.2F', $payment['instdAmt'])) ->addAttribute('Ccy', $ccy); $mndtRltdInf = $drctDbtTxInf->addChild('DrctDbtTx')->addChild('MndtRltdInf'); diff --git a/src/payment-collections/SepaDirectDebit00800302.php b/src/payment-collections/SepaDirectDebit00800302.php index be99215..e46e628 100644 --- a/src/payment-collections/SepaDirectDebit00800302.php +++ b/src/payment-collections/SepaDirectDebit00800302.php @@ -172,7 +172,7 @@ public function generateCollectionXml(\SimpleXMLElement $pmtInf) if( !empty( $this->debitInfo['btchBookg'] ) ) $pmtInf->addChild('BtchBookg', $this->debitInfo['btchBookg']); $pmtInf->addChild('NbOfTxs', $this->getNumberOfTransactions()); - $pmtInf->addChild('CtrlSum', sprintf('%01.2f', $this->getCtrlSum())); + $pmtInf->addChild('CtrlSum', sprintf('%01.2F', $this->getCtrlSum())); $pmtTpInf = $pmtInf->addChild('PmtTpInf'); $pmtTpInf->addChild('SvcLvl')->addChild('Cd', 'SEPA'); @@ -223,7 +223,7 @@ public function generateCollectionXml(\SimpleXMLElement $pmtInf) private function generatePaymentXml(\SimpleXMLElement $drctDbtTxInf, $payment, $ccy) { $drctDbtTxInf->addChild('PmtId')->addChild('EndToEndId', $payment['pmtId']); - $drctDbtTxInf->addChild('InstdAmt', sprintf('%01.2f', $payment['instdAmt'])) + $drctDbtTxInf->addChild('InstdAmt', sprintf('%01.2F', $payment['instdAmt'])) ->addAttribute('Ccy', $ccy); $mndtRltdInf = $drctDbtTxInf->addChild('DrctDbtTx')->addChild('MndtRltdInf');