diff --git a/resources/scripts/admin/stores/company.js b/resources/scripts/admin/stores/company.js index 1e10489b..f5462ae0 100644 --- a/resources/scripts/admin/stores/company.js +++ b/resources/scripts/admin/stores/company.js @@ -184,6 +184,20 @@ export const useCompanyStore = (useWindow = false) => { setDefaultCurrency(data) { this.defaultCurrency = data.currency }, + + checkCompanyHasCurrencyTransactions() { + return new Promise((resolve, reject) => { + axios + .get(`/api/v1/company/has-transactions`) + .then((response) => { + resolve(response) + }) + .catch((err) => { + handleError(err) + reject(err) + }) + }) + }, }, })() } diff --git a/resources/scripts/admin/views/settings/PreferencesSetting.vue b/resources/scripts/admin/views/settings/PreferencesSetting.vue index 6c46f645..531cb83d 100644 --- a/resources/scripts/admin/views/settings/PreferencesSetting.vue +++ b/resources/scripts/admin/views/settings/PreferencesSetting.vue @@ -8,7 +8,11 @@ @@ -21,7 +25,7 @@ :searchable="true" track-by="name" :invalid="v$.currency.$error" - disabled + :disabled="isCurrencyDisabled" class="w-full" > @@ -187,6 +191,7 @@ const { t, tm } = useI18n() let isSaving = ref(false) let isDataSaving = ref(false) let isFetchingInitialData = ref(false) +let isCurrencyDisabled = ref(true) const settingsForm = reactive({ ...companyStore.selectedCompanySettings }) @@ -282,10 +287,14 @@ setInitialData() async function setInitialData() { isFetchingInitialData.value = true Promise.all([ + companyStore.checkCompanyHasCurrencyTransactions(), globalStore.fetchCurrencies(), globalStore.fetchDateFormats(), globalStore.fetchTimeZones(), ]).then(([res1]) => { + if (res1.data?.has_transactions == false) { + isCurrencyDisabled.value = false + } isFetchingInitialData.value = false }) }