feat: init
This commit is contained in:
61
app/composables/useVatRates.ts
Normal file
61
app/composables/useVatRates.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
export interface VatRate {
|
||||
country: string
|
||||
code: string
|
||||
flag: string
|
||||
standard: number
|
||||
reduced: number[]
|
||||
}
|
||||
|
||||
const euVatRates: VatRate[] = [
|
||||
{ country: 'Austria', code: 'AT', flag: '\u{1F1E6}\u{1F1F9}', standard: 20, reduced: [10, 13] },
|
||||
{ country: 'Belgium', code: 'BE', flag: '\u{1F1E7}\u{1F1EA}', standard: 21, reduced: [6, 12] },
|
||||
{ country: 'Bulgaria', code: 'BG', flag: '\u{1F1E7}\u{1F1EC}', standard: 20, reduced: [9] },
|
||||
{ country: 'Croatia', code: 'HR', flag: '\u{1F1ED}\u{1F1F7}', standard: 25, reduced: [5, 13] },
|
||||
{ country: 'Cyprus', code: 'CY', flag: '\u{1F1E8}\u{1F1FE}', standard: 19, reduced: [5, 9] },
|
||||
{ country: 'Czech Republic', code: 'CZ', flag: '\u{1F1E8}\u{1F1FF}', standard: 21, reduced: [12, 15] },
|
||||
{ country: 'Denmark', code: 'DK', flag: '\u{1F1E9}\u{1F1F0}', standard: 25, reduced: [] },
|
||||
{ country: 'Estonia', code: 'EE', flag: '\u{1F1EA}\u{1F1EA}', standard: 22, reduced: [9] },
|
||||
{ country: 'Finland', code: 'FI', flag: '\u{1F1EB}\u{1F1EE}', standard: 25.5, reduced: [10, 14] },
|
||||
{ country: 'France', code: 'FR', flag: '\u{1F1EB}\u{1F1F7}', standard: 20, reduced: [5.5, 10] },
|
||||
{ country: 'Germany', code: 'DE', flag: '\u{1F1E9}\u{1F1EA}', standard: 19, reduced: [7] },
|
||||
{ country: 'Greece', code: 'GR', flag: '\u{1F1EC}\u{1F1F7}', standard: 24, reduced: [6, 13] },
|
||||
{ country: 'Hungary', code: 'HU', flag: '\u{1F1ED}\u{1F1FA}', standard: 27, reduced: [5, 18] },
|
||||
{ country: 'Ireland', code: 'IE', flag: '\u{1F1EE}\u{1F1EA}', standard: 23, reduced: [9, 13.5] },
|
||||
{ country: 'Italy', code: 'IT', flag: '\u{1F1EE}\u{1F1F9}', standard: 22, reduced: [5, 10] },
|
||||
{ country: 'Latvia', code: 'LV', flag: '\u{1F1F1}\u{1F1FB}', standard: 21, reduced: [5, 12] },
|
||||
{ country: 'Lithuania', code: 'LT', flag: '\u{1F1F1}\u{1F1F9}', standard: 21, reduced: [5, 9] },
|
||||
{ country: 'Luxembourg', code: 'LU', flag: '\u{1F1F1}\u{1F1FA}', standard: 17, reduced: [8] },
|
||||
{ country: 'Malta', code: 'MT', flag: '\u{1F1F2}\u{1F1F9}', standard: 18, reduced: [5, 7] },
|
||||
{ country: 'Netherlands', code: 'NL', flag: '\u{1F1F3}\u{1F1F1}', standard: 21, reduced: [9] },
|
||||
{ country: 'Poland', code: 'PL', flag: '\u{1F1F5}\u{1F1F1}', standard: 23, reduced: [5, 8] },
|
||||
{ country: 'Portugal', code: 'PT', flag: '\u{1F1F5}\u{1F1F9}', standard: 23, reduced: [6, 13] },
|
||||
{ country: 'Romania', code: 'RO', flag: '\u{1F1F7}\u{1F1F4}', standard: 19, reduced: [5, 9] },
|
||||
{ country: 'Slovakia', code: 'SK', flag: '\u{1F1F8}\u{1F1F0}', standard: 23, reduced: [5, 10] },
|
||||
{ country: 'Slovenia', code: 'SI', flag: '\u{1F1F8}\u{1F1EE}', standard: 22, reduced: [5, 9.5] },
|
||||
{ country: 'Spain', code: 'ES', flag: '\u{1F1EA}\u{1F1F8}', standard: 21, reduced: [4, 10] },
|
||||
{ country: 'Sweden', code: 'SE', flag: '\u{1F1F8}\u{1F1EA}', standard: 25, reduced: [6, 12] },
|
||||
]
|
||||
|
||||
export function useVatRates() {
|
||||
const rates = readonly(ref(euVatRates))
|
||||
|
||||
function getRateByCode(code: string): VatRate | undefined {
|
||||
return euVatRates.find(r => r.code === code.toUpperCase())
|
||||
}
|
||||
|
||||
function formatApiResponse(rate: VatRate) {
|
||||
return {
|
||||
country: rate.country,
|
||||
country_code: rate.code,
|
||||
standard_rate: rate.standard,
|
||||
reduced_rates: rate.reduced,
|
||||
currency: 'EUR',
|
||||
}
|
||||
}
|
||||
|
||||
function formatAllRatesResponse() {
|
||||
return euVatRates.map(formatApiResponse)
|
||||
}
|
||||
|
||||
return { rates, getRateByCode, formatApiResponse, formatAllRatesResponse }
|
||||
}
|
||||
Reference in New Issue
Block a user