Ruego por favor si alguien sabe el algoritmo utilizado para el calculo del digito de control de un numero de cuenta bancaria.
Gracias
Calculo del digito de control de cuenta bancaria
-
- Posts: 47
- Joined: Wed Oct 12, 2005 6:58 pm
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Julio,
Aquí está el código en php. Es fácil pasarlo a Clipper:
http://bulma.net/body.phtml?nIdNoticia=1396
Aquí está el código en php. Es fácil pasarlo a Clipper:
http://bulma.net/body.phtml?nIdNoticia=1396
- Manuel Aranda
- Posts: 561
- Joined: Wed Oct 19, 2005 8:20 pm
- Location: España
Aquí la tienes para clipper:
cBanco:=SPACE(4)
cSucursal:=SPACE(4)
cRefer2:=SPACE(10)
@ 24,0 SAY SPACE(80)
@ 24,4 SAY "Introduzca Banco, Sucursal y N£m. de cuenta......"
DibujaCuadro(11,8,15,70, "W+/B",.T.)
@ 11,10 SAY " CALCULO DE DIGITOS DE CUENTA BANCARIA " COLOR "W+/R"
SetCursor(3)
@ 13,15 SAY " Banco Sucursal DC Cuenta" COLOR "W+/B"
@ 14,15 SAY " [ ] [ ] [ ] [ ]" COLOR "G/B"
@ 14,18 GET cBanco PICTURE "9999" COLOR "GR+/B"
@ 14,28 GET cSucursal PICTURE "9999" COLOR "GR+/B"
@ 14,45 GET cRefer2 PICTURE "9999999999" COLOR "GR+/B"
READ
cRefer1=cBanco+cSucursal
@ 14,38 SAY digBanco(cRefer1,cRefer2) COLOR "W+/R"
*************************************************************************
FUNCTION Digbanco(cRefer1,cRefer2)
*************************************************************************
LOCAL nDigitos := 10
LOCAL aDigito := ARRAY( nDigitos )
LOCAL aPeso := { 1, 2, 4, 8, 5, 10, 9, 7, 3, 6 }
LOCAL nSuma := 0
LOCAL nCont
LOCAL nModulo
LOCAL nResto
LOCAL cDigito1
LOCAL cDigito2
cRefer1 := STRTRAN(cRefer1,'-')
cRefer1 := STRTRAN(cRefer1,'.')
cRefer1 := STRTRAN(cRefer1,'/')
cRefer1 := STRTRAN(cRefer1,' ')
cRefer1 := RIGHT(cRefer1,nDigitos)
cRefer1 := PADL(cRefer1,nDigitos,'0')
cRefer2 := STRTRAN(cRefer2,'-')
cRefer2 := STRTRAN(cRefer2,'.')
cRefer2 := STRTRAN(cRefer2,'/')
cRefer2 := STRTRAN(cRefer2,' ')
cRefer2 := RIGHT(cRefer2,nDigitos)
cRefer2 := PADL(cRefer2,nDigitos,'0')
FOR nCont := 1 to nDigitos
aDigito[ nCont ] := VAL( SUBSTR( cRefer1, nCont, 1 ) )
nSuma += ( aDigito[ nCont ] * aPeso[ nCont ] )
NEXT
nModulo := 11 - INT( nSuma % 11 )
nResto := IF( nModulo == 10, 1, IF( nModulo == 11, 0, nModulo ) )
cDigito1 := LTRIM(STR(nResto))
nSuma := 0
FOR nCont := 1 to nDigitos
aDigito[ nCont ] := VAL( SUBSTR( cRefer2, nCont, 1 ) )
nSuma += ( aDigito[ nCont ] * aPeso[ nCont ] )
NEXT
nModulo := 11 - INT( nSuma % 11 )
nResto := IF( nModulo == 10, 1, IF( nModulo == 11, 0, nModulo ) )
cDigito2 := LTRIM(STR(nResto))
RETURN(cDigito1+cDigito2)
cBanco:=SPACE(4)
cSucursal:=SPACE(4)
cRefer2:=SPACE(10)
@ 24,0 SAY SPACE(80)
@ 24,4 SAY "Introduzca Banco, Sucursal y N£m. de cuenta......"
DibujaCuadro(11,8,15,70, "W+/B",.T.)
@ 11,10 SAY " CALCULO DE DIGITOS DE CUENTA BANCARIA " COLOR "W+/R"
SetCursor(3)
@ 13,15 SAY " Banco Sucursal DC Cuenta" COLOR "W+/B"
@ 14,15 SAY " [ ] [ ] [ ] [ ]" COLOR "G/B"
@ 14,18 GET cBanco PICTURE "9999" COLOR "GR+/B"
@ 14,28 GET cSucursal PICTURE "9999" COLOR "GR+/B"
@ 14,45 GET cRefer2 PICTURE "9999999999" COLOR "GR+/B"
READ
cRefer1=cBanco+cSucursal
@ 14,38 SAY digBanco(cRefer1,cRefer2) COLOR "W+/R"
*************************************************************************
FUNCTION Digbanco(cRefer1,cRefer2)
*************************************************************************
LOCAL nDigitos := 10
LOCAL aDigito := ARRAY( nDigitos )
LOCAL aPeso := { 1, 2, 4, 8, 5, 10, 9, 7, 3, 6 }
LOCAL nSuma := 0
LOCAL nCont
LOCAL nModulo
LOCAL nResto
LOCAL cDigito1
LOCAL cDigito2
cRefer1 := STRTRAN(cRefer1,'-')
cRefer1 := STRTRAN(cRefer1,'.')
cRefer1 := STRTRAN(cRefer1,'/')
cRefer1 := STRTRAN(cRefer1,' ')
cRefer1 := RIGHT(cRefer1,nDigitos)
cRefer1 := PADL(cRefer1,nDigitos,'0')
cRefer2 := STRTRAN(cRefer2,'-')
cRefer2 := STRTRAN(cRefer2,'.')
cRefer2 := STRTRAN(cRefer2,'/')
cRefer2 := STRTRAN(cRefer2,' ')
cRefer2 := RIGHT(cRefer2,nDigitos)
cRefer2 := PADL(cRefer2,nDigitos,'0')
FOR nCont := 1 to nDigitos
aDigito[ nCont ] := VAL( SUBSTR( cRefer1, nCont, 1 ) )
nSuma += ( aDigito[ nCont ] * aPeso[ nCont ] )
NEXT
nModulo := 11 - INT( nSuma % 11 )
nResto := IF( nModulo == 10, 1, IF( nModulo == 11, 0, nModulo ) )
cDigito1 := LTRIM(STR(nResto))
nSuma := 0
FOR nCont := 1 to nDigitos
aDigito[ nCont ] := VAL( SUBSTR( cRefer2, nCont, 1 ) )
nSuma += ( aDigito[ nCont ] * aPeso[ nCont ] )
NEXT
nModulo := 11 - INT( nSuma % 11 )
nResto := IF( nModulo == 10, 1, IF( nModulo == 11, 0, nModulo ) )
cDigito2 := LTRIM(STR(nResto))
RETURN(cDigito1+cDigito2)
Function cDcontrol( cEntidad, cOficina, cCuenta )
Local nSuma, nPos, nResto, cDc
Local anPeso := {1,2,4,8,5,10,9,7,3,6}
if empty(cCuenta)
return cCuenta
Endif
// Primer digito de control
nSuma := 0
FOR nPos := 1 TO 8
nSuma += Val( SubStr( cEntidad + cOficina, nPos, 1 ) ) * anPeso[nPos + 2]
NEXT nBuc
nResto := 11 - (nSuma % 11)
cDc := If( nResto = 10, '1', If( nResto = 11, '0', Str( nResto, 1 ) ) )
// Segundo digito de control
nSuma := 0
FOR nPos := 1 TO 10
nSuma += Val( SubStr( cCuenta, nPos, 1 ) ) * anPeso[nPos]
NEXT nPos
nResto := 11 - (nSuma % 11)
cDc += If( nResto = 10, '1', If( nResto = 11, '0', Str( nResto, 1 ) ) )
RETURN cDc
/*
Local nSuma, nPos, nResto, cDc
Local anPeso := {1,2,4,8,5,10,9,7,3,6}
if empty(cCuenta)
return cCuenta
Endif
// Primer digito de control
nSuma := 0
FOR nPos := 1 TO 8
nSuma += Val( SubStr( cEntidad + cOficina, nPos, 1 ) ) * anPeso[nPos + 2]
NEXT nBuc
nResto := 11 - (nSuma % 11)
cDc := If( nResto = 10, '1', If( nResto = 11, '0', Str( nResto, 1 ) ) )
// Segundo digito de control
nSuma := 0
FOR nPos := 1 TO 10
nSuma += Val( SubStr( cCuenta, nPos, 1 ) ) * anPeso[nPos]
NEXT nPos
nResto := 11 - (nSuma % 11)
cDc += If( nResto = 10, '1', If( nResto = 11, '0', Str( nResto, 1 ) ) )
RETURN cDc
/*
-
- Posts: 47
- Joined: Wed Oct 12, 2005 6:58 pm