Merge pull request #10832 from turbo124/v5-develop
Adjustments for import +/- create client logic
This commit is contained in:
commit
fc1389a43f
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,12 @@ class CreditsTable extends Component
|
|||
{
|
||||
MultiDB::setDb($this->db);
|
||||
|
||||
|
||||
$this->sort_asc = false;
|
||||
|
||||
$this->sort_field = 'date';
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ class TasksTable extends Component
|
|||
public function mount()
|
||||
{
|
||||
MultiDB::setDb($this->db);
|
||||
|
||||
$this->sort_asc = false;
|
||||
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue