1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-26 20:54:21 +01:00

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

This commit is contained in:
Nicolas Florentin 2023-11-14 10:36:12 +01:00
parent 1fa3f37776
commit 08b4127331
34 changed files with 76 additions and 77 deletions

View File

@ -1,5 +1,10 @@
# Changelog Fab-manager # 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 ## v6.3.1 2023 November 10
- Fix a bug: statistic_sub_type.label of plan was nil - Fix a bug: statistic_sub_type.label of plan was nil

View File

@ -91,9 +91,9 @@ gem 'friendly_id', '~> 5.1.0'
gem 'aasm' gem 'aasm'
# Background job processing # Background job processing
gem 'sidekiq', '>= 6.0.7' gem 'sidekiq', '6.5.12'
# Recurring jobs for Sidekiq # Recurring jobs for Sidekiq
gem 'sidekiq-scheduler' gem 'sidekiq-scheduler', '5.0.3'
gem 'sidekiq-unique-jobs', '~> 7.1.23' gem 'sidekiq-unique-jobs', '~> 7.1.23'
gem 'stripe', '5.29.0' gem 'stripe', '5.29.0'

View File

@ -125,7 +125,7 @@ GEM
coercible (1.0.0) coercible (1.0.0)
descendants_tracker (~> 0.0.1) descendants_tracker (~> 0.0.1)
concurrent-ruby (1.2.2) concurrent-ruby (1.2.2)
connection_pool (2.2.5) connection_pool (2.4.1)
coveralls_reborn (0.18.0) coveralls_reborn (0.18.0)
simplecov (>= 0.18.1, < 0.20.0) simplecov (>= 0.18.1, < 0.20.0)
term-ansicolor (~> 1.6) term-ansicolor (~> 1.6)
@ -182,7 +182,7 @@ GEM
forgery (0.7.0) forgery (0.7.0)
friendly_id (5.1.0) friendly_id (5.1.0)
activerecord (>= 4.0.0) activerecord (>= 4.0.0)
fugit (1.5.3) fugit (1.9.0)
et-orbi (~> 1, >= 1.2.7) et-orbi (~> 1, >= 1.2.7)
raabro (~> 1.4) raabro (~> 1.4)
globalid (1.1.0) globalid (1.1.0)
@ -428,7 +428,7 @@ GEM
nokogiri (>= 1.10.8) nokogiri (>= 1.10.8)
rubyzip (>= 1.3.0) rubyzip (>= 1.3.0)
rubyzip (2.3.2) rubyzip (2.3.2)
rufus-scheduler (3.8.1) rufus-scheduler (3.9.1)
fugit (~> 1.1, >= 1.1.6) fugit (~> 1.1, >= 1.1.6)
safe_yaml (1.0.5) safe_yaml (1.0.5)
sassc (2.4.0) sassc (2.4.0)
@ -448,14 +448,13 @@ GEM
rack-proxy (>= 0.6.1) rack-proxy (>= 0.6.1)
railties (>= 5.2) railties (>= 5.2)
semantic_range (>= 2.3.0) semantic_range (>= 2.3.0)
sidekiq (6.4.2) sidekiq (6.5.12)
connection_pool (>= 2.2.2) connection_pool (>= 2.2.5, < 3)
rack (~> 2.0) rack (~> 2.0)
redis (>= 4.2.0) redis (>= 4.5.0, < 5)
sidekiq-scheduler (4.0.0) sidekiq-scheduler (5.0.3)
redis (>= 4.2.0)
rufus-scheduler (~> 3.2) rufus-scheduler (~> 3.2)
sidekiq (>= 4) sidekiq (>= 6, < 8)
tilt (>= 1.4.0) tilt (>= 1.4.0)
sidekiq-unique-jobs (7.1.23) sidekiq-unique-jobs (7.1.23)
brpoplpush-redis_script (> 0.1.1, <= 2.0.0) brpoplpush-redis_script (> 0.1.1, <= 2.0.0)
@ -484,7 +483,7 @@ GEM
tins (~> 1.0) tins (~> 1.0)
thor (1.2.1) thor (1.2.1)
thread_safe (0.3.6) thread_safe (0.3.6)
tilt (2.0.10) tilt (2.3.0)
timeout (0.3.2) timeout (0.3.2)
tins (1.25.0) tins (1.25.0)
sync sync
@ -609,8 +608,8 @@ DEPENDENCIES
sentry-ruby sentry-ruby
sha3 sha3
shakapacker (= 6.6.0) shakapacker (= 6.6.0)
sidekiq (>= 6.0.7) sidekiq (= 6.5.12)
sidekiq-scheduler sidekiq-scheduler (= 5.0.3)
sidekiq-unique-jobs (~> 7.1.23) sidekiq-unique-jobs (~> 7.1.23)
silencer silencer
spring (~> 4) spring (~> 4)

View File

@ -75,7 +75,7 @@ class Pdf::Invoice < Prawn::Document
invoice.invoice_items.each do |item| invoice.invoice_items.each do |item|
price = item.amount.to_i / 100.00 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_calc += price
total_ht += item.net_amount total_ht += item.net_amount
total_vat += item.vat total_vat += item.vat
@ -92,13 +92,13 @@ class Pdf::Invoice < Prawn::Document
# discount textual description # discount textual description
literal_discount = cp.percent_off 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 # add a row for the coupon
data += [[_t('invoices.coupon_CODE_discount_of_DISCOUNT', data += [[_t('invoices.coupon_CODE_discount_of_DISCOUNT',
CODE: cp.code, CODE: cp.code,
DISCOUNT: literal_discount, DISCOUNT: literal_discount,
TYPE: cp.type), number_to_currency(-discount)]] TYPE: cp.type), number_to_currency(-discount, locale: CURRENCY_LOCALE)]]
end end
# total verification # total verification
@ -109,18 +109,18 @@ class Pdf::Invoice < Prawn::Document
vat_service = VatHistoryService.new vat_service = VatHistoryService.new
vat_rate_group = vat_service.invoice_vat(invoice) vat_rate_group = vat_service.invoice_vat(invoice)
if total_vat.zero? 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 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| vat_rate_group.each do |_type, rate|
data += [[I18n.t('invoices.including_VAT_RATE', data += [[I18n.t('invoices.including_VAT_RATE',
**{ RATE: rate[: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') }), 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 end
data += [[I18n.t('invoices.including_total_excluding_taxes'), number_to_currency(total_ht / 100.00)]] 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)]] data += [[I18n.t('invoices.including_amount_payed_on_ordering'), number_to_currency(total, locale: CURRENCY_LOCALE)]]
# checking the round number # checking the round number
rounded = (sprintf('%.2f', total_vat / 100.00).to_f + sprintf('%.2f', total_ht / 100.00).to_f).to_s rounded = (sprintf('%.2f', total_vat / 100.00).to_f + sprintf('%.2f', total_ht / 100.00).to_f).to_s

View File

@ -80,9 +80,9 @@ class Pdf::PaymentSchedule < Prawn::Document
price = item.amount.to_i / 100.00 price = item.amount.to_i / 100.00
date = I18n.l(item.due_date.to_date) date = I18n.l(item.due_date.to_date)
data += [[date, number_to_currency(price)]] data += [[date, number_to_currency(price, locale: CURRENCY_LOCALE)]]
end 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 # display table
font_size(8) do 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) payment_verbose = _t('payment_schedules.settlement_by_METHOD', METHOD: payment_schedule.payment_method)
if payment_schedule.wallet_amount if payment_schedule.wallet_amount
payment_verbose += I18n.t('payment_schedules.settlement_by_wallet', 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 end
text payment_verbose text payment_verbose

View File

@ -27,14 +27,14 @@ class Invoices::PaymentDetailsService
**{ DATE: I18n.l(invoice.created_at.to_date), **{ DATE: I18n.l(invoice.created_at.to_date),
TIME: I18n.l(invoice.created_at, format: :hour_minute) })}" TIME: I18n.l(invoice.created_at, format: :hour_minute) })}"
if total.positive? || wallet_amount.nil? 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 end
if invoice.wallet_amount if invoice.wallet_amount
payment_verbose += if total.positive? payment_verbose += if total.positive?
" #{I18n.t('invoices.and')} #{I18n.t('invoices.by_wallet')} " \ " #{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 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
end end
payment_verbose payment_verbose
@ -88,7 +88,7 @@ class Invoices::PaymentDetailsService
else else
Rails.logger.error "specified refunding method (#{details}) is unknown" Rails.logger.error "specified refunding method (#{details}) is unknown"
end 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 end
end end

View File

@ -1,5 +1,4 @@
json.title notification.notification_type json.title notification.notification_type
json.description t('.refund_created', 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) USER: notification.attached_object.invoicing_profile&.full_name)

View File

@ -3,7 +3,6 @@
json.title notification.notification_type json.title notification.notification_type
amount = notification.attached_object.amount amount = notification.attached_object.amount
json.description t('.wallet_is_credited', 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'), 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')) ADMIN: notification.attached_object.user&.profile&.full_name || t('api.notifications.deleted_user'))

View File

@ -5,7 +5,6 @@ if notification.attached_object.type == 'percent_off'
CODE: notification.attached_object.code) CODE: notification.attached_object.code)
else else
json.description t('.enjoy_a_discount_of_AMOUNT_with_code_CODE', 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) CODE: notification.attached_object.code)
end end

View File

@ -1,5 +1,4 @@
json.title notification.notification_type json.title notification.notification_type
amount = notification.attached_object.amount amount = notification.attached_object.amount
json.description t('.your_wallet_is_credited', json.description t('.your_wallet_is_credited',
AMOUNT: number_to_currency(amount)) AMOUNT: number_to_currency(amount, locale: CURRENCY_LOCALE))

View File

@ -2,6 +2,5 @@ json.title notification.notification_type
amount = notification.attached_object.total / 100.0 amount = notification.attached_object.total / 100.0
json.description t('.your_avoir_is_ready_html', json.description t('.your_avoir_is_ready_html',
REFERENCE: notification.attached_object.reference, REFERENCE: notification.attached_object.reference,
AMOUNT: number_to_currency(amount), AMOUNT: number_to_currency(amount, locale: CURRENCY_LOCALE),
INVOICE_ID: notification.attached_object.id) INVOICE_ID: notification.attached_object.id)

View File

@ -2,6 +2,5 @@ json.title notification.notification_type
amount = notification.attached_object.total / 100.0 amount = notification.attached_object.total / 100.0
json.description t('.your_invoice_is_ready_html', json.description t('.your_invoice_is_ready_html',
REFERENCE: notification.attached_object.reference, REFERENCE: notification.attached_object.reference,
AMOUNT: number_to_currency(amount), AMOUNT: number_to_currency(amount, locale: CURRENCY_LOCALE),
INVOICE_ID: notification.attached_object.id) INVOICE_ID: notification.attached_object.id)

View File

@ -4,6 +4,5 @@ json.title notification.notification_type
amount = notification.attached_object.total / 100.0 amount = notification.attached_object.total / 100.0
json.description t('.your_schedule_is_ready_html', json.description t('.your_schedule_is_ready_html',
REFERENCE: notification.attached_object.reference, REFERENCE: notification.attached_object.reference,
AMOUNT: number_to_currency(amount), AMOUNT: number_to_currency(amount, locale: CURRENCY_LOCALE),
SCHEDULE_ID: notification.attached_object.id) SCHEDULE_ID: notification.attached_object.id)

View File

@ -9,7 +9,7 @@ json.invoices do
json.type invoice[:invoice].payment_gateway_object.gateway_object_type json.type invoice[:invoice].payment_gateway_object.gateway_object_type
end end
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.user do
json.extract! invoice[:invoice].invoicing_profile, :user_id, :email, :first_name, :last_name json.extract! invoice[:invoice].invoicing_profile, :user_id, :email, :first_name, :last_name
json.address invoice[:invoice].invoicing_profile&.address&.address json.address invoice[:invoice].invoicing_profile&.address&.address
@ -46,7 +46,7 @@ json.payment_schedules do
json.id object.gateway_object_id json.id object.gateway_object_id
json.type object.gateway_object_type json.type object.gateway_object_type
end 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.user do
json.extract! schedule.invoicing_profile, :user_id, :email, :first_name, :last_name json.extract! schedule.invoicing_profile, :user_id, :email, :first_name, :last_name
json.address schedule.invoicing_profile&.address&.address json.address schedule.invoicing_profile&.address&.address
@ -60,7 +60,7 @@ json.payment_schedules do
end end
json.deadlines schedule.payment_schedule_items do |item| json.deadlines schedule.payment_schedule_items do |item|
json.extract! item, :id, :due_date, :state, :details, :invoice_id, :footprint, :created_at 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 end
json.objects schedule.payment_schedule_objects do |object| json.objects schedule.payment_schedule_objects do |object|
json.type object.object_type json.type object.object_type
@ -71,8 +71,8 @@ json.payment_schedules do
end end
json.totals do json.totals do
json.period_total number_to_currency(period_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) json.perpetual_total number_to_currency(perpetual_total / 100.0, locale: CURRENCY_LOCALE)
end end
json.software do json.software do

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
json.amount do json.amount do
json.without_tax number_to_currency((price - (price * vat_rate)) / 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) 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' json.vat_rate vat_rate.positive? ? number_to_percentage(vat_rate * 100) : 'none'
end end

View File

@ -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), t("duration.#{sub.plan.interval}", count: sub.plan.interval_count),
sub.created_at.to_date, sub.created_at.to_date,
sub.expired_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] styles = [nil, nil, nil, nil, nil, date, date, nil, nil]
types = %i[integer string string string string date date string string] types = %i[integer string string string string date date string string]

View File

@ -3,7 +3,7 @@
<p> <p>
<%= t('.body.remember', <%= t('.body.remember',
REFERENCE: @attached_object.payment_schedule.reference, 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)) %> DATE: I18n.l(@attached_object.due_date, format: :long)) %>
<%= t('.body.date') %> <%= t('.body.date') %>
</p> </p>

View File

@ -3,7 +3,7 @@
<p> <p>
<%= t('.body.remember', <%= t('.body.remember',
REFERENCE: @attached_object.payment_schedule.reference, 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)) %> DATE: I18n.l(@attached_object.due_date, format: :long)) %>
<%= t('.body.error', GATEWAY: @attached_object.payment_gateway_object.gateway_object.gateway) %> <%= t('.body.error', GATEWAY: @attached_object.payment_gateway_object.gateway_object.gateway) %>
</p> </p>

View File

@ -3,7 +3,7 @@
<p> <p>
<%= t('.body.remember', <%= t('.body.remember',
REFERENCE: @attached_object.payment_schedule.reference, 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)) %> DATE: I18n.l(@attached_object.due_date, format: :long)) %>
<%= t('.body.error') %> <%= t('.body.error') %>
</p> </p>

View File

@ -3,7 +3,7 @@
<p> <p>
<%= t('.body.remember', <%= t('.body.remember',
REFERENCE: @attached_object.payment_schedule.reference, 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)) %> DATE: I18n.l(@attached_object.due_date, format: :long)) %>
<%= t('.body.date') %> <%= t('.body.date') %>
</p> </p>

View File

@ -1,11 +1,11 @@
<%= render 'notifications_mailer/shared/hello', recipient: @recipient %> <%= render 'notifications_mailer/shared/hello', recipient: @recipient %>
<p><%= t('.body.refund_created', <p><%= 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, INVOICE: @attached_object.invoice.reference,
USER: @attached_object.invoicing_profile&.full_name) if @attached_object.invoice %> USER: @attached_object.invoicing_profile&.full_name) if @attached_object.invoice %>
<%= t('.body.wallet_refund_created', <%= 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 %> USER: @attached_object.invoicing_profile&.full_name) if @attached_object.main_item.object_type === WalletTransaction.name %>
</p> </p>
<p><a href="<%= "#{root_url}api/invoices/#{@attached_object.id}/download" %>" target="_blank"><%= t('.body.download') %></a></p> <p><a href="<%= "#{root_url}api/invoices/#{@attached_object.id}/download" %>" target="_blank"><%= t('.body.download') %></a></p>

View File

@ -2,7 +2,7 @@
<%= render 'notifications_mailer/shared/hello', recipient: @recipient %> <%= render 'notifications_mailer/shared/hello', recipient: @recipient %>
<p> <p>
<%= t('.body.wallet_credit_html', <%= 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'), 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')) ADMIN: @attached_object.user&.profile&.full_name || t('api.notifications.deleted_user'))
%> %>

View File

@ -8,7 +8,7 @@
</p> </p>
<% else %> <% else %>
<p><%= t('.body.enjoy_a_discount_of_AMOUNT_with_code_CODE', <p><%= 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 CODE: @attached_object.code
) %> ) %>
</p> </p>

View File

@ -4,7 +4,7 @@
<%= _t('.body.please_find_attached_html', <%= _t('.body.please_find_attached_html',
{ {
DATE: I18n.l(@attached_object.avoir_date.to_date), 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 TYPE: @attached_object.main_item.object_type
}) })
# messageFormat # messageFormat

View File

@ -4,7 +4,7 @@
<%= _t('.body.please_find_attached_html', <%= _t('.body.please_find_attached_html',
{ {
DATE: I18n.l(@attached_object.created_at.to_date), 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 TYPE: @attached_object.main_item.object_type
}) })
# messageFormat # messageFormat

View File

@ -3,7 +3,7 @@
<p> <p>
<%= t('.body.remember', <%= t('.body.remember',
REFERENCE: @attached_object.payment_schedule.reference, 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)) %> DATE: I18n.l(@attached_object.due_date, format: :long)) %>
<%= t('.body.error') %> <%= t('.body.error') %>
</p> </p>

View File

@ -3,7 +3,7 @@
<p> <p>
<%= t('.body.remember', <%= t('.body.remember',
REFERENCE: @attached_object.payment_schedule.reference, 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)) %> DATE: I18n.l(@attached_object.due_date, format: :long)) %>
<%= t('.body.error') %> <%= t('.body.error') %>
</p> </p>

View File

@ -4,7 +4,7 @@
<%= _t('.body.please_find_attached_html', <%= _t('.body.please_find_attached_html',
{ {
DATE: I18n.l(@attached_object.created_at.to_date), 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 TYPE: @attached_object.main_object.object_type
}) })
# messageFormat # messageFormat

View File

@ -1,2 +1,2 @@
<%= render 'notifications_mailer/shared/hello', recipient: @recipient %> <%= render 'notifications_mailer/shared/hello', recipient: @recipient %>
<p><%= t('.body.wallet_credit_html', AMOUNT: number_to_currency(@attached_object.amount)) %></p> <p><%= t('.body.wallet_credit_html', AMOUNT: number_to_currency(@attached_object.amount, locale: CURRENCY_LOCALE)) %></p>

View File

@ -6,14 +6,15 @@ class PaymentScheduleItemWorker
include Sidekiq::Worker include Sidekiq::Worker
def perform(record_id = nil) def perform(record_id = nil)
if record_id p "WORKER CURRENCY_LOCALE=#{CURRENCY_LOCALE}"
psi = PaymentScheduleItem.find(record_id) # if record_id
check_item(psi) # psi = PaymentScheduleItem.find(record_id)
else # check_item(psi)
PaymentScheduleItem.where.not(state: 'paid').where('due_date < ?', Time.current).each do |item| # else
check_item(item) # PaymentScheduleItem.where.not(state: 'paid').where('due_date < ?', Time.current).each do |item|
end # check_item(item)
end # end
# end
end end
# @param psi [PaymentScheduleItem] # @param psi [PaymentScheduleItem]

View File

@ -0,0 +1 @@
CURRENCY_LOCALE = Rails.application.secrets.rails_locale

View File

@ -31,7 +31,7 @@ namespace :fablab do
puts "\e[4;33mFound an invalid InvoiceItem\e[0m" puts "\e[4;33mFound an invalid InvoiceItem\e[0m"
puts '==============================================' puts '=============================================='
puts "Invoice #{invoice.id} (# #{invoice.reference})" 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 "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 "Operator: #{invoice.operator_profile&.user&.profile&.full_name} (#{invoice.operator_profile&.user&.email})"
puts "Date: #{invoice.created_at}" puts "Date: #{invoice.created_at}"

View File

@ -22,7 +22,7 @@ namespace :fablab do
ii = invoice.invoice_items.where(subscription_id: nil).first ii = invoice.invoice_items.where(subscription_id: nil).first
puts '==============================================' puts '=============================================='
puts "Invoice #{invoice.id} (# #{invoice.reference})" 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 "Subject: #{ii.description}."
puts "Customer: #{invoice.invoicing_profile.full_name} (#{invoice.invoicing_profile.email})" 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 "Operator: #{invoice.operator_profile&.user&.profile&.full_name} (#{invoice.operator_profile&.user&.email})"

View File

@ -38,7 +38,7 @@ class Invoices::VATTest < ActionDispatch::IntegrationTest
assert_invoice_pdf invoice do |lines| assert_invoice_pdf invoice do |lines|
vat_line = I18n.t('invoices.including_VAT_RATE', vat_line = I18n.t('invoices.including_VAT_RATE',
**{ RATE: Setting.get('invoice_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' }) NAME: 'TVQ+TPS' })
assert(lines.any? { |l| /#{Regexp.escape(vat_line)}/.match(l) }) assert(lines.any? { |l| /#{Regexp.escape(vat_line)}/.match(l) })
end end