first commit

This commit is contained in:
root
2026-03-14 09:42:12 +00:00
commit 0adbd20c2c
10991 changed files with 1646955 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.

View File

@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0</cbc:CustomizationID>
<cbc:ProfileID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</cbc:ProfileID>
<cbc:ID>123</cbc:ID>
<cbc:IssueDate>2026-01-01</cbc:IssueDate>
<cbc:DueDate>2026-01-01</cbc:DueDate>
<cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
<cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>
<cac:OrderReference>
<cbc:ID>NA</cbc:ID>
</cac:OrderReference>
<cac:AccountingSupplierParty>
<cac:Party>
<cbc:EndpointID schemeID="PARTICIPANT_SCHEME">PARTICIPANT_ID</cbc:EndpointID>
<cac:PostalAddress>
<cac:Country>
<cbc:IdentificationCode>BE</cbc:IdentificationCode>
</cac:Country>
</cac:PostalAddress>
<cac:PartyTaxScheme>
<cbc:CompanyID>PARTICIPANT_VAT</cbc:CompanyID>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:PartyTaxScheme>
<cac:PartyLegalEntity>
<cbc:RegistrationName>Supplier</cbc:RegistrationName>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
<cac:AccountingCustomerParty>
<cac:Party>
<cbc:EndpointID schemeID="PARTICIPANT_SCHEME">PARTICIPANT_ID</cbc:EndpointID>
<cac:PostalAddress>
<cac:Country>
<cbc:IdentificationCode>BE</cbc:IdentificationCode>
</cac:Country>
</cac:PostalAddress>
<cac:PartyTaxScheme>
<cbc:CompanyID>PARTICIPANT_VAT</cbc:CompanyID>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:PartyTaxScheme>
<cac:PartyLegalEntity>
<cbc:RegistrationName>Customer</cbc:RegistrationName>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingCustomerParty>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="EUR">10</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="EUR">100</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="EUR">10</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID>S</cbc:ID>
<cbc:Percent>10</cbc:Percent>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:LegalMonetaryTotal>
<cbc:LineExtensionAmount currencyID="EUR">100</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount currencyID="EUR">100</cbc:TaxExclusiveAmount>
<cbc:TaxInclusiveAmount currencyID="EUR">110</cbc:TaxInclusiveAmount>
<cbc:PayableAmount currencyID="EUR">110</cbc:PayableAmount>
</cac:LegalMonetaryTotal>
<cac:InvoiceLine>
<cbc:ID>1</cbc:ID>
<cbc:InvoicedQuantity unitCode="C62">1</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="EUR">100</cbc:LineExtensionAmount>
<cac:Item>
<cbc:Name>Product</cbc:Name>
<cac:ClassifiedTaxCategory>
<cbc:ID>S</cbc:ID>
<cbc:Percent>10</cbc:Percent>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:ClassifiedTaxCategory>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="EUR">100</cbc:PriceAmount>
</cac:Price>
</cac:InvoiceLine>
</Invoice>

View File

@@ -0,0 +1,84 @@
==================================
EDocument Peppol Peppyrus Scenario
==================================
Imports::
>>> import os
>>> import time
>>> from unittest.mock import patch
>>> from proteus import Model
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.modules.edocument_peppol.edocument import Peppol
>>> from trytond.tests.tools import activate_modules
>>> from trytond.tools import file_open
>>> FETCH_SLEEP, MAX_SLEEP = 1, 200
Patch Peppol::
>>> _validate = patch.object(Peppol, '_validate').start()
>>> render = patch.object(Peppol, 'render').start()
>>> participant_scheme, participant_id = (
... os.getenv('PEPPYRUS_PARTICIPANT_ID').split(':', 1))
>>> participant_vat = os.getenv('PEPPYRUS_PARTICIPANT_VAT')
>>> with file_open('edocument_peppol_peppyrus/tests/invoice.xml', mode='r') as fp:
... render.return_value = (
... fp.read()
... .replace('PARTICIPANT_SCHEME', participant_scheme)
... .replace('PARTICIPANT_ID', participant_id)
... .replace('PARTICIPANT_VAT', participant_vat.upper())
... .encode())
Activate modules::
>>> config = activate_modules('edocument_peppol_peppyrus', create_company)
>>> Cron = Model.get('ir.cron')
>>> Peppol = Model.get('edocument.peppol')
>>> PeppolService = Model.get('edocument.peppol.service')
Create a service::
>>> peppol_service = PeppolService(sequence=1)
>>> peppol_service.types = ['bis-billing-3']
>>> peppol_service.service = 'peppyrus'
>>> peppol_service.peppyrus_server = 'testing'
>>> peppol_service.peppyrus_api_key = os.getenv('PEPPYRUS_API_KEY')
>>> peppol_service.save()
Send out a Peppol document::
>>> peppol = Peppol(direction='out')
>>> peppol.type = 'bis-billing-3'
>>> peppol.service = peppol_service
>>> peppol.click('submit')
>>> peppol.state
'processing'
>>> bool(peppol.transmission_id)
True
Check Peppol status::
>>> cron, = Cron.find([
... ('method', '=', 'edocument.peppol|update_status'),
... ], limit=1)
>>> while peppol.state == 'processing':
... cron.click('run_once')
... peppol.reload()
>>> peppol.state
'succeeded'
Fetch messages::
>>> for _ in range(MAX_SLEEP):
... cron, = Cron.find([
... ('method', '=', 'edocument.peppol.service|peppyrus_fetch'),
... ], limit=1)
... cron.click('run_once')
... if bool(Peppol.find([('direction', '=', 'in')])):
... break
... time.sleep(FETCH_SLEEP)
>>> bool(Peppol.find([('direction', '=', 'in')]))
True

View File

@@ -0,0 +1,11 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.tests.test_tryton import ModuleTestCase
class EdocumentPeppolPeppyrusTestCase(ModuleTestCase):
"Test Edocument Peppol Peppyrus module"
module = 'edocument_peppol_peppyrus'
del ModuleTestCase

View File

@@ -0,0 +1,17 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import os
from trytond.tests.test_tryton import TEST_NETWORK, load_doc_tests
def load_tests(*args, **kwargs):
if (not TEST_NETWORK
or not (os.getenv('PEPPYRUS_API_KEY')
and os.getenv('PEPPYRUS_PARTICIPANT_ID')
and os.getenv('PEPPYRUS_PARTICIPANT_VAT'))):
kwargs.setdefault('skips', set()).update({
'scenario_edocument_peppol_peppyrus.rst',
})
return load_doc_tests(__name__, __file__, *args, **kwargs)