mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 19:24:42 -04:00
Set most recent payment method as default
This commit is contained in:
parent
0138d8d246
commit
bff5b627fd
@ -132,7 +132,7 @@ class PaymentMethodController extends Controller
|
||||
public function destroy(ClientGatewayToken $payment_method)
|
||||
{
|
||||
/** @var \App\Models\ClientContact auth()->user() **/
|
||||
$client_contact = auth()->user();
|
||||
$client_contact = auth()->guard('contact')->user();
|
||||
|
||||
if ($payment_method->gateway()->exists()) {
|
||||
$payment_method->gateway
|
||||
@ -145,9 +145,19 @@ class PaymentMethodController extends Controller
|
||||
event(new MethodDeleted($payment_method, auth()->guard('contact')->user()->company, Ninja::eventVars(auth()->guard('contact')->user()->id)));
|
||||
|
||||
$payment_method->is_deleted = true;
|
||||
$payment_method->is_default = false;
|
||||
$payment_method->delete();
|
||||
$payment_method->save();
|
||||
|
||||
|
||||
$def_cgt = auth()->guard('contact')->user()->client->gateway_tokens()->orderBy('id','desc')->first();
|
||||
|
||||
if($def_cgt)
|
||||
{
|
||||
$def_cgt->is_default = true;
|
||||
$def_cgt->save();
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
|
||||
|
@ -515,7 +515,7 @@ class BaseDriver extends AbstractPaymentDriver
|
||||
|
||||
$cgt->save();
|
||||
|
||||
if ($this->client->gateway_tokens->count() == 1) {
|
||||
if ($this->client->gateway_tokens->count() > 1) {
|
||||
$this->client->gateway_tokens()->update(['is_default' => 0]);
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,7 @@ class BaseRepository
|
||||
try{
|
||||
$model->service()->getEInvoice();
|
||||
}
|
||||
catch(\Exception $e){
|
||||
catch(\Throwable $e){
|
||||
nlog("EXCEPTION:: BASEREPOSITORY:: Error generating e_invoice for model {$model->id}");
|
||||
nlog($e->getMessage());
|
||||
}
|
||||
|
@ -348,10 +348,11 @@ class Storecove
|
||||
private function httpClient(string $uri, string $verb, array $data, ?array $headers = [])
|
||||
{
|
||||
|
||||
$r = Http::withToken(config('ninja.storecove_api_key'));
|
||||
|
||||
try {
|
||||
$r = Http::withToken(config('ninja.storecove_api_key'))
|
||||
->withHeaders($this->getHeaders($headers))
|
||||
->{$verb}("{$this->base_url}{$uri}", $data)->throw();
|
||||
$r->withHeaders($this->getHeaders($headers))
|
||||
->{$verb}("{$this->base_url}{$uri}", $data)->throw();
|
||||
}
|
||||
catch (ClientException $e) {
|
||||
// 4xx errors
|
||||
|
@ -1278,7 +1278,7 @@ class Peppol extends AbstractService
|
||||
private function checkRequired(bool $required, string $section): self
|
||||
{
|
||||
|
||||
return $required ? throw new \Exception("e-invoice generation halted:: {$section} required") : $this;
|
||||
return $required ? throw new \Exception("e-invoice generation halted:: {$section} required", 400) : $this;
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user