mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 17:24:36 -04:00
Prevent deleted invoice from being paid
This commit is contained in:
parent
7b5cd9e4c1
commit
2a97fc5456
@ -70,7 +70,7 @@ class OnlinePaymentController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
if ( ! floatval($invitation->invoice->balance)) {
|
||||
if ( ! $invitation->invoice->canBePaid()) {
|
||||
return redirect()->to('view/' . $invitation->invitation_key);
|
||||
}
|
||||
|
||||
@ -103,6 +103,10 @@ class OnlinePaymentController extends BaseController
|
||||
$gatewayTypeId = Session::get($invitation->id . 'gateway_type');
|
||||
$paymentDriver = $invitation->account->paymentDriver($invitation, $gatewayTypeId);
|
||||
|
||||
if ( ! $invitation->invoice->canBePaid()) {
|
||||
return redirect()->to('view/' . $invitation->invitation_key);
|
||||
}
|
||||
|
||||
try {
|
||||
$paymentDriver->completeOnsitePurchase($request->all());
|
||||
|
||||
|
@ -514,6 +514,11 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
return storage_path() . '/pdfcache/cache-' . $this->id . '.pdf';
|
||||
}
|
||||
|
||||
public function canBePaid()
|
||||
{
|
||||
return floatval($this->balance) > 0 && ! $this->is_deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice
|
||||
* @return string
|
||||
|
Loading…
x
Reference in New Issue
Block a user