Skip to content
This repository has been archived by the owner on Sep 29, 2022. It is now read-only.

Commit

Permalink
Extinción de sociedad
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloCastellano committed Jan 7, 2017
1 parent 5cfc0eb commit 8d276bb
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
4 changes: 4 additions & 0 deletions borme/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ def _import1(borme):
# not bormeparser.borme.BormeActoCargo
nuevo_anuncio.actos[acto.name] = acto.value

if acto.name == 'Extinción':
company.is_active = False
company._finalizar_cargos(borme.date)

company.anuncios.append(anuncio.id) # TODO: year
company.date_updated = borme.date
company.save()
Expand Down
15 changes: 15 additions & 0 deletions borme/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,21 @@ def update_cargos_salientes(self, cargos):
else:
raise ValueError('type: invalid value')

def _finalizar_cargos(self, date):
""" Se llama a este método cuando una sociedad se extingue.
Todos los cargos vigentes pasan a estar en la lista de cargos cesados.
"""
for cargo in self.cargos_actuales_c:
cargo['date_to'] = date
self.cargos_historial_c.append(cargo)

for cargo in self.cargos_actuales_p:
cargo['date_to'] = date
self.cargos_historial_p.append(cargo)

self.cargos_actuales_c = []
self.cargos_actuales_p = []

def get_absolute_url(self):
return reverse('borme-empresa', args=[str(self.slug)])

Expand Down
33 changes: 33 additions & 0 deletions borme/tests/files/4_extincion.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"cve": "BORME-Z-2015-3-04",
"date": "2015-01-04",
"seccion": "A",
"provincia": "Almer\u00eda",
"num": 1,
"url": "unused_url",
"from_anuncio": 1,
"to_anuncio": 1,
"anuncios": {
"1": {
"empresa": "EMPRESA EXTINGUIDA SL",
"datos registrales": "T 1 , F 2, S 3, H AL 42885, I/A 2 (19.12.14).",
"actos": {
"Nombramientos": {
"Adm. Solid.": [
"FRANCISCO GOMEZ",
]
}
},
"num_actos": 1
},
"2": {
"empresa": "EMPRESA EXTINGUIDA SL",
"datos registrales": "T 1 , F 2, S 3, H AL 42885, I/A 2 (19.12.14).",
"actos": {
"Extinci\u00f3n": true
},
"num_actos": 1
}
},
"num_anuncios": 2
}
19 changes: 18 additions & 1 deletion borme/tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_nombramientos_ceses(self):


class TestImport3(TestCase):

def test_nombramientos_ceses(self):
companies = Company.objects.all()
self.assertEqual(len(companies), 0)
Expand All @@ -61,3 +61,20 @@ def test_nombramientos_ceses(self):
self.assertEqual(company.name, 'EMPRESA TRES')
self.assertEqual(len(company.get_cargos_actuales(limit=0)), 1)
self.assertEqual(len(company.get_cargos_historial(limit=0)), 2)


class TestImport4(TestCase):

def test_extincion(self):
companies = Company.objects.all()
self.assertEqual(len(companies), 0)

json_path = os.path.join(THIS_PATH, 'files', '4_extincion.json')
ret = import_borme_json(json_path)
self.assertTrue(ret)
companies = Company.objects.all()
self.assertEqual(len(companies), 1)
company = companies[0]
self.assertEqual(company.name, 'EMPRESA EXTINGUIDA')
self.assertEqual(len(company.get_cargos_actuales(limit=0)), 0)
self.assertEqual(len(company.get_cargos_historial(limit=0)), 1)

0 comments on commit 8d276bb

Please sign in to comment.