diff --git a/app/Http/ValidationRules/Credit/ValidInvoiceCreditRule.php b/app/Http/ValidationRules/Credit/ValidInvoiceCreditRule.php index aad6133c3f..f42937eb0b 100644 --- a/app/Http/ValidationRules/Credit/ValidInvoiceCreditRule.php +++ b/app/Http/ValidationRules/Credit/ValidInvoiceCreditRule.php @@ -50,7 +50,15 @@ class ValidInvoiceCreditRule implements Rule { $invoice = Invoice::withTrashed()->find($value); - if ($invoice->balance >= $invoice->amount) { + if(!$invoice){ + + $this->error_message = 'Invoice not found.'; + + return false; + + } + + elseif ($invoice->balance >= $invoice->amount) { $this->error_message = 'Cannot reverse an invoice with no payment applied.'; return false; diff --git a/app/Import/Transformer/BaseTransformer.php b/app/Import/Transformer/BaseTransformer.php index d2b6e6294c..2a2e0e04e0 100644 --- a/app/Import/Transformer/BaseTransformer.php +++ b/app/Import/Transformer/BaseTransformer.php @@ -242,6 +242,18 @@ class BaseTransformer } } + $is_free_hosted_client = $this->company->account->isFreeHostedClient(); + $hosted_client_count = $this->company->account->hosted_client_count; + + if ($is_free_hosted_client && ($this->company->clients()->count() > $hosted_client_count)) { + $this->error_array['invoice'][] = [ + 'invoice' => '', + 'error' => "Error, you are attempting to import more clients than your plan allows ({$hosted_client_count})", + ]; + + throw new \App\Import\ImportException("Error, you are attempting to import more clients than your plan allows ({$hosted_client_count})"); + } + $client_repository = app()->make(ClientRepository::class); $client_repository->import_mode = true; diff --git a/app/Livewire/CreditsTable.php b/app/Livewire/CreditsTable.php index dcdafa45a8..ed31a848b9 100644 --- a/app/Livewire/CreditsTable.php +++ b/app/Livewire/CreditsTable.php @@ -34,6 +34,12 @@ class CreditsTable extends Component { MultiDB::setDb($this->db); + + $this->sort_asc = false; + + $this->sort_field = 'date'; + + } public function render() diff --git a/app/Livewire/InvoicesTable.php b/app/Livewire/InvoicesTable.php index 006300a354..8fe27a607b 100644 --- a/app/Livewire/InvoicesTable.php +++ b/app/Livewire/InvoicesTable.php @@ -55,7 +55,7 @@ class InvoicesTable extends Component $q->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . ($this->sort_asc ? 'desc' : 'asc')); }) ->when($this->sort_field != 'number', function ($q){ - $q->orderBy($this->sort_field, ($this->sort_asc ? 'desc' : 'asc')); + $q->orderBy($this->sort_field, ($this->sort_asc ? 'asc' : 'desc')); }); // ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc'); diff --git a/app/Livewire/PaymentsTable.php b/app/Livewire/PaymentsTable.php index b13d08469a..197c736d5b 100644 --- a/app/Livewire/PaymentsTable.php +++ b/app/Livewire/PaymentsTable.php @@ -33,6 +33,10 @@ class PaymentsTable extends Component public function mount() { MultiDB::setDb($this->db); + + $this->sort_asc = false; + + $this->sort_field = 'date'; } public function render() diff --git a/app/Livewire/QuotesTable.php b/app/Livewire/QuotesTable.php index 4317928708..0c2d31ca29 100644 --- a/app/Livewire/QuotesTable.php +++ b/app/Livewire/QuotesTable.php @@ -37,6 +37,10 @@ class QuotesTable extends Component public function mount() { MultiDB::setDb($this->db); + + $this->sort_asc = false; + + $this->sort_field = 'date'; } @@ -55,10 +59,10 @@ class QuotesTable extends Component ->with('client.contacts', 'company') // ->orderBy($this->sort, $this->sort_asc ? 'asc' : 'desc'); ->when($this->sort == 'number', function ($q){ - $q->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . ($this->sort_asc ? 'desc' : 'asc')); + $q->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . ($this->sort_asc ? 'asc' : 'desc')); }) ->when($this->sort != 'number', function ($q){ - $q->orderBy($this->sort, ($this->sort_asc ? 'desc' : 'asc')); + $q->orderBy($this->sort, ($this->sort_asc ? 'asc' : 'desc')); }); diff --git a/app/Livewire/TasksTable.php b/app/Livewire/TasksTable.php index 1528cfc7c6..0dafaf372b 100644 --- a/app/Livewire/TasksTable.php +++ b/app/Livewire/TasksTable.php @@ -32,6 +32,9 @@ class TasksTable extends Component public function mount() { MultiDB::setDb($this->db); + + $this->sort_asc = false; + } public function render() diff --git a/app/PaymentDrivers/Rotessa/Jobs/TransactionReport.php b/app/PaymentDrivers/Rotessa/Jobs/TransactionReport.php index 1e843cdb74..516a966601 100644 --- a/app/PaymentDrivers/Rotessa/Jobs/TransactionReport.php +++ b/app/PaymentDrivers/Rotessa/Jobs/TransactionReport.php @@ -138,14 +138,17 @@ class TransactionReport implements ShouldQueue $error ); - SystemLogger::dispatch( - ['response' => collect($transactions)->where('id', $payment->transaction_reference)->first()->toArray(), 'data' => []], - SystemLog::CATEGORY_GATEWAY_RESPONSE, - SystemLog::EVENT_GATEWAY_FAILURE, - SystemLog::TYPE_ROTESSA, - $payment->client, - $payment->company, - ); + if(collect($transactions)->where('id', $payment->transaction_reference)->first()) + { + SystemLogger::dispatch( + ['response' => collect($transactions)->where('id', $payment->transaction_reference)->first()->toArray(), 'data' => []], + SystemLog::CATEGORY_GATEWAY_RESPONSE, + SystemLog::EVENT_GATEWAY_FAILURE, + SystemLog::TYPE_ROTESSA, + $payment->client, + $payment->company, + ); + } }); }