-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] l10n_ar_edi_ux: Add test_update_from_afip
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_update_from_afip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import odoo.tests.common as common | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class TestUpdateFromAfip(common.TransactionCase): | ||
|
||
def testmonotributo(self): | ||
"""Actualizamos un contacto del tipo monotributo""" | ||
|
||
# Chequeamos que no hay actividades ni impuestos creados | ||
self.assertEqual(self.env['afip.activity'], self.env['afip.activity'].search([]), "Activities are not being created.") | ||
self.assertEqual(self.env['afip.tax'], self.env['afip.tax'].search([]), "Taxes are not being created.") | ||
|
||
contacto = self.env['res.partner'].create({ | ||
'name': 'Partner Monotributo', | ||
'vat': '20221064233', | ||
'l10n_latam_identification_type_id': self.env.ref('l10n_ar.it_cuit').id, | ||
}) | ||
res_id = contacto.button_update_partner_data_from_afip()['res_id'] | ||
wiz = self.env['res.partner.update.from.padron.wizard'].browse(res_id) | ||
wiz.update_selection() | ||
|
||
self.assertEqual(contacto.name, 'Marjorier, Lamara', "Name after the update from afip must change") | ||
|
||
# Chequeamos que las actividades e impuestos se hayan creado con la actualizacion | ||
self.assertTrue(contacto.actividad_monotributo_padron, "Actividad monotributo padron are not being created.") | ||
self.assertTrue(contacto.actividades_padron, "Activities are not being created.") | ||
self.assertTrue(contacto.impuestos_padron, "Taxes are not being created.") | ||
|
||
def testresponsableinscripto(self): | ||
"""Actualizamos un contacto del tipo Responsable Inscripto""" | ||
|
||
# Chequeamos que no hay actividades ni impuestos creados | ||
self.assertEqual(self.env['afip.activity'], self.env['afip.activity'].search([]), "Activities are not being created.") | ||
self.assertEqual(self.env['afip.tax'], self.env['afip.tax'].search([]), "Taxes are not being created.") | ||
|
||
contacto = self.env['res.partner'].create({ | ||
'name': 'Partner Responsable Inscripto', | ||
'vat': '20188027963', | ||
'l10n_latam_identification_type_id': self.env.ref('l10n_ar.it_cuit').id, | ||
}) | ||
res_id = contacto.button_update_partner_data_from_afip()['res_id'] | ||
wiz = self.env['res.partner.update.from.padron.wizard'].browse(res_id) | ||
wiz.update_selection() | ||
|
||
self.assertEqual(contacto.name, 'Paniagua Koler, Venancio', "Name after the update from afip must change") | ||
|
||
# Chequeamos que las actividades e impuestos se hayan creado con la actualizacion | ||
self.assertTrue(contacto.actividades_padron, "Activities are not being created.") | ||
self.assertTrue(contacto.impuestos_padron, "Taxes are not being created.") | ||
|
||
def testcontactoerror(self): | ||
"""Aseguramos de catchear bien el error del contacto""" | ||
|
||
contacto = self.env['res.partner'].create({ | ||
'name': 'Partner Error', | ||
'vat': '30999999995', | ||
'l10n_latam_identification_type_id': self.env.ref('l10n_ar.it_cuit').id, | ||
}) | ||
error_message = 'El número de documento informado es inválido' | ||
with self.assertRaisesRegex(UserError, error_message): | ||
contacto.button_update_partner_data_from_afip() | ||
self.assertTrue(error_message not in contacto.message_ids.mapped('body'), "Not message should be posted in the contact if there was an error") |