Debian Codegraph @

addons/l10n_sg_ubl_pint/tests/test_sg_ubl_pint.py

raw symbols SCIP
1 # Part of Odoo. See LICENSE file for full copyright and licensing details.
2 from datetime import datetime
3
4 from freezegun import freeze_time
5
6 from odoo.addons.account.tests.common import AccountTestInvoicingCommon
7 from odoo.tools import file_open
8 from odoo.tests import tagged
9
10
11 @tagged('post_install_l10n', 'post_install', '-at_install')
12 class TestSgUBLPint(AccountTestInvoicingCommon):
13
14 @classmethod
15 @AccountTestInvoicingCommon.setup_country('sg')
16 def setUpClass(cls):
17 super().setUpClass()
18
19 cls.other_currency = cls.setup_other_currency('EUR')
20
21 # TIN number is required
22 cls.company_data['company'].write({
23 'vat': '197401143C',
24 'l10n_sg_unique_entity_number': '201131415A',
25 'street': 'Tyersall Avenue',
26 'zip': '248048',
27 'city': 'Central Singapore',
28 'phone': '+65 9123 4567',
29 })
30 cls.partner_a.write({
31 'vat': 'S16FC0121D',
32 'country_id': cls.env.ref('base.sg').id,
33 'street': 'that other street, 3',
34 'zip': '248050',
35 'city': 'East Singapore',
36 'phone': '+65 9123 4589',
37 })
38 cls.tax_9 = cls.env['account.tax'].create({
39 'name': '9% GST',
40 'amount_type': 'percent',
41 'amount': 9,
42 'type_tax_use': 'sale',
43 'country_id': cls.env.ref('base.sg').id,
44 'ubl_cii_tax_category_code': 'SR',
45 })
46
47 cls.fakenow = datetime(2024, 7, 15, 10, 00, 00)
48 cls.startClassPatcher(freeze_time(cls.fakenow))
49
50 def test_invoice(self):
51 invoice = self.init_invoice('out_invoice', currency=self.other_currency, products=self.product_a, taxes=self.tax_9)
52 invoice.action_post()
53
54 actual_xml, errors = self.env['account.edi.xml.pint_sg']._export_invoice(invoice)
55 self.assertFalse(errors)
56
57 with file_open('l10n_sg_ubl_pint/tests/expected_xmls/invoice.xml', 'rb') as f:
58 expected_xml = f.read()
59
60 self.assertXmlTreeEqual(
61 self.get_xml_tree_from_string(actual_xml),
62 self.get_xml_tree_from_string(expected_xml),
63 )