1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Fixes for signature dates

This commit is contained in:
David Bomba 2023-07-26 12:18:00 +10:00
parent 150badae05
commit 85de0be560
4 changed files with 31 additions and 9 deletions

View File

@ -185,7 +185,7 @@ class QuoteController extends Controller
$quote->service()->approve(auth()->user())->save();
if (request()->has('signature') && ! is_null(request()->signature) && ! empty(request()->signature)) {
InjectSignature::dispatch($quote, request()->signature);
InjectSignature::dispatch($quote, auth()->guard('contact')->user()->id, request()->signature);
}
}

View File

@ -186,8 +186,7 @@ class PurchaseOrderController extends Controller
->save();
if (request()->has('signature') && ! is_null(request()->signature) && ! empty(request()->signature)) {
(new InjectSignature($purchase_order, request()->signature))->handle();
// InjectSignature::dispatch($purchase_order, request()->signature);
(new InjectSignature($purchase_order, auth()->guard('vendor')->user()->id, request()->signature))->handle();
}
event(new PurchaseOrderWasAccepted($purchase_order, auth()->guard('vendor')->user(), $purchase_order->company, Ninja::eventVars()));

View File

@ -2,11 +2,12 @@
namespace App\Jobs\Invoice;
use App\Models\PurchaseOrder;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class InjectSignature implements ShouldQueue
{
@ -22,16 +23,20 @@ class InjectSignature implements ShouldQueue
*/
public $signature;
public $contact_id;
/**
* Create a new job instance.
*
* @param $entity
* @param string $signature
*/
public function __construct($entity, string $signature)
public function __construct($entity, $contact_id, string $signature)
{
$this->entity = $entity;
$this->contact_id = $contact_id;
$this->signature = $signature;
}
@ -42,8 +47,23 @@ class InjectSignature implements ShouldQueue
*/
public function handle()
{
$invitation = $this->entity->invitations->whereNotNull('signature_base64')->first();
$invitation = false;
if($this->entity instanceof PurchaseOrder){
$invitation = $this->entity->invitations()->where('vendor_contact_id', $this->contact_id)->first();
if(!$invitation)
$invitation = $this->entity->invitations->first();
}
else {
$invitation = $this->entity->invitations()->where('client_contact_id', $this->contact_id)->first();
if(!$invitation)
$invitation = $this->entity->invitations->first();
}
if (! $invitation) {
return;
}

View File

@ -175,8 +175,11 @@ class InstantPayment
}
if ($this->request->has('signature') && ! is_null($this->request->signature) && ! empty($this->request->signature)) {
$invoices->each(function ($invoice) {
InjectSignature::dispatch($invoice, $this->request->signature);
$contact_id = auth()->guard('contact')->user() ? auth()->guard('contact')->user()->id : null;
$invoices->each(function ($invoice) use($contact_id) {
InjectSignature::dispatch($invoice, $contact_id, $this->request->signature);
});
}