Files
exchange-2.0/app/Classes/Modules/Rules/Standards/Rules/CanPassTINRule.php
T

56 lines
1.2 KiB
PHP

<?php
namespace App\Classes\Modules\Rules\Standards\Rules;
use App\Classes\Exceptions\CriteriaNotFulfilledException;
use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\Modules\Companies\Services\FetchesCompany;
class CanPassTINRule extends AbstractRule
{
/** @var FetchesCompany */
private $fetchesCompany;
/**
* CanPassTINRule constructor.
* @param FetchesCompany $fetchesCompany
*/
public function __construct(FetchesCompany $fetchesCompany)
{
$this->fetchesCompany = $fetchesCompany;
}
/**
* @return bool
*/
protected function authorized($object): bool
{
return true;
}
/**
* @return bool
*/
protected function validators($object): bool
{
return true;
}
/**
* @return bool
*/
protected function criteria($object): bool
{
//Check if TIN already provided if account requires E-Invoice
$company = $this->fetchesCompany->execute(['id' => $object->companyId]);
if($company->e_invoice === 1 && !$company->tin){
throw new CriteriaNotFulfilledException("Please provide all requested E-Invoice Info.");
}
return true;
}
}