mirror of
https://github.com/sharevb/it-tools.git
synced 2026-12-05 18:55:11 +03:00
Merge branch 'feat/vat-validator' into chore/all-my-stuffs
# Conflicts: # package.json # pnpm-lock.yaml # src/tools/index.ts
This commit is contained in:
commit
4c424fcddb
5 files changed
+81
No files matched your search
@@ -49,6 +49,7 @@ import { tool as stacktracePrettier } from './stacktrace-prettier';
|
||||
import { tool as dataTransferRateConverter } from './data-transfer-rate-converter';
|
||||
import { tool as dataStorageUnitConverter } from './data-storage-unit-converter';
|
||||
import { tool as unicodeSearch } from './unicode-search';
|
||||
import { tool as vatValidator } from './vat-validator';
|
||||
|
||||
import { tool as cssXpathConverter } from './css-xpath-converter';
|
||||
import { tool as cssSelectorsMemo } from './css-selectors-memo';
|
||||
@@ -436,6 +437,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
phoneParserAndFormatter,
|
||||
ibanValidatorAndParser,
|
||||
luhnValidator,
|
||||
vatValidator,
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { ReceiptTax } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'VAT Numbers Validator',
|
||||
path: '/vat-validator',
|
||||
description: 'Validate VAT Numbers',
|
||||
keywords: ['vat', 'validator'],
|
||||
component: () => import('./vat-validator.vue'),
|
||||
icon: ReceiptTax,
|
||||
createdAt: new Date('2024-08-15'),
|
||||
});
|
||||
@@ -0,0 +1,58 @@
|
||||
<script setup lang="ts">
|
||||
import { checkVAT, countries } from 'jsvat-next';
|
||||
import type { CKeyValueListItems } from '@/ui/c-key-value-list/c-key-value-list.types';
|
||||
|
||||
const rawVATNumber = ref('BE0411905847');
|
||||
const vatInfos = computed<{ isValid: boolean; infos: CKeyValueListItems }>(() => {
|
||||
const vat = checkVAT(rawVATNumber.value, countries);
|
||||
if (vat == null) {
|
||||
return { isValid: false, infos: [] };
|
||||
}
|
||||
return {
|
||||
isValid: vat.isValid,
|
||||
infos: [
|
||||
{
|
||||
label: 'Is VAT Number valid ?',
|
||||
value: vat.isValid,
|
||||
},
|
||||
{
|
||||
label: 'Is VAT Number valid format ?',
|
||||
value: vat.isValidFormat,
|
||||
},
|
||||
{
|
||||
label: 'Cleaned VAT Number',
|
||||
value: vat.value,
|
||||
},
|
||||
{
|
||||
label: 'Country (name)',
|
||||
value: vat.country?.name || 'Unknown',
|
||||
},
|
||||
{
|
||||
label: 'Country (ISO2)',
|
||||
value: vat.country?.isoCode?.short || 'unk',
|
||||
},
|
||||
{
|
||||
label: 'Country (ISO3)',
|
||||
value: vat.country?.isoCode?.long || 'unk',
|
||||
},
|
||||
{
|
||||
label: 'Country (ISO Num)',
|
||||
value: vat.country?.isoCode?.numeric || 0,
|
||||
},
|
||||
],
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-input-text v-model:value="rawVATNumber" placeholder="Enter a VAT number to check for validity..." test-id="vat-input" mb-2 />
|
||||
<n-alert v-if="!vatInfos.isValid" type="error" mb-2>
|
||||
Invalid VAT Number.
|
||||
</n-alert>
|
||||
|
||||
<c-card v-if="vatInfos.infos.length > 0" title="VAT Number Infos">
|
||||
<c-key-value-list :items="vatInfos.infos" data-test-id="vat-info" />
|
||||
</c-card>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user