dorsale 3.8.1 → 3.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +5 -1
- data/app/commands/dorsale/flyboy/task_commands.rb +1 -1
- data/app/controllers/concerns/dorsale/flyboy/tasks_summary_concern.rb +0 -1
- data/app/controllers/dorsale/alexandrie/attachments_controller.rb +1 -2
- data/app/controllers/dorsale/application_controller.rb +0 -1
- data/app/controllers/dorsale/billing_machine/application_controller.rb +0 -2
- data/app/controllers/dorsale/billing_machine/invoices_controller.rb +9 -22
- data/app/controllers/dorsale/billing_machine/payment_terms_controller.rb +0 -1
- data/app/controllers/dorsale/billing_machine/quotations_controller.rb +1 -4
- data/app/controllers/dorsale/comments_controller.rb +3 -2
- data/app/controllers/dorsale/customer_vault/activity_types_controller.rb +0 -1
- data/app/controllers/dorsale/customer_vault/application_controller.rb +0 -1
- data/app/controllers/dorsale/customer_vault/links_controller.rb +22 -12
- data/app/controllers/dorsale/customer_vault/origins_controller.rb +0 -1
- data/app/controllers/dorsale/customer_vault/people_controller.rb +2 -3
- data/app/controllers/dorsale/expense_gun/categories_controller.rb +0 -1
- data/app/controllers/dorsale/expense_gun/expenses_controller.rb +0 -1
- data/app/controllers/dorsale/flyboy/task_comments_controller.rb +0 -1
- data/app/controllers/dorsale/flyboy/tasks_controller.rb +28 -21
- data/app/controllers/dorsale/users_controller.rb +0 -1
- data/app/filters/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb +9 -5
- data/app/filters/dorsale/billing_machine/small_data/filter_strategy_by_state.rb +2 -2
- data/app/filters/dorsale/flyboy/small_data/filter_for_tasks.rb +1 -1
- data/app/helpers/dorsale/billing_machine/application_helper.rb +6 -6
- data/app/helpers/dorsale/context_helper.rb +1 -1
- data/app/helpers/dorsale/flyboy/application_helper.rb +4 -5
- data/app/mailers/dorsale/billing_machine/invoice_mailer.rb +0 -1
- data/app/mailers/dorsale/flyboy/task_mailer.rb +0 -1
- data/app/mailers/dorsale/user_mailer.rb +0 -1
- data/app/models/dorsale/address.rb +2 -2
- data/app/models/dorsale/alexandrie/attachment_type.rb +0 -1
- data/app/models/dorsale/billing_machine.rb +1 -2
- data/app/models/dorsale/billing_machine/invoice.rb +19 -30
- data/app/models/dorsale/billing_machine/invoice_line.rb +2 -2
- data/app/models/dorsale/billing_machine/quotation.rb +11 -17
- data/app/models/dorsale/billing_machine/quotation_line.rb +2 -3
- data/app/models/dorsale/comment.rb +1 -1
- data/app/models/dorsale/customer_vault/corporation.rb +11 -10
- data/app/models/dorsale/customer_vault/event.rb +2 -2
- data/app/models/dorsale/customer_vault/individual.rb +4 -2
- data/app/models/dorsale/customer_vault/person.rb +14 -4
- data/app/models/dorsale/customer_vault/person_data.rb +1 -2
- data/app/models/dorsale/expense_gun/expense.rb +2 -5
- data/app/models/dorsale/expense_gun/expense_line.rb +2 -2
- data/app/models/dorsale/flyboy/task.rb +17 -18
- data/app/models/dorsale/flyboy/task_comment.rb +1 -1
- data/app/models/dorsale/users/active.rb +1 -1
- data/app/models/dorsale/users/avatar.rb +2 -1
- data/app/models/dorsale/users/password_generation.rb +0 -1
- data/app/pdfs/concerns/dorsale/alexandrie/prawn/render_with_attachments.rb +1 -1
- data/app/pdfs/dorsale/application_pdf.rb +7 -0
- data/app/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf.rb +52 -47
- data/app/pdfs/dorsale/billing_machine/invoice_single_vat_pdf.rb +94 -205
- data/app/pdfs/dorsale/prawn_helpers.rb +107 -0
- data/app/policies/dorsale/application_policy.rb +2 -4
- data/app/policies/dorsale/expense_gun/expense_policy_helper.rb +0 -1
- data/app/policies/dorsale/flyboy/task_policy_helper.rb +3 -3
- data/app/policies/dorsale/policy_checker.rb +11 -18
- data/app/services/dorsale/billing_machine/invoice/copy.rb +2 -2
- data/app/services/dorsale/billing_machine/pdf_file_generator.rb +7 -2
- data/app/services/dorsale/billing_machine/quotation/copy.rb +1 -1
- data/app/services/dorsale/billing_machine/quotation/to_invoice.rb +10 -7
- data/app/services/dorsale/flyboy/task/snoozer.rb +1 -1
- data/app/views/dorsale/billing_machine/invoices/_details.html.slim +1 -2
- data/app/views/dorsale/billing_machine/invoices/_form.html.slim +4 -11
- data/app/views/dorsale/billing_machine/invoices/index.xlsx.ruby +1 -1
- data/app/views/dorsale/flyboy/tasks/index.xlsx.ruby +1 -1
- data/config/locales/alexandrie.en.yml +0 -4
- data/config/locales/alexandrie.fr.yml +0 -4
- data/config/locales/billing_machine.en.yml +0 -41
- data/config/locales/billing_machine.fr.yml +0 -41
- data/config/routes.rb +0 -1
- data/db/migrate/20161119064536_delete_id_cards.rb +9 -0
- data/features/billing_machine_invoices.feature +0 -1
- data/features/billing_machine_multiple_vat.feature +0 -1
- data/features/billing_machine_quotations.feature +0 -1
- data/features/step_definitions/billing_machine_invoices_steps.rb +73 -79
- data/features/step_definitions/billing_machine_multiple_vat.rb +5 -6
- data/features/step_definitions/billing_machine_payment_terms_steps.rb +2 -2
- data/features/step_definitions/billing_machine_quotations_steps.rb +45 -80
- data/features/step_definitions/common_steps.rb +0 -4
- data/features/step_definitions/customer_vault_activity_types_steps.rb +1 -1
- data/features/step_definitions/customer_vault_corporations_steps.rb +27 -23
- data/features/step_definitions/customer_vault_individuals_steps.rb +8 -9
- data/features/step_definitions/customer_vault_invoices_steps.rb +1 -1
- data/features/step_definitions/customer_vault_links_steps.rb +6 -6
- data/features/step_definitions/customer_vault_origins_steps.rb +1 -1
- data/features/step_definitions/customer_vault_people_steps.rb +2 -1
- data/features/step_definitions/expense_gun_categories_steps.rb +2 -2
- data/features/step_definitions/expense_gun_expenses_steps.rb +6 -6
- data/features/step_definitions/flyboy_tasks_steps.rb +4 -7
- data/features/step_definitions/tasks_summary_steps.rb +3 -3
- data/features/support/env.rb +3 -2
- data/lib/dorsale/engine.rb +8 -8
- data/lib/dorsale/file_loader.rb +1 -1
- data/lib/dorsale/simple_form.rb +3 -3
- data/lib/dorsale/simple_form_bootstrap.rb +46 -46
- data/lib/dorsale/version.rb +1 -1
- data/spec/controllers/dorsale/alexandrie/attachments_controller_spec.rb +3 -3
- data/spec/controllers/dorsale/billing_machine/invoices_controller_spec.rb +0 -1
- data/spec/controllers/dorsale/comments_controller_spec.rb +1 -1
- data/spec/controllers/dorsale/customer_vault/events_controller_spec.rb +9 -9
- data/spec/controllers/dorsale/customer_vault/people_controller_spec.rb +15 -19
- data/spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb +1 -2
- data/spec/controllers/dorsale/flyboy/tasks_controller_spec.rb +43 -19
- data/spec/factories/alexandrie_attachment_types.rb +1 -1
- data/spec/factories/alexandrie_attachments.rb +1 -1
- data/spec/factories/billing_machine_invoice_lines.rb +1 -1
- data/spec/factories/billing_machine_invoices.rb +1 -2
- data/spec/factories/billing_machine_payment_terms.rb +1 -1
- data/spec/factories/billing_machine_quotation_lines.rb +1 -2
- data/spec/factories/billing_machine_quotations.rb +1 -2
- data/spec/factories/customer_vault_activity_types.rb +1 -1
- data/spec/factories/customer_vault_corporations.rb +1 -1
- data/spec/factories/customer_vault_event.rb +1 -1
- data/spec/factories/customer_vault_individuals.rb +2 -2
- data/spec/factories/customer_vault_links.rb +1 -1
- data/spec/factories/customer_vault_origins.rb +1 -1
- data/spec/factories/dorsale_addresses.rb +1 -1
- data/spec/factories/dorsale_comments.rb +1 -1
- data/spec/factories/expense_gun_categories.rb +2 -2
- data/spec/factories/expense_gun_expense_lines.rb +8 -8
- data/spec/factories/expense_gun_expenses.rb +2 -3
- data/spec/factories/flyboy_task_comments.rb +1 -1
- data/spec/factories/flyboy_tasks.rb +1 -1
- data/spec/mailers/user_mailer.rb +5 -6
- data/spec/models/dorsale/address_spec.rb +26 -26
- data/spec/models/dorsale/billing_machine/invoice_line_spec.rb +6 -6
- data/spec/models/dorsale/billing_machine/invoice_spec.rb +37 -23
- data/spec/models/dorsale/billing_machine/quotation_line_spec.rb +9 -10
- data/spec/models/dorsale/billing_machine/quotation_spec.rb +26 -28
- data/spec/models/dorsale/billing_machine_spec.rb +0 -1
- data/spec/models/dorsale/comment_spec.rb +0 -1
- data/spec/models/dorsale/customer_vault/corporation_spec.rb +20 -20
- data/spec/models/dorsale/customer_vault/event_spec.rb +1 -1
- data/spec/models/dorsale/customer_vault/individual_spec.rb +0 -2
- data/spec/models/dorsale/customer_vault/link_spec.rb +0 -1
- data/spec/models/dorsale/customer_vault/person_spec.rb +7 -6
- data/spec/models/dorsale/expense_gun/category_spec.rb +2 -2
- data/spec/models/dorsale/expense_gun/expense_line_spec.rb +14 -14
- data/spec/models/dorsale/expense_gun/expense_spec.rb +23 -13
- data/spec/models/dorsale/flyboy/task_comment_spec.rb +5 -6
- data/spec/models/dorsale/flyboy/task_spec.rb +66 -42
- data/spec/models/dorsale/users_spec.rb +3 -5
- data/spec/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf_spec.rb +6 -11
- data/spec/pdfs/dorsale/billing_machine/invoice_single_vat_pdf_spec.rb +7 -11
- data/spec/pdfs/dorsale/billing_machine/quotation_multiple_vat_pdf_spec.rb +6 -11
- data/spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb +7 -14
- data/spec/rails_helper.rb +1 -1
- data/spec/routing/dorsale/billing_machine/invoices_routing_spec.rb +0 -1
- data/spec/routing/dorsale/billing_machine/quotations_routing_spec.rb +0 -1
- data/spec/routing/dorsale/comments_routing_spec.rb +0 -2
- data/spec/routing/dorsale/customer_vault/people_routing_spec.rb +0 -1
- data/spec/routing/dorsale/expense_gun/expenses_routing_spec.rb +0 -1
- data/spec/routing/dorsale/flyboy/task_comments_routing_spec.rb +0 -1
- data/spec/routing/dorsale/users_routing_spec.rb +1 -1
- data/spec/services/dorsale/billing_machine/quotation/copy_spec.rb +2 -2
- data/spec/services/dorsale/expense_gun/expense/copy_spec.rb +13 -17
- data/spec/services/dorsale/flyboy/task/copy_spec.rb +1 -2
- data/spec/services/dorsale/flyboy/task/snoozer_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -0
- metadata +5 -43
- data/app/controllers/dorsale/billing_machine/id_cards_controller.rb +0 -106
- data/app/models/dorsale/billing_machine/id_card.rb +0 -14
- data/app/policies/dorsale/billing_machine/id_card_policy_helper.rb +0 -7
- data/app/views/dorsale/billing_machine/id_cards/_form.html.slim +0 -42
- data/app/views/dorsale/billing_machine/id_cards/_index_actions.html.slim +0 -2
- data/app/views/dorsale/billing_machine/id_cards/_list.html.slim +0 -27
- data/app/views/dorsale/billing_machine/id_cards/edit.html.slim +0 -1
- data/app/views/dorsale/billing_machine/id_cards/index.html.slim +0 -11
- data/app/views/dorsale/billing_machine/id_cards/new.html.slim +0 -1
- data/features/billing_machine_id_cards.feature +0 -19
- data/features/step_definitions/billing_machine_id_cards_steps.rb +0 -53
- data/features/support/ajax.rb +0 -20
- data/features/support/database_cleaner.rb +0 -12
- data/features/support/factory_girl.rb +0 -1
- data/features/support/fix_referrer.rb +0 -9
- data/features/support/message_delivery.rb +0 -1
- data/features/support/poltergeist.rb +0 -22
- data/features/support/rails.rb +0 -1
- data/features/support/rspec.rb +0 -6
- data/features/support/screenshots.rb +0 -5
- data/features/support/sign_in.rb +0 -17
- data/features/support/simplecov.rb +0 -1
- data/features/support/turbolinks.rb +0 -30
- data/spec/factories/billing_machine_id_cards.rb +0 -26
- data/spec/models/dorsale/billing_machine/id_card_spec.rb +0 -12
data/spec/mailers/user_mailer.rb
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
require
|
1
|
+
require "rails_helper"
|
2
2
|
|
3
3
|
describe ::Dorsale::UserMailer do
|
4
4
|
describe "New Account" do
|
5
5
|
let(:user) { create(:user) }
|
6
6
|
let(:email) { ::Dorsale::UserMailer.new_account(user, user.password) }
|
7
7
|
|
8
|
-
it
|
8
|
+
it "should send to the right person" do
|
9
9
|
expect(email.to).to eq([user.email])
|
10
10
|
end
|
11
11
|
|
12
|
-
it
|
12
|
+
it "should have the right sender" do
|
13
13
|
expect(email.from).to eq(["contact@example.org"])
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it "should contain user_type, login and password" do
|
17
17
|
expect(email.body).to include user.email
|
18
18
|
expect(email.body).to include user.password
|
19
19
|
end
|
20
|
-
|
21
20
|
end
|
22
|
-
end
|
21
|
+
end
|
@@ -1,45 +1,45 @@
|
|
1
|
-
require
|
1
|
+
require "rails_helper"
|
2
2
|
|
3
3
|
module Dorsale
|
4
4
|
RSpec.describe Address, :type => :model do
|
5
5
|
it { should belong_to :addressable }
|
6
6
|
it { should validate_presence_of :addressable }
|
7
7
|
|
8
|
-
describe
|
9
|
-
it
|
10
|
-
address = Address.
|
11
|
-
street:
|
12
|
-
street_bis:
|
13
|
-
zip:
|
14
|
-
city:
|
15
|
-
country:
|
8
|
+
describe "#one_line" do
|
9
|
+
it "should build a one line address" do
|
10
|
+
address = Address.new(
|
11
|
+
street: "3 Rue Marx Dormoy",
|
12
|
+
street_bis: "L'atelier",
|
13
|
+
zip: "13004",
|
14
|
+
city: "Marseille",
|
15
|
+
country: "France",
|
16
16
|
)
|
17
17
|
|
18
|
-
expect(address.one_line).to eq(
|
18
|
+
expect(address.one_line).to eq("3 Rue Marx Dormoy, L'atelier, 13004 Marseille, France")
|
19
19
|
end
|
20
20
|
|
21
|
-
it
|
22
|
-
address = Address.
|
23
|
-
street:
|
24
|
-
street_bis:
|
25
|
-
zip:
|
26
|
-
city:
|
27
|
-
country:
|
21
|
+
it "should remove useless commas" do
|
22
|
+
address = Address.new(
|
23
|
+
street: "3 Rue Marx Dormoy",
|
24
|
+
street_bis: "",
|
25
|
+
zip: "13004",
|
26
|
+
city: "Marseille",
|
27
|
+
country: "",
|
28
28
|
)
|
29
29
|
|
30
|
-
expect(address.one_line).to eq(
|
30
|
+
expect(address.one_line).to eq("3 Rue Marx Dormoy, 13004 Marseille")
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
34
|
-
address = Address.
|
35
|
-
street:
|
36
|
-
street_bis:
|
37
|
-
zip:
|
38
|
-
city:
|
39
|
-
country:
|
33
|
+
it "should remove useless commas" do
|
34
|
+
address = Address.new(
|
35
|
+
street: "3 Rue Marx Dormoy",
|
36
|
+
street_bis: "",
|
37
|
+
zip: "",
|
38
|
+
city: "Marseille",
|
39
|
+
country: "",
|
40
40
|
)
|
41
41
|
|
42
|
-
expect(address.one_line).to eq(
|
42
|
+
expect(address.one_line).to eq("3 Rue Marx Dormoy, Marseille")
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "rails_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Dorsale::BillingMachine::InvoiceLine, type: :model do
|
4
4
|
it { is_expected.to belong_to :invoice }
|
5
5
|
it { is_expected.to validate_presence_of :invoice }
|
6
6
|
|
@@ -17,26 +17,26 @@ describe ::Dorsale::BillingMachine::InvoiceLine, type: :model do
|
|
17
17
|
|
18
18
|
describe "default values" do
|
19
19
|
it "quantity should be 0" do
|
20
|
-
expect(
|
20
|
+
expect(described_class.new.quantity).to eq 0
|
21
21
|
end
|
22
22
|
|
23
23
|
it "unit_price should be 0" do
|
24
|
-
expect(
|
24
|
+
expect(described_class.new.unit_price).to eq 0
|
25
25
|
end
|
26
26
|
|
27
27
|
it "vat_rate should be 0" do
|
28
|
-
expect(
|
28
|
+
expect(described_class.new.vat_rate).to eq Dorsale::BillingMachine::DEFAULT_VAT_RATE
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should be sorted by created_at" do
|
33
|
-
line1 = create(:billing_machine_invoice_line, :created_at => Time.zone.now + 1.
|
33
|
+
line1 = create(:billing_machine_invoice_line, :created_at => Time.zone.now + 1.minute)
|
34
34
|
line2 = create(:billing_machine_invoice_line, :created_at => Time.zone.now + 2.minutes)
|
35
35
|
line3 = create(:billing_machine_invoice_line, :created_at => Time.zone.now + 3.minutes)
|
36
36
|
line4 = create(:billing_machine_invoice_line, :created_at => Time.zone.now + 4.minutes)
|
37
37
|
line3.update!(:created_at => Time.zone.now + 5.minutes)
|
38
38
|
|
39
|
-
lines =
|
39
|
+
lines = described_class.all
|
40
40
|
expect(lines).to eq [line1, line2, line4, line3]
|
41
41
|
end
|
42
42
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "rails_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Dorsale::BillingMachine::Invoice, type: :model do
|
4
4
|
# Reset to default mode before each test
|
5
5
|
before :each do
|
6
6
|
::Dorsale::BillingMachine.vat_mode = :single
|
@@ -10,7 +10,6 @@ describe ::Dorsale::BillingMachine::Invoice, type: :model do
|
|
10
10
|
it { is_expected.to belong_to :payment_term }
|
11
11
|
it { is_expected.to have_many(:lines).dependent(:destroy) }
|
12
12
|
|
13
|
-
it { is_expected.to validate_presence_of :id_card }
|
14
13
|
it { is_expected.to validate_presence_of :date }
|
15
14
|
|
16
15
|
it { is_expected.to respond_to :date }
|
@@ -19,8 +18,8 @@ describe ::Dorsale::BillingMachine::Invoice, type: :model do
|
|
19
18
|
it { is_expected.to respond_to :unique_index }
|
20
19
|
it { is_expected.to respond_to :commercial_discount }
|
21
20
|
|
22
|
-
it {is_expected.to respond_to :total_excluding_taxes}
|
23
|
-
it {is_expected.to respond_to :total_including_taxes}
|
21
|
+
it { is_expected.to respond_to :total_excluding_taxes }
|
22
|
+
it { is_expected.to respond_to :total_including_taxes }
|
24
23
|
|
25
24
|
it { is_expected.to respond_to :advance }
|
26
25
|
|
@@ -39,7 +38,7 @@ describe ::Dorsale::BillingMachine::Invoice, type: :model do
|
|
39
38
|
|
40
39
|
context "when unique index is nil" do
|
41
40
|
it "should be assigned upon creation" do
|
42
|
-
|
41
|
+
described_class.destroy_all
|
43
42
|
invoice1 = create(:billing_machine_invoice, date: "2014-02-01")
|
44
43
|
expect(invoice1.unique_index).to eq(1)
|
45
44
|
end
|
@@ -55,33 +54,49 @@ describe ::Dorsale::BillingMachine::Invoice, type: :model do
|
|
55
54
|
|
56
55
|
describe "payment_status" do
|
57
56
|
it "should be pending if nothing special" do
|
58
|
-
invoice = create(:billing_machine_invoice,
|
57
|
+
invoice = create(:billing_machine_invoice,
|
58
|
+
:due_date => Date.current,
|
59
|
+
:date => Date.current,
|
60
|
+
:paid => false,
|
61
|
+
)
|
59
62
|
expect(invoice.payment_status).to eq(:pending)
|
60
63
|
end
|
61
64
|
|
62
65
|
it "should be late if a bit late" do
|
63
|
-
|
64
|
-
|
66
|
+
invoice = create(:billing_machine_invoice,
|
67
|
+
:due_date => Date.current-1,
|
68
|
+
:date => Date.current-1,
|
69
|
+
:paid => false,
|
70
|
+
)
|
71
|
+
expect(invoice.payment_status).to eq(:late)
|
65
72
|
end
|
66
73
|
|
67
74
|
it "should be on_alert if a too late" do
|
68
|
-
|
69
|
-
|
75
|
+
invoice = create(:billing_machine_invoice,
|
76
|
+
:due_date => Date.current-16,
|
77
|
+
:date => Date.current-16,
|
78
|
+
:paid => false,
|
79
|
+
)
|
80
|
+
expect(invoice.payment_status).to eq(:on_alert)
|
70
81
|
end
|
71
82
|
|
72
83
|
it "should be paid if paid" do
|
73
|
-
|
74
|
-
|
84
|
+
invoice = create(:billing_machine_invoice,
|
85
|
+
:due_date => Date.current-16,
|
86
|
+
:date => Date.current-16,
|
87
|
+
:paid => true,
|
88
|
+
)
|
89
|
+
expect(invoice.payment_status).to eq(:paid)
|
75
90
|
end
|
76
91
|
|
77
92
|
it "should be on_alert if no due date is defined" do
|
78
|
-
|
79
|
-
|
93
|
+
invoice = create(:billing_machine_invoice, due_date: nil, date: Date.current, paid: false)
|
94
|
+
expect(invoice.payment_status).to eq(:on_alert)
|
80
95
|
end
|
81
96
|
|
82
97
|
it "should be on_alert if no due date is defined" do
|
83
|
-
|
84
|
-
|
98
|
+
invoice = create(:billing_machine_invoice, due_date: nil, date: Date.current, paid: true)
|
99
|
+
expect(invoice.payment_status).to eq(:paid)
|
85
100
|
end
|
86
101
|
|
87
102
|
it "should work fine upon creation" do
|
@@ -101,7 +116,7 @@ describe ::Dorsale::BillingMachine::Invoice, type: :model do
|
|
101
116
|
|
102
117
|
describe "vat rate" do
|
103
118
|
it "default vat rate should be 20" do
|
104
|
-
expect(
|
119
|
+
expect(described_class.new.vat_rate).to eq ::Dorsale::BillingMachine::DEFAULT_VAT_RATE
|
105
120
|
end
|
106
121
|
|
107
122
|
it "it should be specified vat rate" do
|
@@ -119,15 +134,15 @@ describe ::Dorsale::BillingMachine::Invoice, type: :model do
|
|
119
134
|
invoice = create(:billing_machine_invoice)
|
120
135
|
line1 = create(:billing_machine_invoice_line, invoice: invoice, vat_rate: 10)
|
121
136
|
|
122
|
-
expect{
|
123
|
-
line2
|
137
|
+
expect {
|
138
|
+
line2 = create(:billing_machine_invoice_line, invoice: invoice, vat_rate: 15)
|
124
139
|
}.to raise_error(RuntimeError)
|
125
140
|
end
|
126
141
|
|
127
142
|
it "it should raise when vat mode is multiple" do
|
128
143
|
::Dorsale::BillingMachine.vat_mode = :multiple
|
129
144
|
invoice = build(:billing_machine_invoice)
|
130
|
-
expect{ invoice.vat_rate }.to raise_error(RuntimeError)
|
145
|
+
expect { invoice.vat_rate }.to raise_error(RuntimeError)
|
131
146
|
end
|
132
147
|
end
|
133
148
|
|
@@ -143,7 +158,7 @@ describe ::Dorsale::BillingMachine::Invoice, type: :model do
|
|
143
158
|
:unit_price => 5,
|
144
159
|
:vat_rate => 20,
|
145
160
|
:invoice => invoice,
|
146
|
-
) #total 50
|
161
|
+
) # total 50
|
147
162
|
|
148
163
|
create(:billing_machine_invoice_line,
|
149
164
|
:quantity => 10,
|
@@ -168,7 +183,7 @@ describe ::Dorsale::BillingMachine::Invoice, type: :model do
|
|
168
183
|
:unit_price => 5,
|
169
184
|
:vat_rate => 20,
|
170
185
|
:invoice => invoice,
|
171
|
-
) #total 50
|
186
|
+
) # total 50
|
172
187
|
|
173
188
|
create(:billing_machine_invoice_line,
|
174
189
|
:quantity => 10,
|
@@ -194,5 +209,4 @@ describe ::Dorsale::BillingMachine::Invoice, type: :model do
|
|
194
209
|
expect(invoice.balance).to eq(0)
|
195
210
|
end
|
196
211
|
end
|
197
|
-
|
198
212
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "rails_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Dorsale::BillingMachine::QuotationLine do
|
4
4
|
it { is_expected.to belong_to :quotation }
|
5
5
|
it { is_expected.to validate_presence_of :quotation }
|
6
6
|
|
@@ -17,25 +17,25 @@ describe ::Dorsale::BillingMachine::QuotationLine do
|
|
17
17
|
|
18
18
|
describe "default values" do
|
19
19
|
it "quantity should be 0" do
|
20
|
-
expect(
|
20
|
+
expect(described_class.new.quantity).to eq 0
|
21
21
|
end
|
22
22
|
|
23
23
|
it "unit_price should be 0" do
|
24
|
-
expect(
|
24
|
+
expect(described_class.new.unit_price).to eq 0
|
25
25
|
end
|
26
26
|
|
27
27
|
it "vat_rate should be 0" do
|
28
|
-
expect(
|
28
|
+
expect(described_class.new.vat_rate).to eq ::Dorsale::BillingMachine::DEFAULT_VAT_RATE
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should be sorted by created_at" do
|
33
|
-
line1 = create(:billing_machine_quotation_line
|
34
|
-
line2 = create(:billing_machine_quotation_line
|
35
|
-
line3 = create(:billing_machine_quotation_line
|
36
|
-
line4 = create(:billing_machine_quotation_line
|
33
|
+
line1 = create(:billing_machine_quotation_line, :created_at => Time.zone.now + 1.minute)
|
34
|
+
line2 = create(:billing_machine_quotation_line, :created_at => Time.zone.now + 2.minutes)
|
35
|
+
line3 = create(:billing_machine_quotation_line, :created_at => Time.zone.now + 3.minutes)
|
36
|
+
line4 = create(:billing_machine_quotation_line, :created_at => Time.zone.now + 4.minutes)
|
37
37
|
line3.update!(:created_at => Time.zone.now + 5.minutes)
|
38
|
-
lines =
|
38
|
+
lines = described_class.all
|
39
39
|
expect(lines).to eq [line1, line2, line4, line3]
|
40
40
|
end
|
41
41
|
|
@@ -48,5 +48,4 @@ describe ::Dorsale::BillingMachine::QuotationLine do
|
|
48
48
|
quotation = create(:billing_machine_quotation_line, quantity: nil, unit_price: nil, total: 0)
|
49
49
|
expect(quotation.total).to eq(0)
|
50
50
|
end
|
51
|
-
|
52
51
|
end
|
@@ -1,14 +1,13 @@
|
|
1
1
|
require "rails_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Dorsale::BillingMachine::Quotation do
|
4
4
|
it { is_expected.to belong_to :customer }
|
5
5
|
it { is_expected.to belong_to :payment_term }
|
6
6
|
it { is_expected.to have_many(:lines).dependent(:destroy) }
|
7
7
|
|
8
|
-
it { is_expected.to validate_presence_of :id_card }
|
9
8
|
it { is_expected.to validate_presence_of :date }
|
10
9
|
it { is_expected.to validate_presence_of :state }
|
11
|
-
it { is_expected.to ensure_inclusion_of(:state).in_array(::
|
10
|
+
it { is_expected.to ensure_inclusion_of(:state).in_array(described_class::STATES) }
|
12
11
|
it { is_expected.to respond_to :date }
|
13
12
|
it { is_expected.to respond_to :label }
|
14
13
|
it { is_expected.to respond_to :vat_amount }
|
@@ -24,16 +23,16 @@ describe ::Dorsale::BillingMachine::Quotation do
|
|
24
23
|
|
25
24
|
describe "default values" do
|
26
25
|
it "default date should be today" do
|
27
|
-
expect(
|
26
|
+
expect(described_class.new.date).to eq Date.current
|
28
27
|
end
|
29
28
|
|
30
29
|
it "default expires_at should be date + 1 month" do
|
31
|
-
quotation =
|
30
|
+
quotation = described_class.new(date: "21/12/2012")
|
32
31
|
expect(quotation.expires_at).to eq Date.parse("21/01/2013")
|
33
32
|
end
|
34
33
|
|
35
34
|
it "default state should be pending" do
|
36
|
-
expect(
|
35
|
+
expect(described_class.new.state).to eq "pending"
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
@@ -44,34 +43,34 @@ describe ::Dorsale::BillingMachine::Quotation do
|
|
44
43
|
quotation.save
|
45
44
|
end
|
46
45
|
|
47
|
-
describe
|
48
|
-
context
|
49
|
-
it
|
50
|
-
quotation1 = create(:billing_machine_quotation, date:
|
51
|
-
quotation2 = create(:billing_machine_quotation, date:
|
46
|
+
describe "unique_index" do
|
47
|
+
context "when unique index is 69" do
|
48
|
+
it "should be assigned upon creation" do
|
49
|
+
quotation1 = create(:billing_machine_quotation, date: "2014-02-01", unique_index: 69)
|
50
|
+
quotation2 = create(:billing_machine_quotation, date: "2014-02-01")
|
52
51
|
expect(quotation2.unique_index).to eq(70)
|
53
52
|
end
|
54
53
|
end
|
55
54
|
|
56
|
-
context
|
57
|
-
it
|
58
|
-
|
59
|
-
quotation1 = create(:billing_machine_quotation, date:
|
55
|
+
context "when unique index is nil" do
|
56
|
+
it "should be assigned upon creation" do
|
57
|
+
described_class.destroy_all
|
58
|
+
quotation1 = create(:billing_machine_quotation, date: "2014-02-01")
|
60
59
|
expect(quotation1.unique_index).to eq(1)
|
61
60
|
end
|
62
61
|
end
|
63
62
|
end
|
64
63
|
|
65
|
-
describe
|
66
|
-
it
|
67
|
-
quotation = create(:billing_machine_quotation, date:
|
68
|
-
expect(quotation.tracking_id).to eq(
|
64
|
+
describe "tracking_id" do
|
65
|
+
it "should return correct tracking_id" do
|
66
|
+
quotation = create(:billing_machine_quotation, date: "2014-02-01")
|
67
|
+
expect(quotation.tracking_id).to eq("2014-01")
|
69
68
|
end
|
70
69
|
end
|
71
70
|
|
72
71
|
describe "vat rate" do
|
73
72
|
it "default vat rate should be 20" do
|
74
|
-
expect(
|
73
|
+
expect(described_class.new.vat_rate).to eq ::Dorsale::BillingMachine::DEFAULT_VAT_RATE
|
75
74
|
end
|
76
75
|
|
77
76
|
it "it should be specified vat rate" do
|
@@ -80,24 +79,24 @@ describe ::Dorsale::BillingMachine::Quotation do
|
|
80
79
|
|
81
80
|
it "it should be first line vat rate" do
|
82
81
|
quotation = create(:billing_machine_quotation)
|
83
|
-
line1
|
84
|
-
line2
|
82
|
+
line1 = create(:billing_machine_quotation_line, quotation: quotation, vat_rate: 10)
|
83
|
+
line2 = create(:billing_machine_quotation_line, quotation: quotation, vat_rate: 10)
|
85
84
|
expect(quotation.vat_rate).to eq 10
|
86
85
|
end
|
87
86
|
|
88
87
|
it "it should raise if multiple vat_rates" do
|
89
88
|
quotation = create(:billing_machine_quotation)
|
90
|
-
line1
|
89
|
+
line1 = create(:billing_machine_quotation_line, quotation: quotation, vat_rate: 10)
|
91
90
|
|
92
|
-
expect{
|
93
|
-
line2
|
91
|
+
expect {
|
92
|
+
line2 = create(:billing_machine_quotation_line, quotation: quotation, vat_rate: 15)
|
94
93
|
}.to raise_error(RuntimeError)
|
95
94
|
end
|
96
95
|
|
97
96
|
it "it should raise when vat mode is multiple" do
|
98
97
|
::Dorsale::BillingMachine.vat_mode = :multiple
|
99
98
|
quotation = build(:billing_machine_quotation)
|
100
|
-
expect{ quotation.vat_rate }.to raise_error(RuntimeError)
|
99
|
+
expect { quotation.vat_rate }.to raise_error(RuntimeError)
|
101
100
|
end
|
102
101
|
end
|
103
102
|
|
@@ -116,7 +115,7 @@ describe ::Dorsale::BillingMachine::Quotation do
|
|
116
115
|
:vat_rate => 20,
|
117
116
|
:quantity => 10,
|
118
117
|
:unit_price => 5,
|
119
|
-
:quotation => quotation
|
118
|
+
:quotation => quotation,
|
120
119
|
)
|
121
120
|
|
122
121
|
expect(quotation.total_excluding_taxes).to eq(90.0)
|
@@ -165,5 +164,4 @@ describe ::Dorsale::BillingMachine::Quotation do
|
|
165
164
|
expect(quotation.balance).to eq(0.0)
|
166
165
|
end
|
167
166
|
end
|
168
|
-
|
169
167
|
end
|