Prevent marking delete invoice as sent

This commit is contained in:
Hillel Coren 2017-07-04 12:16:47 +03:00
parent b8e3b7e579
commit c2d2c05c81

View File

@ -448,6 +448,10 @@ class Invoice extends EntityModel implements BalanceAffecting
public function markSent() public function markSent()
{ {
if ($this->is_deleted) {
return;
}
if (! $this->isSent()) { if (! $this->isSent()) {
$this->invoice_status_id = INVOICE_STATUS_SENT; $this->invoice_status_id = INVOICE_STATUS_SENT;
} }
@ -464,6 +468,10 @@ class Invoice extends EntityModel implements BalanceAffecting
*/ */
public function markInvitationsSent($notify = false, $reminder = false) public function markInvitationsSent($notify = false, $reminder = false)
{ {
if ($this->is_deleted) {
return;
}
if (! $this->relationLoaded('invitations')) { if (! $this->relationLoaded('invitations')) {
$this->load('invitations'); $this->load('invitations');
} }
@ -496,6 +504,10 @@ class Invoice extends EntityModel implements BalanceAffecting
*/ */
public function markInvitationSent($invitation, $messageId = false, $notify = true, $notes = false) public function markInvitationSent($invitation, $messageId = false, $notify = true, $notes = false)
{ {
if ($this->is_deleted) {
return;
}
if (! $this->isSent()) { if (! $this->isSent()) {
$this->is_public = true; $this->is_public = true;
$this->invoice_status_id = INVOICE_STATUS_SENT; $this->invoice_status_id = INVOICE_STATUS_SENT;