From 16c24e565c10508314790a2487a7169fac2190b4 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 3 Jan 2023 11:07:41 +0100 Subject: [PATCH] (feat) custom message on invoice PDF not found --- CHANGELOG.md | 2 ++ app/controllers/api/invoices_controller.rb | 6 +++++- config/locales/app.shared.de.yml | 1 + config/locales/app.shared.es.yml | 1 + config/locales/app.shared.fr.yml | 1 + config/locales/app.shared.no.yml | 1 + config/locales/app.shared.pt.yml | 1 + config/locales/app.shared.zu.yml | 1 + config/locales/de.yml | 1 + config/locales/en.yml | 1 + config/locales/es.yml | 1 + config/locales/fr.yml | 1 + config/locales/no.yml | 1 + config/locales/pt.yml | 1 + config/locales/zu.yml | 1 + 15 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1ea2bfc3..e1ca14297 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - OpenAPI users endpoint return first name, last name, gender, organization and address - Default accounting codes and labels if not set - Active serving static files from the `/public` folder by default from rails +- Display custom error message if the PDF invoice is not found - Fix a bug: unable to run test in negative timezones (#425) - Fix a bug: providing an array of attributes to filter OpenApi data, results in error - Fix a bug: unable to manage stocks on new products @@ -27,6 +28,7 @@ - Fix a bug: clearing the new expiration date field in the offer days modal result in errors - Fix a bug: low stock notification is always sent if one of the stocks has reached the threshold - Fix a bug: unable to update title of availability after admin remove a machine/plan in calendar +- Fix a bug: unable to access files from the public folder (like example.csv) - Updated react-modal to 3.16.1 - Updated tiptap editor and its dependencies to 2.0.0-beta.204 - [TODO DEPLOY] `rails db:seed` diff --git a/app/controllers/api/invoices_controller.rb b/app/controllers/api/invoices_controller.rb index 8a45329fa..e24225c1d 100644 --- a/app/controllers/api/invoices_controller.rb +++ b/app/controllers/api/invoices_controller.rb @@ -12,9 +12,13 @@ class API::InvoicesController < API::ApiController ).all.order('reference DESC') end + def show; end + def download authorize @invoice - send_file File.join(Rails.root, @invoice.file), type: 'application/pdf', disposition: 'attachment' + send_file Rails.root.join(@invoice.file), type: 'application/pdf', disposition: 'attachment' + rescue ActionController::MissingFile + render html: I18n.t('invoices.unable_to_find_pdf'), status: :not_found end def list diff --git a/config/locales/app.shared.de.yml b/config/locales/app.shared.de.yml index 26672c38d..73a4bce4b 100644 --- a/config/locales/app.shared.de.yml +++ b/config/locales/app.shared.de.yml @@ -536,5 +536,6 @@ de: spaces: "Spaces" events: "Events" externals: "Other calendars" + show_reserved_uniq: "Show reserved slots only" machine: machine_uncategorized: "Uncategorized machines" diff --git a/config/locales/app.shared.es.yml b/config/locales/app.shared.es.yml index f50968532..0d9ce060f 100644 --- a/config/locales/app.shared.es.yml +++ b/config/locales/app.shared.es.yml @@ -536,5 +536,6 @@ es: spaces: "Spaces" events: "Events" externals: "Other calendars" + show_reserved_uniq: "Show reserved slots only" machine: machine_uncategorized: "Uncategorized machines" diff --git a/config/locales/app.shared.fr.yml b/config/locales/app.shared.fr.yml index e7d3d0bdb..099f63d47 100644 --- a/config/locales/app.shared.fr.yml +++ b/config/locales/app.shared.fr.yml @@ -536,5 +536,6 @@ fr: spaces: "Espaces" events: "Événements" externals: "Autres calendriers" + show_reserved_uniq: "Show reserved slots only" machine: machine_uncategorized: "Machines non classés" diff --git a/config/locales/app.shared.no.yml b/config/locales/app.shared.no.yml index 8364fe916..d4c8edc78 100644 --- a/config/locales/app.shared.no.yml +++ b/config/locales/app.shared.no.yml @@ -536,5 +536,6 @@ spaces: "Spaces" events: "Events" externals: "Other calendars" + show_reserved_uniq: "Show reserved slots only" machine: machine_uncategorized: "Uncategorized machines" diff --git a/config/locales/app.shared.pt.yml b/config/locales/app.shared.pt.yml index 9941c7414..7417a4215 100644 --- a/config/locales/app.shared.pt.yml +++ b/config/locales/app.shared.pt.yml @@ -536,5 +536,6 @@ pt: spaces: "Spaces" events: "Events" externals: "Other calendars" + show_reserved_uniq: "Show reserved slots only" machine: machine_uncategorized: "Uncategorized machines" diff --git a/config/locales/app.shared.zu.yml b/config/locales/app.shared.zu.yml index 287e916d0..4d0f7a373 100644 --- a/config/locales/app.shared.zu.yml +++ b/config/locales/app.shared.zu.yml @@ -536,5 +536,6 @@ zu: spaces: "crwdns36191:0crwdne36191:0" events: "crwdns36193:0crwdne36193:0" externals: "crwdns36195:0crwdne36195:0" + show_reserved_uniq: "crwdns36249:0crwdne36249:0" machine: machine_uncategorized: "crwdns36219:0crwdne36219:0" diff --git a/config/locales/de.yml b/config/locales/de.yml index 42db21567..98625dafa 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -133,6 +133,7 @@ de: prepaid_pack: "Prepaid-Stundenpaket" pack_item: "Paket von %{COUNT} Stunden für %{ITEM}" order: "Your order on the store" + unable_to_find_pdf: "We cannot find your invoice. If you ordered recently, it may have not been generated yet. Please retry in a moment." #PDF payment schedule generation payment_schedules: schedule_reference: "Zahlungsplan Referenz: %{REF}" diff --git a/config/locales/en.yml b/config/locales/en.yml index 2d01b6799..af11db2cc 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -133,6 +133,7 @@ en: prepaid_pack: "Prepaid pack of hours" pack_item: "Pack of %{COUNT} hours for the %{ITEM}" order: "Your order on the store" + unable_to_find_pdf: "We cannot find your invoice. If you ordered recently, it may have not been generated yet. Please retry in a moment." #PDF payment schedule generation payment_schedules: schedule_reference: "Payment schedule reference: %{REF}" diff --git a/config/locales/es.yml b/config/locales/es.yml index d5f4a02ea..51c6b04e6 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -133,6 +133,7 @@ es: prepaid_pack: "Prepaid pack of hours" pack_item: "Pack of %{COUNT} hours for the %{ITEM}" order: "Your order on the store" + unable_to_find_pdf: "We cannot find your invoice. If you ordered recently, it may have not been generated yet. Please retry in a moment." #PDF payment schedule generation payment_schedules: schedule_reference: "Payment schedule reference: %{REF}" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index a86c34b44..e08d6beed 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -133,6 +133,7 @@ fr: prepaid_pack: "Paquet d'heures prépayé" pack_item: "Pack de %{COUNT} heures pour la %{ITEM}" order: "Votre commande sur la boutique" + unable_to_find_pdf: "Nous ne trouvons pas votre facture. Si vous avez commandé récemment, il se peut qu'elle n'ait pas encore été générée. Veuillez réessayer dans un instant." #PDF payment schedule generation payment_schedules: schedule_reference: "Référence de l'échéancier : %{REF}" diff --git a/config/locales/no.yml b/config/locales/no.yml index 62670b0e0..c12e8cbfc 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -133,6 +133,7 @@ prepaid_pack: "Forhåndsbetalt pakke med timer" pack_item: "Pakke med %{COUNT} timer for %{ITEM}" order: "Your order on the store" + unable_to_find_pdf: "We cannot find your invoice. If you ordered recently, it may have not been generated yet. Please retry in a moment." #PDF payment schedule generation payment_schedules: schedule_reference: "Referanse til betalingsplanen: %{REF}" diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 53ce3d654..59a34bbab 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -133,6 +133,7 @@ pt: prepaid_pack: "Pacote de horas pré-pago" pack_item: "Pacote de %{COUNT} horas para a %{ITEM}" order: "Your order on the store" + unable_to_find_pdf: "We cannot find your invoice. If you ordered recently, it may have not been generated yet. Please retry in a moment." #PDF payment schedule generation payment_schedules: schedule_reference: "Agendamento de pagamento: %{REF}" diff --git a/config/locales/zu.yml b/config/locales/zu.yml index 93c07de17..a673e15f5 100644 --- a/config/locales/zu.yml +++ b/config/locales/zu.yml @@ -133,6 +133,7 @@ zu: prepaid_pack: "crwdns22022:0crwdne22022:0" pack_item: "crwdns22024:0%{COUNT}crwdnd22024:0%{ITEM}crwdne22024:0" order: "crwdns31699:0crwdne31699:0" + unable_to_find_pdf: "crwdns36251:0crwdne36251:0" #PDF payment schedule generation payment_schedules: schedule_reference: "crwdns21094:0%{REF}crwdne21094:0"