mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Set credit payments for subscriptions
This commit is contained in:
parent
079889a711
commit
c7fe3c8824
@ -149,12 +149,18 @@ class PaymentController extends Controller
|
||||
$payment = $payment->service()->applyCredits($payment_hash)->save();
|
||||
|
||||
$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($payment_hash->invoices(), 'invoice_id')));
|
||||
|
||||
$invoices->each(function ($i){
|
||||
$i->is_proforma = false;
|
||||
$i->saveQuietly();
|
||||
});
|
||||
|
||||
event('eloquent.created: App\Models\Payment', $payment);
|
||||
|
||||
if($invoices->sum('balance') > 0){
|
||||
|
||||
$invoice = $invoices->first();
|
||||
$invoice->service()->touchPdf(true);
|
||||
|
||||
return redirect()->route('client.invoice.show', ['invoice' => $invoice->hashed_id, 'hash' => $request->input('hash')]);
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ class InvoicesTable extends Component
|
||||
$query = Invoice::query()
|
||||
->where('company_id', $this->company->id)
|
||||
->where('is_deleted', false)
|
||||
->where('is_proforma', false)
|
||||
->with('client.gateway_tokens', 'client.contacts')
|
||||
->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc');
|
||||
|
||||
|
@ -193,7 +193,7 @@ class InstantPayment
|
||||
$payment_method_id = $this->request->input('payment_method_id');
|
||||
$invoice_totals = $payable_invoices->sum('amount');
|
||||
$first_invoice = $invoices->first();
|
||||
$credit_totals = $first_invoice->client->getSetting('use_credits_payment') == 'always' ? $first_invoice->client->service()->getCreditBalance() : 0;
|
||||
$credit_totals = in_array($first_invoice->client->getSetting('use_credits_payment'), ['always', 'option']) ? $first_invoice->client->service()->getCreditBalance() : 0;
|
||||
$starting_invoice_amount = $first_invoice->balance;
|
||||
|
||||
/* Schedule a job to check the gateway fees for this invoice*/
|
||||
@ -297,7 +297,7 @@ class InstantPayment
|
||||
}
|
||||
|
||||
public function processCreditPayment(Request $request, array $data)
|
||||
{
|
||||
{
|
||||
return render('gateways.credit.index', $data);
|
||||
}
|
||||
}
|
||||
|
@ -271,11 +271,6 @@ class CreditService
|
||||
|
||||
public function restoreCredit()
|
||||
{
|
||||
// $this->credit->payments()->each(function ($payment){
|
||||
|
||||
// $payment->pivot->update(['deleted_at' => null]);
|
||||
|
||||
// });
|
||||
|
||||
$this->credit
|
||||
->client
|
||||
|
Loading…
x
Reference in New Issue
Block a user