<?php
namespace ModulesAbstract\PluginReports\Report\Model\Gatherer\ExportData;

/**
 * Helper class for exported cashing xml files
 * @author cristiana.matache
 */
class Payment extends AbstractExportDataFile
{
	public function getDate()
	{
		return (String)$this->docDate;
	}

	/**
	 * Returns the partner type based on the xml client type
	 * @return string
	 */
	public function getPartnerType()
	{
		return 'supplier';
	}

	/**
	 * Returns an associative array of xml information based on the client type
	 * @return string[]|NULL[]
	 */
	public function getPartnerDetails()
	{

		$supplierAddress = "";
		$countryCode = "";

		$supplierEnt = \Entity\Supplier::select((String)$this->invoiceDetails->supplier['id']);
		if ($supplierEnt->recordExists()) {
			$supplierAddress = $supplierEnt->address;
			$countryCode = $supplierEnt->country->code;
		}


		return [
			'id'	=>			(String)$this->invoiceDetails->supplier['id'],
			'type'	=>			(String)$this->getPartnerType(),
			'alias'	=>			(String)$this->invoiceDetails->supplier->alias,
			'company'	=>		(String)$this->invoiceDetails->supplier->company,
			'companyPrefix'	=>	(String)$this->invoiceDetails->supplier->company['prefix'],
			'companySuffix'	=>	(String)$this->invoiceDetails->supplier->company['suffix'],
			'fiscalCode'	=>	(String)$this->invoiceDetails->supplier->fiscalCode,
			'address'	=>		$supplierAddress,
			'countryCode' =>	$countryCode,
		];
	}

	/**
	 *
	 * {@inheritDoc}
	 * @see \ModulesAbstract\PluginReports\Report\Model\Gatherer\ExportData\AbstractExportDataFile::isVoid()
	 */
	public function isVoid()
	{
		return (((String)$this['operation'] == 'void') or ((String)$this['operation'] == 'unconfirm'));
	}

	/**
	 *
	 * {@inheritDoc}
	 * @see \ModulesAbstract\PluginReports\Report\Model\Gatherer\ExportData\AbstractExportDataFile::getVoidDate()
	 */
	public function getVoidDate()
	{
		return $this->getExportDate();
	}

	/**
	 *
	 * {@inheritDoc}
	 * @see \ModulesAbstract\PluginReports\Report\Model\Gatherer\ExportData\AbstractExportDataFile::isConfirmed()
	 */
	public function isIssue()
	{
		return (((String)$this['operation'] == 'issue') or ((String)$this['operation'] == 'confirm'));

	}

	/**
	 *
	 * {@inheritDoc}
	 * @see \ModulesAbstract\PluginReports\Report\Model\Gatherer\ExportData\AbstractExportDataFile::getIssueDate()
	 */
	public function getIssueDate()
	{
		return $this->getDate();
	}

	/**
	 *
	 * {@inheritDoc}
	 * @see \ModulesAbstract\PluginReports\Report\Model\Gatherer\ExportData\AbstractExportDataFile::isCoreDocument()
	 */
	public function isCoreDocument()
	{
		return true;
	}

	/**
	 *
	 * {@inheritDoc}
	 * @see \ModulesAbstract\PluginReports\Report\Model\Gatherer\ExportData\AbstractExportDataFile::isCashbookDocument()
	 */
	public function isCashbookDocument()
	{
		return false;
	}

	/**
	 *
	 * {@inheritDoc}
	 * @see \ModulesAbstract\PluginReports\Report\Model\Gatherer\ExportData\AbstractExportDataFile::isImportedDocument()
	 */
	public function isImportedDocument()
	{
		return false;
	}

}
