Treat DGII authorizations as independent imports
Publicar paquete PyPI / publish (push) Successful in 1m14s

This commit is contained in:
José Arturo García
2026-08-16 14:17:20 -04:00
parent 3fa3f2dd78
commit 65b70bee53
3 changed files with 59 additions and 26 deletions
+40
View File
@@ -313,6 +313,46 @@ class NcfManagerTestCase(ModuleTestCase):
self.assertEqual(Manager.search_count([
('app_number', '=', '6009912073')]), 1)
@with_transaction()
def test_import_new_authorization_for_active_request(self):
'A new NUM_AUTOR may reuse NUM_SOL without reopening the active one'
pool = Pool()
Manager = pool.get('ncf.manager')
Line = pool.get('ncf.manager.sequence')
company = self._create_company()
first_data = self._dgii_xml()
first_managers, _ = import_dgii_authorizations(
company, first_data, 'authorization-31.xml', activate=True)
first_manager, = first_managers
self.assertEqual(Manager(first_manager.id).state, 'active')
second_data = self._dgii_xml(
ncf_type='34', authorization='6005423852',
start='E340000000001', end='E340000001000', quantity='1000')
second_managers, second_lines = import_dgii_authorizations(
company, second_data, 'authorization-34.xml')
self.assertEqual(len(second_managers), 1)
self.assertEqual(len(second_lines), 1)
self.assertNotEqual(second_managers[0].id, first_manager.id)
self.assertEqual(second_managers[0].state, 'draft')
self.assertEqual(second_lines[0].auth_number, '6005423852')
self.assertEqual(Manager(first_manager.id).state, 'active')
self.assertEqual(Manager.search_count([
('company', '=', company.id),
('app_number', '=', '6009912073'),
]), 2)
self.assertEqual(Line.search_count([
('pos.company', '=', company.id),
('auth_number', 'in', ['6005423851', '6005423852']),
]), 2)
managers, lines = import_dgii_authorizations(
company, second_data, 'authorization-34-again.xml')
self.assertEqual(managers, [])
self.assertEqual(lines, [])
del ModuleTestCase