csb43.utils
¶
Note
license: GNU Lesser General Public License v3.0 (see LICENSE)
-
exception
csb43.utils.
Csb43Exception
(value)¶
-
class
csb43.utils.
CurrencyLite
(letter, numeric)¶
-
csb43.utils.
b_left_pad
(bvalue, n, fill=b' ')¶
-
csb43.utils.
b_right_pad
(bvalue, n, fill=b' ')¶
-
csb43.utils.
check_strict
(pattern)¶ Note
decorator
Parameters: - pattern (
basestring
) – pattern description using regular expressions - field – variable to be checked
- strict (
bool
) – treat exceptions as warnings if False
Raises: Csb43Exception
if field doesn’t match pattern and strict is True- pattern (
-
csb43.utils.
check_string
(pattern='', field='', strict=True, **csbexc)¶ Parameters: - pattern (
basestring
) – pattern description using regular expressions - field – variable to be checked
- strict (
bool
) – treat exceptions as warnings if False
Raises: Csb43Exception
if field doesn’t match pattern and strict is True- pattern (
-
csb43.utils.
currency2raw
(value, decimal=2)¶ Convert a real to the CSB amount format
- Args:
- value (float) – quantity as a real number decimal (int) – number of digits reserved for decimal numbers
- Return:
- tuple of absolute amount and debit flag
Examples:
>>> currency2raw(-123.456) (12345L, '1') >>> currency2raw(123.45) (12345L, '2')
-
csb43.utils.
currencyISO
(numeric)¶ Parameters: code ( str
) – a ISO 4217 numeric codeReturn type: pycountry.db.Currency
object from its numeric code
-
csb43.utils.
currencyISOByLetter
(letter)¶ Parameters: code ( str
) – a ISO 4217 numeric codeReturn type: pycountry.db.Currency
object from its numeric code
-
csb43.utils.
date2raw
(value, yearFirst=True)¶ Convert a datetime object to a CSB formatted date
- Args:
- value (datetime.datetime) – datetime object yearFirst (bool) – if False, consider the CSB format is DDMMYY instead of YYMMDD
- Return:
- (str) the CSB date
Examples:
>>> a = raw2date('020301') >>> date2raw(a) '020301'
-
csb43.utils.
isCurrency
(obj)¶
-
csb43.utils.
raiseCsb43Exception
(value='', strict=False, silent=False, **kwargs)¶ raise a
Csb43Exception
or print the exception’s message to standard errorParameters: - value – message of the exception
- strict – print to standard error instead of raising an exception if not strict
Raises:
-
csb43.utils.
raw2currency
(value, decimal=2, debit='2')¶ Format the CSB composite type for amounts as a real number
- Args:
- value (long or str) – absolute amount without decimal separator decimal (int) – number of digits reserved for decimal numbers debit (‘1’,‘2’) – ‘1’ debit, ‘2’ credit
- Return:
- (float) the amount as a real number
Examples:
>>> raw2currency('123456') 1234.56 >>> raw2currency('12345',debit='1') -123.45
-
csb43.utils.
raw2date
(value, yearFirst=True)¶ Convert the CSB date format to a datetime.datetime object
- Args:
- value (str) – date using the CSB format yearFirst (bool) – if False, consider the CSB format is DDMMYY instead of YYMMDD
- Return:
- (datetime.datetime) the date object
Examples:
>>> raw2date('020301') datetime.datetime(2002, 3, 1, 0, 0)
-
exception
csb43.utils.
Csb43Exception
(value)
-
csb43.utils.
raiseCsb43Exception
(value='', strict=False, silent=False, **kwargs) raise a
Csb43Exception
or print the exception’s message to standard errorParameters: - value – message of the exception
- strict – print to standard error instead of raising an exception if not strict
Raises:
-
csb43.utils.
check_strict
(pattern) Note
decorator
Parameters: - pattern (
basestring
) – pattern description using regular expressions - field – variable to be checked
- strict (
bool
) – treat exceptions as warnings if False
Raises: Csb43Exception
if field doesn’t match pattern and strict is True- pattern (
-
csb43.utils.
currencyISO
(numeric) Parameters: code ( str
) – a ISO 4217 numeric codeReturn type: pycountry.db.Currency
object from its numeric code
-
utils.
DECIMAL
= 2¶
-
utils.
DATEFORMAT
= ['%d%m%y', '%y%m%d']¶
-
utils.
CONCEPTOS
= {'02': 'ABONARES - ENTREGAS - INGRESOS', '03': 'DOMICILIADOS - RECIBOS - LETRAS - PAGOS POR SU CUENTA', '13': 'OPERACIONES EXTRANJERO', '99': 'VARIOS', '98': 'ANULACIONES - CORRECCIONES ASIENTO', '05': 'AMORTIZACIONES, PRESTAMOS, CREDITOS, ETC.', '17': 'INTERESES - COMISIONES - CUSTODIA - GASTOS E IMPUESTOS', '10': 'CHEQUES GASOLINA', '06': 'REMESAS, EFECTOS', '01': 'TALONES - REINTEGROS', '09': 'OPERACIONES DE BOLSA Y/O COMPRA/VENTA VALORES', '14': 'DEVOLUCIONES E IMPAGADOS', '08': 'DIV. CUPONES - PRIMA JUNTA - AMORTIZACIONES', '12': 'TARJETAS DE CREDITO - TARJETAS DE DEBITO', '15': 'NOMINAS - SEGUROS SOCIALES', '16': 'TIMBRES - CORRETAJE - POLIZA', '07': 'SUSCRIPCIONES - DIV. PASIVOS - CANJES', '04': 'GIROS - TRANSFERENCIAS - TRASPASOS - CHEQUES', '11': 'CAJERO AUTOMATICO'}¶