<commit_before><?php

namespace FatcaIdesPhp;

// Implementation of FatcaDataInterface that is suitable for institutions that have only a flat array of individuals with reportable accounts
class FatcaDataOecd implements FatcaDataInterface {

	function __construct($oecd) {
	// oecd: php object of type FatcaXsdPhp\FATCA_OECD

    assert($oecd instanceOf \FatcaXsdPhp\FATCA_OECD,"Test that ".get_class($oecd)." is of class \FatcaXsdPhp\FATCA_OECD: ");
    $this->oecd=$oecd;
  }

  function start() {
    ; // do nothing
	}

  public static function toHtmlIndividual($row,$dom,$ind) {
    $row->appendChild($dom->createElement('td',$ind->TIN));
    $row->appendChild($dom->createElement('td',$ind->Name->FirstName));
    $row->appendChild($dom->createElement('td',$ind->Name->LastName));
    $row->appendChild($dom->createElement('td',"N/A"));

    $row->appendChild($dom->createElement('td',$ind->Address->CountryCode));
    $row->appendChild($dom->createElement('td',$ind->Address->AddressFree));

    return $row;
  }

	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 &&
         is_array($this->oecd->FATCA->ReportingGroup->AccountReport)
      ) {
      foreach($this->oecd->FATCA->ReportingGroup->AccountReport as $ar) {
        $row = $dom->createElement('tr');
        $row->appendChild($dom->createElement('td',$ar->AccountNumber));

        if(!!$ar->AccountHolder->Individual) {
          $row = FatcaDataOecd::toHtmlIndividual(
            $row,
            $dom,
            $ar->AccountHolder->Individual);
        }

        if(!!$ar->AccountHolder->Organisation) {
          $row->appendChild($dom->createElement('td',"N/A"));
          $row->appendChild(
            $dom->createElement('td',$ar->AccountHolder->Organisation->Name->value));
          $row->appendChild($dom->createElement('td',"N/A"));
          $row->appendChild($dom->createElement('td',$ar->AccountHolder->AcctHolderType->value));

          $row->appendChild($dom->createElement('td',$ar->AccountHolder->Organisation->Address->CountryCode));
          $row->appendChild($dom->createElement('td',$ar->AccountHolder->Organisation->Address->AddressFree));
        }

        $table->appendChild($row);
<commit_msg>split out organisation tohtml and added balances tohtml<commit_after><?php

namespace FatcaIdesPhp;

// Implementation of FatcaDataInterface that is suitable for institutions that have only a flat array of individuals with reportable accounts
class FatcaDataOecd implements FatcaDataInterface {

	function __construct($oecd) {
	// oecd: php object of type FatcaXsdPhp\FATCA_OECD

    assert($oecd instanceOf \FatcaXsdPhp\FATCA_OECD,"Test that ".get_class($oecd)." is of class \FatcaXsdPhp\FATCA_OECD: ");
    $this->oecd=$oecd;
  }

  function start() {
    ; // do nothing
	}

  public static function toHtmlIndividual($row,$dom,$ind) {
    $row->appendChild($dom->createElement('td',$ind->TIN));
    $row->appendChild($dom->createElement('td',$ind->Name->FirstName));
    $row->appendChild($dom->createElement('td',$ind->Name->LastName));

    $row->appendChild($dom->createElement('td',$ind->Address->CountryCode));
    $row->appendChild($dom->createElement('td',$ind->Address->AddressFree));

    return $row;
  }

  public static function toHtmlOrganisation($row,$dom,$org) {
    $row->appendChild($dom->createElement('td',"N/A"));
    $row->appendChild($dom->createElement('td',$org->Name->value));
    $row->appendChild($dom->createElement('td',"N/A"));

    $row->appendChild($dom->createElement('td',$org->Address->CountryCode));
    $row->appendChild($dom->createElement('td',$org->Address->AddressFree));
    return $row;
  }


	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);

{'fraction_non_alphanumeric': 0.18968296614723268, 'fraction_numerical': 0.0014329213684399068, 'mean_word_length': 3.692436974789916, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 169, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2345045', 'n_tokens_mistral': 1740, 'n_tokens_neox': 1682, 'n_words': 226}