FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour C贸dico IBAN
Posts: 118
Joined: Fri Dec 20, 2013 10:39 AM
C贸dico IBAN
Posted: Fri Dec 27, 2013 12:28 PM
Hola. He creado una funci贸n para calcular el c贸digo CCC IBAN. La he depurado bastante. La pongo por si a alguien le sirve:
Code (fw): Select all Collapse
FUNCTION IBAN()
聽 聽 聽 聽 聽LOCAL ACTUALCCC,PRIMERAPAIS,SEGUNDAPAIS
聽 聽 聽 聽 聽//// en CLI[35] est谩 el c贸digo del pa铆s (ES para espa帽a) 聽 聽 聽 聽 
聽 聽 聽 聽 聽PRIMERAPAIS:=ASC(LEFT(CLI[35],1))-55 聽 //A-65 B-66 C-67 ...
聽 聽 聽 聽 聽SEGUNDAPAIS:=ASC(RIGHT(CLI[35],1))-55
聽 聽 聽 聽 聽
聽 聽 聽 聽 聽//// en CLI[10] est谩 el c贸digo de banco (string de 4)
聽 聽 聽 聽 聽//// en cli[11] est谩 el c贸digo de oficina (string de 4)
聽 聽 聽 聽 聽//// en CLI[12] est谩 el d铆gito de control (string de 2)
聽 聽 聽 聽 聽//// en CLI[13] est谩 el n煤mero de cuenta (string de 10)
聽 聽 聽 聽 
聽 聽 聽 聽 聽ACTUALCCC=CLI[10]+CLI[11]+CLI[12]+CLI[13]+ALLTRIM(STR(PRIMERAPAIS))+ALLTRIM(STR(SEGUNDAPAIS))+"00"
聽 聽 聽 聽 聽CLI[36]:=ALLTRIM(STR(ROUND(98-MOD(VAL(ACTUALCCC),97),0)))
聽 聽 聽 聽 聽//// en cli[36] guardo el c贸digo calculado

RETURN NIL


As铆 en 4 l铆neas lo calcula. Un saludo.
Windows 10 + FWH 20.08 + BCC 7.4 + Harbour 3.2.0 + PSPad 5.0.3
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: C贸dico IBAN
Posted: Fri Dec 27, 2013 05:53 PM

Eloy,

gracias!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: C贸dico IBAN
Posted: Fri Dec 27, 2013 06:05 PM

Eloy,

En el github de quin ferrer hay ya una.

https://github.com/QuimFerrer/iban/blob ... t-iban.prg
Lo que no se es si las rutinas SEPA funcionan.

Por cierto el IBAN, segun parece puede alcanzar hasta 35 CARACTERES y las entidades europeas pueden tener digitos ALFANUMERICOS. Por tanto, no se si pedir el IBAN separado por bloques o en una cadena. 驴 ideas ?

Saludos

Posts: 711
Joined: Thu Oct 06, 2005 09:57 PM
Re: C贸dico IBAN
Posted: Sat Dec 28, 2013 06:00 AM

En principio esa f贸rmula parece correcta y es la que yo utilic茅. Pero comparando el IBAN que a mi me sal铆a de una cuenta, con el que me sal铆a con una calculadora de una entidad bancaria, a veces, el d铆gito era un n煤mero menos o mas. Seg煤n descubr铆 en una circular de la AEB, lo que ocurr铆a, es que si el guarismo es demasiado largo (un n煤mero entero de 32 bits representa un m谩ximo de 9 d铆gitos), se produc铆a el error y para solucionarlo ellos aconsejan "dividir el c谩lculo en c谩lculos restantes consecutivos sobre n煤meros enteros con una extensi贸n m谩xima de 9 d铆gitos para 32 bits y 18 d铆gitos para 64 bits".

Yo lo hago as铆:

// cPais siempre 'ES'
FUNCTION fIban( cBanco, cSucursal, cDC, cCuenta )
local nIban, cIban, nMod, nContador, cPais := 'ES', cPais2:=''

// comprueba ccc es correcto
IF !CCC (cBanco, cSucursal, cDC, cCuenta)
// devuelve cadena vacia por error CCC
RETURN ' '
ENDIF

FOR ncontador = 1 TO 2
IF ASC(SUBSTR(cPais, ncontador, 1)) >= 65
cPais2 += STR( (ASC(UPPER(SUBSTR(cPais, ncontador, 1)))-55), 2, 0)
ELSE
cPais2 += SUBSTR(cPais, ncontador, 1)
ENDIF
NEXT

cIban := cBanco + cSucursal
nMod := INT ( VAL(cIban) % 97)
cIban := LTRIM(STR(nMod,3,0))+cDC+SUBS(cCuenta,1,2)
nMod := INT ( VAL(cIban) % 97)
cIban := LTRIM(STR(nMod,3,0))+SUBS(cCuenta,3) + cPais2 + "00"
nMod := INT ( VAL(cIban) % 97 )
nIban := INT ( 98 - ( VAL(cIban) % 97) )

return cPais + STRZERO( nIban, 2)+cBanco+cSucursal+cDC+cCuenta

La funci贸n es mucho mas grande que la tuya, pero me ha funcionado en todas las pruebas que he hecho.

Por otra parte indicarle a Paquito que el c谩lculo del IBAN es diferente en cada pa铆s. En Espa帽a tiene 24 caracteres, pero en otros paises puede ser diferente. Las normas para cada pais las aprueba http://www.swift.com/dsp/resources/docu ... gistry.pdf

Un saludo



Manuel
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: C贸dico IBAN
Posted: Sat Dec 28, 2013 10:45 AM

Manuel, gracias por el codigo y la explicacion

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: C贸dico IBAN
Posted: Sun Dec 29, 2013 07:39 PM

Antonio,
Emg made last two year ago a Iban function good run

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 711
Joined: Thu Oct 06, 2005 09:57 PM
Re: C贸dico IBAN
Posted: Tue Dec 31, 2013 11:23 AM
Silvio.Falconi wrote:Antonio,
Emg made last two year ago a Iban function good run


Silvio,

IBAN calculation is different in each country. For instance in Italy account number has 23 digits and in Spain 20. Italy IBAN length is 27 characters and in Spain 24.
Un saludo



Manuel
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: C贸dico IBAN
Posted: Tue Dec 31, 2013 05:43 PM

the Iban in Italy is the sum of different codes

sample : IT62N0100515300000000016125 ----------------> 27 dgt

cPae + cChk + cCin + cAbi + cCab + cCon

cPae = state IT
cChk = number check 62
cCin = CIN code N
cAbi = Abi Code 01005
cCab = Cab Code 15300
cCon = Number of mine account bank 000000016125 ( mine is 12 dgt but I Know there are also 10 dgt in italy)

the Cin, Abi and Cab codes are codes of Bank

the Cin Code is create from cAbi,cCab and cCon

perhals on Espana or another State it can be different but perhaps they are small changes !!!

if you wish i can try with your data and see if the functions I use run ok ...

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 711
Joined: Thu Oct 06, 2005 09:57 PM
Re: C贸dico IBAN
Posted: Thu Jan 02, 2014 04:18 PM
Silvio,

In this page
http://www.swift.com/dsp/resources/docu ... gistry.pdf
you have the Formula for each country. The method is simliarbutthe formula is different.

EMG IBAN is OK for Italy and my formula is OK for Spain.

:-)
Un saludo



Manuel
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: C贸dico IBAN
Posted: Thu Jan 02, 2014 05:13 PM

404 - Page Not Found

Sorry, the page you requested is not available

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 711
Joined: Thu Oct 06, 2005 09:57 PM
Re: C贸dico IBAN
Posted: Thu Jan 02, 2014 06:50 PM
Un saludo



Manuel

Continue the discussion