diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index 87a327350a9f..59fcfaf0c6f2 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -23,6 +23,7 @@ use App\Utils\Helpers; use App\Utils\Ninja; use App\Utils\Traits\MakesHash; use App\Utils\Traits\SavesDocuments; +use Google\Service\Vision\Property; use ReflectionClass; class BaseRepository @@ -185,15 +186,17 @@ class BaseRepository if(!$model->id){ $this->new_model = true; - - $model->line_items = (collect($model->line_items))->map(function ($item) use($model,$client) { - $item->notes = Helpers::processReservedKeywords($item->notes, $client); + if(is_array($model->line_items)) + { + $model->line_items = (collect($model->line_items))->map(function ($item) use($model,$client) { - return $item; + $item->notes = Helpers::processReservedKeywords($item->notes, $client); - }); + return $item; + }); + } } $model->saveQuietly(); diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index bb76f66b62ef..19586b19d779 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -218,6 +218,7 @@ class InvoiceService public function markDeleted() { $this->removeUnpaidGatewayFees(); + $this->deletePdf(); $this->invoice = (new MarkInvoiceDeleted($this->invoice))->run(); @@ -298,6 +299,9 @@ class InvoiceService } elseif ($this->invoice->balance > 0 && $this->invoice->balance < $this->invoice->amount) { $this->setStatus(Invoice::STATUS_PARTIAL); } + elseif($this->invoice->balance < 0) { + $this->setStatus(Invoice::STATUS_PARTIAL); + } return $this; } diff --git a/app/Services/Invoice/MarkInvoiceDeleted.php b/app/Services/Invoice/MarkInvoiceDeleted.php index b7478f920133..96c03ac92b77 100644 --- a/app/Services/Invoice/MarkInvoiceDeleted.php +++ b/app/Services/Invoice/MarkInvoiceDeleted.php @@ -71,10 +71,6 @@ class MarkInvoiceDeleted extends AbstractService private function adjustPaidToDateAndBalance() { - // $client = $this->invoice->client->fresh(); - // $client->paid_to_date += $this->adjustment_amount * -1; - // $client->balance += $this->balance_adjustment * -1; - // $client->save(); // 06-09-2022 $this->invoice diff --git a/app/Utils/Traits/ClientGroupSettingsSaver.php b/app/Utils/Traits/ClientGroupSettingsSaver.php index 585b42ee8e99..67c2b6a774b3 100644 --- a/app/Utils/Traits/ClientGroupSettingsSaver.php +++ b/app/Utils/Traits/ClientGroupSettingsSaver.php @@ -65,7 +65,17 @@ trait ClientGroupSettingsSaver } $entity->settings = $entity_settings; - $entity->save(); + + try{ + $entity->save(); + } + catch(\Exception $e){ + + nlog("client settings failure"); + nlog($entity_settings); + nlog($e->getMessage()); + + } return $entity_settings; }