Minor fixes for subscriptions

This commit is contained in:
David Bomba 2021-10-22 10:55:58 +11:00
parent b915cc32c3
commit b92f16bfe5
5 changed files with 13 additions and 9 deletions

View File

@ -39,7 +39,6 @@ class NinjaPlanController extends Controller
else
$account = $company->account;
if (MultiDB::findAndSetDbByContactKey($contact_key) && $client_contact = ClientContact::where('contact_key', $contact_key)->first())
{
@ -49,7 +48,7 @@ class NinjaPlanController extends Controller
/* Current paid users get pushed straight to subscription overview page*/
if($account->isPaidHostedClient())
return redirect('/client/subscriptions');
return redirect('/client/dashboard');
/* Users that are not paid get pushed to a custom purchase page */
return $this->render('subscriptions.ninja_plan', ['settings' => $client_contact->company->settings]);

View File

@ -51,7 +51,7 @@ class PaymentType extends StaticModel
const PRZELEWY24 = 40;
const EPS = 41;
const DIRECT_DEBIT = 42;
` const BECS = 43;
const BECS = 43;
const ACSS = 44;
public static function parseCardType($cardName)

View File

@ -39,7 +39,7 @@ class MarkPaid extends AbstractService
public function run()
{
if ($this->invoice->status_id == Invoice::STATUS_DRAFT) {
$this->invoice->service()->markSent();
$this->invoice->service()->markSent()->save();
}
/*Don't double pay*/
@ -77,14 +77,16 @@ class MarkPaid extends AbstractService
$this->invoice->next_send_date = null;
$this->invoice->service()
$this->invoice
->service()
->setExchangeRate()
->updateBalance($payment->amount * -1)
->updatePaidToDate($payment->amount)
->setStatus(Invoice::STATUS_PAID)
->save();
$this->invoice->service()
$this->invoice
->service()
->applyNumber()
->deletePdf()
->save();

View File

@ -223,6 +223,7 @@ class SubscriptionService
->first();
}
if ($outstanding->count() == 0){
//nothing outstanding
return $target->price - $this->calculateProRataRefundForSubscription($outstanding_invoice);
@ -426,6 +427,8 @@ class SubscriptionService
nlog("total payable = {$total_payable}");
/* Only generate a credit if the previous invoice was paid in full. */
if($last_invoice->balance == 0)
$credit = $this->createCredit($last_invoice, $target_subscription, $is_credit);
$new_recurring_invoice = $this->createNewRecurringInvoice($recurring_invoice);
@ -575,7 +578,7 @@ class SubscriptionService
$old_recurring_invoice->service()->stop()->save();
$recurring_invoice_repo = new RecurringInvoiceRepository();
$recurring_invoice_repo->archive($old_recurring_invoice);
$recurring_invoice_repo->delete($old_recurring_invoice);
$recurring_invoice = $this->convertInvoiceToRecurring($old_recurring_invoice->client_id);
$recurring_invoice = $recurring_invoice_repo->save([], $recurring_invoice);

View File

@ -6,7 +6,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddStripePaymentsToPaymentTypes extends Migration
class StripePaymentGateways extends Migration
{
/**
* Run the migrations.