2021-06-24 13:52:49 +03:00
|
|
|
<?php
|
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
namespace App\Abstracts\View\Components\Transactions;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
use App\Abstracts\View\Component;
|
2021-06-24 13:52:49 +03:00
|
|
|
use App\Models\Common\Media;
|
|
|
|
use App\Traits\DateTime;
|
|
|
|
use App\Traits\Transactions;
|
|
|
|
use App\Utilities\Modules;
|
2022-06-01 10:15:55 +03:00
|
|
|
use Illuminate\Support\Facades\File;
|
2021-06-24 13:52:49 +03:00
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
use Illuminate\Support\Str;
|
2022-06-01 10:15:55 +03:00
|
|
|
use Intervention\Image\Facades\Image;
|
|
|
|
use Intervention\Image\Exception\NotReadableException;
|
|
|
|
use App\Traits\ViewComponents;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
abstract class Template extends Component
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2022-06-01 10:15:55 +03:00
|
|
|
use DateTime, Transactions, ViewComponents;
|
|
|
|
|
|
|
|
public const OBJECT_TYPE = 'transaction';
|
|
|
|
public const DEFAULT_TYPE = 'transaction';
|
|
|
|
public const DEFAULT_PLURAL_TYPE = 'transactions';
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var string */
|
2021-06-24 13:52:49 +03:00
|
|
|
public $type;
|
|
|
|
|
|
|
|
public $transaction;
|
|
|
|
|
|
|
|
public $logo;
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var array */
|
|
|
|
public $payment_methods;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hideCompany;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
2021-06-24 13:52:49 +03:00
|
|
|
public $hideCompanyLogo;
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
2021-06-24 13:52:49 +03:00
|
|
|
public $hideCompanyDetails;
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
2021-06-24 13:52:49 +03:00
|
|
|
public $hideCompanyName;
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
2021-06-24 13:52:49 +03:00
|
|
|
public $hideCompanyAddress;
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
2021-06-24 13:52:49 +03:00
|
|
|
public $hideCompanyTaxNumber;
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
2021-06-24 13:52:49 +03:00
|
|
|
public $hideCompanyPhone;
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
2021-06-24 13:52:49 +03:00
|
|
|
public $hideCompanyEmail;
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hideContentTitle;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hideNumber;
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hidePaidAt;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hideAccount;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hideCategory;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hidePaymentMethods;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hideReference;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hideDescription;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hideAmount;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var string */
|
|
|
|
public $textContentTitle;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
/** @var string */
|
|
|
|
public $textNumber;
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var string */
|
|
|
|
public $textPaidAt;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
/** @var string */
|
2021-06-25 08:45:00 +03:00
|
|
|
public $textAccount;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
/** @var string */
|
2021-06-25 08:45:00 +03:00
|
|
|
public $textCategory;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var string */
|
|
|
|
public $textPaymentMethods;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
/** @var string */
|
2021-06-25 08:45:00 +03:00
|
|
|
public $textReference;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
/** @var string */
|
2021-06-25 08:45:00 +03:00
|
|
|
public $textDescription;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
/** @var string */
|
2021-06-25 08:45:00 +03:00
|
|
|
public $textAmount;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
/** @var string */
|
2021-06-25 08:45:00 +03:00
|
|
|
public $textPaidBy;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-12-01 13:22:24 +00:00
|
|
|
/** @var string */
|
|
|
|
public $textContactInfo;
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hideContact;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hideContactInfo;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hideContactName;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hideContactAddress;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hideContactTaxNumber;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hideContactPhone;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $hideContactEmail;
|
|
|
|
|
|
|
|
/** @var bool */
|
2021-11-22 23:09:01 +03:00
|
|
|
public $hideRelated;
|
2021-06-25 08:45:00 +03:00
|
|
|
|
|
|
|
/** @var bool */
|
2021-11-22 23:09:01 +03:00
|
|
|
public $hideRelatedDocumentNumber;
|
2021-06-25 08:45:00 +03:00
|
|
|
|
|
|
|
/** @var bool */
|
2021-11-22 23:09:01 +03:00
|
|
|
public $hideRelatedContact;
|
2021-06-25 08:45:00 +03:00
|
|
|
|
|
|
|
/** @var bool */
|
2021-11-22 23:09:01 +03:00
|
|
|
public $hideRelatedDocumentDate;
|
2021-06-25 08:45:00 +03:00
|
|
|
|
|
|
|
/** @var bool */
|
2021-11-22 23:09:01 +03:00
|
|
|
public $hideRelatedDocumentAmount;
|
2021-06-25 08:45:00 +03:00
|
|
|
|
|
|
|
/** @var bool */
|
2021-11-22 23:09:01 +03:00
|
|
|
public $hideRelatedAmount;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
/** @var string */
|
2021-11-22 23:09:01 +03:00
|
|
|
public $textRelatedTransansaction;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
/** @var string */
|
2021-11-22 23:09:01 +03:00
|
|
|
public $textRelatedDocumentNumber;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
/** @var string */
|
2021-11-22 23:09:01 +03:00
|
|
|
public $textRelatedContact;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
/** @var string */
|
2021-11-22 23:09:01 +03:00
|
|
|
public $textRelatedDocumentDate;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var string */
|
2021-11-22 23:09:01 +03:00
|
|
|
public $textRelatedDocumentAmount;
|
2021-06-25 08:45:00 +03:00
|
|
|
|
|
|
|
/** @var string */
|
2021-11-22 23:09:01 +03:00
|
|
|
public $textRelatedAmount;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
/** @var string */
|
|
|
|
public $routeDocumentShow;
|
2021-06-25 09:44:30 +03:00
|
|
|
|
2021-06-24 13:52:49 +03:00
|
|
|
/**
|
|
|
|
* Create a new component instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct(
|
2021-06-25 08:45:00 +03:00
|
|
|
$type, $transaction, $logo = '', array $payment_methods = [],
|
2021-12-01 13:22:24 +00:00
|
|
|
bool $hideCompany = false, bool $hideCompanyLogo = false, bool $hideCompanyDetails = false, bool $hideCompanyName = false, bool $hideCompanyAddress = false,
|
2021-06-25 08:45:00 +03:00
|
|
|
bool $hideCompanyTaxNumber = false, bool $hideCompanyPhone = false, bool $hideCompanyEmail = false,
|
2022-06-01 10:15:55 +03:00
|
|
|
bool $hideContentTitle = false, bool $hideNumber = false, bool $hidePaidAt = false, bool $hideAccount = false, bool $hideCategory = false, bool $hidePaymentMethods = false, bool $hideReference = false,
|
|
|
|
bool $hideDescription = false, bool $hideAmount = false,
|
|
|
|
string $textContentTitle = '', string $textNumber = '', string $textPaidAt = '', string $textAccount = '', string $textCategory = '', string $textPaymentMethods = '', string $textReference = '',
|
|
|
|
string $textDescription = '', string $textAmount = '', string $textPaidBy = '', string $textContactInfo = '',
|
2021-06-25 08:45:00 +03:00
|
|
|
bool $hideContact = false, bool $hideContactInfo = false, bool $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false,
|
|
|
|
bool $hideContactPhone = false, bool $hideContactEmail = false,
|
2021-11-22 23:09:01 +03:00
|
|
|
bool $hideRelated = false, bool $hideRelatedDocumentNumber = false, bool $hideRelatedContact = false, bool $hideRelatedDocumentDate = false, bool $hideRelatedDocumentAmount = false, bool $hideRelatedAmount = false,
|
|
|
|
string $textRelatedTransansaction = '', string $textRelatedDocumentNumber = '', string $textRelatedContact = '', string $textRelatedDocumentDate = '', string $textRelatedDocumentAmount = '', string $textRelatedAmount = '',
|
2021-06-25 08:45:00 +03:00
|
|
|
string $routeDocumentShow = ''
|
|
|
|
) {
|
2021-06-24 13:52:49 +03:00
|
|
|
$this->type = $type;
|
|
|
|
$this->transaction = $transaction;
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
$this->logo = $this->getLogo($logo);
|
2021-06-27 12:59:56 +03:00
|
|
|
$this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods('all');
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
// Company Information Hide checker
|
|
|
|
$this->hideCompany = $hideCompany;
|
2021-06-24 13:52:49 +03:00
|
|
|
$this->hideCompanyLogo = $hideCompanyLogo;
|
|
|
|
$this->hideCompanyDetails = $hideCompanyDetails;
|
|
|
|
$this->hideCompanyName = $hideCompanyName;
|
|
|
|
$this->hideCompanyAddress = $hideCompanyAddress;
|
|
|
|
$this->hideCompanyTaxNumber = $hideCompanyTaxNumber;
|
|
|
|
$this->hideCompanyPhone = $hideCompanyPhone;
|
|
|
|
$this->hideCompanyEmail = $hideCompanyEmail;
|
2021-06-25 08:45:00 +03:00
|
|
|
|
|
|
|
// Transaction Information Hide checker
|
|
|
|
$this->hideContentTitle = $hideContentTitle;
|
2022-06-01 10:15:55 +03:00
|
|
|
$this->hideNumber = $hideNumber;
|
2021-06-25 08:45:00 +03:00
|
|
|
$this->hidePaidAt = $hidePaidAt;
|
|
|
|
$this->hideAccount = $hideAccount;
|
|
|
|
$this->hideCategory = $hideCategory;
|
|
|
|
$this->hidePaymentMethods = $hidePaymentMethods;
|
|
|
|
$this->hideReference = $hideReference;
|
|
|
|
$this->hideDescription = $hideDescription;
|
|
|
|
$this->hideAmount = $hideAmount;
|
|
|
|
|
|
|
|
// Transaction Information Text
|
|
|
|
$this->textContentTitle = $this->getTextContentTitle($type, $textContentTitle);
|
2022-06-01 10:15:55 +03:00
|
|
|
$this->textNumber = $this->getTextNumber($type, $textNumber);
|
2021-06-25 08:45:00 +03:00
|
|
|
$this->textPaidAt = $this->getTextPaidAt($type, $textPaidAt);
|
|
|
|
$this->textAccount = $this->getTextAccount($type, $textAccount);
|
|
|
|
$this->textCategory = $this->getTextCategory($type, $textCategory);
|
|
|
|
$this->textPaymentMethods = $this->getTextPaymentMethods($type, $textPaymentMethods);
|
|
|
|
$this->textReference = $this->getTextReference($type, $textReference);
|
|
|
|
$this->textDescription = $this->getTextDescription($type, $textDescription);
|
|
|
|
$this->textAmount = $this->getTextAmount($type, $textAmount);
|
|
|
|
$this->textPaidBy = $this->getTextPaidBy($type, $textPaidBy);
|
2021-12-01 13:22:24 +00:00
|
|
|
$this->textContactInfo = $this->getTextContactInfo($type, $textContactInfo);
|
2021-06-25 08:45:00 +03:00
|
|
|
|
|
|
|
// Contact Information Hide checker
|
|
|
|
$this->hideContact = $hideContact;
|
2021-06-24 13:52:49 +03:00
|
|
|
$this->hideContactInfo = $hideContactInfo;
|
|
|
|
$this->hideContactName = $hideContactName;
|
|
|
|
$this->hideContactAddress = $hideContactAddress;
|
|
|
|
$this->hideContactTaxNumber = $hideContactTaxNumber;
|
|
|
|
$this->hideContactPhone = $hideContactPhone;
|
|
|
|
$this->hideContactEmail = $hideContactEmail;
|
|
|
|
|
2021-11-22 23:09:01 +03:00
|
|
|
// Related Information Hide checker
|
|
|
|
$this->hideRelated = $hideRelated;
|
|
|
|
$this->hideRelatedDocumentNumber = $hideRelatedDocumentNumber;
|
|
|
|
$this->hideRelatedContact = $hideRelatedContact;
|
|
|
|
$this->hideRelatedDocumentDate = $hideRelatedDocumentDate;
|
|
|
|
$this->hideRelatedDocumentAmount = $hideRelatedDocumentAmount;
|
|
|
|
$this->hideRelatedAmount = $hideRelatedAmount;
|
|
|
|
|
|
|
|
// Related Information Text
|
|
|
|
$this->textRelatedTransansaction = $this->getTextRelatedTransansaction($type, $textRelatedTransansaction);
|
|
|
|
$this->textRelatedDocumentNumber = $this->getTextRelatedDocumentNumber($type, $textRelatedDocumentNumber);
|
|
|
|
$this->textRelatedContact = $this->getTextRelatedContact($type, $textRelatedContact);
|
|
|
|
$this->textRelatedDocumentDate = $this->getTextRelatedDocumentDate($type, $textRelatedDocumentDate);
|
|
|
|
$this->textRelatedDocumentAmount = $this->getTextRelatedDocumentAmount($type, $textRelatedDocumentAmount);
|
|
|
|
$this->textRelatedAmount = $this->getTextRelatedAmount($type, $textRelatedAmount);
|
2021-06-25 08:45:00 +03:00
|
|
|
|
|
|
|
$this->routeDocumentShow = $this->routeDocumentShow($type, $routeDocumentShow);
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getLogo($logo)
|
|
|
|
{
|
|
|
|
if (!empty($logo)) {
|
|
|
|
return $logo;
|
|
|
|
}
|
|
|
|
|
2021-06-27 18:06:36 +03:00
|
|
|
$media_id = (!empty($this->transaction->contact->logo) && !empty($this->transaction->contact->logo->id)) ? $this->transaction->contact->logo->id : setting('company.logo');
|
|
|
|
|
|
|
|
$media = Media::find($media_id);
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
if (!empty($media)) {
|
|
|
|
$path = $media->getDiskPath();
|
|
|
|
|
2023-02-16 16:43:12 +03:00
|
|
|
if (! $media->fileExists()) {
|
2021-06-24 13:52:49 +03:00
|
|
|
return $logo;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$path = base_path('public/img/company.png');
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
$image = Image::cache(function($image) use ($media, $path) {
|
|
|
|
$width = setting('invoice.logo_size_width');
|
|
|
|
$height = setting('invoice.logo_size_height');
|
|
|
|
|
|
|
|
if ($media) {
|
2023-02-16 16:43:12 +03:00
|
|
|
$image->make($media->contents())->resize($width, $height)->encode();
|
2021-06-24 13:52:49 +03:00
|
|
|
} else {
|
|
|
|
$image->make($path)->resize($width, $height)->encode();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (NotReadableException | \Exception $e) {
|
|
|
|
Log::info('Company ID: ' . company_id() . ' components/transactionshow.php exception.');
|
|
|
|
Log::info($e->getMessage());
|
|
|
|
|
|
|
|
$path = base_path('public/img/company.png');
|
|
|
|
|
|
|
|
$image = Image::cache(function($image) use ($path) {
|
|
|
|
$width = setting('invoice.logo_size_width');
|
|
|
|
$height = setting('invoice.logo_size_height');
|
|
|
|
|
|
|
|
$image->make($path)->resize($width, $height)->encode();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($image)) {
|
|
|
|
return $logo;
|
|
|
|
}
|
|
|
|
|
|
|
|
$extension = File::extension($path);
|
|
|
|
|
|
|
|
return 'data:image/' . $extension . ';base64,' . base64_encode($image);
|
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
protected function getTextContentTitle($type, $textContentTitle)
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2021-06-25 08:45:00 +03:00
|
|
|
if (!empty($textContentTitle)) {
|
|
|
|
return $textContentTitle;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-27 10:15:39 +03:00
|
|
|
switch ($type) {
|
|
|
|
case 'bill':
|
|
|
|
case 'expense':
|
|
|
|
case 'purchase':
|
|
|
|
$default_key = 'payment_made';
|
|
|
|
break;
|
|
|
|
default:
|
2022-06-01 10:15:55 +03:00
|
|
|
$default_key = 'receipts';
|
2021-06-27 10:15:39 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$translation = $this->getTextFromConfig($type, $type . '_made', $default_key);
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
if (!empty($translation)) {
|
2021-06-25 08:45:00 +03:00
|
|
|
return $translation;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
return 'general.receipts';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTextNumber($type, $textNumber)
|
|
|
|
{
|
|
|
|
if (!empty($textNumber)) {
|
|
|
|
return $textNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'general.numbers';
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
protected function getTextPaidAt($type, $textPaidAt)
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2021-06-25 08:45:00 +03:00
|
|
|
if (!empty($textPaidAt)) {
|
|
|
|
return $textPaidAt;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
$translation = $this->getTextFromConfig($type, 'paid_at', 'date');
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
if (!empty($translation)) {
|
2021-06-25 08:45:00 +03:00
|
|
|
return $translation;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
return 'general.date';
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
protected function getTextAccount($type, $textAccount)
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2021-06-25 08:45:00 +03:00
|
|
|
if (!empty($textAccount)) {
|
|
|
|
return $textAccount;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
$translation = $this->getTextFromConfig($type, 'accounts', 'accounts', 'trans_choice');
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
return 'general.accounts';
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
protected function getTextCategory($type, $textCategory)
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2021-06-25 08:45:00 +03:00
|
|
|
if (!empty($textCategory)) {
|
|
|
|
return $textCategory;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
$translation = $this->getTextFromConfig($type, 'categories', 'categories', 'trans_choice');
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
return 'general.categories';
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
protected function getTextPaymentMethods($type, $textPaymentMethods)
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2021-06-25 08:45:00 +03:00
|
|
|
if (!empty($textPaymentMethods)) {
|
|
|
|
return $textPaymentMethods;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
$translation = $this->getTextFromConfig($type, 'payment_methods', 'payment_methods', 'trans_choice');
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
return 'general.payment_methods';
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
protected function getTextReference($type, $textReference)
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2021-06-25 08:45:00 +03:00
|
|
|
if (!empty($textReference)) {
|
|
|
|
return $textReference;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
$translation = $this->getTextFromConfig($type, 'reference', 'reference');
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
return 'general.reference';
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
protected function getTextDescription($type, $textDescription)
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2021-06-25 08:45:00 +03:00
|
|
|
if (!empty($textDescription)) {
|
|
|
|
return $textDescription;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
$translation = $this->getTextFromConfig($type, 'description', 'description');
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
return 'general.description';
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
protected function getTextAmount($type, $textAmount)
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2021-06-25 08:45:00 +03:00
|
|
|
if (!empty($textAmount)) {
|
|
|
|
return $textAmount;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
$translation = $this->getTextFromConfig($type, 'amount', 'amount');
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
return 'general.amount';
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
protected function getTextPaidBy($type, $textPaidBy)
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2021-06-25 08:45:00 +03:00
|
|
|
if (!empty($textPaidBy)) {
|
|
|
|
return $textPaidBy;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-27 10:15:39 +03:00
|
|
|
switch ($type) {
|
|
|
|
case 'bill':
|
|
|
|
case 'expense':
|
|
|
|
case 'purchase':
|
|
|
|
$default_key = 'paid_to';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$default_key = 'paid_by';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$translation = $this->getTextFromConfig($type, 'paid_to_by', $default_key);
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
|
|
|
}
|
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
return 'transactions.paid_by';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTextContactInfo($type, $textContactInfo)
|
|
|
|
{
|
|
|
|
if (!empty($textContactInfo)) {
|
|
|
|
return $textContactInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ($type) {
|
|
|
|
case 'bill':
|
|
|
|
case 'expense':
|
|
|
|
case 'purchase':
|
|
|
|
$textContactInfo = 'bills.bill_from';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$textContactInfo = 'invoices.bill_to';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $textContactInfo;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-11-22 23:09:01 +03:00
|
|
|
protected function getTextRelatedTransansaction($type, $textRelatedTransansaction)
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2021-11-22 23:09:01 +03:00
|
|
|
if (!empty($textRelatedTransansaction)) {
|
|
|
|
return $textRelatedTransansaction;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-27 10:15:39 +03:00
|
|
|
switch ($type) {
|
|
|
|
case 'bill':
|
|
|
|
case 'expense':
|
|
|
|
case 'purchase':
|
|
|
|
$default_key = 'related_bill';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$default_key = 'related_invoice';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$translation = $this->getTextFromConfig($type, 'related_type', $default_key);
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
|
|
|
}
|
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
return 'transactions.related_invoice';
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-11-22 23:09:01 +03:00
|
|
|
protected function getTextRelatedDocumentNumber($type, $textRelatedDocumentNumber)
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2021-11-22 23:09:01 +03:00
|
|
|
if (!empty($textRelatedDocumentNumber)) {
|
|
|
|
return $textRelatedDocumentNumber;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
$translation = $this->getTextFromConfig($type, 'related_document_number', 'numbers');
|
2021-06-24 13:52:49 +03:00
|
|
|
|
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
return 'general.numbers';
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-11-22 23:09:01 +03:00
|
|
|
protected function getTextRelatedContact($type, $textRelatedContact)
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2021-11-22 23:09:01 +03:00
|
|
|
if (!empty($textRelatedContact)) {
|
|
|
|
return $textRelatedContact;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
$default_key = Str::plural(config('type.transaction.' . $type . '.contact_type'), 2);
|
2021-06-27 10:15:39 +03:00
|
|
|
|
|
|
|
$translation = $this->getTextFromConfig($type, 'related_contact', $default_key, 'trans_choice');
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
return 'general.customers';
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-11-22 23:09:01 +03:00
|
|
|
protected function getTextRelatedDocumentDate($type, $textRelatedDocumentDate)
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2021-11-22 23:09:01 +03:00
|
|
|
if (!empty($textRelatedDocumentDate)) {
|
|
|
|
return $textRelatedDocumentDate;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-27 10:15:39 +03:00
|
|
|
switch ($type) {
|
|
|
|
case 'bill':
|
|
|
|
case 'expense':
|
|
|
|
case 'purchase':
|
|
|
|
$default_key = 'bill_date';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$default_key = 'invoice_date';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$translation = $this->getTextFromConfig($type, 'related_document_date', $default_key);
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
return 'invoices.invoice_date';
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-11-22 23:09:01 +03:00
|
|
|
protected function getTextRelatedDocumentAmount($type, $textRelatedDocumentAmount)
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2021-11-22 23:09:01 +03:00
|
|
|
if (!empty($textRelatedDocumentAmount)) {
|
|
|
|
return $textRelatedDocumentAmount;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-27 10:15:39 +03:00
|
|
|
switch ($type) {
|
|
|
|
case 'bill':
|
|
|
|
case 'expense':
|
|
|
|
case 'purchase':
|
|
|
|
$default_key = 'bill_amount';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$default_key = 'invoice_amount';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$translation = $this->getTextFromConfig($type, 'related_document_amount', $default_key);
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
return 'general.amount';
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-11-22 23:09:01 +03:00
|
|
|
protected function getTextRelatedAmount($type, $textRelatedAmount)
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2021-11-22 23:09:01 +03:00
|
|
|
if (!empty($textRelatedAmount)) {
|
|
|
|
return $textRelatedAmount;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
$translation = $this->getTextFromConfig($type, 'related_amount', 'amount');
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
return 'general.amount';
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
protected function routeDocumentShow($type, $routeDocumentShow)
|
2021-06-24 13:52:49 +03:00
|
|
|
{
|
2021-06-25 08:45:00 +03:00
|
|
|
if (!empty($routeDocumentShow)) {
|
|
|
|
return $routeDocumentShow;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
if (!$this->transaction->document) {
|
|
|
|
return $routeDocumentShow;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
//example route parameter.
|
|
|
|
$parameter = 1;
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
$route = $this->getRouteFromConfig($this->transaction->document->type, 'show', $parameter);
|
2021-06-24 13:52:49 +03:00
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
if (!empty($route)) {
|
|
|
|
return $route;
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
|
2021-06-25 08:45:00 +03:00
|
|
|
return 'invoices.show';
|
2021-06-24 13:52:49 +03:00
|
|
|
}
|
|
|
|
}
|