1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-11 22:24:21 +01:00
fab-manager/test/integration/invoices/vat_test.rb

47 lines
1.2 KiB
Ruby
Raw Normal View History

2022-12-23 15:52:10 +01:00
# frozen_string_literal: true
require 'test_helper'
module Invoices; end
class Invoices::VATTest < ActionDispatch::IntegrationTest
include ActionView::Helpers::NumberHelper
def setup
@admin = User.find_by(username: 'admin')
login_as(@admin, scope: :user)
end
test 'renamed VAT' do
user = User.find_by(username: 'vlonchamp')
plan = Plan.find(5)
Setting.set('invoice_VAT-active', true)
Setting.set('invoice_VAT-name', 'TVQ+TPS')
post '/api/local_payment/confirm_payment', params: {
customer_id: user.id,
items: [
{
subscription: {
plan_id: plan.id
}
}
]
}.to_json, headers: default_headers
# Check response format & status
assert_equal 201, response.status, response.body
2023-02-24 17:26:55 +01:00
assert_match Mime[:json].to_s, response.content_type
2022-12-23 15:52:10 +01:00
invoice = Invoice.last
assert_invoice_pdf invoice do |lines|
vat_line = I18n.t('invoices.including_VAT_RATE',
2023-02-24 17:26:55 +01:00
**{ RATE: Setting.get('invoice_VAT-rate'),
AMOUNT: number_to_currency(invoice.total / 100.00),
NAME: 'TVQ+TPS' })
2022-12-23 15:52:10 +01:00
assert(lines.any? { |l| /#{Regexp.escape(vat_line)}/.match(l) })
end
end
end