Fix exchange rate parity across all document types

- Fix exchange-rate service types to match actual backend response shapes
  (exchangeRate array, activeProvider success/error, used currencies as strings)
- Add ExchangeRateConverter to payments, expenses, and recurring invoices
- Set currency_id from customer currency in invoice/estimate selectCustomer()
- Load globalStore.currencies in ExchangeRateConverter on mount
- Pass driver/key/driver_config params to getSupportedCurrencies in provider modal
- Fix OpenExchangeRateDriver validateConnection to use base=USD (free plan compat)
- Fix checkActiveCurrencies SQLite whereJsonContains with array values
- Remove broken currency/companyCurrency props from ExpenseCreateView, use stores
- Show base currency equivalent in document line items and totals when exchange
  rate is active
This commit is contained in:
Darko Gjorgjijoski
2026-04-06 21:07:50 +02:00
parent e64529468c
commit b0b7d40c73
12 changed files with 213 additions and 54 deletions

View File

@@ -217,12 +217,20 @@
<BaseFormatMoney :amount="store.getTotal" :currency="defaultCurrency" />
</label>
</div>
<!-- Base currency equivalent -->
<div v-if="showBaseCurrencyEquivalent" class="flex items-center justify-end w-full mt-1">
<label class="text-xs text-muted">
<BaseFormatMoney :amount="baseCurrencyGrandTotal" :currency="companyCurrency" />
</label>
</div>
</div>
</template>
<script setup lang="ts">
import { computed, ref, watch } from 'vue'
import TaxSelectPopup from './TaxSelectPopup.vue'
import { useCompanyStore } from '../../../stores/company.store'
import { generateClientId } from '../../../utils'
import type { Currency } from '../../../types/domain/currency'
import type { TaxType } from '../../../types/domain/tax'
@@ -245,6 +253,7 @@ const props = withDefaults(defineProps<Props>(), {
isLoading: false,
})
const companyStore = useCompanyStore()
const taxModal = ref<HTMLElement | null>(null)
const formData = computed<DocumentFormData>(() => {
@@ -263,6 +272,17 @@ const defaultCurrencySymbol = computed<string>(() => {
return (curr?.symbol as string) ?? '$'
})
const companyCurrency = computed(() => companyStore.selectedCompanyCurrency)
const showBaseCurrencyEquivalent = computed<boolean>(() => {
return !!(formData.value.exchange_rate && (props.store as Record<string, unknown>).showExchangeRate)
})
const baseCurrencyGrandTotal = computed<number>(() => {
if (!formData.value.exchange_rate) return 0
return Math.round(props.store.getTotal * Number(formData.value.exchange_rate))
})
watch(
() => formData.value.items,
() => setDiscount(),