Allow archived invoices to be paid.

This commit is contained in:
David Bomba 2021-06-20 08:14:56 +10:00
parent 0772c05e66
commit 5535ce8faf
4 changed files with 4 additions and 3 deletions

View File

@ -89,6 +89,7 @@ class InvoiceController extends Controller
{ {
$invoices = Invoice::whereIn('id', $ids) $invoices = Invoice::whereIn('id', $ids)
->whereClientId(auth()->user()->client->id) ->whereClientId(auth()->user()->client->id)
->withTrashed()
->get(); ->get();
//filter invoices which are payable //filter invoices which are payable

View File

@ -95,7 +95,7 @@ class PaymentController extends Controller
*/ */
$payable_invoices = collect($request->payable_invoices); $payable_invoices = collect($request->payable_invoices);
$invoices = Invoice::whereIn('id', $this->transformKeys($payable_invoices->pluck('invoice_id')->toArray()))->get(); $invoices = Invoice::whereIn('id', $this->transformKeys($payable_invoices->pluck('invoice_id')->toArray()))->withTrashed()->get();
$invoices->each(function($invoice){ $invoices->each(function($invoice){
$invoice->service()->removeUnpaidGatewayFees()->save(); $invoice->service()->removeUnpaidGatewayFees()->save();

View File

@ -188,7 +188,7 @@ class BaseDriver extends AbstractPaymentDriver
public function attachInvoices(Payment $payment, PaymentHash $payment_hash): Payment public function attachInvoices(Payment $payment, PaymentHash $payment_hash): Payment
{ {
$paid_invoices = $payment_hash->invoices(); $paid_invoices = $payment_hash->invoices();
$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($paid_invoices, 'invoice_id')))->get(); $invoices = Invoice::whereIn('id', $this->transformKeys(array_column($paid_invoices, 'invoice_id')))->withTrashed()->get();
$payment->invoices()->sync($invoices); $payment->invoices()->sync($invoices);
$invoices->each(function ($invoice) use ($payment) { $invoices->each(function ($invoice) use ($payment) {

View File

@ -37,7 +37,7 @@ class UpdateInvoicePayment
{ {
$paid_invoices = $this->payment_hash->invoices(); $paid_invoices = $this->payment_hash->invoices();
$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($paid_invoices, 'invoice_id')))->get(); $invoices = Invoice::whereIn('id', $this->transformKeys(array_column($paid_invoices, 'invoice_id')))->withTrashed()->get();
collect($paid_invoices)->each(function ($paid_invoice) use ($invoices) { collect($paid_invoices)->each(function ($paid_invoice) use ($invoices) {