From 8f0316a2ec2517c74b0ee29c704a3a9ffbe24430 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 28 Aug 2022 11:08:15 +1000 Subject: [PATCH] Improve Check Data --- app/Console/Commands/CheckData.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index 80ff44a1329f..e993454c2d4c 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -114,7 +114,8 @@ class CheckData extends Command $this->checkEntityInvitations(); $this->checkCompanyData(); $this->checkBalanceVsPaidStatus(); - + $this->checkDuplicateRecurringInvoices(); + if(Ninja::isHosted()) $this->checkAccountStatuses(); @@ -145,6 +146,23 @@ class CheckData extends Command $this->log .= $str."\n"; } + private function checkDuplicateRecurringInvoices() + { + + if(Ninja::isHosted()) + { + $c = Client::on('db-ninja-01')->where('company_id', config('ninja.ninja_default_company_id')) + ->with('recurring_invoices') + ->cursor() + ->each(function ($client){ + if($client->recurring_invoices()->where('is_deleted', 0)->where('deleted_at', null)->count() > 1) + $this->logMessage("Duplicate Recurring Invoice => {$client->custom_value1}"); + }); + } + + } + + private function checkOAuth() { // check for duplicate oauth ids