From af8a788dfb975cddeab6a8ec290d243730e1abe2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 16 Jul 2023 16:36:52 +1000 Subject: [PATCH] Updates for deleting activities when purging clients --- app/Models/Client.php | 5 +++++ app/Repositories/ClientRepository.php | 2 +- app/Services/Payment/DeletePayment.php | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Models/Client.php b/app/Models/Client.php index acd034b9643c..5896488cce73 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -347,6 +347,11 @@ class Client extends BaseModel implements HasLocalePreference return $this->hasMany(Credit::class)->withTrashed(); } + public function purgeable_activities() + { + return $this->hasMany(Activity::class); + } + public function activities() { return $this->hasMany(Activity::class)->take(50)->orderBy('id', 'desc'); diff --git a/app/Repositories/ClientRepository.php b/app/Repositories/ClientRepository.php index ec324ef6934d..f9abbd6fa88b 100644 --- a/app/Repositories/ClientRepository.php +++ b/app/Repositories/ClientRepository.php @@ -136,7 +136,7 @@ class ClientRepository extends BaseRepository $client->projects()->forceDelete(); $client->credits()->forceDelete(); $client->quotes()->forceDelete(); - $client->activities()->forceDelete(); + $client->purgeable_activities()->forceDelete(); $client->recurring_invoices()->forceDelete(); $client->expenses()->forceDelete(); $client->recurring_expenses()->forceDelete(); diff --git a/app/Services/Payment/DeletePayment.php b/app/Services/Payment/DeletePayment.php index fb50797b64f5..98242ecb8543 100644 --- a/app/Services/Payment/DeletePayment.php +++ b/app/Services/Payment/DeletePayment.php @@ -148,7 +148,7 @@ class DeletePayment $client ->service() - ->updatePaidToDate(($paymentable_credit->pivot->amount) * -1) + // ->updatePaidToDate(($paymentable_credit->pivot->amount) * -1) ->adjustCreditBalance($paymentable_credit->pivot->amount) ->save(); });