<?php
namespace App\Galileo\StructureParser\Structures\NDCReissue;

class Documents extends \App\Galileo\StructureParser\Structures\Base\Documents
{
	protected function _getData()
	{
		list($parsedStructure, $transactionType, $transactionIndexes, ) = $this->getTransactionDetails();

		$item = new \App\Galileo\StructureParser\Types\Document();

		$extraTransaction = $parsedStructure['A14_NDC']['ExtraTransactions'][$transactionIndexes['kx']];
		$item->docNumber = 	substr($parsedStructure['A14_NDC']['TicketNumbers'][$transactionIndexes['ks']]['TicketNumbers']['ticketNumber'], -10);
		$item->docDate =	$extraTransaction['RemarksTransactionReason']['date'];

		if (!$item->docNumber) {
			throw new \App\Utils\BaseParser\Structure\Exception\InvalidStructure(sprintf("The docNumber cannot be extracted. Please investigate this case"));
		}

		$item = $this->populateForNDC($item, $parsedStructure, $transactionType, $transactionIndexes);

		$item->transactionCode = $this->populateTransactionCodeForNDC($parsedStructure, $transactionType, $transactionIndexes);
		return $item;
	}

}
