Compare commits

...

4 commits

Author SHA1 Message Date
Frederik Jaeckel
01616c6c4b Update copyright 2025-05-02 14:34:43 +02:00
Frederik Jaeckel
d52774a77e round incoming unit_price and quantity to match digits of fields 2025-01-29 10:50:13 +01:00
Frederik Jaeckel
5fc191697a extras_depend to sale_point_invoice to arrange order of execution of '_process_supplier_invoice' 2025-01-27 12:32:49 +01:00
Frederik Jaeckel
024cf87978 configuration: add filter to 'product_category' 2025-01-27 10:55:17 +01:00
7 changed files with 39 additions and 22 deletions

View file

@ -1,6 +1,5 @@
Copyright (C) 2015-2025 Cédric Krier. Copyright (C) 2024-2025 martin-data services.
Copyright (C) 2015-2025 B2CK SPRL. Copyright (C) 2025 Mathias Behrle <mathiasb@m9s.biz>
Copyright (C) 2021-2025 martin-data services.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View file

@ -34,7 +34,7 @@ class Configuration(metaclass=PoolMeta):
product_category = fields.Many2Many( product_category = fields.Many2Many(
string='Categories', origin='config', target='category', string='Categories', origin='config', target='category',
help='Categories used to determine tax and accounts for a product ' + help='Categories used to determine tax and accounts for a product ' +
'on an invoice line.', 'on an invoice line.', filter=[('accounting', '=', True)],
relation_name='document.incoming.confprodcat_rel') relation_name='document.incoming.confprodcat_rel')
@classmethod @classmethod

View file

@ -20,6 +20,7 @@ from trytond.i18n import gettext
from trytond.model import fields from trytond.model import fields
from trytond.pyson import Eval from trytond.pyson import Eval
from trytond.protocols.jsonrpc import JSONEncoder from trytond.protocols.jsonrpc import JSONEncoder
from trytond.modules.product import round_price
xml_types = [ xml_types = [
@ -719,12 +720,15 @@ class Incoming(metaclass=PoolMeta):
if units: if units:
xml_uom = units[0] xml_uom = units[0]
unitprice = line_data.get('unit_net_price', {}).pop('amount', None)
line = Line( line = Line(
invoice=invoice, invoice=invoice,
type='line', type='line',
unit=xml_uom, unit=xml_uom,
quantity=line_data.get('quantity', {}).pop('billed', None), quantity=xml_uom.round(
unit_price=line_data.get('unit_net_price', {}).pop('amount', None)) line_data.get('quantity', {}).pop('billed', None)),
unit_price=round_price(unitprice)
if unitprice is not None else Decimal('0.0'))
line_no = line_data.pop('line_no', None) line_no = line_data.pop('line_no', None)
# description # description
@ -963,9 +967,9 @@ class Incoming(metaclass=PoolMeta):
result['quantity'] = self._readxml_read_listdata( result['quantity'] = self._readxml_read_listdata(
xmldata, xpath_line, [ xmldata, xpath_line, [
'ram:SpecifiedLineTradeDelivery'], [ 'ram:SpecifiedLineTradeDelivery'], [
('ram:BilledQuantity', 'billed', Decimal), ('ram:BilledQuantity', 'billed', float),
('ram:ChargeFreeQuantity', 'chargefree', Decimal), ('ram:ChargeFreeQuantity', 'chargefree', float),
('ram:PackageQuantity', 'package', Decimal), ('ram:PackageQuantity', 'package', float),
])[0] ])[0]
result['quantity']['unit_code'] = self._readxml_getattrib( result['quantity']['unit_code'] = self._readxml_getattrib(
xmldata, xpath_quantity + ['ram:BilledQuantity'], 'unitCode') xmldata, xpath_quantity + ['ram:BilledQuantity'], 'unitCode')

View file

@ -85,6 +85,8 @@ setup(
'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
], ],
keywords='tryton account invoice xrechnung edocument incoming', keywords='tryton account invoice xrechnung edocument incoming',

View file

@ -23,7 +23,7 @@ parsed_data_ci_invoice = {
'total': {'amount': Decimal('1350.00')}, 'total': {'amount': Decimal('1350.00')},
'line_no': '1', 'line_no': '1',
'quantity': { 'quantity': {
'billed': Decimal('1.0'), 'billed': 1.0,
'unit_code': 'KGM'}, 'unit_code': 'KGM'},
'unit_net_price': {'amount': Decimal('1350.00')}, 'unit_net_price': {'amount': Decimal('1350.00')},
}, { }, {
@ -34,7 +34,7 @@ parsed_data_ci_invoice = {
'total': {'amount': Decimal('1200.00')}, 'total': {'amount': Decimal('1200.00')},
'line_no': '2', 'line_no': '2',
'quantity': { 'quantity': {
'billed': Decimal('1.5'), 'billed': 1.5,
'unit_code': 'KGM'}, 'unit_code': 'KGM'},
'unit_net_price': {'amount': Decimal('800.00')}, 'unit_net_price': {'amount': Decimal('800.00')},
}, { }, {
@ -42,7 +42,7 @@ parsed_data_ci_invoice = {
'total': {'amount': Decimal('300.00')}, 'total': {'amount': Decimal('300.00')},
'line_no': '3', 'line_no': '3',
'quantity': { 'quantity': {
'billed': Decimal('2.0'), 'billed': 2.0,
'unit_code': 'MTR'}, 'unit_code': 'MTR'},
'unit_net_price': {'amount': Decimal('150.00')}}], 'unit_net_price': {'amount': Decimal('150.00')}}],
'note_list': [{ 'note_list': [{
@ -101,7 +101,7 @@ parsed_data_facturx_en16931 = {
'description': 'Description of Product 1', 'description': 'Description of Product 1',
'unit_net_price': {'amount': Decimal('1350.00')}, 'unit_net_price': {'amount': Decimal('1350.00')},
'quantity': { 'quantity': {
'billed': Decimal('1.0'), 'unit_code': 'KGM'}, 'billed': 1.0, 'unit_code': 'KGM'},
'taxes': [{ 'taxes': [{
'type': 'VAT', 'type': 'VAT',
'category_code': 'S', 'category_code': 'S',
@ -127,7 +127,7 @@ parsed_data_facturx_en16931 = {
'amount': Decimal('950.00'), 'amount': Decimal('950.00'),
'basequantity': Decimal('1.0')}, 'basequantity': Decimal('1.0')},
'quantity': { 'quantity': {
'billed': Decimal('1.5'), 'billed': 1.5,
'unit_code': 'KGM'}, 'unit_code': 'KGM'},
'taxes': [{ 'taxes': [{
'type': 'VAT', 'type': 'VAT',
@ -141,7 +141,7 @@ parsed_data_facturx_en16931 = {
'description': 'Description of Product 3', 'description': 'Description of Product 3',
'unit_net_price': {'amount': Decimal('150.00')}, 'unit_net_price': {'amount': Decimal('150.00')},
'quantity': { 'quantity': {
'billed': Decimal('2.0'), 'billed': 2.0,
'unit_code': 'MTR'}, 'unit_code': 'MTR'},
'taxes': [{ 'taxes': [{
'type': 'VAT', 'type': 'VAT',
@ -213,7 +213,7 @@ parsed_data_facturx_basic = {
'line_no': '1', 'line_no': '1',
'name': 'Name of Product 1', 'name': 'Name of Product 1',
'unit_net_price': {'amount': Decimal('1350.00')}, 'unit_net_price': {'amount': Decimal('1350.00')},
'quantity': {'billed': Decimal('1.0'), 'unit_code': 'KGM'}, 'quantity': {'billed': 1.0, 'unit_code': 'KGM'},
'taxes': [{ 'taxes': [{
'type': 'VAT', 'type': 'VAT',
'category_code': 'S', 'category_code': 'S',
@ -231,7 +231,7 @@ parsed_data_facturx_basic = {
'amount': Decimal('950.00'), 'amount': Decimal('950.00'),
'basequantity': Decimal('1.0')}, 'basequantity': Decimal('1.0')},
'quantity': { 'quantity': {
'billed': Decimal('1.5'), 'billed': 1.5,
'unit_code': 'KGM'}, 'unit_code': 'KGM'},
'taxes': [{ 'taxes': [{
'type': 'VAT', 'type': 'VAT',
@ -243,7 +243,7 @@ parsed_data_facturx_basic = {
'name': 'Name of Product 3', 'name': 'Name of Product 3',
'unit_net_price': {'amount': Decimal('150.00')}, 'unit_net_price': {'amount': Decimal('150.00')},
'quantity': { 'quantity': {
'billed': Decimal('2.0'), 'billed': 2.0,
'unit_code': 'MTR'}, 'unit_code': 'MTR'},
'taxes': [{ 'taxes': [{
'type': 'VAT', 'type': 'VAT',
@ -328,7 +328,7 @@ parsed_data_facturx_extended = {
'name': 'Name of Product 1', 'name': 'Name of Product 1',
'description': 'Description of Product 1', 'description': 'Description of Product 1',
'unit_net_price': {'amount': Decimal('1350.00')}, 'unit_net_price': {'amount': Decimal('1350.00')},
'quantity': {'billed': Decimal('1.0'), 'unit_code': 'KGM'}, 'quantity': {'billed': 1.0, 'unit_code': 'KGM'},
'taxes': [{ 'taxes': [{
'type': 'VAT', 'type': 'VAT',
'category_code': 'S', 'category_code': 'S',
@ -379,7 +379,7 @@ parsed_data_facturx_extended = {
'amount': Decimal('950.00'), 'amount': Decimal('950.00'),
'basequantity': Decimal('1.0')}, 'basequantity': Decimal('1.0')},
'quantity': { 'quantity': {
'billed': Decimal('1.5'), 'billed': 1.5,
'unit_code': 'KGM', 'unit_code': 'KGM',
'package': Decimal('1.5')}, 'package': Decimal('1.5')},
'taxes': [{ 'taxes': [{
@ -392,7 +392,7 @@ parsed_data_facturx_extended = {
'name': 'Name of Product 3', 'name': 'Name of Product 3',
'description': 'Description of Product 3', 'description': 'Description of Product 3',
'unit_net_price': {'amount': Decimal('150.00')}, 'unit_net_price': {'amount': Decimal('150.00')},
'quantity': {'billed': Decimal('2.0'), 'unit_code': 'MTR'}, 'quantity': {'billed': 2.0, 'unit_code': 'MTR'},
'taxes': [{ 'taxes': [{
'type': 'VAT', 'type': 'VAT',
'category_code': 'S', 'category_code': 'S',

View file

@ -4,7 +4,7 @@
# this repository contains the full copyright notices and license terms. # this repository contains the full copyright notices and license terms.
from trytond.tests.test_tryton import ModuleTestCase from trytond.tests.test_tryton import ModuleTestCase, activate_module
from .document import DocumentTestCase from .document import DocumentTestCase
@ -14,6 +14,16 @@ class XmlIncomingTestCase(
'Test document incoming xml converter module' 'Test document incoming xml converter module'
module = 'document_incoming_invoice_xml' module = 'document_incoming_invoice_xml'
@classmethod
def setUpClass(cls):
""" add modelues
"""
super(XmlIncomingTestCase, cls).setUpClass()
try:
activate_module(['sale_point_invoice'])
except Exception as e1:
print('- skipped install of "sale_point_invoice"', str(e1))
# end XmlIncomingTestCase # end XmlIncomingTestCase

View file

@ -3,6 +3,8 @@ version=7.0.0
depends: depends:
document_incoming_invoice document_incoming_invoice
edocument_unece edocument_unece
extras_depend:
sale_point_invoice
xml: xml:
message.xml message.xml
configuration.xml configuration.xml