Explain the reason for evtl. tax mismatch.

This commit is contained in:
Mathias Behrle 2025-01-29 11:33:19 +01:00
parent 2bf95fb245
commit 970fb9caaf
3 changed files with 24 additions and 5 deletions

View file

@ -101,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'),
@ -115,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

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>