Skip to content

Commit

Permalink
Merge pull request #84 from fyndata/develop
Browse files Browse the repository at this point in the history
Release v0.8.1
  • Loading branch information
glarrain committed Sep 25, 2019
2 parents c046bf6 + 053b79a commit 8d0a5f4
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.8.0
current_version = 0.8.1
commit = True
tag = True

Expand Down
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
History
-------

0.8.1 (2019-09-25)
+++++++++++++++++++++++

* (PR #83, 2019-09-12) rcv.parse_csv: remove whitespace from "razon social"

0.8.0 (2019-09-03)
+++++++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion cl_sii/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"""


__version__ = '0.8.0'
__version__ = '0.8.1'
12 changes: 12 additions & 0 deletions cl_sii/rcv/parse_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,9 @@ def postprocess(self, data: dict) -> dict:
data['fecha_reclamo_dt'] = tz_utils.convert_naive_dt_to_tz_aware(
dt=data['fecha_reclamo_dt'], tz=self.FIELD_FECHA_RECLAMO_DT_TZ)

# Remove leading and trailing whitespace.
data['receptor_razon_social'] = data['receptor_razon_social'].strip()

return data

def to_detalle_entry(self, data: dict) -> RvDetalleEntry:
Expand Down Expand Up @@ -741,6 +744,9 @@ def postprocess(self, data: dict) -> dict:
# note: to express this value in another timezone (but the value does not change), do
# `dt_obj.astimezone(pytz.timezone('some timezone'))`

# Remove leading and trailing whitespace.
data['emisor_razon_social'] = data['emisor_razon_social'].strip()

return data

def to_detalle_entry(self, data: dict) -> RcRegistroDetalleEntry:
Expand Down Expand Up @@ -918,6 +924,9 @@ def postprocess(self, data: dict) -> dict:
# note: to express this value in another timezone (but the value does not change), do
# `dt_obj.astimezone(pytz.timezone('some timezone'))`

# Remove leading and trailing whitespace.
data['emisor_razon_social'] = data['emisor_razon_social'].strip()

return data

def to_detalle_entry(self, data: dict) -> RcReclamadoDetalleEntry:
Expand Down Expand Up @@ -1043,6 +1052,9 @@ def postprocess(self, data: dict) -> dict:
# note: to express this value in another timezone (but the value does not change), do
# `dt_obj.astimezone(pytz.timezone('some timezone'))`

# Remove leading and trailing whitespace.
data['emisor_razon_social'] = data['emisor_razon_social'].strip()

return data

def to_detalle_entry(self, data: dict) -> RcPendienteDetalleEntry:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Nro;Tipo Doc;Tipo Compra;RUT Proveedor;Razon Social;Folio;Fecha Docto;Fecha Recepcion;Fecha Acuse;Monto Exento;Monto Neto;Monto IVA Recuperable;Monto Iva No Recuperable;Codigo IVA No Rec.;Monto Total;Monto Neto Activo Fijo;IVA Activo Fijo;IVA uso Comun;Impto. Sin Derecho a Credito;IVA No Retenido;NCE o NDE sobre Fact. de Compra;Codigo Otro Impuesto;Valor Otro Impuesto;Tasa Otro Impuesto
1;33;No Corresp. Incluir;12345678-5;Fake Company S.A. ;19000035;13/12/2019;14/12/2019 15:56:27;;0;87699;;16663;9;104362;;;;;0;0;;;;
2;33;No Corresp. Incluir;12345678-5; Fake Company S.A.;19000036;13/12/2019;14/12/2019 15:56:27;;0;155473;;29540;9;185013;;;;;0;0;;;;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Nro;Tipo Doc;Tipo Compra;RUT Proveedor;Razon Social;Folio;Fecha Docto;Fecha Recepcion;Monto Exento;Monto Neto;Monto IVA Recuperable;Monto Iva No Recuperable;Codigo IVA No Rec.;Monto Total;Monto Neto Activo Fijo;IVA Activo Fijo;IVA uso Comun;Impto. Sin Derecho a Credito;IVA No Retenido;NCE o NDE sobre Fact. de Compra;Codigo Otro Impuesto;Valor Otro Impuesto;Tasa Otro Impuesto
1;33;Del Giro;12345678-5;Fake Company S.A. ;9800042;28/06/2019;01/07/2019 13:21:32;0;41838;7949;;;49787;;;;;0;0;;;;
7;33;Del Giro;12345678-5; Fake Company S.A.;380007;01/07/2019;02/07/2019 17:34:28;0;54411;10338;;;64749;;;;;0;0;;;;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Nro;Tipo Doc;Tipo Compra;RUT Proveedor;Razon Social;Folio;Fecha Docto;Fecha Recepcion;Fecha Reclamo;Monto Exento;Monto Neto;Monto IVA Recuperable;Monto Iva No Recuperable;Codigo IVA No Rec.;Monto Total;Monto Neto Activo Fijo;IVA Activo Fijo;IVA uso Comun;Impto. Sin Derecho a Credito;IVA No Retenido;NCE o NDE sobre Fact. de Compra;Codigo Otro Impuesto;Valor Otro Impuesto;Tasa Otro Impuesto
1;33;Del Giro;12345678-5;Fake Company S.A. ;1000055;05/06/2019;05/06/2019 21:58:49;12/06/2019 09:47:23;0;970894;184470;;;1155364;;;;;0;0;;;;
2;61;Del Giro;12345678-5; Fake Company S.A.;70013;24/06/2019;24/06/2019 15:24:41;null;0;1652840;314040;;;1966880;;;;;0;0;;;;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Nro;Tipo Doc;Tipo Compra;RUT Proveedor;Razon Social;Folio;Fecha Docto;Fecha Recepcion;Fecha Acuse;Monto Exento;Monto Neto;Monto IVA Recuperable;Monto Iva No Recuperable;Codigo IVA No Rec.;Monto Total;Monto Neto Activo Fijo;IVA Activo Fijo;IVA uso Comun;Impto. Sin Derecho a Credito;IVA No Retenido;Tabacos Puros;Tabacos Cigarrillos;Tabacos Elaborados;NCE o NDE sobre Fact. de Compra;Codigo Otro Impuesto;Valor Otro Impuesto;Tasa Otro Impuesto
1;33;Del Giro;12345678-5;Fake Company S.A. ;23084;21/06/2019;24/06/2019 09:55:53;;0;240169;45632;;;285801;;;;;0;;;;0;;;;
7;33;Del Giro;12345678-5; Fake Company S.A.;31000097;02/07/2019;03/07/2019 00:15:30;;0;27356;5198;;;32554;;;;;0;;;;0;;;;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Nro;Tipo Doc;Tipo Venta;Rut cliente;Razon Social;Folio;Fecha Docto;Fecha Recepcion;Fecha Acuse Recibo;Fecha Reclamo;Monto Exento;Monto Neto;Monto IVA;Monto total;IVA Retenido Total;IVA Retenido Parcial;IVA no retenido;IVA propio;IVA Terceros;RUT Emisor Liquid. Factura;Neto Comision Liquid. Factura;Exento Comision Liquid. Factura;IVA Comision Liquid. Factura;IVA fuera de plazo;Tipo Docto. Referencia;Folio Docto. Referencia;Num. Ident. Receptor Extranjero;Nacionalidad Receptor Extranjero;Credito empresa constructora;Impto. Zona Franca (Ley 18211);Garantia Dep. Envases;Indicador Venta sin Costo;Indicador Servicio Periodico;Monto No facturable;Total Monto Periodo;Venta Pasajes Transporte Nacional;Venta Pasajes Transporte Internacional;Numero Interno;Codigo Sucursal;NCE o NDE sobre Fact. de Compra;Codigo Otro Imp.;Valor Otro Imp.;Tasa Otro Imp.
1;33;Del Giro;12345678-5;Fake Company S.A. ;506;04/06/2019;18/06/2019 17:01:06;;;0;1750181;332534;2082715;0;0;0;0;0;-;0;0;0;0;;;;;0;;0;2;0;0;0;;;;0;;;;;
23;33;Del Giro;12345678-5; Fake Company S.A.;508;28/06/2019;01/07/2019 13:49:42;;;0;2209597;419823;2629420;0;0;0;0;0;-;0;0;0;0;0;;;;0;;0;2;0;0;0;;;;0;;;;;
93 changes: 93 additions & 0 deletions tests/test_rcv_parse_csv.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from typing import Callable

from cl_sii.rcv.parse_csv import ( # noqa: F401
RcvCompraNoIncluirCsvRowSchema, RcvCompraPendienteCsvRowSchema,
Expand All @@ -11,6 +12,8 @@
)
from cl_sii.rut import Rut

from .utils import get_test_file_path


class RcvVentaCsvRowSchemaTest(unittest.TestCase):

Expand Down Expand Up @@ -65,6 +68,58 @@ def test_fail_parse_rcv_venta_csv_file_bad_razon_social(self) -> None:
cm.exception.args,
("Value must not have leading or trailing whitespace.", ))

def test_parse_rcv_venta_csv_file_receptor_rz_leading_trailing_whitespace(self) -> None:
rcv_file_path = get_test_file_path(
'test_data/sii-rcv/RCV-venta-rz_leading_trailing_whitespace.csv',
)

items = parse_rcv_venta_csv_file(
rut=Rut('1-9'),
razon_social='Whitespace Seller SpA',
input_file_path=rcv_file_path,
n_rows_offset=0,
max_n_rows=None,
)

# Test trailing whitespace
entry_struct, row_ix, row_data, row_parsing_errors = next(items)
self.assertEqual(row_data['Razon Social'], 'Fake Company S.A. ')
self.assertEqual(entry_struct.receptor_razon_social, 'Fake Company S.A.')
self.assertEqual(len(row_parsing_errors), 0)

# Test leading whitespace
entry_struct, row_ix, row_data, row_parsing_errors = next(items)
self.assertEqual(row_data['Razon Social'], ' Fake Company S.A.')
self.assertEqual(entry_struct.receptor_razon_social, 'Fake Company S.A.')
self.assertEqual(len(row_parsing_errors), 0)

def _test_parse_rcv_compra_csv_file_emisor_rz_leading_trailing_whitespace(
self,
parse_rcv_compra_csv_file_function: Callable,
rcv_file_path: str,
) -> None:
rcv_file_path = get_test_file_path(rcv_file_path)

items = parse_rcv_compra_csv_file_function(
rut=Rut('1-9'),
razon_social='Whitespace Buyer SpA',
input_file_path=rcv_file_path,
n_rows_offset=0,
max_n_rows=None,
)

# Test trailing whitespace
entry_struct, row_ix, row_data, row_parsing_errors = next(items)
self.assertEqual(row_data['Razon Social'], 'Fake Company S.A. ')
self.assertEqual(entry_struct.emisor_razon_social, 'Fake Company S.A.')
self.assertEqual(len(row_parsing_errors), 0)

# Test leading whitespace
entry_struct, row_ix, row_data, row_parsing_errors = next(items)
self.assertEqual(row_data['Razon Social'], ' Fake Company S.A.')
self.assertEqual(entry_struct.emisor_razon_social, 'Fake Company S.A.')
self.assertEqual(len(row_parsing_errors), 0)

def test_parse_rcv_compra_registro_csv_file(self) -> None:
# TODO: implement for 'parse_rcv_compra_registro_csv_file'.
pass
Expand All @@ -86,6 +141,14 @@ def test_fail_parse_rcv_compra_registro_csv_file_bad_razon_social(self) -> None:
cm.exception.args,
("Value must not have leading or trailing whitespace.", ))

def test_parse_rcv_compra_registro_csv_file_emisor_rz_leading_trailing_whitespace(self) -> None:
self._test_parse_rcv_compra_csv_file_emisor_rz_leading_trailing_whitespace(
parse_rcv_compra_csv_file_function=parse_rcv_compra_registro_csv_file,
rcv_file_path=(
'test_data/sii-rcv/RCV-compra-registro-rz_leading_trailing_whitespace.csv'
),
)

def test_parse_rcv_compra_no_incluir_csv_file(self) -> None:
# TODO: implement for 'parse_rcv_compra_no_incluir_csv_file'.
pass
Expand All @@ -107,6 +170,16 @@ def test_fail_parse_rcv_compra_no_incluir_csv_file_bad_razon_social(self) -> Non
cm.exception.args,
("Value must not have leading or trailing whitespace.", ))

def test_parse_rcv_compra_no_incluir_csv_file_emisor_rz_leading_trailing_whitespace(
self,
) -> None:
self._test_parse_rcv_compra_csv_file_emisor_rz_leading_trailing_whitespace(
parse_rcv_compra_csv_file_function=parse_rcv_compra_no_incluir_csv_file,
rcv_file_path=(
'test_data/sii-rcv/RCV-compra-no_incluir-rz_leading_trailing_whitespace.csv'
),
)

def test_parse_rcv_compra_reclamado_csv_file(self) -> None:
# TODO: implement for 'parse_rcv_compra_reclamado_csv_file'.
pass
Expand All @@ -128,6 +201,16 @@ def test_fail_parse_rcv_compra_reclamado_csv_file_bad_razon_social(self) -> None
cm.exception.args,
("Value must not have leading or trailing whitespace.", ))

def test_parse_rcv_compra_reclamado_csv_file_emisor_rz_leading_trailing_whitespace(
self,
) -> None:
self._test_parse_rcv_compra_csv_file_emisor_rz_leading_trailing_whitespace(
parse_rcv_compra_csv_file_function=parse_rcv_compra_reclamado_csv_file,
rcv_file_path=(
'test_data/sii-rcv/RCV-compra-reclamado-rz_leading_trailing_whitespace.csv'
),
)

def test_parse_rcv_compra_pendiente_csv_file(self) -> None:
# TODO: implement for 'parse_rcv_compra_pendiente_csv_file'.
pass
Expand All @@ -149,6 +232,16 @@ def test_fail_parse_rcv_compra_pendiente_csv_file_bad_razon_social(self) -> None
cm.exception.args,
("Value must not have leading or trailing whitespace.", ))

def test_parse_rcv_compra_pendiente_csv_file_emisor_rz_leading_trailing_whitespace(
self,
) -> None:
self._test_parse_rcv_compra_csv_file_emisor_rz_leading_trailing_whitespace(
parse_rcv_compra_csv_file_function=parse_rcv_compra_pendiente_csv_file,
rcv_file_path=(
'test_data/sii-rcv/RCV-compra-pendiente-rz_leading_trailing_whitespace.csv'
),
)

def test__parse_rcv_csv_file(self) -> None:
# TODO: implement for '_parse_rcv_csv_file'.
pass
8 changes: 8 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
_TESTS_DIR_PATH = os.path.dirname(__file__)


def get_test_file_path(path: str) -> str:
filepath = os.path.join(
_TESTS_DIR_PATH,
path,
)
return filepath


def read_test_file_bytes(path: str) -> bytes:
filepath = os.path.join(
_TESTS_DIR_PATH,
Expand Down

0 comments on commit 8d0a5f4

Please sign in to comment.