Compare commits

...

4 commits

Author SHA1 Message Date
Mathias Behrle
28eb6b478b Explain the reason for evtl. tax mismatch. 2025-01-29 12:00:51 +01:00
Frederik Jaeckel
897f565a19 Version 7.0.4 2025-01-29 10:53:32 +01:00
Frederik Jaeckel
a35e9dec7b Merge branch 'main' into 7.0 2025-01-29 10:51:13 +01:00
Frederik Jaeckel
d52774a77e round incoming unit_price and quantity to match digits of fields 2025-01-29 10:50:13 +01:00
6 changed files with 50 additions and 23 deletions

View file

@ -15,6 +15,10 @@ Requires
Changes Changes
======= =======
*7.0.4 - 29.01.2025*
- add: Round unit_price + quantity to match the decimal places of the fields.
*7.0.3 - 27.01.2025* *7.0.3 - 27.01.2025*
- filter product-categories in configuration - filter product-categories in configuration

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 = [
@ -100,12 +101,15 @@ class Incoming(metaclass=PoolMeta):
UserError: if calculated values dont match UserError: if calculated values dont match
with xml-values with xml-values
""" """
pool = Pool()
Configuration = pool.get('account.configuration.tax_rounding')
configuration = Configuration(1)
totals = self.parsed_data.get('total', None) totals = self.parsed_data.get('total', None)
if not totals: if not totals:
raise UserError(gettext( raise UserError(gettext(
'msg_convert_error.msg_convert_error', 'msg_convert_error.msg_convert_error',
msg='no totals-section in xml-data')) msg='no totals-section in xml-data'))
for xfield, inv_field in [ for xfield, inv_field in [
('taxbase', 'untaxed_amount'), ('taxbase', 'untaxed_amount'),
('taxtotal', 'tax_amount'), ('taxtotal', 'tax_amount'),
@ -114,15 +118,25 @@ class Incoming(metaclass=PoolMeta):
inv_val = getattr(invoice, inv_field) inv_val = getattr(invoice, inv_field)
if xml_val != inv_val: if xml_val != inv_val:
raise UserError(gettext( rounding = configuration.tax_rounding
'document_incoming_invoice_xml.msg_convert_error', field_name = 'tax_rounding'
selection_values = configuration.fields_get(
[field_name])[field_name]['selection']
rounding_cfg = [
i[1] for i in selection_values if i[0] == rounding][0]
msg = ' '.join([ msg = ' '.join([
inv_field + ' mismatch', inv_field + ' mismatch',
'from-xml=' + Report.format_currency( 'from-xml=' + Report.format_currency(
xml_val, None, invoice.currency), xml_val, None, invoice.currency),
'calculated=' + Report.format_currency( 'calculated=' + Report.format_currency(
inv_val, None, invoice.currency) inv_val, None, invoice.currency)
]))) ])
msg += '\n\n' + gettext(
'document_incoming_invoice_xml.msg_tax_amount_mismatch',
rounding=rounding_cfg)
raise UserError(gettext(
'document_incoming_invoice_xml.msg_convert_error',
msg=msg))
def _readxml_xpath(self, tags): def _readxml_xpath(self, tags):
""" generate xpath """ generate xpath
@ -719,12 +733,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 +980,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

@ -46,6 +46,9 @@ msgctxt "model:ir.message,text:msg_unused_linevalues"
msgid "The following data was not used to generate the invoice line:" msgid "The following data was not used to generate the invoice line:"
msgstr "Die folgenden Daten wurden für die Erzeugung der Rechnungszeile nicht verwendet:" msgstr "Die folgenden Daten wurden für die Erzeugung der Rechnungszeile nicht verwendet:"
msgctxt "model:ir.message,text:msg_tax_amount_mismatch"
msgid "You have configured tax rounding method '%(rounding)s' in the account configuration. Maybe try with a different method"
msgstr "In Rechnungswesen/Einstellungen ist die Steuerrundungsmethode '%(rounding)s' eingetragen. Versuchen Sie es u.U. mit einer anderen Methode'
################################### ###################################
# document.incoming.configuration # # document.incoming.configuration #

View file

@ -35,6 +35,9 @@
<record model="ir.message" id="msg_unused_linevalues"> <record model="ir.message" id="msg_unused_linevalues">
<field name="text">The following data was not used to generate the invoice line:</field> <field name="text">The following data was not used to generate the invoice line:</field>
</record> </record>
<record model="ir.message" id="msg_tax_amount_mismatch">
<field name="text">You have configured tax rounding method '%(rounding)s' in the account configuration. Maybe try with a different method</field>
</record>
</data> </data>
</tryton> </tryton>

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

@ -1,5 +1,5 @@
[tryton] [tryton]
version=7.0.3 version=7.0.4
depends: depends:
document_incoming_invoice document_incoming_invoice
edocument_unece edocument_unece