Skip to content

Commit

Permalink
Fix decimal mark by using F as type specifier in sprintf() (#13)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
markcoenradie authored and AbcAeffchen committed Oct 8, 2017
1 parent 3a79ae4 commit b67c97e
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Sephpa.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/payment-collections/SepaCreditTransfer00100103.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion src/payment-collections/SepaCreditTransfer00100203.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/payment-collections/SepaCreditTransfer00100303.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions src/payment-collections/SepaDirectDebit00800102.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions src/payment-collections/SepaDirectDebit00800202.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions src/payment-collections/SepaDirectDebit00800302.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit b67c97e

Please sign in to comment.