public function testToHtmlBuilt()
 {
     $fdo = new FatcaDataOecd($this->oecd);
     $fdo->start();
     $html = $fdo->toHtml();
     $this->assertTrue(!!$html);
 }
 function toHtml()
 {
     $dom = new \DOMDocument('1.0', 'utf-8');
     $table = $dom->createElement('table');
     $border = $dom->createAttribute('border');
     $border->value = 1;
     $table->appendChild($border);
     if (!!$this->oecd->FATCA->ReportingGroup->AccountReport) {
         $arar = $this->oecd->FATCA->ReportingGroup->AccountReport;
         if (!is_array($arar)) {
             $arar = array($arar);
         }
         foreach ($arar as $ar) {
             $row = $dom->createElement('tr');
             $row->appendChild($dom->createElement('td', $ar->AccountNumber));
             if (!!$ar->AccountHolder->Individual) {
                 $row->appendChild($dom->createElement('td', '{Individual}'));
                 $row = FatcaDataOecd::toHtmlIndividual($row, $dom, $ar->AccountHolder->Individual);
             }
             if (!!$ar->AccountHolder->Organisation) {
                 $row->appendChild($dom->createElement('td', $ar->AccountHolder->AcctHolderType->value));
                 $row = FatcaDataOecd::toHtmlOrganisation($row, $dom, $ar->AccountHolder->Organisation);
             }
             $row->appendChild($dom->createElement('td', $ar->AccountBalance->currCode));
             $row->appendChild($dom->createElement('td', $ar->AccountBalance->value));
             if (!!$ar->Payment) {
                 $arpay = $ar->Payment;
                 if (!is_array($arpay)) {
                     $arpay = array($arpay);
                 }
                 foreach ($arpay as $pay) {
                     $row->appendChild($dom->createElement('td', $pay->Type));
                     $row->appendChild($dom->createElement('td', $pay->PaymentAmnt->currCode));
                     $row->appendChild($dom->createElement('td', $pay->PaymentAmnt->value));
                 }
             }
             // end if ar->payment
             $table->appendChild($row);
             if (!!$ar->SubstantialOwner) {
                 foreach ($ar->SubstantialOwner as $so) {
                     $row = $dom->createElement('tr');
                     $row->appendChild($dom->createElement('td', $ar->AccountNumber));
                     $row->appendChild($dom->createElement('td', '{Substantial Owner}'));
                     $row = FatcaDataOecd::toHtmlIndividual($row, $dom, $so);
                     $table->appendChild($row);
                 }
             }
         }
     }
     $dom->appendChild($table);
     // pretty print html
     $dom->preserveWhiteSpace = true;
     $dom->formatOutput = true;
     //false;
     $html = $dom->saveHTML();
     return $html;
 }