Skip to content

Commit 5be6e28

Browse files
committed
[IMP] l10n_{anz,jp,my,sg}_ubl_pint: Add XML generation tests
closes odoo#213402 Related: odoo/enterprise#87222 Signed-off-by: Laurent Smet (las) <[email protected]>
1 parent e0ab8c2 commit 5be6e28

File tree

15 files changed

+970
-13
lines changed

15 files changed

+970
-13
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_anz_ubl_pint
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Invoice xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
3+
<cbc:CustomizationID>urn:peppol:pint:billing-1@aunz-1</cbc:CustomizationID>
4+
<cbc:ProfileID>urn:peppol:bis:billing</cbc:ProfileID>
5+
<cbc:ID>INV/18-19/0001</cbc:ID>
6+
<cbc:IssueDate>2019-01-01</cbc:IssueDate>
7+
<cbc:DueDate>2019-01-01</cbc:DueDate>
8+
<cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
9+
<cbc:DocumentCurrencyCode>NZD</cbc:DocumentCurrencyCode>
10+
<cbc:TaxCurrencyCode>AUD</cbc:TaxCurrencyCode>
11+
<cac:OrderReference>
12+
<cbc:ID>INV/18-19/0001</cbc:ID>
13+
</cac:OrderReference>
14+
<cac:AccountingSupplierParty>
15+
<cac:Party>
16+
<cbc:EndpointID schemeID="0151">11225459588</cbc:EndpointID>
17+
<cac:PartyName>
18+
<cbc:Name>company_1_data</cbc:Name>
19+
</cac:PartyName>
20+
<cac:PostalAddress>
21+
<cbc:StreetName>Henry Lawson Drive</cbc:StreetName>
22+
<cbc:CityName>Home Rule</cbc:CityName>
23+
<cbc:PostalZone>2850</cbc:PostalZone>
24+
<cbc:CountrySubentity>Western Australia</cbc:CountrySubentity>
25+
<cac:Country>
26+
<cbc:IdentificationCode>AU</cbc:IdentificationCode>
27+
</cac:Country>
28+
</cac:PostalAddress>
29+
<cac:PartyTaxScheme>
30+
<cbc:CompanyID>11225459588</cbc:CompanyID>
31+
<cac:TaxScheme>
32+
<cbc:ID>GST</cbc:ID>
33+
</cac:TaxScheme>
34+
</cac:PartyTaxScheme>
35+
<cac:PartyLegalEntity>
36+
<cbc:RegistrationName>company_1_data</cbc:RegistrationName>
37+
<cbc:CompanyID schemeID="0151">11225459588</cbc:CompanyID>
38+
</cac:PartyLegalEntity>
39+
<cac:Contact>
40+
<cbc:Name>company_1_data</cbc:Name>
41+
<cbc:Telephone>+61 412 345 678</cbc:Telephone>
42+
</cac:Contact>
43+
</cac:Party>
44+
</cac:AccountingSupplierParty>
45+
<cac:AccountingCustomerParty>
46+
<cac:Party>
47+
<cbc:EndpointID schemeID="0088">9429047488083</cbc:EndpointID>
48+
<cac:PartyName>
49+
<cbc:Name>partner_a</cbc:Name>
50+
</cac:PartyName>
51+
<cac:PostalAddress>
52+
<cbc:StreetName>Victoria Street</cbc:StreetName>
53+
<cbc:CityName>Hamilton</cbc:CityName>
54+
<cbc:PostalZone>3247</cbc:PostalZone>
55+
<cbc:CountrySubentity>West Coast</cbc:CountrySubentity>
56+
<cac:Country>
57+
<cbc:IdentificationCode>NZ</cbc:IdentificationCode>
58+
</cac:Country>
59+
</cac:PostalAddress>
60+
<cac:PartyTaxScheme>
61+
<cbc:CompanyID>49098576</cbc:CompanyID>
62+
<cac:TaxScheme>
63+
<cbc:ID>GST</cbc:ID>
64+
</cac:TaxScheme>
65+
</cac:PartyTaxScheme>
66+
<cac:PartyLegalEntity>
67+
<cbc:RegistrationName>partner_a</cbc:RegistrationName>
68+
<cbc:CompanyID schemeID="0088">49098576</cbc:CompanyID>
69+
</cac:PartyLegalEntity>
70+
<cac:Contact>
71+
<cbc:Name>partner_a</cbc:Name>
72+
<cbc:Telephone>+64 21 123 4567</cbc:Telephone>
73+
</cac:Contact>
74+
</cac:Party>
75+
</cac:AccountingCustomerParty>
76+
<cac:Delivery>
77+
<cac:DeliveryLocation>
78+
<cac:Address>
79+
<cbc:StreetName>Victoria Street</cbc:StreetName>
80+
<cbc:CityName>Hamilton</cbc:CityName>
81+
<cbc:PostalZone>3247</cbc:PostalZone>
82+
<cbc:CountrySubentity>West Coast</cbc:CountrySubentity>
83+
<cac:Country>
84+
<cbc:IdentificationCode>NZ</cbc:IdentificationCode>
85+
</cac:Country>
86+
</cac:Address>
87+
</cac:DeliveryLocation>
88+
</cac:Delivery>
89+
<cac:PaymentMeans>
90+
<cbc:PaymentMeansCode name="mutually defined">ZZZ</cbc:PaymentMeansCode>
91+
<cbc:PaymentID>INV/18-19/0001</cbc:PaymentID>
92+
</cac:PaymentMeans>
93+
<cac:PaymentTerms>
94+
<cbc:Note>Payment terms: Immediate Payment</cbc:Note>
95+
</cac:PaymentTerms>
96+
<cac:TaxTotal>
97+
<cbc:TaxAmount currencyID="NZD">200.00</cbc:TaxAmount>
98+
<cac:TaxSubtotal>
99+
<cbc:TaxableAmount currencyID="NZD">2000.00</cbc:TaxableAmount>
100+
<cbc:TaxAmount currencyID="NZD">200.00</cbc:TaxAmount>
101+
<cac:TaxCategory>
102+
<cbc:ID>S</cbc:ID>
103+
<cbc:Percent>10.0</cbc:Percent>
104+
<cac:TaxScheme>
105+
<cbc:ID>GST</cbc:ID>
106+
</cac:TaxScheme>
107+
</cac:TaxCategory>
108+
</cac:TaxSubtotal>
109+
</cac:TaxTotal>
110+
<cac:TaxTotal>
111+
<cbc:TaxAmount currencyID="AUD">100.00</cbc:TaxAmount>
112+
</cac:TaxTotal>
113+
<cac:LegalMonetaryTotal>
114+
<cbc:LineExtensionAmount currencyID="NZD">2000.00</cbc:LineExtensionAmount>
115+
<cbc:TaxExclusiveAmount currencyID="NZD">2000.00</cbc:TaxExclusiveAmount>
116+
<cbc:TaxInclusiveAmount currencyID="NZD">2200.00</cbc:TaxInclusiveAmount>
117+
<cbc:PrepaidAmount currencyID="NZD">0.00</cbc:PrepaidAmount>
118+
<cbc:PayableAmount currencyID="NZD">2200.00</cbc:PayableAmount>
119+
</cac:LegalMonetaryTotal>
120+
<cac:InvoiceLine>
121+
<cbc:ID>1</cbc:ID>
122+
<cbc:InvoicedQuantity unitCode="C62">1.0</cbc:InvoicedQuantity>
123+
<cbc:LineExtensionAmount currencyID="NZD">2000.00</cbc:LineExtensionAmount>
124+
<cac:Item>
125+
<cbc:Description>product_a</cbc:Description>
126+
<cbc:Name>product_a</cbc:Name>
127+
<cac:ClassifiedTaxCategory>
128+
<cbc:ID>S</cbc:ID>
129+
<cbc:Percent>10.0</cbc:Percent>
130+
<cac:TaxScheme>
131+
<cbc:ID>GST</cbc:ID>
132+
</cac:TaxScheme>
133+
</cac:ClassifiedTaxCategory>
134+
</cac:Item>
135+
<cac:Price>
136+
<cbc:PriceAmount currencyID="NZD">2000.0</cbc:PriceAmount>
137+
</cac:Price>
138+
</cac:InvoiceLine>
139+
</Invoice>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 TestAnzUBLPint(AccountTestInvoicingCommon):
13+
14+
@classmethod
15+
@AccountTestInvoicingCommon.setup_country('au')
16+
def setUpClass(cls):
17+
super().setUpClass()
18+
19+
cls.other_currency = cls.setup_other_currency('NZD')
20+
21+
# TIN number is required
22+
cls.company_data['company'].write({
23+
'vat': '11225459588',
24+
'street': 'Henry Lawson Drive',
25+
'zip': '2850',
26+
'city': 'Home Rule',
27+
'state_id': cls.env.ref('base.state_au_8').id,
28+
'phone': '+61 412 345 678',
29+
})
30+
cls.partner_a.write({
31+
'vat': '49098576',
32+
'company_registry': '9429047488083',
33+
'street': 'Victoria Street',
34+
'zip': '3247',
35+
'city': 'Hamilton',
36+
'state_id': cls.env.ref('base.state_nz_wtc').id,
37+
'country_id': cls.env.ref('base.nz').id,
38+
'phone': '+64 21 123 4567',
39+
})
40+
41+
cls.fakenow = datetime(2024, 7, 15, 10, 00, 00)
42+
cls.startClassPatcher(freeze_time(cls.fakenow))
43+
44+
def test_invoice(self):
45+
invoice = self.init_invoice('out_invoice', currency=self.other_currency, products=self.product_a)
46+
invoice.action_post()
47+
48+
actual_xml, errors = self.env['account.edi.xml.pint_anz']._export_invoice(invoice)
49+
self.assertFalse(errors)
50+
51+
with file_open('l10n_anz_ubl_pint/tests/expected_xmls/invoice.xml', 'rb') as f:
52+
expected_xml = f.read()
53+
54+
self.assertXmlTreeEqual(
55+
self.get_xml_tree_from_string(actual_xml),
56+
self.get_xml_tree_from_string(expected_xml),
57+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_jp_ubl_pint
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
3+
<cbc:CustomizationID>urn:peppol:pint:billing-1@jp-1</cbc:CustomizationID>
4+
<cbc:ProfileID>urn:peppol:bis:billing</cbc:ProfileID>
5+
<cbc:ID>INV/2019/00001</cbc:ID>
6+
<cbc:IssueDate>2019-01-01</cbc:IssueDate>
7+
<cbc:DueDate>2019-01-01</cbc:DueDate>
8+
<cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
9+
<cbc:DocumentCurrencyCode>USD</cbc:DocumentCurrencyCode>
10+
<cbc:TaxCurrencyCode>JPY</cbc:TaxCurrencyCode>
11+
<cac:InvoicePeriod>
12+
<cbc:StartDate>2019-01-01</cbc:StartDate>
13+
<cbc:EndDate>2019-01-01</cbc:EndDate>
14+
</cac:InvoicePeriod>
15+
<cac:OrderReference>
16+
<cbc:ID>INV/2019/00001</cbc:ID>
17+
</cac:OrderReference>
18+
<cac:AccountingSupplierParty>
19+
<cac:Party>
20+
<cbc:EndpointID schemeID="0221">7482543580381</cbc:EndpointID>
21+
<cac:PartyName>
22+
<cbc:Name>company_1_data</cbc:Name>
23+
</cac:PartyName>
24+
<cac:PostalAddress>
25+
<cbc:StreetName>池上通り</cbc:StreetName>
26+
<cbc:CityName>品川区</cbc:CityName>
27+
<cbc:PostalZone>140-0004</cbc:PostalZone>
28+
<cbc:CountrySubentity>Yamanashi</cbc:CountrySubentity>
29+
<cac:Country>
30+
<cbc:IdentificationCode>JP</cbc:IdentificationCode>
31+
</cac:Country>
32+
</cac:PostalAddress>
33+
<cac:PartyTaxScheme>
34+
<cbc:CompanyID>7482543580381</cbc:CompanyID>
35+
<cac:TaxScheme>
36+
<cbc:ID>NOT_EU_VAT</cbc:ID>
37+
</cac:TaxScheme>
38+
</cac:PartyTaxScheme>
39+
<cac:PartyLegalEntity>
40+
<cbc:RegistrationName>company_1_data</cbc:RegistrationName>
41+
</cac:PartyLegalEntity>
42+
<cac:Contact>
43+
<cbc:Name>company_1_data</cbc:Name>
44+
<cbc:Telephone>+81 90-1234-5678</cbc:Telephone>
45+
</cac:Contact>
46+
</cac:Party>
47+
</cac:AccountingSupplierParty>
48+
<cac:AccountingCustomerParty>
49+
<cac:Party>
50+
<cbc:EndpointID schemeID="0221">T7000012050002</cbc:EndpointID>
51+
<cac:PartyName>
52+
<cbc:Name>partner_a</cbc:Name>
53+
</cac:PartyName>
54+
<cac:PostalAddress>
55+
<cbc:StreetName>3F 星和池袋ビル</cbc:StreetName>
56+
<cbc:CityName>豊島区</cbc:CityName>
57+
<cbc:PostalZone>170-0013</cbc:PostalZone>
58+
<cbc:CountrySubentity>Tokyo</cbc:CountrySubentity>
59+
<cac:Country>
60+
<cbc:IdentificationCode>JP</cbc:IdentificationCode>
61+
</cac:Country>
62+
</cac:PostalAddress>
63+
<cac:PartyTaxScheme>
64+
<cbc:CompanyID>T7000012050002</cbc:CompanyID>
65+
<cac:TaxScheme>
66+
<cbc:ID>NOT_EU_VAT</cbc:ID>
67+
</cac:TaxScheme>
68+
</cac:PartyTaxScheme>
69+
<cac:PartyLegalEntity>
70+
<cbc:RegistrationName>partner_a</cbc:RegistrationName>
71+
</cac:PartyLegalEntity>
72+
<cac:Contact>
73+
<cbc:Name>partner_a</cbc:Name>
74+
<cbc:Telephone>+81 3-5798-5555</cbc:Telephone>
75+
</cac:Contact>
76+
</cac:Party>
77+
</cac:AccountingCustomerParty>
78+
<cac:Delivery>
79+
<cac:DeliveryLocation>
80+
<cac:Address>
81+
<cbc:StreetName>3F 星和池袋ビル</cbc:StreetName>
82+
<cbc:CityName>豊島区</cbc:CityName>
83+
<cbc:PostalZone>170-0013</cbc:PostalZone>
84+
<cbc:CountrySubentity>Tokyo</cbc:CountrySubentity>
85+
<cac:Country>
86+
<cbc:IdentificationCode>JP</cbc:IdentificationCode>
87+
</cac:Country>
88+
</cac:Address>
89+
</cac:DeliveryLocation>
90+
</cac:Delivery>
91+
<cac:PaymentMeans>
92+
<cbc:PaymentMeansCode name="mutually defined">ZZZ</cbc:PaymentMeansCode>
93+
<cbc:PaymentID>INV/2019/00001</cbc:PaymentID>
94+
</cac:PaymentMeans>
95+
<cac:PaymentTerms>
96+
<cbc:Note>Payment terms: Immediate Payment</cbc:Note>
97+
</cac:PaymentTerms>
98+
<cac:TaxTotal>
99+
<cbc:TaxAmount currencyID="USD">100.00</cbc:TaxAmount>
100+
<cac:TaxSubtotal>
101+
<cbc:TaxableAmount currencyID="USD">1000.00</cbc:TaxableAmount>
102+
<cbc:TaxAmount currencyID="USD">100.00</cbc:TaxAmount>
103+
<cac:TaxCategory>
104+
<cbc:ID>S</cbc:ID>
105+
<cbc:Percent>10.0</cbc:Percent>
106+
<cac:TaxScheme>
107+
<cbc:ID>VAT</cbc:ID>
108+
</cac:TaxScheme>
109+
</cac:TaxCategory>
110+
</cac:TaxSubtotal>
111+
</cac:TaxTotal>
112+
<cac:TaxTotal>
113+
<cbc:TaxAmount currencyID="JPY">50</cbc:TaxAmount>
114+
<cac:TaxSubtotal>
115+
<cbc:TaxableAmount currencyID="JPY">500</cbc:TaxableAmount>
116+
<cbc:TaxAmount currencyID="JPY">50</cbc:TaxAmount>
117+
<cbc:Percent>10.0</cbc:Percent>
118+
<cac:TaxCategory>
119+
<cbc:ID>S</cbc:ID>
120+
<cbc:Percent>10.0</cbc:Percent>
121+
<cac:TaxScheme>
122+
<cbc:ID>VAT</cbc:ID>
123+
</cac:TaxScheme>
124+
</cac:TaxCategory>
125+
</cac:TaxSubtotal>
126+
</cac:TaxTotal>
127+
<cac:LegalMonetaryTotal>
128+
<cbc:LineExtensionAmount currencyID="USD">1000.00</cbc:LineExtensionAmount>
129+
<cbc:TaxExclusiveAmount currencyID="USD">1000.00</cbc:TaxExclusiveAmount>
130+
<cbc:TaxInclusiveAmount currencyID="USD">1100.00</cbc:TaxInclusiveAmount>
131+
<cbc:PrepaidAmount currencyID="USD">0.00</cbc:PrepaidAmount>
132+
<cbc:PayableAmount currencyID="USD">1100.00</cbc:PayableAmount>
133+
</cac:LegalMonetaryTotal>
134+
<cac:InvoiceLine>
135+
<cbc:ID>1</cbc:ID>
136+
<cbc:InvoicedQuantity unitCode="C62">1.0</cbc:InvoicedQuantity>
137+
<cbc:LineExtensionAmount currencyID="USD">1000.00</cbc:LineExtensionAmount>
138+
<cac:Item>
139+
<cbc:Description>product_a</cbc:Description>
140+
<cbc:Name>product_a</cbc:Name>
141+
<cac:ClassifiedTaxCategory>
142+
<cbc:ID>S</cbc:ID>
143+
<cbc:Percent>10.0</cbc:Percent>
144+
<cac:TaxScheme>
145+
<cbc:ID>VAT</cbc:ID>
146+
</cac:TaxScheme>
147+
</cac:ClassifiedTaxCategory>
148+
</cac:Item>
149+
<cac:Price>
150+
<cbc:PriceAmount currencyID="USD">1000.0</cbc:PriceAmount>
151+
</cac:Price>
152+
</cac:InvoiceLine>
153+
</Invoice>

0 commit comments

Comments
 (0)