From 9638e02eb8ff05158fe7e66c90b1ee9ec81e65f5 Mon Sep 17 00:00:00 2001 From: Darko Gjorgjijoski Date: Mon, 6 Apr 2026 23:37:56 +0200 Subject: [PATCH] Fix customer portal not reflecting company default currency The customer portal bootstrap now returns current_company_currency alongside the customer's own currency. The store falls back to the company currency when the customer has no currency assigned. Fixes #142 --- .../Controllers/CustomerPortal/General/BootstrapController.php | 3 +++ resources/scripts-v2/features/customer-portal/store.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/CustomerPortal/General/BootstrapController.php b/app/Http/Controllers/CustomerPortal/General/BootstrapController.php index 115b5d0b..657c2d78 100644 --- a/app/Http/Controllers/CustomerPortal/General/BootstrapController.php +++ b/app/Http/Controllers/CustomerPortal/General/BootstrapController.php @@ -31,10 +31,13 @@ class BootstrapController extends Controller } } + $companyCurrencyId = CompanySetting::getSetting('currency', $customer->company_id); + return (new CustomerResource($customer)) ->additional(['meta' => [ 'menu' => $menu, 'current_customer_currency' => Currency::find($customer->currency_id), + 'current_company_currency' => $companyCurrencyId ? Currency::find($companyCurrencyId) : null, 'modules' => Module::where('enabled', true)->pluck('name'), 'current_company_language' => CompanySetting::getSetting('language', $customer->company_id), ]]); diff --git a/resources/scripts-v2/features/customer-portal/store.ts b/resources/scripts-v2/features/customer-portal/store.ts index e7028efa..35130264 100644 --- a/resources/scripts-v2/features/customer-portal/store.ts +++ b/resources/scripts-v2/features/customer-portal/store.ts @@ -77,6 +77,7 @@ export interface CustomerPortalBootstrapMeta { menu: CustomerPortalMenuItem[] modules: string[] current_customer_currency?: Currency | null + current_company_currency?: Currency | null current_company_language?: string } @@ -280,7 +281,7 @@ export const useCustomerPortalStore = defineStore('customerPortal', { this.currentUser = data.data this.mainMenu = data.meta.menu ?? [] - this.currency = data.data.currency ?? data.meta.current_customer_currency ?? null + this.currency = data.data.currency ?? data.meta.current_customer_currency ?? data.meta.current_company_currency ?? null this.enabledModules = data.meta.modules ?? [] this.currentCompanyLanguage = data.meta.current_company_language ?? 'en' this.userForm = hydrateUserForm(data.data)