53 lines
977 B
PHP
53 lines
977 B
PHP
<?php
|
|
/**
|
|
* Created by Pensare Software.
|
|
* User: Theo Weijmer
|
|
* Date: 10/06/2018
|
|
* Time: 17:06
|
|
*/
|
|
|
|
class RemoveInvoice {
|
|
|
|
private $invoiceID;
|
|
private $payments;
|
|
private $removeAllowed;
|
|
|
|
public function __construct( $invoiceID )
|
|
{
|
|
$this->setInvoiceID( $invoiceID );
|
|
|
|
$this->handle();
|
|
}
|
|
|
|
public function getRemoveAllowed()
|
|
{
|
|
return $this->removeAllowed;
|
|
}
|
|
|
|
private function setInvoiceID( $invoiceID )
|
|
{
|
|
$this->invoiceID = $invoiceID;
|
|
}
|
|
|
|
private function handle()
|
|
{
|
|
$this->setPayment();
|
|
|
|
$this->setRemoveAllowed();
|
|
}
|
|
|
|
private function setPayment()
|
|
{
|
|
$payments = Payment::whereInvoiceId( $this->invoiceID );
|
|
|
|
$this->payments = $payments->count() == 0 ? TRUE : FALSE;
|
|
}
|
|
|
|
private function setRemoveAllowed()
|
|
{
|
|
if ( $this->payments === FALSE ) return $this->removeAllowed = FALSE;
|
|
|
|
$this->removeAllowed = TRUE;
|
|
}
|
|
|
|
} |