Compare commits

..

No commits in common. "master" and "v0.0" have entirely different histories.
master ... v0.0

9 changed files with 17 additions and 53 deletions

View File

@ -2,8 +2,7 @@ MODULE_big = vat
OBJS = vatin.o es.o OBJS = vatin.o es.o
EXTENSION = vat EXTENSION = vat
DATA = vat--0.0.sql \ DATA = vat--0.0.sql
vat--0.0--0.1.sql
PGFILEDESC = "vat - data type for VAT identification numbers" PGFILEDESC = "vat - data type for VAT identification numbers"
REGRESS = vat REGRESS = vat

18
debian/changelog vendored
View File

@ -1,21 +1,3 @@
vat (0.3-1) bookworm; urgency=medium
* Mark the type as collatable.
-- jordi fita mas <jordi@tandem.blog> Mon, 03 Jul 2023 17:44:51 +0002
vat (0.2-1) bookworm; urgency=medium
* Fix CIF computation for CIF ending with 0.
-- jordi fita mas <jordi@tandem.blog> Mon, 03 Jul 2023 01:37:34 +0002
vat (0.0-2) bookworm; urgency=medium
* Fix CIF computation.
-- jordi fita mas <jordi@tandem.blog> Sat, 21 Jan 2023 19:41:05 +0002
vat (0.0-1) bullseye; urgency=medium vat (0.0-1) bullseye; urgency=medium
* Initial release. * Initial release.

11
debian/control vendored
View File

@ -11,13 +11,14 @@ Vcs-Git: https://dev.tandem.ws/tandem/vat.git
Homepage: https://dev.tandem.ws/tandem/vat Homepage: https://dev.tandem.ws/tandem/vat
Rules-Requires-Root: no Rules-Requires-Root: no
Package: postgresql-15-vat Package: postgresql-13-vat
Architecture: any Architecture: all
Depends: Depends:
${shlibs:Depends}, ${shlibs:Depends},
${misc:Depends}, ${misc:Depends},
postgresql-15 postgresql-13
Description: VAT identification number extension for PostgreSQL 15 Provides: postgresql-pgtap
Description: VAT identification number extension for PostgreSQL 13
vat is a library to check for valid format of VAT identification numbers. vat is a library to check for valid format of VAT identification numbers.
. .
This package contains the extension for PostgreSQL 15. This package contains the extension for PostgreSQL 13.

3
debian/control.in vendored
View File

@ -12,11 +12,12 @@ Homepage: https://dev.tandem.ws/tandem/vat
Rules-Requires-Root: no Rules-Requires-Root: no
Package: postgresql-PGVERSION-vat Package: postgresql-PGVERSION-vat
Architecture: any Architecture: all
Depends: Depends:
${shlibs:Depends}, ${shlibs:Depends},
${misc:Depends}, ${misc:Depends},
postgresql-PGVERSION postgresql-PGVERSION
Provides: postgresql-pgtap
Description: VAT identification number extension for PostgreSQL PGVERSION Description: VAT identification number extension for PostgreSQL PGVERSION
vat is a library to check for valid format of VAT identification numbers. vat is a library to check for valid format of VAT identification numbers.
. .

4
es.c
View File

@ -50,13 +50,13 @@ valid_cif(const char *cif) {
if (n % 2 == 0) { if (n % 2 == 0) {
evens += cif[n] - 48; evens += cif[n] - 48;
} else { } else {
int d = (cif[n] - 48) * 2; int d = cif[n] * 2;
int a = d / 10; int a = d / 10;
int b = d % 10; int b = d % 10;
odds += a + b; odds += a + b;
} }
} }
checksum = (10 - (odds + evens) % 10) % 10; checksum = 10 - (odds + evens) % 10;
return cif[8] == checksum + 48 || cif[8] == "JABCDEFGHI"[checksum]; return cif[8] == checksum + 48 || cif[8] == "JABCDEFGHI"[checksum];
} }

View File

@ -7,13 +7,11 @@ SELECT 'ES40404040D'::VATIN,
'ES40404040-D'::VATIN, 'ES40404040-D'::VATIN,
' esx0523821l '::VATIN, ' esx0523821l '::VATIN,
'ESM0243487d'::VATIN, 'ESM0243487d'::VATIN,
' ESb17616756 '::VATIN, ' ESb17616756 '::VATIN
'ESb17385717'::VATIN,
'ESA08023780'::VATIN
; ;
vatin | vatin | vatin | vatin | vatin | vatin | vatin vatin | vatin | vatin | vatin | vatin
-------------+-------------+-------------+-------------+-------------+-------------+------------- -------------+-------------+-------------+-------------+-------------
ES40404040D | ES40404040D | ESX0523821L | ESM0243487D | ESB17616756 | ESB17385717 | ESA08023780 ES40404040D | ES40404040D | ESX0523821L | ESM0243487D | ESB17616756
(1 row) (1 row)
-- Test invalid checksums -- Test invalid checksums

View File

@ -9,9 +9,7 @@ SELECT 'ES40404040D'::VATIN,
'ES40404040-D'::VATIN, 'ES40404040-D'::VATIN,
' esx0523821l '::VATIN, ' esx0523821l '::VATIN,
'ESM0243487d'::VATIN, 'ESM0243487d'::VATIN,
' ESb17616756 '::VATIN, ' ESb17616756 '::VATIN
'ESb17385717'::VATIN,
'ESA08023780'::VATIN
; ;
-- Test invalid checksums -- Test invalid checksums

View File

@ -1,15 +0,0 @@
/*
* SPDX-FileCopyrightText: 2023 jordi fita mas <jfita@peritasoft.com>
*
* SPDX-License-Identifier: PostgreSQL
*/
-- complain if script is sources in psql, rather than via CREATE EXTENSION
\echo Use "ALTER EXTENSION vat UPDATE TO '0.1'" to load this file. \quit
-- mark the type as collatable
UPDATE pg_catalog.pg_type SET typcollation = 100
WHERE oid = 'vatin'::pg_catalog.regtype;
UPDATE pg_catalog.pg_attribute SET attcollation = 100
WHERE atttypid = 'vatin'::pg_catalog.regtype;

View File

@ -1,5 +1,5 @@
comment = 'data type for VAT registration numbers' comment = 'data type for VAT registration numbers'
default_version = '0.1' default_version = '0.0'
module_pathname = '$libdir/vat' module_pathname = '$libdir/vat'
relocatable = true relocatable = true
superuser = false superuser = false