mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 19:51:09 -04:00
change company currency if it does not have any transaction.
This commit is contained in:
@ -184,6 +184,20 @@ export const useCompanyStore = (useWindow = false) => {
|
|||||||
setDefaultCurrency(data) {
|
setDefaultCurrency(data) {
|
||||||
this.defaultCurrency = data.currency
|
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)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})()
|
})()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,11 @@
|
|||||||
<BaseInputGroup
|
<BaseInputGroup
|
||||||
:content-loading="isFetchingInitialData"
|
:content-loading="isFetchingInitialData"
|
||||||
:label="$tc('settings.preferences.currency')"
|
:label="$tc('settings.preferences.currency')"
|
||||||
:help-text="$t('settings.preferences.company_currency_unchangeable')"
|
:help-text="
|
||||||
|
isCurrencyDisabled
|
||||||
|
? $t('settings.preferences.company_currency_unchangeable')
|
||||||
|
: ''
|
||||||
|
"
|
||||||
:error="v$.currency.$error && v$.currency.$errors[0].$message"
|
:error="v$.currency.$error && v$.currency.$errors[0].$message"
|
||||||
required
|
required
|
||||||
>
|
>
|
||||||
@ -21,7 +25,7 @@
|
|||||||
:searchable="true"
|
:searchable="true"
|
||||||
track-by="name"
|
track-by="name"
|
||||||
:invalid="v$.currency.$error"
|
:invalid="v$.currency.$error"
|
||||||
disabled
|
:disabled="isCurrencyDisabled"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
>
|
>
|
||||||
</BaseMultiselect>
|
</BaseMultiselect>
|
||||||
@ -187,6 +191,7 @@ const { t, tm } = useI18n()
|
|||||||
let isSaving = ref(false)
|
let isSaving = ref(false)
|
||||||
let isDataSaving = ref(false)
|
let isDataSaving = ref(false)
|
||||||
let isFetchingInitialData = ref(false)
|
let isFetchingInitialData = ref(false)
|
||||||
|
let isCurrencyDisabled = ref(true)
|
||||||
|
|
||||||
const settingsForm = reactive({ ...companyStore.selectedCompanySettings })
|
const settingsForm = reactive({ ...companyStore.selectedCompanySettings })
|
||||||
|
|
||||||
@ -282,10 +287,14 @@ setInitialData()
|
|||||||
async function setInitialData() {
|
async function setInitialData() {
|
||||||
isFetchingInitialData.value = true
|
isFetchingInitialData.value = true
|
||||||
Promise.all([
|
Promise.all([
|
||||||
|
companyStore.checkCompanyHasCurrencyTransactions(),
|
||||||
globalStore.fetchCurrencies(),
|
globalStore.fetchCurrencies(),
|
||||||
globalStore.fetchDateFormats(),
|
globalStore.fetchDateFormats(),
|
||||||
globalStore.fetchTimeZones(),
|
globalStore.fetchTimeZones(),
|
||||||
]).then(([res1]) => {
|
]).then(([res1]) => {
|
||||||
|
if (res1.data?.has_transactions == false) {
|
||||||
|
isCurrencyDisabled.value = false
|
||||||
|
}
|
||||||
isFetchingInitialData.value = false
|
isFetchingInitialData.value = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user