Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
|
0bbb04196f | |
|
6db136f578 | |
|
9635b2f3a3 | |
|
c229754d6a | |
|
256ba9c5e1 | |
|
d280b233b1 |
3
Makefile
3
Makefile
|
@ -2,7 +2,8 @@ MODULE_big = vat
|
|||
OBJS = vatin.o es.o
|
||||
|
||||
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"
|
||||
|
||||
REGRESS = vat
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
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
|
||||
|
||||
* Initial release.
|
||||
|
|
|
@ -11,14 +11,13 @@ Vcs-Git: https://dev.tandem.ws/tandem/vat.git
|
|||
Homepage: https://dev.tandem.ws/tandem/vat
|
||||
Rules-Requires-Root: no
|
||||
|
||||
Package: postgresql-13-vat
|
||||
Architecture: all
|
||||
Package: postgresql-15-vat
|
||||
Architecture: any
|
||||
Depends:
|
||||
${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
postgresql-13
|
||||
Provides: postgresql-pgtap
|
||||
Description: VAT identification number extension for PostgreSQL 13
|
||||
postgresql-15
|
||||
Description: VAT identification number extension for PostgreSQL 15
|
||||
vat is a library to check for valid format of VAT identification numbers.
|
||||
.
|
||||
This package contains the extension for PostgreSQL 13.
|
||||
This package contains the extension for PostgreSQL 15.
|
||||
|
|
|
@ -12,12 +12,11 @@ Homepage: https://dev.tandem.ws/tandem/vat
|
|||
Rules-Requires-Root: no
|
||||
|
||||
Package: postgresql-PGVERSION-vat
|
||||
Architecture: all
|
||||
Architecture: any
|
||||
Depends:
|
||||
${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
postgresql-PGVERSION
|
||||
Provides: postgresql-pgtap
|
||||
Description: VAT identification number extension for PostgreSQL PGVERSION
|
||||
vat is a library to check for valid format of VAT identification numbers.
|
||||
.
|
||||
|
|
4
es.c
4
es.c
|
@ -50,13 +50,13 @@ valid_cif(const char *cif) {
|
|||
if (n % 2 == 0) {
|
||||
evens += cif[n] - 48;
|
||||
} else {
|
||||
int d = cif[n] * 2;
|
||||
int d = (cif[n] - 48) * 2;
|
||||
int a = d / 10;
|
||||
int b = d % 10;
|
||||
odds += a + b;
|
||||
}
|
||||
}
|
||||
checksum = 10 - (odds + evens) % 10;
|
||||
checksum = (10 - (odds + evens) % 10) % 10;
|
||||
return cif[8] == checksum + 48 || cif[8] == "JABCDEFGHI"[checksum];
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,13 @@ SELECT 'ES40404040D'::VATIN,
|
|||
'ES40404040-D'::VATIN,
|
||||
' esx0523821l '::VATIN,
|
||||
'ESM0243487d'::VATIN,
|
||||
' ESb17616756 '::VATIN
|
||||
' ESb17616756 '::VATIN,
|
||||
'ESb17385717'::VATIN,
|
||||
'ESA08023780'::VATIN
|
||||
;
|
||||
vatin | vatin | vatin | vatin | vatin
|
||||
-------------+-------------+-------------+-------------+-------------
|
||||
ES40404040D | ES40404040D | ESX0523821L | ESM0243487D | ESB17616756
|
||||
vatin | vatin | vatin | vatin | vatin | vatin | vatin
|
||||
-------------+-------------+-------------+-------------+-------------+-------------+-------------
|
||||
ES40404040D | ES40404040D | ESX0523821L | ESM0243487D | ESB17616756 | ESB17385717 | ESA08023780
|
||||
(1 row)
|
||||
|
||||
-- Test invalid checksums
|
||||
|
|
|
@ -9,7 +9,9 @@ SELECT 'ES40404040D'::VATIN,
|
|||
'ES40404040-D'::VATIN,
|
||||
' esx0523821l '::VATIN,
|
||||
'ESM0243487d'::VATIN,
|
||||
' ESb17616756 '::VATIN
|
||||
' ESb17616756 '::VATIN,
|
||||
'ESb17385717'::VATIN,
|
||||
'ESA08023780'::VATIN
|
||||
;
|
||||
|
||||
-- Test invalid checksums
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* 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;
|
|
@ -1,5 +1,5 @@
|
|||
comment = 'data type for VAT registration numbers'
|
||||
default_version = '0.0'
|
||||
default_version = '0.1'
|
||||
module_pathname = '$libdir/vat'
|
||||
relocatable = true
|
||||
superuser = false
|
||||
|
|
Loading…
Reference in New Issue