예제 #1
0
파일: Sephpa.php 프로젝트: KoenLav/Sephpa
 /**
  * Generates the XML file from the given data
  *
  * @param string $creDtTm You should not use this
  * @throws SephpaInputException
  * @return string Just the xml code of the file
  */
 public function generateXml($creDtTm = '')
 {
     if (empty($creDtTm) || SepaUtilities::checkCreateDateTime($creDtTm) === false) {
         $now = new \DateTime();
         $creDtTm = $now->format('Y-m-d\\TH:i:s');
     }
     $totalNumberOfTransaction = $this->getNumberOfTransactions();
     if ($totalNumberOfTransaction === 0) {
         throw new SephpaInputException('No Payments provided.');
     }
     $fileHead = $this->xml->addChild($this->xmlType);
     $grpHdr = $fileHead->addChild('GrpHdr');
     $grpHdr->addChild('MsgId', $this->msgId);
     $grpHdr->addChild('CreDtTm', $creDtTm);
     $grpHdr->addChild('NbOfTxs', $totalNumberOfTransaction);
     $grpHdr->addChild('CtrlSum', sprintf("%01.2f", $this->getCtrlSum()));
     $grpHdr->addChild('InitgPty')->addChild('Nm', $this->initgPty);
     foreach ($this->paymentCollections as $paymentCollection) {
         // ignore empty collections
         if ($paymentCollection->getNumberOfTransactions() === 0) {
             continue;
         }
         $pmtInf = $fileHead->addChild('PmtInf');
         $paymentCollection->generateCollectionXml($pmtInf);
     }
     return $this->xml->asXML();
 }
예제 #2
0
 public function testCheckCreateDateTime()
 {
     $this->assertSame('2014-10-19T00:36:11', SepaUtilities::checkCreateDateTime('2014-10-19T00:36:11'));
 }