Merge pull request #10832 from turbo124/v5-develop

Adjustments for import +/- create client logic
This commit is contained in:
David Bomba 2025-03-31 19:11:36 +11:00 committed by GitHub
commit fc1389a43f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 52 additions and 12 deletions

View File

@ -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;

View File

@ -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;

View File

@ -34,6 +34,12 @@ class CreditsTable extends Component
{
MultiDB::setDb($this->db);
$this->sort_asc = false;
$this->sort_field = 'date';
}
public function render()

View File

@ -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');

View File

@ -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()

View File

@ -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'));
});

View File

@ -32,6 +32,9 @@ class TasksTable extends Component
public function mount()
{
MultiDB::setDb($this->db);
$this->sort_asc = false;
}
public function render()

View File

@ -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,
);
}
});
}