diff --git a/app/Models/ClientContact.php b/app/Models/ClientContact.php index 05f1c7392b86..9607bb24361f 100644 --- a/app/Models/ClientContact.php +++ b/app/Models/ClientContact.php @@ -92,7 +92,7 @@ class ClientContact extends Authenticatable implements HasLocalePreference 'custom_value4', 'email', 'is_primary', - // 'client_id', + 'send_email', ]; /** diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index 2f62dbc6ccf3..cf37b1d3f141 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -113,25 +113,26 @@ class BaseRepository * @param $action * * @return int + * @deprecated - this doesn't appear to be used anywhere? */ - public function bulk($ids, $action) - { - if (! $ids) { - return 0; - } + // public function bulk($ids, $action) + // { + // if (! $ids) { + // return 0; + // } - $ids = $this->transformKeys($ids); + // $ids = $this->transformKeys($ids); - $entities = $this->findByPublicIdsWithTrashed($ids); + // $entities = $this->findByPublicIdsWithTrashed($ids); - foreach ($entities as $entity) { - if (auth()->user()->can('edit', $entity)) { - $this->$action($entity); - } - } + // foreach ($entities as $entity) { + // if (auth()->user()->can('edit', $entity)) { + // $this->$action($entity); + // } + // } - return count($entities); - } + // return count($entities); + // } /* Returns an invoice if defined as a key in the $resource array*/ public function getInvitation($invitation, $resource) diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index ed02b1e366b5..45d0ab893a13 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -134,9 +134,9 @@ class InvoiceService * * @return InvoiceService Parent class object */ - public function updateBalance($balance_adjustment) + public function updateBalance($balance_adjustment, bool $is_draft = false) { - $this->invoice = (new UpdateBalance($this->invoice, $balance_adjustment))->run(); + $this->invoice = (new UpdateBalance($this->invoice, $balance_adjustment, $is_draft))->run(); if ((int)$this->invoice->balance == 0) { $this->invoice->next_send_date = null; diff --git a/app/Services/Invoice/MarkSent.php b/app/Services/Invoice/MarkSent.php index fbf874f9558b..a205b83dd047 100644 --- a/app/Services/Invoice/MarkSent.php +++ b/app/Services/Invoice/MarkSent.php @@ -47,7 +47,7 @@ class MarkSent extends AbstractService ->service() ->applyNumber() ->setDueDate() - ->updateBalance($this->invoice->amount) + ->updateBalance($this->invoice->amount, true) ->deletePdf() ->setReminder() ->save(); diff --git a/app/Services/Invoice/UpdateBalance.php b/app/Services/Invoice/UpdateBalance.php index 9a95391abbf5..0aab1c2e8c69 100644 --- a/app/Services/Invoice/UpdateBalance.php +++ b/app/Services/Invoice/UpdateBalance.php @@ -20,10 +20,13 @@ class UpdateBalance extends AbstractService public $balance_adjustment; - public function __construct($invoice, $balance_adjustment) + private $is_draft; + + public function __construct($invoice, $balance_adjustment, bool $is_draft) { $this->invoice = $invoice; $this->balance_adjustment = $balance_adjustment; + $this->is_draft = $is_draft; } public function run() @@ -34,7 +37,7 @@ class UpdateBalance extends AbstractService $this->invoice->balance += floatval($this->balance_adjustment); - if ($this->invoice->balance == 0) { + if ($this->invoice->balance == 0 && !$this->is_draft) { $this->invoice->status_id = Invoice::STATUS_PAID; }