diff --git a/app/Http/Controllers/ClientPortal/SubscriptionPurchaseController.php b/app/Http/Controllers/ClientPortal/SubscriptionPurchaseController.php index b8d8f1fe395c..e5007a607d98 100644 --- a/app/Http/Controllers/ClientPortal/SubscriptionPurchaseController.php +++ b/app/Http/Controllers/ClientPortal/SubscriptionPurchaseController.php @@ -23,6 +23,8 @@ class SubscriptionPurchaseController extends Controller { public function index(Subscription $subscription, Request $request) { + App::setLocale($subscription->company->locale()); + /* Make sure the contact is logged into the correct company for this subscription */ if (auth()->guard('contact')->user() && auth()->guard('contact')->user()->company_id != $subscription->company_id) { auth()->guard('contact')->logout(); @@ -42,6 +44,9 @@ class SubscriptionPurchaseController extends Controller public function upgrade(Subscription $subscription, Request $request) { + + App::setLocale($subscription->company->locale()); + /* Make sure the contact is logged into the correct company for this subscription */ if (auth()->guard('contact')->user() && auth()->guard('contact')->user()->company_id != $subscription->company_id) { auth()->guard('contact')->logout(); diff --git a/app/Http/Livewire/BillingPortalPurchasev2.php b/app/Http/Livewire/BillingPortalPurchasev2.php index ae9c980d082c..f37475836c92 100644 --- a/app/Http/Livewire/BillingPortalPurchasev2.php +++ b/app/Http/Livewire/BillingPortalPurchasev2.php @@ -271,6 +271,10 @@ class BillingPortalPurchasev2 extends Component */ public function handleCoupon() { + + $this->resetErrorBag('coupon'); + $this->resetValidation('coupon'); + if ($this->coupon == $this->subscription->promo_code) { $this->valid_coupon = true; $this->buildBundle(); @@ -278,6 +282,9 @@ class BillingPortalPurchasev2 extends Component $this->discount = 0; $this->valid_coupon = false; $this->buildBundle(); + $errors = $this->getErrorBag(); + $errors->add('coupon', ctrans('texts.invalid_coupon')); + return $this; } } diff --git a/app/Http/Livewire/SubscriptionsTable.php b/app/Http/Livewire/SubscriptionsTable.php index dc4744b250ab..f05c07f4b7df 100644 --- a/app/Http/Livewire/SubscriptionsTable.php +++ b/app/Http/Livewire/SubscriptionsTable.php @@ -39,9 +39,9 @@ class SubscriptionsTable extends Component ->where('company_id', $this->company->id) ->whereNotNull('subscription_id') ->where('is_deleted', false) - ->where('status_id', RecurringInvoice::STATUS_ACTIVE) - ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc') + ->whereIn('status_id', [RecurringInvoice::STATUS_ACTIVE, RecurringInvoice::STATUS_PAUSED]) ->withTrashed() + ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc') ->paginate($this->per_page); return render('components.livewire.subscriptions-table', [ diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index 4487a381e6af..a2d4927a6ebd 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -13,7 +13,6 @@ namespace App\Services\PdfMaker; use App\Models\Credit; -use App\Models\Invoice; use App\Models\Quote; use App\Services\PdfMaker\Designs\Utilities\BaseDesign; use App\Services\PdfMaker\Designs\Utilities\DesignHelpers; diff --git a/app/Utils/Number.php b/app/Utils/Number.php index 3451ab6dd0c5..76dccb6f0a34 100644 --- a/app/Utils/Number.php +++ b/app/Utils/Number.php @@ -201,6 +201,8 @@ class Number public static function formatMoneyNoRounding($value, $entity) :string { $currency = $entity->currency(); + + $_value = $value; $thousand = $currency->thousand_separator; $decimal = $currency->decimal_separator; @@ -247,6 +249,12 @@ class Number } elseif ($swapSymbol) { return "{$value} ".trim($symbol); } elseif ($entity->getSetting('show_currency_code') === false) { + + if ($_value < 0) { + $value = substr($value, 1); + $symbol = "-{$symbol}"; + } + return "{$symbol}{$value}"; } else { return self::formatValue($value, $currency); diff --git a/lang/en/texts.php b/lang/en/texts.php index 18fa7cc2195a..c9ec4d4daa47 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -5010,6 +5010,7 @@ $LANG = array( 'change_plan_description' => 'Upgrade or downgrade your current plan.', 'add_company_logo' => 'Add Logo', 'add_stripe' => 'Add Stripe', + 'invalid_coupon' => 'Invalid Coupon', ); diff --git a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php index 2adb5cfcf1e4..81346b33798c 100644 --- a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php @@ -253,6 +253,14 @@ {{ ctrans('texts.apply') }} + @if($errors && $errors->has('coupon')) + @error("coupon") +
+ + {{ ctrans('texts.status') }} + + |
{{ ctrans('texts.subscription') }} @@ -47,6 +52,9 @@ |
---|---|
+ {!! $recurring_invoice->badgeForStatus($recurring_invoice->status_id) !!} + | {{ $recurring_invoice->subscription->name }} |