dorsale 3.9.3 → 3.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/app/controllers/dorsale/billing_machine/application_controller.rb +14 -0
  4. data/app/controllers/dorsale/billing_machine/invoices_controller.rb +16 -12
  5. data/app/controllers/dorsale/billing_machine/quotations_controller.rb +32 -2
  6. data/app/{commands/dorsale/flyboy/task_commands.rb → crons/dorsale/flyboy/task_crons.rb} +1 -1
  7. data/app/mailers/dorsale/generic_mailer.rb +9 -0
  8. data/app/models/dorsale/billing_machine/email.rb +33 -0
  9. data/app/models/dorsale/billing_machine/invoice.rb +7 -2
  10. data/app/models/dorsale/billing_machine/quotation.rb +7 -2
  11. data/app/models/dorsale/email.rb +80 -0
  12. data/app/policies/dorsale/billing_machine/invoice_policy_helper.rb +1 -5
  13. data/app/policies/dorsale/billing_machine/quotation_policy_helper.rb +3 -0
  14. data/app/services/dorsale/billing_machine/pdf_file_generator.rb +6 -2
  15. data/app/views/dorsale/_actions.html.slim +1 -1
  16. data/app/views/dorsale/billing_machine/commons/_details.html.slim +121 -0
  17. data/app/views/dorsale/billing_machine/commons/_email.html.slim +16 -0
  18. data/app/views/dorsale/billing_machine/commons/_form.html.slim +115 -0
  19. data/app/views/dorsale/billing_machine/commons/_header_infos.html.slim +9 -0
  20. data/app/views/dorsale/billing_machine/{invoices → commons}/_line_details.html.slim +0 -0
  21. data/app/views/dorsale/billing_machine/commons/_line_fields.html.slim +27 -0
  22. data/app/views/dorsale/billing_machine/commons/_preview_button.html.slim +25 -0
  23. data/app/views/dorsale/billing_machine/invoices/_details.html.slim +1 -126
  24. data/app/views/dorsale/billing_machine/invoices/_form.html.slim +1 -115
  25. data/app/views/dorsale/billing_machine/invoices/_header_infos.html.slim +1 -9
  26. data/app/views/dorsale/billing_machine/invoices/_line_fields.html.slim +1 -27
  27. data/app/views/dorsale/billing_machine/invoices/_show_title.html.slim +2 -7
  28. data/app/views/dorsale/billing_machine/invoices/email.html.slim +1 -51
  29. data/app/views/dorsale/billing_machine/quotations/_details.html.slim +6 -1
  30. data/app/views/dorsale/billing_machine/quotations/_form.html.slim +1 -1
  31. data/app/views/dorsale/billing_machine/quotations/_header_infos.html.slim +1 -1
  32. data/app/views/dorsale/billing_machine/quotations/_line_fields.html.slim +1 -1
  33. data/app/views/dorsale/billing_machine/quotations/_show_actions.html.slim +4 -1
  34. data/app/views/dorsale/billing_machine/quotations/_show_title.html.slim +7 -1
  35. data/app/views/dorsale/billing_machine/quotations/email.html.slim +1 -0
  36. data/app/views/dorsale/forms/_send_email_buttons.html.slim +10 -0
  37. data/config/locales/billing_machine.en.yml +10 -5
  38. data/config/locales/billing_machine.fr.yml +10 -4
  39. data/config/locales/dorsale.en.yml +11 -0
  40. data/config/locales/dorsale.fr.yml +11 -0
  41. data/config/routes.rb +11 -4
  42. data/config/schedule.rb +1 -1
  43. data/features/billing_machine_invoices.feature +7 -0
  44. data/features/billing_machine_quotations.feature +14 -0
  45. data/features/step_definitions/billing_machine_invoices_steps.rb +17 -0
  46. data/features/step_definitions/billing_machine_quotations_steps.rb +40 -0
  47. data/features/step_definitions/flyboy_tasks_steps.rb +1 -1
  48. data/lib/dorsale/version.rb +1 -1
  49. data/spec/controllers/dorsale/billing_machine/invoices_controller_spec.rb +16 -0
  50. data/spec/controllers/dorsale/billing_machine/quotations_controller_spec.rb +19 -0
  51. data/spec/models/dorsale/billing_machine/invoice_spec.rb +4 -0
  52. data/spec/models/dorsale/billing_machine/quotation_spec.rb +5 -1
  53. data/spec/models/dorsale/expense_gun/expense_line_spec.rb +1 -1
  54. data/spec/rails_helper.rb +1 -4
  55. data/spec/routing/dorsale/billing_machine/invoices_routing_spec.rb +5 -0
  56. data/spec/routing/dorsale/billing_machine/quotations_routing_spec.rb +15 -0
  57. metadata +15 -6
  58. data/app/mailers/dorsale/billing_machine/invoice_mailer.rb +0 -13
  59. data/app/views/dorsale/billing_machine/quotations/_line_details.html.slim +0 -1
@@ -0,0 +1,16 @@
1
+ .billing_machine
2
+ .panel.panel-default
3
+ .panel-heading: .panel-title = t("actions.email")
4
+
5
+ .panel-body
6
+ = horizontal_form_for @email, as: :email, url: url_for do |f|
7
+ = f.input :from, disabled: true
8
+ = f.input :to
9
+ = f.input :subject
10
+ = f.input :attachment_names, disabled: true
11
+ = f.input :body, as: :text
12
+ = render "dorsale/forms/send_email_buttons", back_url: engine_polymorphic_path(document)
13
+
14
+ hr
15
+
16
+ = render "dorsale/billing_machine/#{document.document_type.to_s.pluralize}/details", document: document
@@ -0,0 +1,115 @@
1
+ - vat_mode = ::Dorsale::BillingMachine.vat_mode
2
+
3
+ #billing_machine-form
4
+ = horizontal_form_for document, as: document.document_type do |f|
5
+ h1
6
+ = document.class.t.capitalize
7
+ - if document.tracking_id.present?
8
+ = " n° "
9
+ = document.tracking_id
10
+
11
+ .row
12
+ .col-md-6
13
+ .well.well-sm
14
+ = f.input :label
15
+ = f.input :date, html5: true
16
+
17
+ .col-md-6
18
+ .well.well-sm
19
+ = f.input :customer_guid, collection: @people.map{ |e| [e.to_s, e.guid] }, input_html: {class: "select2"}
20
+
21
+ table#lines-table
22
+ thead
23
+ tr
24
+ th.actions
25
+ th.line-label = Dorsale::BillingMachine::InvoiceLine.t(:label)
26
+ th.line-quantity = Dorsale::BillingMachine::InvoiceLine.t(:quantity)
27
+ th.line-unit = Dorsale::BillingMachine::InvoiceLine.t(:unit)
28
+ - if vat_mode == :multiple
29
+ th.line-vat_rate = Dorsale::BillingMachine::InvoiceLine.t(:vat_rate)
30
+ th.line-unit_price = Dorsale::BillingMachine::InvoiceLine.t(:unit_price)
31
+ th.line-total = Dorsale::BillingMachine::InvoiceLine.t(:total)
32
+
33
+ tbody
34
+ = f.simple_fields_for :lines do |lf|
35
+ = render "dorsale/billing_machine/invoices/line_fields", f: lf
36
+
37
+ .row
38
+ .col-sm-6
39
+ = link_to_add_association t("actions.add_line"), f, :lines, class: "btn btn-success btn-sm", id: "add-new-line", "data-association-insertion-node" => "#lines-table tbody", "data-association-insertion-method" => "append"
40
+
41
+ = f.association :payment_term, collection: @payment_terms
42
+
43
+ - if document.document_type == :invoice
44
+ = f.input :due_date, html5: true
45
+ = f.input :paid, as: :select, include_blank: false
46
+
47
+ - if document.document_type == :quotation
48
+ = f.input :state, collection: billing_machine_quotation_states_for_select
49
+ = f.input :expires_at, html5: true
50
+
51
+ = f.input :comments
52
+
53
+ .col-sm-6
54
+ table#totals-table
55
+ tbody
56
+ tr
57
+ th.commercial_discount-label
58
+ = document.class.t(:commercial_discount)
59
+
60
+ td.commercial_discount
61
+ = f.text_field :commercial_discount, class: "number"
62
+ span.unit = Dorsale::BillingMachine.default_currency
63
+
64
+ tr
65
+ th.total_excluding_taxes-label
66
+ = document.class.t(:total_excluding_taxes)
67
+
68
+ td.total_excluding_taxes
69
+ = f.text_field :total_excluding_taxes, class: "number", disabled: true
70
+ span.unit = Dorsale::BillingMachine.default_currency
71
+
72
+ - if vat_mode == :single
73
+ tr
74
+ th.vat_rate-label
75
+ = document.class.t(:vat_rate)
76
+
77
+ td.vat_rate
78
+ = f.text_field :vat_rate, class: "number"
79
+ span.unit = "%"
80
+
81
+ tr
82
+ th.vat_amount-label
83
+ = document.class.t(:vat_amount)
84
+
85
+ td.vat_amount
86
+ = f.text_field :vat_amount, class: "number", disabled: true
87
+ span.unit = Dorsale::BillingMachine.default_currency
88
+
89
+ tr
90
+ th.total_including_taxes-label
91
+ = document.class.t(:total_including_taxes)
92
+
93
+ td.total_including_taxes
94
+ = f.text_field :total_including_taxes, class: "number", disabled: true
95
+ span.unit = Dorsale::BillingMachine.default_currency
96
+
97
+ - if document.respond_to?(:advance)
98
+ tr
99
+ th.advance-label
100
+ = document.class.t(:advance)
101
+
102
+ td.advance
103
+ = f.text_field :advance, class: "number"
104
+ span.unit = Dorsale::BillingMachine.default_currency
105
+
106
+ tr
107
+ th.balance-label
108
+ = document.class.t(:balance)
109
+
110
+ td.balance
111
+ = f.text_field :balance, class: "number", disabled: true
112
+ span.unit = Dorsale::BillingMachine.default_currency
113
+
114
+ = form_buttons
115
+ = render "dorsale/billing_machine/commons/preview_button", document: document
@@ -0,0 +1,9 @@
1
+ .well.text-center
2
+ .row
3
+ .col-md-4 = info @statistics, :total_excluding_taxes, helper: :bm_currency
4
+ .col-md-4 = info @statistics, :vat_amount, helper: :bm_currency
5
+ .col-md-4 = info @statistics, :total_including_taxes, helper: :bm_currency
6
+
7
+ - if params[:controller].end_with?("invoices")
8
+ hr
9
+ = billing_machine_invoices_chart
@@ -0,0 +1,27 @@
1
+ tr.line
2
+ td.actions
3
+ a.delete href="#"
4
+ span.fa.fa-fw.fa-trash
5
+ = f.hidden_field :_destroy
6
+
7
+ td.line-label
8
+ = f.text_area :label, rows: 1
9
+
10
+ td.line-quantity
11
+ = f.text_field :quantity, class: "number"
12
+
13
+ td.line-unit
14
+ = f.text_field :unit
15
+
16
+ - if ::Dorsale::BillingMachine.vat_mode == :multiple
17
+ td.line-vat_rate
18
+ = f.text_field :vat_rate, class: "number"
19
+ span.unit = "%"
20
+
21
+ td.line-unit_price
22
+ = f.text_field :unit_price, class: "number"
23
+ span.unit = Dorsale::BillingMachine.default_currency
24
+
25
+ td.line-total
26
+ = f.text_field :total, class: "number", disabled: true
27
+ span.unit = Dorsale::BillingMachine.default_currency
@@ -0,0 +1,25 @@
1
+ - if policy(document.class).preview?
2
+ button(
3
+ id = "preview-button"
4
+ class = "btn btn-default"
5
+ type = "button"
6
+ data-url = url_for(action: :preview, format: :pdf)
7
+ )
8
+ = icon(:eye)
9
+ = " "
10
+ = ta(:preview)
11
+
12
+ coffee:
13
+ $button = $("#preview-button").detach()
14
+ $button.click ->
15
+ $form = $("form").clone()
16
+ $form.find("input[name='_method']").remove()
17
+ $form.find("input[id*='lines_attributes'][id$=id]").remove()
18
+ $form.attr(action: $button.data("url"), method: "post", target: "_blank")
19
+ $form.hide()
20
+ $(document.body).append($form)
21
+ $form.submit()
22
+ $form.remove()
23
+
24
+ $submit = $("form [type=submit]")
25
+ $button.insertBefore($submit)
@@ -1,126 +1 @@
1
- - vat_mode = ::Dorsale::BillingMachine.vat_mode
2
- - document_type = document.class.to_s.split("::").last.downcase.to_sym
3
-
4
- #billing_machine-show
5
- .row
6
- .col-md-6
7
- .well
8
- = info document, :label
9
- = info document, :date
10
-
11
- .col-md-6
12
- .well
13
- - if document.customer.present?
14
- = document.customer
15
- br
16
-
17
- - if document.customer.address.street.present?
18
- = document.customer.address.street
19
- br
20
-
21
- - if document.customer.address.street_bis.present?
22
- = document.customer.address.street_bis
23
- br
24
-
25
- - if document.customer.address.zip.present? || document.customer.address.city.present?
26
- = document.customer.address.zip
27
- = " "
28
- = document.customer.address.city
29
-
30
- - if document.customer.address.country.present?
31
- = document.customer.address.country
32
-
33
- table#lines-table
34
- thead
35
- tr
36
- th.line-label = Dorsale::BillingMachine::InvoiceLine.t(:label)
37
- th.line-quantity = Dorsale::BillingMachine::InvoiceLine.t(:quantity)
38
- th.line-unit = Dorsale::BillingMachine::InvoiceLine.t(:unit)
39
- - if vat_mode == :multiple
40
- th.line-vat_rate = Dorsale::BillingMachine::InvoiceLine.t(:vat_rate)
41
- th.line-unit_price = Dorsale::BillingMachine::InvoiceLine.t(:unit_price)
42
- th.line-total = Dorsale::BillingMachine::InvoiceLine.t(:total)
43
-
44
- tbody
45
- - document.lines.each do |line|
46
- = render "dorsale/billing_machine/invoices/line_details", line: line
47
-
48
- .row
49
- .col-sm-6
50
- .well
51
- = info document, :payment_term
52
- br
53
-
54
- - if document_type == :invoice
55
- = info document, :due_date
56
-
57
- - if document_type == :quotation
58
-
59
- = info document, :expires_at
60
- br
61
-
62
- - if document.comments.present?
63
- = info document, :comments, text2html(document.comments), separator: " :<br />".html_safe
64
- br
65
-
66
-
67
- .col-sm-6
68
- table#totals-table
69
- tbody
70
- - if document.commercial_discount.nonzero?
71
- tr
72
- th.commercial_discount-label
73
- = document.class.t(:commercial_discount)
74
-
75
- td.commercial_discount
76
- = " - #{bm_currency document.commercial_discount}"
77
-
78
-
79
- tr
80
- th.total_excluding_taxes-label
81
- = document.class.t(:total_excluding_taxes)
82
-
83
- td.total_excluding_taxes
84
- = bm_currency document.total_excluding_taxes
85
-
86
- - if vat_mode == :single
87
- tr
88
- th.vat_rate-label
89
- = document.class.t(:vat_rate)
90
-
91
- td.vat_rate
92
- = percentage document.vat_rate
93
-
94
- tr
95
- th.vat_amount-label
96
- = document.class.t(:vat_amount)
97
-
98
- td.vat_amount
99
- = bm_currency document.vat_amount
100
-
101
- tr
102
- th.total_including_taxes-label
103
- = document.class.t(:total_including_taxes)
104
-
105
- td.total_including_taxes
106
- = bm_currency document.total_including_taxes
107
-
108
- - if document.respond_to?(:advance)
109
- - document.advance.present?
110
- tr
111
- th.advance-label
112
- = document.class.t(:advance)
113
-
114
- td.advance
115
- = bm_currency document.advance
116
-
117
- tr
118
- th.balance-label
119
- = document.class.t(:balance)
120
-
121
- td.balance
122
- = bm_currency document.balance
123
-
124
- - if document_type == :quotation
125
- .attachments-panel
126
- = attachments_for(document)
1
+ = render "dorsale/billing_machine/commons/details", document: document
@@ -1,115 +1 @@
1
- - vat_mode = ::Dorsale::BillingMachine.vat_mode
2
- - document_type = document.class.to_s.split("::").last.downcase.to_sym
3
-
4
- #billing_machine-form
5
- = horizontal_form_for document, as: document_type do |f|
6
- h1
7
- = document.class.t.capitalize
8
- - if document.tracking_id.present?
9
- = " n° "
10
- = document.tracking_id
11
-
12
- .row
13
- .col-md-6
14
- .well.well-sm
15
- = f.input :label
16
- = f.input :date, html5: true
17
-
18
- .col-md-6
19
- .well.well-sm
20
- = f.input :customer_guid, collection: @people.map{ |e| [e.to_s, e.guid] }, input_html: {class: "select2"}
21
-
22
- table#lines-table
23
- thead
24
- tr
25
- th.actions
26
- th.line-label = Dorsale::BillingMachine::InvoiceLine.t(:label)
27
- th.line-quantity = Dorsale::BillingMachine::InvoiceLine.t(:quantity)
28
- th.line-unit = Dorsale::BillingMachine::InvoiceLine.t(:unit)
29
- - if vat_mode == :multiple
30
- th.line-vat_rate = Dorsale::BillingMachine::InvoiceLine.t(:vat_rate)
31
- th.line-unit_price = Dorsale::BillingMachine::InvoiceLine.t(:unit_price)
32
- th.line-total = Dorsale::BillingMachine::InvoiceLine.t(:total)
33
-
34
- tbody
35
- = f.simple_fields_for :lines do |lf|
36
- = render "dorsale/billing_machine/invoices/line_fields", f: lf
37
-
38
- .row
39
- .col-sm-6
40
- = link_to_add_association t("actions.add_line"), f, :lines, class: "btn btn-success btn-sm", id: "add-new-line", "data-association-insertion-node" => "#lines-table tbody", "data-association-insertion-method" => "append"
41
-
42
- = f.association :payment_term, collection: @payment_terms
43
-
44
- - if document_type == :invoice
45
- = f.input :due_date, html5: true
46
- = f.input :paid, as: :select, include_blank: false
47
-
48
- - if document_type == :quotation
49
- = f.input :state, collection: billing_machine_quotation_states_for_select
50
- = f.input :expires_at, html5: true
51
-
52
- = f.input :comments
53
-
54
- .col-sm-6
55
- table#totals-table
56
- tbody
57
- tr
58
- th.commercial_discount-label
59
- = document.class.t(:commercial_discount)
60
-
61
- td.commercial_discount
62
- = f.text_field :commercial_discount, class: "number"
63
- span.unit = Dorsale::BillingMachine.default_currency
64
-
65
- tr
66
- th.total_excluding_taxes-label
67
- = document.class.t(:total_excluding_taxes)
68
-
69
- td.total_excluding_taxes
70
- = f.text_field :total_excluding_taxes, class: "number", disabled: true
71
- span.unit = Dorsale::BillingMachine.default_currency
72
-
73
- - if vat_mode == :single
74
- tr
75
- th.vat_rate-label
76
- = document.class.t(:vat_rate)
77
-
78
- td.vat_rate
79
- = f.text_field :vat_rate, class: "number"
80
- span.unit = "%"
81
-
82
- tr
83
- th.vat_amount-label
84
- = document.class.t(:vat_amount)
85
-
86
- td.vat_amount
87
- = f.text_field :vat_amount, class: "number", disabled: true
88
- span.unit = Dorsale::BillingMachine.default_currency
89
-
90
- tr
91
- th.total_including_taxes-label
92
- = document.class.t(:total_including_taxes)
93
-
94
- td.total_including_taxes
95
- = f.text_field :total_including_taxes, class: "number", disabled: true
96
- span.unit = Dorsale::BillingMachine.default_currency
97
-
98
- - if document.respond_to?(:advance)
99
- tr
100
- th.advance-label
101
- = document.class.t(:advance)
102
-
103
- td.advance
104
- = f.text_field :advance, class: "number"
105
- span.unit = Dorsale::BillingMachine.default_currency
106
-
107
- tr
108
- th.balance-label
109
- = document.class.t(:balance)
110
-
111
- td.balance
112
- = f.text_field :balance, class: "number", disabled: true
113
- span.unit = Dorsale::BillingMachine.default_currency
114
-
115
- = form_buttons
1
+ = render "dorsale/billing_machine/commons/form", document: @invoice
@@ -1,9 +1 @@
1
- .well.text-center
2
- .row
3
- .col-md-4 = info @statistics, :total_excluding_taxes, helper: :bm_currency
4
- .col-md-4 = info @statistics, :vat_amount, helper: :bm_currency
5
- .col-md-4 = info @statistics, :total_including_taxes, helper: :bm_currency
6
-
7
- - if params[:controller].end_with?("invoices")
8
- hr
9
- = billing_machine_invoices_chart
1
+ = render "dorsale/billing_machine/commons/header_infos"