mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
test invoice with VAT
This commit is contained in:
parent
10080b8676
commit
2a92b06ef6
@ -1,7 +1,7 @@
|
||||
module Events
|
||||
class AsUserTest < ActionDispatch::IntegrationTest
|
||||
|
||||
test 'reserve event with many prices and payment means' do
|
||||
test 'reserve event with many prices and payment means and VAT' do
|
||||
|
||||
vlonchamp = User.find_by(username: 'vlonchamp')
|
||||
login_as(vlonchamp, scope: :user)
|
||||
@ -15,6 +15,15 @@ module Events
|
||||
users_credit_count = UsersCredit.count
|
||||
wallet_transactions_count = WalletTransaction.count
|
||||
|
||||
# Enable the VAT at 19.6%
|
||||
vat_active = Setting.find_by(name: 'invoice_VAT-active')
|
||||
vat_active.value = 'true'
|
||||
vat_active.save!
|
||||
|
||||
vat_rate = Setting.find_by(name: 'invoice_VAT-rate')
|
||||
vat_rate.value = '19.6'
|
||||
vat_rate.save!
|
||||
|
||||
# Reserve the 'radio' event
|
||||
VCR.use_cassette('reserve_event_with_many_prices_and_payment_means') do
|
||||
post reservations_path, {
|
||||
|
@ -89,7 +89,9 @@ class ActiveSupport::TestCase
|
||||
|
||||
if Setting.find_by(name: 'invoice_VAT-active').value == 'true'
|
||||
vat_rate = Setting.find_by({name: 'invoice_VAT-rate'}).value.to_f
|
||||
assert_equal (invoice.total / (vat_rate / 100 + 1)), ht_amount, 'Total excluding taxes rendered in the PDF file is not computed correct'
|
||||
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'
|
||||
else
|
||||
assert_equal invoice.total, ht_amount, 'VAT information was rendered in the PDF file despite that VAT was disabled'
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user