<?php
 namespace App\ReportsData\Populate\Entity; class ClientInvoiceCashing extends \App\ReportsData\Populate\GeneralAbstract { protected function getDbTableName() { global $DBTRd_clientInvoiceCashings; return $DBTRd_clientInvoiceCashings; } protected function getEntityFields() { $entity = \Entity\InvoiceCashing::select($this->id); if (!$entity->recordExists()) { return null; } $defaultCurrency = \App\CurrencyExchange\Date::getInstance($entity->docDate)->getMarketCurrency(); $workCurrency = \App\Config\Currencies::getInstance()->getWorkCurrency(); $currencyRate = \App\CurrencyExchange\Rates::getInstance($entity->docDate)->convert(1, $entity->currency, $defaultCurrency, null); $workCurrencyRate = \App\CurrencyExchange\Rates::getInstance($entity->docDate)->convert(1, $workCurrency, $defaultCurrency, null); $return = [ 'id' => $this->id, 'idInvoice' => $entity->idInvoice, 'idCashingSeries' => $entity->idCashingSeries, 'docType' => $entity->docType, 'docDate' => $entity->docDate, 'docNumber' => $entity->docNumber, 'value' => $entity->value, 'currency' => $entity->currency, 'currencyRate' => $currencyRate, 'workCurrencyRate' => $workCurrencyRate, 'invoiceCashedValue' => $entity->invoiceCashedValue, 'idBankAccount' => $entity->idBankAccount, 'explanations' => $entity->explanations, 'comments' => $entity->comments, 'idImportedDoc' => $entity->idImportedDoc, 'remarks' => $entity->remarks, 'processedRemarks' => ($entity->processedRemarks ? json_encode($entity->processedRemarks) : ''), 'genDocsAssoc' => ($entity->generatedDocumentsAssoc ? json_encode($entity->generatedDocumentsAssoc) : ''), 'extraInfo' => ($entity->extraInfo ? json_encode($entity->extraInfo) : ''), 'idUser' => $entity->idUser, 'idOffice' => $entity->idOffice, 'idIssueUser' => $entity->idIssueUser, 'issueTime' => ( $entity->issueTime ? \Engine\DateTime::createFromTimestamp($entity->issueTime)->formatDatetimeIso() : null ), 'voidReason' => $entity->voidReason, 'idVoidUser' => $entity->idVoidUser, 'voidTime' => ( $entity->voidTime ? \Engine\DateTime::createFromTimestamp($entity->voidTime)->formatDatetimeIso() : null ), 'idBlockUser' => $entity->idBlockUser, 'blockTime' => ( $entity->blockTime ? \Engine\DateTime::createFromTimestamp($entity->blockTime)->formatDatetimeIso() : null ), 'idAddUser' => $entity->idAddUser, 'addTime' => \Engine\DateTime::createFromTimestamp($entity->addTime)->formatDatetimeIso(), 'idUpdateUser' => $entity->idUpdateUser, 'lastUpdateTime' => ( $entity->lastUpdateTime ? \Engine\DateTime::createFromTimestamp($entity->lastUpdateTime)->formatDatetimeIso() : null ), 'updatesCount' => $entity->updatesCount, ]; $this->addPopulatingReference('ClientInvoice', $entity->idInvoice); if ($entity->idImportedDoc) { $this->addPopulatingReference('ImportedDocument', $entity->idImportedDoc); } return $return; } } 