mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
test invoice with VAT
This commit is contained in:
parent
10080b8676
commit
2a92b06ef6
@ -1,7 +1,7 @@
|
|||||||
module Events
|
module Events
|
||||||
class AsUserTest < ActionDispatch::IntegrationTest
|
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')
|
vlonchamp = User.find_by(username: 'vlonchamp')
|
||||||
login_as(vlonchamp, scope: :user)
|
login_as(vlonchamp, scope: :user)
|
||||||
@ -15,6 +15,15 @@ module Events
|
|||||||
users_credit_count = UsersCredit.count
|
users_credit_count = UsersCredit.count
|
||||||
wallet_transactions_count = WalletTransaction.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
|
# Reserve the 'radio' event
|
||||||
VCR.use_cassette('reserve_event_with_many_prices_and_payment_means') do
|
VCR.use_cassette('reserve_event_with_many_prices_and_payment_means') do
|
||||||
post reservations_path, {
|
post reservations_path, {
|
||||||
|
@ -89,7 +89,9 @@ class ActiveSupport::TestCase
|
|||||||
|
|
||||||
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_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
|
else
|
||||||
assert_equal invoice.total, ht_amount, 'VAT information was rendered in the PDF file despite that VAT was disabled'
|
assert_equal invoice.total, ht_amount, 'VAT information was rendered in the PDF file despite that VAT was disabled'
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user