From 842cddc6bd058e9b576e370a4aca74e161e7d05a Mon Sep 17 00:00:00 2001 From: LovroColic Date: Fri, 30 Aug 2024 11:11:23 +0200 Subject: [PATCH] fix (tax-integrations): apply zero tax for unknown tax exemption (#2517) ## Context Apply zero tax for unknown tax exemption --- app/models/invoice/applied_tax.rb | 2 +- .../aggregator/taxes/invoices/base_service.rb | 11 +++++++++-- config/locales/de/invoice.yml | 2 ++ config/locales/en/invoice.yml | 2 ++ config/locales/es/invoice.yml | 2 ++ config/locales/fr/invoice.yml | 2 ++ config/locales/it/invoice.yml | 2 ++ config/locales/nb/invoice.yml | 2 ++ config/locales/sv/invoice.yml | 2 ++ schema.graphql | 2 ++ schema.json | 12 ++++++++++++ .../taxes/invoices/create_draft_service_spec.rb | 4 +++- 12 files changed, 41 insertions(+), 4 deletions(-) diff --git a/app/models/invoice/applied_tax.rb b/app/models/invoice/applied_tax.rb index bdcf0727327..6b08484273f 100644 --- a/app/models/invoice/applied_tax.rb +++ b/app/models/invoice/applied_tax.rb @@ -16,7 +16,7 @@ class AppliedTax < ApplicationRecord validates :amount_cents, numericality: {greater_than_or_equal_to: 0} TAX_CODES_APPLICABLE_ON_WHOLE_INVOICE = %w[not_collecting juris_not_taxed reverse_charge customer_exempt - transaction_exempt].freeze + transaction_exempt juris_has_no_tax unknown_taxation].freeze def applied_on_whole_invoice? TAX_CODES_APPLICABLE_ON_WHOLE_INVOICE.include?(tax_code) diff --git a/app/services/integrations/aggregator/taxes/invoices/base_service.rb b/app/services/integrations/aggregator/taxes/invoices/base_service.rb index 8a63e490246..61d580693da 100644 --- a/app/services/integrations/aggregator/taxes/invoices/base_service.rb +++ b/app/services/integrations/aggregator/taxes/invoices/base_service.rb @@ -5,7 +5,7 @@ module Aggregator module Taxes module Invoices class BaseService < Integrations::Aggregator::BaseService - SPECIAL_TAXATION_TYPES = %w[exempt notCollecting productNotTaxed jurisNotTaxed].freeze + SPECIAL_TAXATION_TYPES = %w[exempt notCollecting productNotTaxed jurisNotTaxed jurisHasNoTax].freeze def initialize(invoice:, fees: nil) @invoice = invoice @fees = fees || invoice.fees @@ -84,13 +84,20 @@ def tax_breakdown(breakdown) tax_amount: 0, type: b['type'] ) - else + elsif b['rate'] OpenStruct.new( name: b['name'], rate: b['rate'], tax_amount: b['tax_amount'], type: b['type'] ) + else + OpenStruct.new( + name: humanize_tax_name(b['reason'].presence || b['type'] || 'unknown_taxation'), + rate: '0.00', + tax_amount: 0, + type: b['type'] || 'unknown_taxation' + ) end end end diff --git a/config/locales/de/invoice.yml b/config/locales/de/invoice.yml index 6f148e46c2e..b8dff46a6b3 100644 --- a/config/locales/de/invoice.yml +++ b/config/locales/de/invoice.yml @@ -67,10 +67,12 @@ de: tax_name: "%{name} (%{rate}% on %{amount})" tax_name_only: customer_exempt: Der Kunde ist von der Umsatzsteuer befreit + juris_has_no_tax: Keine Steuer juris_not_taxed: Keine Steuer not_collecting: Keine Steuer reverse_charge: Reverse-Charge-Verfahren - Steuerschuldnerschaft auf den Kunden übertragen transaction_exempt: Der Kunde ist von der Umsatzsteuer befreit + unknown_taxation: Unbekannt tax_name_with_details: "%{name} (%{rate}%)" tax_rate: Steuersatz taxes: diff --git a/config/locales/en/invoice.yml b/config/locales/en/invoice.yml index a285c5840e4..39ef954b043 100644 --- a/config/locales/en/invoice.yml +++ b/config/locales/en/invoice.yml @@ -67,10 +67,12 @@ en: tax_name: "%{name} (%{rate}% on %{amount})" tax_name_only: customer_exempt: Customer is tax exempt + juris_has_no_tax: No tax juris_not_taxed: No tax not_collecting: No tax reverse_charge: Reverse charge - Tax liability shifted to customer transaction_exempt: Customer is tax exempt + unknown_taxation: Unknown tax_name_with_details: "%{name} (%{rate}%)" tax_rate: Tax rate taxes: diff --git a/config/locales/es/invoice.yml b/config/locales/es/invoice.yml index f744419031d..54f6136ea6f 100644 --- a/config/locales/es/invoice.yml +++ b/config/locales/es/invoice.yml @@ -66,10 +66,12 @@ es: tax_name: "%{name} (%{rate}% sobre %{amount})" tax_name_only: customer_exempt: El cliente está exento de impuestos + juris_has_no_tax: Sin impuesto juris_not_taxed: Sin impuesto not_collecting: Sin impuesto reverse_charge: Inversión del sujeto pasivo - Responsabilidad fiscal trasladada al cliente transaction_exempt: El cliente está exento de impuestos + unknown_taxation: Desconocido tax_name_with_details: "%{name} (%{rate}%)" tax_rate: Tasas de impuestos taxes: diff --git a/config/locales/fr/invoice.yml b/config/locales/fr/invoice.yml index 693a4dc0920..c88d1b488ff 100644 --- a/config/locales/fr/invoice.yml +++ b/config/locales/fr/invoice.yml @@ -67,10 +67,12 @@ fr: tax_name: "%{name} (%{rate}% sur %{amount})" tax_name_only: customer_exempt: Le client est exonéré de taxe + juris_has_no_tax: Taxe non applicable juris_not_taxed: Taxe non applicable not_collecting: Pas de taxe reverse_charge: Autoliquidation - Responsabilité fiscale transférée au client transaction_exempt: Le client est exonéré de taxe + unknown_taxation: Inconnu tax_name_with_details: "%{name} (%{rate}%)" tax_rate: Taux de taxe taxes: diff --git a/config/locales/it/invoice.yml b/config/locales/it/invoice.yml index 3fa3fde2bd7..0518834b875 100644 --- a/config/locales/it/invoice.yml +++ b/config/locales/it/invoice.yml @@ -67,10 +67,12 @@ it: tax_name: "%{name} (%{rate}% su %{amount})" tax_name_only: customer_exempt: Il cliente è esente da tasse + juris_has_no_tax: Nessuna tassa juris_not_taxed: Nessuna tassa not_collecting: Nessuna tassa reverse_charge: Inversione contabile - Responsabilità fiscale trasferita al cliente transaction_exempt: Il cliente è esente da tasse + unknown_taxation: Sconosciuto tax_name_with_details: "%{name} (%{rate}%)" tax_rate: Aliquota fiscale taxes: diff --git a/config/locales/nb/invoice.yml b/config/locales/nb/invoice.yml index 04013023883..f23563bd1e6 100644 --- a/config/locales/nb/invoice.yml +++ b/config/locales/nb/invoice.yml @@ -67,10 +67,12 @@ nb: tax_name: "%{name} (%{rate}% on %{amount})" tax_name_only: customer_exempt: Kunden er fritatt for avgift + juris_has_no_tax: Ingen skatt juris_not_taxed: Ingen skatt not_collecting: Ingen skatt reverse_charge: Omvendt avgiftsplikt - Skatteplikt overført til kunden transaction_exempt: Kunden er fritatt for avgift + unknown_taxation: Ukjent tax_name_with_details: "%{name} (%{rate}%)" tax_rate: Skattesats taxes: diff --git a/config/locales/sv/invoice.yml b/config/locales/sv/invoice.yml index f3972d05dca..5271207502d 100644 --- a/config/locales/sv/invoice.yml +++ b/config/locales/sv/invoice.yml @@ -66,10 +66,12 @@ sv: tax_name: "%{name} (%{rate}% på %{amount})" tax_name_only: customer_exempt: Kunden är befriad från moms + juris_has_no_tax: Ingen skatt juris_not_taxed: Ingen skatt not_collecting: Ingen skatt reverse_charge: Omvänd skattskyldighet - Skatteskyldighet överförd till kunden transaction_exempt: Kunden är befriad från moms + unknown_taxation: Okänd tax_name_with_details: "%{name} (%{rate}%)" tax_rate: Momssats taxes: diff --git a/schema.graphql b/schema.graphql index 7031bc1c0af..532c4ded8f1 100644 --- a/schema.graphql +++ b/schema.graphql @@ -4086,10 +4086,12 @@ type InvoiceAppliedTax implements AppliedTax { enum InvoiceAppliedTaxOnWholeInvoiceCodeEnum { customer_exempt + juris_has_no_tax juris_not_taxed not_collecting reverse_charge transaction_exempt + unknown_taxation } """ diff --git a/schema.json b/schema.json index 1fecb9630ac..dd72bd7d2c0 100644 --- a/schema.json +++ b/schema.json @@ -19537,6 +19537,18 @@ "description": null, "isDeprecated": false, "deprecationReason": null + }, + { + "name": "juris_has_no_tax", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "unknown_taxation", + "description": null, + "isDeprecated": false, + "deprecationReason": null } ] }, diff --git a/spec/services/integrations/aggregator/taxes/invoices/create_draft_service_spec.rb b/spec/services/integrations/aggregator/taxes/invoices/create_draft_service_spec.rb index a9ebb5fdb2e..3c5903948dc 100644 --- a/spec/services/integrations/aggregator/taxes/invoices/create_draft_service_spec.rb +++ b/spec/services/integrations/aggregator/taxes/invoices/create_draft_service_spec.rb @@ -150,7 +150,9 @@ [ {received_type: 'notCollecting', expected_name: 'Not collecting'}, {received_type: 'productNotTaxed', expected_name: 'Product not taxed'}, - {received_type: 'jurisNotTaxed', expected_name: 'Juris not taxed'} + {received_type: 'jurisNotTaxed', expected_name: 'Juris not taxed'}, + {received_type: 'jurisHasNoTax', expected_name: 'Juris has no tax'}, + {received_type: 'specialUnknownRule', expected_name: 'Special unknown rule'} ] special_rules.each do |specific_rule|