diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index fbe7c386..26911fe6 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -56,6 +56,7 @@ public function share(Request $request) ]); }, 'locale' => app()->getLocale(), + 'settings' => $team ? $team->settings->mapWithKeys(fn ($setting) => [$setting['name'] => $setting['value']]) : [], 'accountDetailTypes' => AccountDetailType::all(), 'trialEndsAt' => $team ? $team->trial_ends_at : null, 'unreadNotifications' => function () use ($user) { diff --git a/resources/js/app.js b/resources/js/app.js index f1dce721..442a6461 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -38,6 +38,11 @@ createInertiaApp({ legacy: false, }) + window.logerAppSettings = { + currency_code: props.initialPage.props.settings?.team_primary_currency_code ?? 'USD', + date_format: props.initialPage.props.settings?.team_date_format, + } + const t = (...param) => i18n.global.t(...param) window.t = t diff --git a/resources/js/domains/budget/components/BudgetBalanceAssign.vue b/resources/js/domains/budget/components/BudgetBalanceAssign.vue index 1b8911d3..71c0f227 100644 --- a/resources/js/domains/budget/components/BudgetBalanceAssign.vue +++ b/resources/js/domains/budget/components/BudgetBalanceAssign.vue @@ -104,7 +104,7 @@ [field]: props.category.id, source_category_id: data.source_category_id?.value, 'type': 'movement', - date: format(new Date(), 'yyyy-MM-dd') + date: format(startOfMonth(pageState?.dates?.endDate), 'yyyy-MM-dd') })).post(`/budgets/${props.category.id}/months/${month}`, { onSuccess() { router.reload({ diff --git a/resources/js/utils/formatMoney.ts b/resources/js/utils/formatMoney.ts index 2d182081..db9bd277 100644 --- a/resources/js/utils/formatMoney.ts +++ b/resources/js/utils/formatMoney.ts @@ -1,8 +1,9 @@ -export const formatMoney = (value, symbol = "DOP") => { +export const formatMoney = (value, symbol = null) => { + const defaultSymbol = symbol ?? window?.logerAppSettings?.currency_code ?? 'DOP'; try { return new Intl.NumberFormat("en-US", { style: "currency", - currency: symbol, + currency: defaultSymbol, currencyDisplay: "symbol" }).format(Number(value) || 0); } catch (err) {