Update quota when sending einvoice docs
This commit is contained in:
parent
a5094e0537
commit
cee0f7ec95
|
|
@ -95,12 +95,19 @@ class SendEDocument implements ShouldQueue
|
|||
$r = Http::withHeaders([...$this->getHeaders(), 'X-EInvoice-Token' => $model->company->account->e_invoicing_token])
|
||||
->post(config('ninja.hosted_ninja_url')."/api/einvoice/submission", $payload);
|
||||
|
||||
if ($r->hasHeader('X-EINVOICE-QUOTA')) {
|
||||
$account = $model->company->account;
|
||||
|
||||
$account->e_invoice_quota = (int) $r->header('X-EINVOICE-QUOTA');
|
||||
$account->save();
|
||||
}
|
||||
|
||||
if ($r->successful()) {
|
||||
nlog("Model {$model->number} was successfully sent for third party processing via hosted Invoice Ninja");
|
||||
|
||||
$data = $r->json();
|
||||
return $this->writeActivity($model, $data['guid']);
|
||||
|
||||
return $this->writeActivity($model, $data['guid']);
|
||||
}
|
||||
|
||||
if ($r->failed()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue