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

fix vat history usage in invoice test + fix sidekiq delay extension

This commit is contained in:
Sylvain 2019-08-01 11:50:03 +02:00
parent 4210405932
commit 35c31b96ea
3 changed files with 19 additions and 11 deletions

View File

@ -1,5 +1,8 @@
# frozen_string_literal: true
# Mailer configuration
class BaseMailer < ActionMailer::Base class BaseMailer < ActionMailer::Base
default :from => ENV['DEFAULT_MAIL_FROM'] default from: ENV['DEFAULT_MAIL_FROM']
layout 'notifications_mailer' layout 'notifications_mailer'
helper :application helper :application

View File

@ -1,24 +1,28 @@
if Rails.env.staging? # frozen_string_literal: true
namespace = "fablab_staging"
namespace = if Rails.env.staging?
'fablab_staging'
else else
namespace = "fablab" 'fablab'
end end
redis_host = ENV["REDIS_HOST"] || 'localhost' redis_host = ENV['REDIS_HOST'] || 'localhost'
redis_url = "redis://#{redis_host}:6379" redis_url = "redis://#{redis_host}:6379"
Sidekiq.configure_server do |config| Sidekiq.configure_server do |config|
config.redis = { url: redis_url, namespace: namespace } config.redis = { url: redis_url, namespace: namespace }
# load sidekiq-cron schedule config # load sidekiq-cron schedule config
schedule_file = "config/schedule.yml" schedule_file = 'config/schedule.yml'
if File.exists?(schedule_file) if File.exist?(schedule_file)
rendered_schedule_file = ERB.new(File.read(schedule_file)).result rendered_schedule_file = ERB.new(File.read(schedule_file)).result
Sidekiq::Cron::Job.load_from_hash YAML.load(rendered_schedule_file) Sidekiq::Cron::Job.load_from_hash YAML.safe_load(rendered_schedule_file)
end end
end end
Sidekiq.configure_client do |config| Sidekiq.configure_client do |config|
config.redis = { url: redis_url, namespace: namespace } config.redis = { url: redis_url, namespace: namespace }
end end
Sidekiq::Extensions.enable_delay!

View File

@ -92,7 +92,8 @@ class ActiveSupport::TestCase
end end
if Setting.find_by(name: 'invoice_VAT-active').value == 'true' if Setting.find_by(name: 'invoice_VAT-active').value == 'true'
vat_rate = Setting.find_by(name: 'invoice_VAT-rate').value.to_f vat_service = VatHistoryService.new
vat_rate = vat_service.invoice_vat(invoice)
computed_ht = sprintf('%.2f', (invoice.total / (vat_rate / 100 + 1)) / 100.0).to_f computed_ht = sprintf('%.2f', (invoice.total / (vat_rate / 100 + 1)) / 100.0).to_f
assert_equal computed_ht, ht_amount, 'Total excluding taxes rendered in the PDF file is not computed correctly' assert_equal computed_ht, ht_amount, 'Total excluding taxes rendered in the PDF file is not computed correctly'