65 lines
1.2 KiB
PHP
65 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* Created by Pensare Software.
|
|
* User: Theo Weijmer
|
|
* Date: 10/06/2018
|
|
* Time: 17:06
|
|
*/
|
|
|
|
class RemoveVat {
|
|
|
|
private $vatID;
|
|
private $projects;
|
|
private $invoices;
|
|
private $removeAllowed;
|
|
|
|
public function __construct( $vatID )
|
|
{
|
|
$this->setVatID( $vatID );
|
|
|
|
$this->handle();
|
|
}
|
|
|
|
public function getRemoveAllowed()
|
|
{
|
|
return $this->removeAllowed;
|
|
}
|
|
|
|
private function setVatID( $vatID )
|
|
{
|
|
$this->vatID = $vatID;
|
|
}
|
|
|
|
private function handle()
|
|
{
|
|
$this->setProject();
|
|
|
|
$this->setInvoices();
|
|
|
|
$this->setRemoveAllowed();
|
|
}
|
|
|
|
private function setProject()
|
|
{
|
|
$projects = Project::whereVatId( $this->vatID );
|
|
|
|
$this->projects = $projects->count() == 0 ? TRUE : FALSE;
|
|
}
|
|
|
|
private function setInvoices()
|
|
{
|
|
$invoices = Invoice::whereVatId( $this->vatID );
|
|
|
|
$this->invoices = $invoices->count() == 0 ? TRUE : FALSE;
|
|
}
|
|
|
|
private function setRemoveAllowed()
|
|
{
|
|
if ( $this->projects === FALSE ) return $this->removeAllowed = FALSE;
|
|
|
|
if ( $this->invoices === FALSE ) return $this->removeAllowed = FALSE;
|
|
|
|
$this->removeAllowed = TRUE;
|
|
}
|
|
|
|
} |