<?php
namespace ModulesAbstract\PluginReports\Report\Model\Gatherer\ExportData; class Invoice extends AbstractExportDataFile { public function getPartnerType() { if ($this->client['type'] == 'individual') { return 'customer'; } elseif ($this->client['type'] == 'legalEntity') { return 'corporate'; } else { throw new \Exception("Unknown client type: {$this->client['type']}"); } } public function getPartnerDetails() { $partnerType = $this->getPartnerType(); if ($partnerType == 'customer') { return [ 'id' => (String)$this->client['id'], 'type' => $partnerType, 'firstName' => (String)$this->client->individualDetails->firstName, 'lastName' => (String)$this->client->individualDetails->lastName, 'PNC' => (String)$this->client->individualDetails->PNC, 'address' => (String)$this->client->individualDetails->address, 'zipCode' => (String)$this->client->individualDetails->zipCode, 'country' => (String)$this->client->individualDetails->country, 'countryCode' => (String)$this->client->individualDetails->country['code'], 'city' => (String)$this->client->individualDetails->city, 'cityId' => (String)$this->client->individualDetails->city['id'], 'email' => (String)$this->client->individualDetails->email, 'bankName' => (String)$this->client->individualDetails->bankName, 'idBank' => (String)$this->client->individualDetails->bankName['id'], 'bankOfficeName' => (String)$this->client->individualDetails->bankOfficeName, 'idBankOffice' => (String)$this->client->individualDetails->bankOfficeName['id'], 'bankAccount' => (String)$this->client->individualDetails->bankAccount, ]; } elseif ($partnerType == 'corporate') { $mainOffice = ""; foreach ($this->client->corporateDetails->offices as $offices) { if ((String)$offices->office['type'] == "central") { $mainOffice = $offices->office; break; } } return [ 'id' => (String)$this->client['id'], 'type' => $partnerType, 'alias' => (String)$this->client->corporateDetails->alias, 'company' => (String)$this->client->corporateDetails->company, 'companyPrefix' => (String)$this->client->corporateDetails->company['prefix'], 'companySuffix' => (String)$this->client->corporateDetails->company['suffix'], 'fiscalCode' => (String)$this->client->corporateDetails->fiscalCode, 'email' => (String)$this->client->corporateDetails->email, 'mainOffice' => [ 'id' => (String)$mainOffice['id'], 'name' => (String)$mainOffice->name, 'country' => (String)$mainOffice->country, 'countryCode' => (String)$mainOffice->country['code'], 'city' => (String)$mainOffice->city, 'cityId' => (String)$mainOffice->city['id'], ] ]; } else { throw new \Exception('Unknown partner type : '.$partnerType); } } public function getInvoiceRows() { $rows = []; if (isset($this->invoiceRows->row)) { foreach ($this->invoiceRows->row as $row) { $rows[(String)$row['id']] = $row; } } return $rows; } public function getDate() { return (String)$this->invoiceDate; } public function isVoid() { return ((String)$this['operation'] == 'void'); } public function getVoidDate() { return \Engine\DateTime::create((String)$this->voidTime)->formatDateIso(); } public function isIssue() { return ((String)$this['operation'] == 'issue'); } public function getIssueDate() { return $this->getDate(); } public function isCoreDocument() { return true; } public function isCashbookDocument() { return false; } public function isImportedDocument() { return false; } } 