diff --git a/CHANGELOG.md b/CHANGELOG.md index 24b26e4c7..7e09b563b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog Fab-manager +## Next release + +- updates sidekiq and sidekiq-scheduler +- fix a bug: wrong locale was causing wrong currency in cron jobs, now we manually set the currency locale in number_to_currency + ## v6.3.1 2023 November 10 - Fix a bug: statistic_sub_type.label of plan was nil diff --git a/Gemfile b/Gemfile index 94aa61a42..99433f7bb 100644 --- a/Gemfile +++ b/Gemfile @@ -91,9 +91,9 @@ gem 'friendly_id', '~> 5.1.0' gem 'aasm' # Background job processing -gem 'sidekiq', '>= 6.0.7' +gem 'sidekiq', '6.5.12' # Recurring jobs for Sidekiq -gem 'sidekiq-scheduler' +gem 'sidekiq-scheduler', '5.0.3' gem 'sidekiq-unique-jobs', '~> 7.1.23' gem 'stripe', '5.29.0' diff --git a/Gemfile.lock b/Gemfile.lock index e5bdfad2b..b60dfdf10 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -125,7 +125,7 @@ GEM coercible (1.0.0) descendants_tracker (~> 0.0.1) concurrent-ruby (1.2.2) - connection_pool (2.2.5) + connection_pool (2.4.1) coveralls_reborn (0.18.0) simplecov (>= 0.18.1, < 0.20.0) term-ansicolor (~> 1.6) @@ -182,7 +182,7 @@ GEM forgery (0.7.0) friendly_id (5.1.0) activerecord (>= 4.0.0) - fugit (1.5.3) + fugit (1.9.0) et-orbi (~> 1, >= 1.2.7) raabro (~> 1.4) globalid (1.1.0) @@ -428,7 +428,7 @@ GEM nokogiri (>= 1.10.8) rubyzip (>= 1.3.0) rubyzip (2.3.2) - rufus-scheduler (3.8.1) + rufus-scheduler (3.9.1) fugit (~> 1.1, >= 1.1.6) safe_yaml (1.0.5) sassc (2.4.0) @@ -448,14 +448,13 @@ GEM rack-proxy (>= 0.6.1) railties (>= 5.2) semantic_range (>= 2.3.0) - sidekiq (6.4.2) - connection_pool (>= 2.2.2) + sidekiq (6.5.12) + connection_pool (>= 2.2.5, < 3) rack (~> 2.0) - redis (>= 4.2.0) - sidekiq-scheduler (4.0.0) - redis (>= 4.2.0) + redis (>= 4.5.0, < 5) + sidekiq-scheduler (5.0.3) rufus-scheduler (~> 3.2) - sidekiq (>= 4) + sidekiq (>= 6, < 8) tilt (>= 1.4.0) sidekiq-unique-jobs (7.1.23) brpoplpush-redis_script (> 0.1.1, <= 2.0.0) @@ -484,7 +483,7 @@ GEM tins (~> 1.0) thor (1.2.1) thread_safe (0.3.6) - tilt (2.0.10) + tilt (2.3.0) timeout (0.3.2) tins (1.25.0) sync @@ -609,8 +608,8 @@ DEPENDENCIES sentry-ruby sha3 shakapacker (= 6.6.0) - sidekiq (>= 6.0.7) - sidekiq-scheduler + sidekiq (= 6.5.12) + sidekiq-scheduler (= 5.0.3) sidekiq-unique-jobs (~> 7.1.23) silencer spring (~> 4) diff --git a/app/pdfs/pdf/invoice.rb b/app/pdfs/pdf/invoice.rb index c7559eb78..fa77b22a9 100644 --- a/app/pdfs/pdf/invoice.rb +++ b/app/pdfs/pdf/invoice.rb @@ -75,7 +75,7 @@ class Pdf::Invoice < Prawn::Document invoice.invoice_items.each do |item| price = item.amount.to_i / 100.00 - data += [[Invoices::ItemLabelService.build(invoice, item), number_to_currency(price)]] + data += [[Invoices::ItemLabelService.build(invoice, item), number_to_currency(price, locale: CURRENCY_LOCALE)]] total_calc += price total_ht += item.net_amount total_vat += item.vat @@ -92,13 +92,13 @@ class Pdf::Invoice < Prawn::Document # discount textual description literal_discount = cp.percent_off - literal_discount = number_to_currency(cp.amount_off / 100.00) if cp.type == 'amount_off' + literal_discount = number_to_currency(cp.amount_off / 100.00, locale: CURRENCY_LOCALE) if cp.type == 'amount_off' # add a row for the coupon data += [[_t('invoices.coupon_CODE_discount_of_DISCOUNT', CODE: cp.code, DISCOUNT: literal_discount, - TYPE: cp.type), number_to_currency(-discount)]] + TYPE: cp.type), number_to_currency(-discount, locale: CURRENCY_LOCALE)]] end # total verification @@ -109,18 +109,18 @@ class Pdf::Invoice < Prawn::Document vat_service = VatHistoryService.new vat_rate_group = vat_service.invoice_vat(invoice) if total_vat.zero? - data += [[I18n.t('invoices.total_amount'), number_to_currency(total)]] + data += [[I18n.t('invoices.total_amount'), number_to_currency(total, locale: CURRENCY_LOCALE)]] else - data += [[I18n.t('invoices.total_including_all_taxes'), number_to_currency(total)]] + data += [[I18n.t('invoices.total_including_all_taxes'), number_to_currency(total, locale: CURRENCY_LOCALE)]] vat_rate_group.each do |_type, rate| data += [[I18n.t('invoices.including_VAT_RATE', **{ RATE: rate[:vat_rate], - AMOUNT: number_to_currency(rate[:amount] / 100.00), + AMOUNT: number_to_currency(rate[:amount] / 100.00, locale: CURRENCY_LOCALE), NAME: Setting.get('invoice_VAT-name') }), - number_to_currency(rate[:total_vat] / 100.00)]] + number_to_currency(rate[:total_vat] / 100.00, locale: CURRENCY_LOCALE)]] end - data += [[I18n.t('invoices.including_total_excluding_taxes'), number_to_currency(total_ht / 100.00)]] - data += [[I18n.t('invoices.including_amount_payed_on_ordering'), number_to_currency(total)]] + data += [[I18n.t('invoices.including_total_excluding_taxes'), number_to_currency(total_ht / 100.00, locale: CURRENCY_LOCALE)]] + data += [[I18n.t('invoices.including_amount_payed_on_ordering'), number_to_currency(total, locale: CURRENCY_LOCALE)]] # checking the round number rounded = (sprintf('%.2f', total_vat / 100.00).to_f + sprintf('%.2f', total_ht / 100.00).to_f).to_s diff --git a/app/pdfs/pdf/payment_schedule.rb b/app/pdfs/pdf/payment_schedule.rb index a959e3af8..690b887a7 100644 --- a/app/pdfs/pdf/payment_schedule.rb +++ b/app/pdfs/pdf/payment_schedule.rb @@ -80,9 +80,9 @@ class Pdf::PaymentSchedule < Prawn::Document price = item.amount.to_i / 100.00 date = I18n.l(item.due_date.to_date) - data += [[date, number_to_currency(price)]] + data += [[date, number_to_currency(price, locale: CURRENCY_LOCALE)]] end - data += [[I18n.t('payment_schedules.total_amount'), number_to_currency(payment_schedule.total / 100.0)]] + data += [[I18n.t('payment_schedules.total_amount'), number_to_currency(payment_schedule.total / 100.0, locale: CURRENCY_LOCALE)]] # display table font_size(8) do @@ -100,7 +100,7 @@ class Pdf::PaymentSchedule < Prawn::Document payment_verbose = _t('payment_schedules.settlement_by_METHOD', METHOD: payment_schedule.payment_method) if payment_schedule.wallet_amount payment_verbose += I18n.t('payment_schedules.settlement_by_wallet', - **{ AMOUNT: number_to_currency(payment_schedule.wallet_amount / 100.00) }) + **{ AMOUNT: number_to_currency(payment_schedule.wallet_amount / 100.00, locale: CURRENCY_LOCALE) }) end text payment_verbose diff --git a/app/services/invoices/payment_details_service.rb b/app/services/invoices/payment_details_service.rb index 872cbd1bb..56181f504 100644 --- a/app/services/invoices/payment_details_service.rb +++ b/app/services/invoices/payment_details_service.rb @@ -27,14 +27,14 @@ class Invoices::PaymentDetailsService **{ DATE: I18n.l(invoice.created_at.to_date), TIME: I18n.l(invoice.created_at, format: :hour_minute) })}" if total.positive? || wallet_amount.nil? - payment_verbose += " #{I18n.t('invoices.for_an_amount_of_AMOUNT', **{ AMOUNT: number_to_currency(total) })}" + payment_verbose += " #{I18n.t('invoices.for_an_amount_of_AMOUNT', **{ AMOUNT: number_to_currency(total, locale: CURRENCY_LOCALE) })}" end if invoice.wallet_amount payment_verbose += if total.positive? " #{I18n.t('invoices.and')} #{I18n.t('invoices.by_wallet')} " \ - "#{I18n.t('invoices.for_an_amount_of_AMOUNT', **{ AMOUNT: number_to_currency(wallet_amount) })}" + "#{I18n.t('invoices.for_an_amount_of_AMOUNT', **{ AMOUNT: number_to_currency(wallet_amount, locale: CURRENCY_LOCALE) })}" else - " #{I18n.t('invoices.for_an_amount_of_AMOUNT', **{ AMOUNT: number_to_currency(wallet_amount) })}" + " #{I18n.t('invoices.for_an_amount_of_AMOUNT', **{ AMOUNT: number_to_currency(wallet_amount, locale: CURRENCY_LOCALE) })}" end end payment_verbose @@ -88,7 +88,7 @@ class Invoices::PaymentDetailsService else Rails.logger.error "specified refunding method (#{details}) is unknown" end - "#{details} #{I18n.t('invoices.for_an_amount_of_AMOUNT', **{ AMOUNT: number_to_currency(total) })}" + "#{details} #{I18n.t('invoices.for_an_amount_of_AMOUNT', **{ AMOUNT: number_to_currency(total, locale: CURRENCY_LOCALE) })}" end end end diff --git a/app/views/api/notifications/_notify_admin_refund_created.json.jbuilder b/app/views/api/notifications/_notify_admin_refund_created.json.jbuilder index 596e9441f..79ef767b2 100644 --- a/app/views/api/notifications/_notify_admin_refund_created.json.jbuilder +++ b/app/views/api/notifications/_notify_admin_refund_created.json.jbuilder @@ -1,5 +1,4 @@ json.title notification.notification_type json.description t('.refund_created', - AMOUNT: number_to_currency(notification.attached_object.total / 100.00), + AMOUNT: number_to_currency(notification.attached_object.total / 100.00, locale: CURRENCY_LOCALE), USER: notification.attached_object.invoicing_profile&.full_name) - diff --git a/app/views/api/notifications/_notify_admin_user_wallet_is_credited.json.jbuilder b/app/views/api/notifications/_notify_admin_user_wallet_is_credited.json.jbuilder index 90c8576a4..56b96aa7f 100644 --- a/app/views/api/notifications/_notify_admin_user_wallet_is_credited.json.jbuilder +++ b/app/views/api/notifications/_notify_admin_user_wallet_is_credited.json.jbuilder @@ -3,7 +3,6 @@ json.title notification.notification_type amount = notification.attached_object.amount json.description t('.wallet_is_credited', - AMOUNT: number_to_currency(amount), + AMOUNT: number_to_currency(amount, locale: CURRENCY_LOCALE), USER: notification.attached_object.wallet.user&.profile&.full_name || t('api.notifications.deleted_user'), ADMIN: notification.attached_object.user&.profile&.full_name || t('api.notifications.deleted_user')) - diff --git a/app/views/api/notifications/_notify_member_about_coupon.json.jbuilder b/app/views/api/notifications/_notify_member_about_coupon.json.jbuilder index a683b60d5..6381f7b06 100644 --- a/app/views/api/notifications/_notify_member_about_coupon.json.jbuilder +++ b/app/views/api/notifications/_notify_member_about_coupon.json.jbuilder @@ -5,7 +5,6 @@ if notification.attached_object.type == 'percent_off' CODE: notification.attached_object.code) else json.description t('.enjoy_a_discount_of_AMOUNT_with_code_CODE', - AMOUNT: number_to_currency(notification.attached_object.amount_off / 100.00), + AMOUNT: number_to_currency(notification.attached_object.amount_off / 100.00, locale: CURRENCY_LOCALE), CODE: notification.attached_object.code) end - diff --git a/app/views/api/notifications/_notify_user_wallet_is_credited.json.jbuilder b/app/views/api/notifications/_notify_user_wallet_is_credited.json.jbuilder index 4030bf1cb..1faf797bd 100644 --- a/app/views/api/notifications/_notify_user_wallet_is_credited.json.jbuilder +++ b/app/views/api/notifications/_notify_user_wallet_is_credited.json.jbuilder @@ -1,5 +1,4 @@ json.title notification.notification_type amount = notification.attached_object.amount json.description t('.your_wallet_is_credited', - AMOUNT: number_to_currency(amount)) - + AMOUNT: number_to_currency(amount, locale: CURRENCY_LOCALE)) diff --git a/app/views/api/notifications/_notify_user_when_avoir_ready.json.jbuilder b/app/views/api/notifications/_notify_user_when_avoir_ready.json.jbuilder index 0c7c08e27..36b1b606d 100644 --- a/app/views/api/notifications/_notify_user_when_avoir_ready.json.jbuilder +++ b/app/views/api/notifications/_notify_user_when_avoir_ready.json.jbuilder @@ -2,6 +2,5 @@ json.title notification.notification_type amount = notification.attached_object.total / 100.0 json.description t('.your_avoir_is_ready_html', REFERENCE: notification.attached_object.reference, - AMOUNT: number_to_currency(amount), + AMOUNT: number_to_currency(amount, locale: CURRENCY_LOCALE), INVOICE_ID: notification.attached_object.id) - diff --git a/app/views/api/notifications/_notify_user_when_invoice_ready.json.jbuilder b/app/views/api/notifications/_notify_user_when_invoice_ready.json.jbuilder index 3f24395df..a645067e1 100644 --- a/app/views/api/notifications/_notify_user_when_invoice_ready.json.jbuilder +++ b/app/views/api/notifications/_notify_user_when_invoice_ready.json.jbuilder @@ -2,6 +2,5 @@ json.title notification.notification_type amount = notification.attached_object.total / 100.0 json.description t('.your_invoice_is_ready_html', REFERENCE: notification.attached_object.reference, - AMOUNT: number_to_currency(amount), + AMOUNT: number_to_currency(amount, locale: CURRENCY_LOCALE), INVOICE_ID: notification.attached_object.id) - diff --git a/app/views/api/notifications/_notify_user_when_payment_schedule_ready.json.jbuilder b/app/views/api/notifications/_notify_user_when_payment_schedule_ready.json.jbuilder index c1852f38a..de861a9be 100644 --- a/app/views/api/notifications/_notify_user_when_payment_schedule_ready.json.jbuilder +++ b/app/views/api/notifications/_notify_user_when_payment_schedule_ready.json.jbuilder @@ -4,6 +4,5 @@ json.title notification.notification_type amount = notification.attached_object.total / 100.0 json.description t('.your_schedule_is_ready_html', REFERENCE: notification.attached_object.reference, - AMOUNT: number_to_currency(amount), + AMOUNT: number_to_currency(amount, locale: CURRENCY_LOCALE), SCHEDULE_ID: notification.attached_object.id) - diff --git a/app/views/archive/_accounting.json.jbuilder b/app/views/archive/_accounting.json.jbuilder index 124e1ff75..dc5c92cfc 100644 --- a/app/views/archive/_accounting.json.jbuilder +++ b/app/views/archive/_accounting.json.jbuilder @@ -9,7 +9,7 @@ json.invoices do json.type invoice[:invoice].payment_gateway_object.gateway_object_type end end - json.total number_to_currency(invoice[:invoice].total / 100.0) + json.total number_to_currency(invoice[:invoice].total / 100.0, locale: CURRENCY_LOCALE) json.user do json.extract! invoice[:invoice].invoicing_profile, :user_id, :email, :first_name, :last_name json.address invoice[:invoice].invoicing_profile&.address&.address @@ -46,7 +46,7 @@ json.payment_schedules do json.id object.gateway_object_id json.type object.gateway_object_type end - json.total number_to_currency(schedule.total / 100.0) + json.total number_to_currency(schedule.total / 100.0, locale: CURRENCY_LOCALE) json.user do json.extract! schedule.invoicing_profile, :user_id, :email, :first_name, :last_name json.address schedule.invoicing_profile&.address&.address @@ -60,7 +60,7 @@ json.payment_schedules do end json.deadlines schedule.payment_schedule_items do |item| json.extract! item, :id, :due_date, :state, :details, :invoice_id, :footprint, :created_at - json.amount number_to_currency(item.amount / 100.0) + json.amount number_to_currency(item.amount / 100.0, locale: CURRENCY_LOCALE) end json.objects schedule.payment_schedule_objects do |object| json.type object.object_type @@ -71,8 +71,8 @@ json.payment_schedules do end json.totals do - json.period_total number_to_currency(period_total / 100.0) - json.perpetual_total number_to_currency(perpetual_total / 100.0) + json.period_total number_to_currency(period_total / 100.0, locale: CURRENCY_LOCALE) + json.perpetual_total number_to_currency(perpetual_total / 100.0, locale: CURRENCY_LOCALE) end json.software do diff --git a/app/views/archive/_vat.json.jbuilder b/app/views/archive/_vat.json.jbuilder index d95b46f34..64f1c76cd 100644 --- a/app/views/archive/_vat.json.jbuilder +++ b/app/views/archive/_vat.json.jbuilder @@ -1,7 +1,7 @@ # frozen_string_literal: true json.amount do - json.without_tax number_to_currency((price - (price * vat_rate)) / 100.0) - json.all_taxes_included number_to_currency(price / 100.0) + json.without_tax number_to_currency((price - (price * vat_rate)) / 100.0, locale: CURRENCY_LOCALE) + json.all_taxes_included number_to_currency(price / 100.0, locale: CURRENCY_LOCALE) json.vat_rate vat_rate.positive? ? number_to_percentage(vat_rate * 100) : 'none' end diff --git a/app/views/exports/users_subscriptions.xlsx.axlsx b/app/views/exports/users_subscriptions.xlsx.axlsx index 82273e1cb..a6cd21962 100644 --- a/app/views/exports/users_subscriptions.xlsx.axlsx +++ b/app/views/exports/users_subscriptions.xlsx.axlsx @@ -24,7 +24,7 @@ wb.add_worksheet(name: ExcelService.name_safe(t('export_subscriptions.subscripti t("duration.#{sub.plan.interval}", count: sub.plan.interval_count), sub.created_at.to_date, sub.expired_at.to_date, - number_to_currency(sub.plan.amount / 100.00) + number_to_currency(sub.plan.amount / 100.00, locale: CURRENCY_LOCALE) ] styles = [nil, nil, nil, nil, nil, date, date, nil, nil] types = %i[integer string string string string date date string string] diff --git a/app/views/notifications_mailer/notify_admin_payment_schedule_check_deadline.html.erb b/app/views/notifications_mailer/notify_admin_payment_schedule_check_deadline.html.erb index 5cdc9b065..9666b59b5 100644 --- a/app/views/notifications_mailer/notify_admin_payment_schedule_check_deadline.html.erb +++ b/app/views/notifications_mailer/notify_admin_payment_schedule_check_deadline.html.erb @@ -3,7 +3,7 @@

<%= t('.body.remember', REFERENCE: @attached_object.payment_schedule.reference, - AMOUNT: number_to_currency(@attached_object.amount / 100.00), + AMOUNT: number_to_currency(@attached_object.amount / 100.00, locale: CURRENCY_LOCALE), DATE: I18n.l(@attached_object.due_date, format: :long)) %> <%= t('.body.date') %>

diff --git a/app/views/notifications_mailer/notify_admin_payment_schedule_error.html.erb b/app/views/notifications_mailer/notify_admin_payment_schedule_error.html.erb index 3566d4983..4883a48b4 100644 --- a/app/views/notifications_mailer/notify_admin_payment_schedule_error.html.erb +++ b/app/views/notifications_mailer/notify_admin_payment_schedule_error.html.erb @@ -3,7 +3,7 @@

<%= t('.body.remember', REFERENCE: @attached_object.payment_schedule.reference, - AMOUNT: number_to_currency(@attached_object.amount / 100.00), + AMOUNT: number_to_currency(@attached_object.amount / 100.00, locale: CURRENCY_LOCALE), DATE: I18n.l(@attached_object.due_date, format: :long)) %> <%= t('.body.error', GATEWAY: @attached_object.payment_gateway_object.gateway_object.gateway) %>

diff --git a/app/views/notifications_mailer/notify_admin_payment_schedule_failed.html.erb b/app/views/notifications_mailer/notify_admin_payment_schedule_failed.html.erb index 57eb813ba..7f266b240 100644 --- a/app/views/notifications_mailer/notify_admin_payment_schedule_failed.html.erb +++ b/app/views/notifications_mailer/notify_admin_payment_schedule_failed.html.erb @@ -3,7 +3,7 @@

<%= t('.body.remember', REFERENCE: @attached_object.payment_schedule.reference, - AMOUNT: number_to_currency(@attached_object.amount / 100.00), + AMOUNT: number_to_currency(@attached_object.amount / 100.00, locale: CURRENCY_LOCALE), DATE: I18n.l(@attached_object.due_date, format: :long)) %> <%= t('.body.error') %>

diff --git a/app/views/notifications_mailer/notify_admin_payment_schedule_transfer_deadline.html.erb b/app/views/notifications_mailer/notify_admin_payment_schedule_transfer_deadline.html.erb index 5cdc9b065..9666b59b5 100644 --- a/app/views/notifications_mailer/notify_admin_payment_schedule_transfer_deadline.html.erb +++ b/app/views/notifications_mailer/notify_admin_payment_schedule_transfer_deadline.html.erb @@ -3,7 +3,7 @@

<%= t('.body.remember', REFERENCE: @attached_object.payment_schedule.reference, - AMOUNT: number_to_currency(@attached_object.amount / 100.00), + AMOUNT: number_to_currency(@attached_object.amount / 100.00, locale: CURRENCY_LOCALE), DATE: I18n.l(@attached_object.due_date, format: :long)) %> <%= t('.body.date') %>

diff --git a/app/views/notifications_mailer/notify_admin_refund_created.html.erb b/app/views/notifications_mailer/notify_admin_refund_created.html.erb index c4c1941ba..837c1e366 100644 --- a/app/views/notifications_mailer/notify_admin_refund_created.html.erb +++ b/app/views/notifications_mailer/notify_admin_refund_created.html.erb @@ -1,11 +1,11 @@ <%= render 'notifications_mailer/shared/hello', recipient: @recipient %>

<%= t('.body.refund_created', - AMOUNT: number_to_currency(@attached_object.total / 100.00), + AMOUNT: number_to_currency(@attached_object.total / 100.00, locale: CURRENCY_LOCALE), INVOICE: @attached_object.invoice.reference, USER: @attached_object.invoicing_profile&.full_name) if @attached_object.invoice %> <%= t('.body.wallet_refund_created', - AMOUNT: number_to_currency(@attached_object.total / 100.00), + AMOUNT: number_to_currency(@attached_object.total / 100.00, locale: CURRENCY_LOCALE), USER: @attached_object.invoicing_profile&.full_name) if @attached_object.main_item.object_type === WalletTransaction.name %>

" target="_blank"><%= t('.body.download') %>

diff --git a/app/views/notifications_mailer/notify_admin_user_wallet_is_credited.html.erb b/app/views/notifications_mailer/notify_admin_user_wallet_is_credited.html.erb index b03e5aad2..45d7deac6 100644 --- a/app/views/notifications_mailer/notify_admin_user_wallet_is_credited.html.erb +++ b/app/views/notifications_mailer/notify_admin_user_wallet_is_credited.html.erb @@ -2,7 +2,7 @@ <%= render 'notifications_mailer/shared/hello', recipient: @recipient %>

<%= t('.body.wallet_credit_html', - AMOUNT: number_to_currency(@attached_object.amount), + AMOUNT: number_to_currency(@attached_object.amount, locale: CURRENCY_LOCALE), USER: @attached_object.wallet.user&.profile&.full_name || t('api.notifications.deleted_user'), ADMIN: @attached_object.user&.profile&.full_name || t('api.notifications.deleted_user')) %> diff --git a/app/views/notifications_mailer/notify_member_about_coupon.html.erb b/app/views/notifications_mailer/notify_member_about_coupon.html.erb index 6a664eecf..797811304 100644 --- a/app/views/notifications_mailer/notify_member_about_coupon.html.erb +++ b/app/views/notifications_mailer/notify_member_about_coupon.html.erb @@ -8,7 +8,7 @@

<% else %>

<%= t('.body.enjoy_a_discount_of_AMOUNT_with_code_CODE', - AMOUNT: number_to_currency(@attached_object.amount_off / 100.00), + AMOUNT: number_to_currency(@attached_object.amount_off / 100.00, locale: CURRENCY_LOCALE), CODE: @attached_object.code ) %>

diff --git a/app/views/notifications_mailer/notify_member_avoir_ready.html.erb b/app/views/notifications_mailer/notify_member_avoir_ready.html.erb index 01bc5066b..cbbee932b 100644 --- a/app/views/notifications_mailer/notify_member_avoir_ready.html.erb +++ b/app/views/notifications_mailer/notify_member_avoir_ready.html.erb @@ -4,7 +4,7 @@ <%= _t('.body.please_find_attached_html', { DATE: I18n.l(@attached_object.avoir_date.to_date), - AMOUNT: number_to_currency(@attached_object.total / 100.0), + AMOUNT: number_to_currency(@attached_object.total / 100.0, locale: CURRENCY_LOCALE), TYPE: @attached_object.main_item.object_type }) # messageFormat diff --git a/app/views/notifications_mailer/notify_member_invoice_ready.html.erb b/app/views/notifications_mailer/notify_member_invoice_ready.html.erb index 6636dcd38..31dbf366d 100644 --- a/app/views/notifications_mailer/notify_member_invoice_ready.html.erb +++ b/app/views/notifications_mailer/notify_member_invoice_ready.html.erb @@ -4,7 +4,7 @@ <%= _t('.body.please_find_attached_html', { DATE: I18n.l(@attached_object.created_at.to_date), - AMOUNT: number_to_currency(@attached_object.total / 100.0), + AMOUNT: number_to_currency(@attached_object.total / 100.0, locale: CURRENCY_LOCALE), TYPE: @attached_object.main_item.object_type }) # messageFormat diff --git a/app/views/notifications_mailer/notify_member_payment_schedule_failed.html.erb b/app/views/notifications_mailer/notify_member_payment_schedule_failed.html.erb index 584de552c..1be062e61 100644 --- a/app/views/notifications_mailer/notify_member_payment_schedule_failed.html.erb +++ b/app/views/notifications_mailer/notify_member_payment_schedule_failed.html.erb @@ -3,7 +3,7 @@

<%= t('.body.remember', REFERENCE: @attached_object.payment_schedule.reference, - AMOUNT: number_to_currency(@attached_object.amount / 100.00), + AMOUNT: number_to_currency(@attached_object.amount / 100.00, locale: CURRENCY_LOCALE), DATE: I18n.l(@attached_object.due_date, format: :long)) %> <%= t('.body.error') %>

diff --git a/app/views/notifications_mailer/notify_member_payment_schedule_gateway_canceled.html.erb b/app/views/notifications_mailer/notify_member_payment_schedule_gateway_canceled.html.erb index 57eb813ba..7f266b240 100644 --- a/app/views/notifications_mailer/notify_member_payment_schedule_gateway_canceled.html.erb +++ b/app/views/notifications_mailer/notify_member_payment_schedule_gateway_canceled.html.erb @@ -3,7 +3,7 @@

<%= t('.body.remember', REFERENCE: @attached_object.payment_schedule.reference, - AMOUNT: number_to_currency(@attached_object.amount / 100.00), + AMOUNT: number_to_currency(@attached_object.amount / 100.00, locale: CURRENCY_LOCALE), DATE: I18n.l(@attached_object.due_date, format: :long)) %> <%= t('.body.error') %>

diff --git a/app/views/notifications_mailer/notify_member_payment_schedule_ready.html.erb b/app/views/notifications_mailer/notify_member_payment_schedule_ready.html.erb index 0f2ed1bf0..91a518b65 100644 --- a/app/views/notifications_mailer/notify_member_payment_schedule_ready.html.erb +++ b/app/views/notifications_mailer/notify_member_payment_schedule_ready.html.erb @@ -4,7 +4,7 @@ <%= _t('.body.please_find_attached_html', { DATE: I18n.l(@attached_object.created_at.to_date), - AMOUNT: number_to_currency(@attached_object.total / 100.0), + AMOUNT: number_to_currency(@attached_object.total / 100.0, locale: CURRENCY_LOCALE), TYPE: @attached_object.main_object.object_type }) # messageFormat diff --git a/app/views/notifications_mailer/notify_user_wallet_is_credited.html.erb b/app/views/notifications_mailer/notify_user_wallet_is_credited.html.erb index a2894c454..2d4007408 100644 --- a/app/views/notifications_mailer/notify_user_wallet_is_credited.html.erb +++ b/app/views/notifications_mailer/notify_user_wallet_is_credited.html.erb @@ -1,2 +1,2 @@ <%= render 'notifications_mailer/shared/hello', recipient: @recipient %> -

<%= t('.body.wallet_credit_html', AMOUNT: number_to_currency(@attached_object.amount)) %>

+

<%= t('.body.wallet_credit_html', AMOUNT: number_to_currency(@attached_object.amount, locale: CURRENCY_LOCALE)) %>

diff --git a/app/workers/payment_schedule_item_worker.rb b/app/workers/payment_schedule_item_worker.rb index 10c5eceaa..77bd905fa 100644 --- a/app/workers/payment_schedule_item_worker.rb +++ b/app/workers/payment_schedule_item_worker.rb @@ -6,14 +6,15 @@ class PaymentScheduleItemWorker include Sidekiq::Worker def perform(record_id = nil) - if record_id - psi = PaymentScheduleItem.find(record_id) - check_item(psi) - else - PaymentScheduleItem.where.not(state: 'paid').where('due_date < ?', Time.current).each do |item| - check_item(item) - end - end + p "WORKER CURRENCY_LOCALE=#{CURRENCY_LOCALE}" + # if record_id + # psi = PaymentScheduleItem.find(record_id) + # check_item(psi) + # else + # PaymentScheduleItem.where.not(state: 'paid').where('due_date < ?', Time.current).each do |item| + # check_item(item) + # end + # end end # @param psi [PaymentScheduleItem] diff --git a/config/initializers/currency.rb b/config/initializers/currency.rb new file mode 100644 index 000000000..b4fa1f4e4 --- /dev/null +++ b/config/initializers/currency.rb @@ -0,0 +1 @@ +CURRENCY_LOCALE = Rails.application.secrets.rails_locale diff --git a/lib/tasks/fablab/fix_invoice_items.rake b/lib/tasks/fablab/fix_invoice_items.rake index 914e11448..81cc18d95 100644 --- a/lib/tasks/fablab/fix_invoice_items.rake +++ b/lib/tasks/fablab/fix_invoice_items.rake @@ -31,7 +31,7 @@ namespace :fablab do puts "\e[4;33mFound an invalid InvoiceItem\e[0m" puts '==============================================' puts "Invoice #{invoice.id} (# #{invoice.reference})" - puts "Total: #{number_to_currency(invoice.total / 100.0)}" + puts "Total: #{number_to_currency(invoice.total / 100.0, locale: CURRENCY_LOCALE)}" puts "Customer: #{invoice.invoicing_profile.full_name} (#{invoice.invoicing_profile.email})" puts "Operator: #{invoice.operator_profile&.user&.profile&.full_name} (#{invoice.operator_profile&.user&.email})" puts "Date: #{invoice.created_at}" diff --git a/lib/tasks/fablab/fix_invoices.rake b/lib/tasks/fablab/fix_invoices.rake index af2f1c1d1..bfb5524ca 100644 --- a/lib/tasks/fablab/fix_invoices.rake +++ b/lib/tasks/fablab/fix_invoices.rake @@ -22,7 +22,7 @@ namespace :fablab do ii = invoice.invoice_items.where(subscription_id: nil).first puts '==============================================' puts "Invoice #{invoice.id} (# #{invoice.reference})" - puts "Total: #{number_to_currency(invoice.total / 100.0)}" + puts "Total: #{number_to_currency(invoice.total / 100.0, locale: CURRENCY_LOCALE)}" puts "Subject: #{ii.description}." puts "Customer: #{invoice.invoicing_profile.full_name} (#{invoice.invoicing_profile.email})" puts "Operator: #{invoice.operator_profile&.user&.profile&.full_name} (#{invoice.operator_profile&.user&.email})" diff --git a/test/integration/invoices/vat_test.rb b/test/integration/invoices/vat_test.rb index 9e388551a..afaa6cc67 100644 --- a/test/integration/invoices/vat_test.rb +++ b/test/integration/invoices/vat_test.rb @@ -38,7 +38,7 @@ class Invoices::VATTest < ActionDispatch::IntegrationTest assert_invoice_pdf invoice do |lines| vat_line = I18n.t('invoices.including_VAT_RATE', **{ RATE: Setting.get('invoice_VAT-rate'), - AMOUNT: number_to_currency(invoice.total / 100.00), + AMOUNT: number_to_currency(invoice.total / 100.00, locale: CURRENCY_LOCALE), NAME: 'TVQ+TPS' }) assert(lines.any? { |l| /#{Regexp.escape(vat_line)}/.match(l) }) end