dorsale 3.8.1 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/README.md +5 -1
  4. data/app/commands/dorsale/flyboy/task_commands.rb +1 -1
  5. data/app/controllers/concerns/dorsale/flyboy/tasks_summary_concern.rb +0 -1
  6. data/app/controllers/dorsale/alexandrie/attachments_controller.rb +1 -2
  7. data/app/controllers/dorsale/application_controller.rb +0 -1
  8. data/app/controllers/dorsale/billing_machine/application_controller.rb +0 -2
  9. data/app/controllers/dorsale/billing_machine/invoices_controller.rb +9 -22
  10. data/app/controllers/dorsale/billing_machine/payment_terms_controller.rb +0 -1
  11. data/app/controllers/dorsale/billing_machine/quotations_controller.rb +1 -4
  12. data/app/controllers/dorsale/comments_controller.rb +3 -2
  13. data/app/controllers/dorsale/customer_vault/activity_types_controller.rb +0 -1
  14. data/app/controllers/dorsale/customer_vault/application_controller.rb +0 -1
  15. data/app/controllers/dorsale/customer_vault/links_controller.rb +22 -12
  16. data/app/controllers/dorsale/customer_vault/origins_controller.rb +0 -1
  17. data/app/controllers/dorsale/customer_vault/people_controller.rb +2 -3
  18. data/app/controllers/dorsale/expense_gun/categories_controller.rb +0 -1
  19. data/app/controllers/dorsale/expense_gun/expenses_controller.rb +0 -1
  20. data/app/controllers/dorsale/flyboy/task_comments_controller.rb +0 -1
  21. data/app/controllers/dorsale/flyboy/tasks_controller.rb +28 -21
  22. data/app/controllers/dorsale/users_controller.rb +0 -1
  23. data/app/filters/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb +9 -5
  24. data/app/filters/dorsale/billing_machine/small_data/filter_strategy_by_state.rb +2 -2
  25. data/app/filters/dorsale/flyboy/small_data/filter_for_tasks.rb +1 -1
  26. data/app/helpers/dorsale/billing_machine/application_helper.rb +6 -6
  27. data/app/helpers/dorsale/context_helper.rb +1 -1
  28. data/app/helpers/dorsale/flyboy/application_helper.rb +4 -5
  29. data/app/mailers/dorsale/billing_machine/invoice_mailer.rb +0 -1
  30. data/app/mailers/dorsale/flyboy/task_mailer.rb +0 -1
  31. data/app/mailers/dorsale/user_mailer.rb +0 -1
  32. data/app/models/dorsale/address.rb +2 -2
  33. data/app/models/dorsale/alexandrie/attachment_type.rb +0 -1
  34. data/app/models/dorsale/billing_machine.rb +1 -2
  35. data/app/models/dorsale/billing_machine/invoice.rb +19 -30
  36. data/app/models/dorsale/billing_machine/invoice_line.rb +2 -2
  37. data/app/models/dorsale/billing_machine/quotation.rb +11 -17
  38. data/app/models/dorsale/billing_machine/quotation_line.rb +2 -3
  39. data/app/models/dorsale/comment.rb +1 -1
  40. data/app/models/dorsale/customer_vault/corporation.rb +11 -10
  41. data/app/models/dorsale/customer_vault/event.rb +2 -2
  42. data/app/models/dorsale/customer_vault/individual.rb +4 -2
  43. data/app/models/dorsale/customer_vault/person.rb +14 -4
  44. data/app/models/dorsale/customer_vault/person_data.rb +1 -2
  45. data/app/models/dorsale/expense_gun/expense.rb +2 -5
  46. data/app/models/dorsale/expense_gun/expense_line.rb +2 -2
  47. data/app/models/dorsale/flyboy/task.rb +17 -18
  48. data/app/models/dorsale/flyboy/task_comment.rb +1 -1
  49. data/app/models/dorsale/users/active.rb +1 -1
  50. data/app/models/dorsale/users/avatar.rb +2 -1
  51. data/app/models/dorsale/users/password_generation.rb +0 -1
  52. data/app/pdfs/concerns/dorsale/alexandrie/prawn/render_with_attachments.rb +1 -1
  53. data/app/pdfs/dorsale/application_pdf.rb +7 -0
  54. data/app/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf.rb +52 -47
  55. data/app/pdfs/dorsale/billing_machine/invoice_single_vat_pdf.rb +94 -205
  56. data/app/pdfs/dorsale/prawn_helpers.rb +107 -0
  57. data/app/policies/dorsale/application_policy.rb +2 -4
  58. data/app/policies/dorsale/expense_gun/expense_policy_helper.rb +0 -1
  59. data/app/policies/dorsale/flyboy/task_policy_helper.rb +3 -3
  60. data/app/policies/dorsale/policy_checker.rb +11 -18
  61. data/app/services/dorsale/billing_machine/invoice/copy.rb +2 -2
  62. data/app/services/dorsale/billing_machine/pdf_file_generator.rb +7 -2
  63. data/app/services/dorsale/billing_machine/quotation/copy.rb +1 -1
  64. data/app/services/dorsale/billing_machine/quotation/to_invoice.rb +10 -7
  65. data/app/services/dorsale/flyboy/task/snoozer.rb +1 -1
  66. data/app/views/dorsale/billing_machine/invoices/_details.html.slim +1 -2
  67. data/app/views/dorsale/billing_machine/invoices/_form.html.slim +4 -11
  68. data/app/views/dorsale/billing_machine/invoices/index.xlsx.ruby +1 -1
  69. data/app/views/dorsale/flyboy/tasks/index.xlsx.ruby +1 -1
  70. data/config/locales/alexandrie.en.yml +0 -4
  71. data/config/locales/alexandrie.fr.yml +0 -4
  72. data/config/locales/billing_machine.en.yml +0 -41
  73. data/config/locales/billing_machine.fr.yml +0 -41
  74. data/config/routes.rb +0 -1
  75. data/db/migrate/20161119064536_delete_id_cards.rb +9 -0
  76. data/features/billing_machine_invoices.feature +0 -1
  77. data/features/billing_machine_multiple_vat.feature +0 -1
  78. data/features/billing_machine_quotations.feature +0 -1
  79. data/features/step_definitions/billing_machine_invoices_steps.rb +73 -79
  80. data/features/step_definitions/billing_machine_multiple_vat.rb +5 -6
  81. data/features/step_definitions/billing_machine_payment_terms_steps.rb +2 -2
  82. data/features/step_definitions/billing_machine_quotations_steps.rb +45 -80
  83. data/features/step_definitions/common_steps.rb +0 -4
  84. data/features/step_definitions/customer_vault_activity_types_steps.rb +1 -1
  85. data/features/step_definitions/customer_vault_corporations_steps.rb +27 -23
  86. data/features/step_definitions/customer_vault_individuals_steps.rb +8 -9
  87. data/features/step_definitions/customer_vault_invoices_steps.rb +1 -1
  88. data/features/step_definitions/customer_vault_links_steps.rb +6 -6
  89. data/features/step_definitions/customer_vault_origins_steps.rb +1 -1
  90. data/features/step_definitions/customer_vault_people_steps.rb +2 -1
  91. data/features/step_definitions/expense_gun_categories_steps.rb +2 -2
  92. data/features/step_definitions/expense_gun_expenses_steps.rb +6 -6
  93. data/features/step_definitions/flyboy_tasks_steps.rb +4 -7
  94. data/features/step_definitions/tasks_summary_steps.rb +3 -3
  95. data/features/support/env.rb +3 -2
  96. data/lib/dorsale/engine.rb +8 -8
  97. data/lib/dorsale/file_loader.rb +1 -1
  98. data/lib/dorsale/simple_form.rb +3 -3
  99. data/lib/dorsale/simple_form_bootstrap.rb +46 -46
  100. data/lib/dorsale/version.rb +1 -1
  101. data/spec/controllers/dorsale/alexandrie/attachments_controller_spec.rb +3 -3
  102. data/spec/controllers/dorsale/billing_machine/invoices_controller_spec.rb +0 -1
  103. data/spec/controllers/dorsale/comments_controller_spec.rb +1 -1
  104. data/spec/controllers/dorsale/customer_vault/events_controller_spec.rb +9 -9
  105. data/spec/controllers/dorsale/customer_vault/people_controller_spec.rb +15 -19
  106. data/spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb +1 -2
  107. data/spec/controllers/dorsale/flyboy/tasks_controller_spec.rb +43 -19
  108. data/spec/factories/alexandrie_attachment_types.rb +1 -1
  109. data/spec/factories/alexandrie_attachments.rb +1 -1
  110. data/spec/factories/billing_machine_invoice_lines.rb +1 -1
  111. data/spec/factories/billing_machine_invoices.rb +1 -2
  112. data/spec/factories/billing_machine_payment_terms.rb +1 -1
  113. data/spec/factories/billing_machine_quotation_lines.rb +1 -2
  114. data/spec/factories/billing_machine_quotations.rb +1 -2
  115. data/spec/factories/customer_vault_activity_types.rb +1 -1
  116. data/spec/factories/customer_vault_corporations.rb +1 -1
  117. data/spec/factories/customer_vault_event.rb +1 -1
  118. data/spec/factories/customer_vault_individuals.rb +2 -2
  119. data/spec/factories/customer_vault_links.rb +1 -1
  120. data/spec/factories/customer_vault_origins.rb +1 -1
  121. data/spec/factories/dorsale_addresses.rb +1 -1
  122. data/spec/factories/dorsale_comments.rb +1 -1
  123. data/spec/factories/expense_gun_categories.rb +2 -2
  124. data/spec/factories/expense_gun_expense_lines.rb +8 -8
  125. data/spec/factories/expense_gun_expenses.rb +2 -3
  126. data/spec/factories/flyboy_task_comments.rb +1 -1
  127. data/spec/factories/flyboy_tasks.rb +1 -1
  128. data/spec/mailers/user_mailer.rb +5 -6
  129. data/spec/models/dorsale/address_spec.rb +26 -26
  130. data/spec/models/dorsale/billing_machine/invoice_line_spec.rb +6 -6
  131. data/spec/models/dorsale/billing_machine/invoice_spec.rb +37 -23
  132. data/spec/models/dorsale/billing_machine/quotation_line_spec.rb +9 -10
  133. data/spec/models/dorsale/billing_machine/quotation_spec.rb +26 -28
  134. data/spec/models/dorsale/billing_machine_spec.rb +0 -1
  135. data/spec/models/dorsale/comment_spec.rb +0 -1
  136. data/spec/models/dorsale/customer_vault/corporation_spec.rb +20 -20
  137. data/spec/models/dorsale/customer_vault/event_spec.rb +1 -1
  138. data/spec/models/dorsale/customer_vault/individual_spec.rb +0 -2
  139. data/spec/models/dorsale/customer_vault/link_spec.rb +0 -1
  140. data/spec/models/dorsale/customer_vault/person_spec.rb +7 -6
  141. data/spec/models/dorsale/expense_gun/category_spec.rb +2 -2
  142. data/spec/models/dorsale/expense_gun/expense_line_spec.rb +14 -14
  143. data/spec/models/dorsale/expense_gun/expense_spec.rb +23 -13
  144. data/spec/models/dorsale/flyboy/task_comment_spec.rb +5 -6
  145. data/spec/models/dorsale/flyboy/task_spec.rb +66 -42
  146. data/spec/models/dorsale/users_spec.rb +3 -5
  147. data/spec/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf_spec.rb +6 -11
  148. data/spec/pdfs/dorsale/billing_machine/invoice_single_vat_pdf_spec.rb +7 -11
  149. data/spec/pdfs/dorsale/billing_machine/quotation_multiple_vat_pdf_spec.rb +6 -11
  150. data/spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb +7 -14
  151. data/spec/rails_helper.rb +1 -1
  152. data/spec/routing/dorsale/billing_machine/invoices_routing_spec.rb +0 -1
  153. data/spec/routing/dorsale/billing_machine/quotations_routing_spec.rb +0 -1
  154. data/spec/routing/dorsale/comments_routing_spec.rb +0 -2
  155. data/spec/routing/dorsale/customer_vault/people_routing_spec.rb +0 -1
  156. data/spec/routing/dorsale/expense_gun/expenses_routing_spec.rb +0 -1
  157. data/spec/routing/dorsale/flyboy/task_comments_routing_spec.rb +0 -1
  158. data/spec/routing/dorsale/users_routing_spec.rb +1 -1
  159. data/spec/services/dorsale/billing_machine/quotation/copy_spec.rb +2 -2
  160. data/spec/services/dorsale/expense_gun/expense/copy_spec.rb +13 -17
  161. data/spec/services/dorsale/flyboy/task/copy_spec.rb +1 -2
  162. data/spec/services/dorsale/flyboy/task/snoozer_spec.rb +3 -3
  163. data/spec/spec_helper.rb +1 -0
  164. metadata +5 -43
  165. data/app/controllers/dorsale/billing_machine/id_cards_controller.rb +0 -106
  166. data/app/models/dorsale/billing_machine/id_card.rb +0 -14
  167. data/app/policies/dorsale/billing_machine/id_card_policy_helper.rb +0 -7
  168. data/app/views/dorsale/billing_machine/id_cards/_form.html.slim +0 -42
  169. data/app/views/dorsale/billing_machine/id_cards/_index_actions.html.slim +0 -2
  170. data/app/views/dorsale/billing_machine/id_cards/_list.html.slim +0 -27
  171. data/app/views/dorsale/billing_machine/id_cards/edit.html.slim +0 -1
  172. data/app/views/dorsale/billing_machine/id_cards/index.html.slim +0 -11
  173. data/app/views/dorsale/billing_machine/id_cards/new.html.slim +0 -1
  174. data/features/billing_machine_id_cards.feature +0 -19
  175. data/features/step_definitions/billing_machine_id_cards_steps.rb +0 -53
  176. data/features/support/ajax.rb +0 -20
  177. data/features/support/database_cleaner.rb +0 -12
  178. data/features/support/factory_girl.rb +0 -1
  179. data/features/support/fix_referrer.rb +0 -9
  180. data/features/support/message_delivery.rb +0 -1
  181. data/features/support/poltergeist.rb +0 -22
  182. data/features/support/rails.rb +0 -1
  183. data/features/support/rspec.rb +0 -6
  184. data/features/support/screenshots.rb +0 -5
  185. data/features/support/sign_in.rb +0 -17
  186. data/features/support/simplecov.rb +0 -1
  187. data/features/support/turbolinks.rb +0 -30
  188. data/spec/factories/billing_machine_id_cards.rb +0 -26
  189. data/spec/models/dorsale/billing_machine/id_card_spec.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a17406e315fbb33c48f5604ce568769965b4d3b4
4
- data.tar.gz: e41ccc6d00e2e3d627dcc386047d5069fcc83210
3
+ metadata.gz: 9f957740f5e197d1396130300fa94904f32e3571
4
+ data.tar.gz: 1a1210313bd18d1bae5e90c5a057bd4db71fe876
5
5
  SHA512:
6
- metadata.gz: 793932d453f32824948498bec31c14274aea9297c906d28d95ab818a81f3141294285098fac81cdd652563ffd0eb8502c247721fb8c44fc47af26d4b74c5318c
7
- data.tar.gz: eef15ca0089f73911c95775d081feb8f4b6b7e176f0a5991f99334b0ae9da9c38ca1c48705a6ad8b95b919c3196c8722effa3ec6e13da0d973ecb8525585a261
6
+ metadata.gz: 3bfb5ef6465100808adb9fdb9b88d26475d53ad63a50f607ccd3b82d8ca04d6bd3e9e11f4a4ba1f8c29ce86e3d288934cda1510403b43f716d7773836365348f
7
+ data.tar.gz: 4a0afd7c630a26b280a4b555c0e48c8e70da325ad2f02b088e7507220e5c1f3c7c3e82160bd53301ca16048f4f2aaecadcf083024be39ce632d9b3e2a490b0f2
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Next version
4
4
 
5
+ ## 3.9.0
6
+
7
+ - Remove BM id cards
8
+ - Syntax improvements and refactors
9
+
5
10
  ## 3.8.1
6
11
 
7
12
  - Change CV contact type default value
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ [![Build Status](https://semaphoreci.com/api/v1/agilidee/dorsale/branches/master/badge.svg)](https://semaphoreci.com/agilidee/dorsale)
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/c3b2143566f714fcb104/maintainability)](https://codeclimate.com/github/agilidee/dorsale/maintainability)
3
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/c3b2143566f714fcb104/test_coverage)](https://codeclimate.com/github/agilidee/dorsale/test_coverage)
4
+
1
5
  # Dorsale
2
6
 
3
7
  This project uses the GNU AGPLv3 license.
@@ -20,4 +24,4 @@ Hosting application shall define a global current_user method providing the curr
20
24
 
21
25
  Returned user shall implement followings methods:
22
26
  tasks: returns all taks visible by the user
23
- colleagues(context): return all people affected in the provided context
27
+ colleagues(context): return all people affected in the provided context
@@ -2,7 +2,7 @@ module Dorsale::Flyboy::TaskCommands
2
2
  def self.send_daily_term_emails!
3
3
  ::Dorsale::Flyboy::Task.all.each do |task|
4
4
  next if task.done?
5
- next if task.term != Time.zone.now.to_date
5
+ next if task.term != Date.current
6
6
  next if task.owner.nil?
7
7
 
8
8
  ::Dorsale::Flyboy::TaskMailer.term_email(task).deliver_later
@@ -11,5 +11,4 @@ module Dorsale::Flyboy::TasksSummaryConcern
11
11
  @next_week_tasks = tasks.next_week
12
12
  @next_next_week_tasks = tasks.next_next_week
13
13
  end
14
-
15
14
  end
@@ -98,7 +98,7 @@ class Dorsale::Alexandrie::AttachmentsController < ::Dorsale::ApplicationControl
98
98
  def common_permitted_params
99
99
  [
100
100
  :name,
101
- :attachment_type_id
101
+ :attachment_type_id,
102
102
  ]
103
103
  end
104
104
 
@@ -138,5 +138,4 @@ class Dorsale::Alexandrie::AttachmentsController < ::Dorsale::ApplicationControl
138
138
  def notify_attachable
139
139
  @attachment.attachable.send(:try, :after_attachments_changes)
140
140
  end
141
-
142
141
  end
@@ -30,5 +30,4 @@ class Dorsale::ApplicationController < ::ApplicationController
30
30
  end
31
31
 
32
32
  helper_method :scope
33
-
34
33
  end
@@ -11,8 +11,6 @@ class Dorsale::BillingMachine::ApplicationController < ::Dorsale::ApplicationCon
11
11
 
12
12
  def set_common_variables
13
13
  @payment_terms ||= policy_scope(::Dorsale::BillingMachine::PaymentTerm)
14
- @id_cards ||= policy_scope(::Dorsale::BillingMachine::IdCard)
15
14
  @people ||= policy_scope(::Dorsale::CustomerVault::Person)
16
15
  end
17
-
18
16
  end
@@ -26,8 +26,7 @@ class Dorsale::BillingMachine::InvoicesController < ::Dorsale::BillingMachine::A
26
26
  # callback in BillingMachine::ApplicationController
27
27
  @invoice ||= scope.new
28
28
 
29
- @invoice.lines.build if @invoice.lines.empty?
30
- @invoice.id_card = @id_cards.first if @id_cards.one?
29
+ @invoice.lines.build if @invoice.lines.empty?
31
30
 
32
31
  authorize @invoice, :create?
33
32
  end
@@ -103,26 +102,16 @@ class Dorsale::BillingMachine::InvoicesController < ::Dorsale::BillingMachine::A
103
102
  def email
104
103
  authorize @invoice, :email?
105
104
 
106
- @subject =
107
- begin
108
- params[:email][:subject]
109
- rescue
110
- "#{model.t} #{@invoice.tracking_id} : #{@invoice.label}"
111
- end
105
+ default_subject = "#{model.t} #{@invoice.tracking_id} : #{@invoice.label}"
106
+ default_body = t("emails.invoices.send_invoice_to_customer",
107
+ :from => current_user.to_s,
108
+ :to => @invoice.customer.to_s,
109
+ )
112
110
 
113
- @body =
114
- begin
115
- params[:email][:body]
116
- rescue
117
- t("emails.invoices.send_invoice_to_customer",
118
- :from => current_user.to_s,
119
- :to => @invoice.customer.to_s,
120
- )
121
- end
111
+ @subject = params.dig(:email, :subject) || default_subject
112
+ @body = params.dig(:email, :body) || default_body
122
113
 
123
- if request.get?
124
- return
125
- end
114
+ return if request.get?
126
115
 
127
116
  email = ::Dorsale::BillingMachine::InvoiceMailer
128
117
  .send_invoice_to_customer(@invoice, @subject, @body, current_user)
@@ -156,7 +145,6 @@ class Dorsale::BillingMachine::InvoicesController < ::Dorsale::BillingMachine::A
156
145
 
157
146
  def permitted_params
158
147
  [
159
- :id_card_id,
160
148
  :customer_guid,
161
149
  :payment_term_id,
162
150
  :label,
@@ -190,5 +178,4 @@ class Dorsale::BillingMachine::InvoicesController < ::Dorsale::BillingMachine::A
190
178
  def invoice_params_for_update
191
179
  invoice_params
192
180
  end
193
-
194
181
  end
@@ -72,5 +72,4 @@ class Dorsale::BillingMachine::PaymentTermsController < ::Dorsale::BillingMachin
72
72
  def payment_term_params_for_update
73
73
  payment_term_params
74
74
  end
75
-
76
75
  end
@@ -26,8 +26,7 @@ class Dorsale::BillingMachine::QuotationsController < ::Dorsale::BillingMachine:
26
26
  # callback in BillingMachine::ApplicationController
27
27
  @quotation ||= scope.new
28
28
 
29
- @quotation.lines.build if @quotation.lines.empty?
30
- @quotation.id_card = @id_cards.first if @id_cards.one?
29
+ @quotation.lines.build if @quotation.lines.empty?
31
30
 
32
31
  authorize @quotation, :create?
33
32
  end
@@ -133,7 +132,6 @@ class Dorsale::BillingMachine::QuotationsController < ::Dorsale::BillingMachine:
133
132
  :state,
134
133
  :customer_guid,
135
134
  :payment_term_id,
136
- :id_card_id,
137
135
  :date,
138
136
  :expires_at,
139
137
  :comments,
@@ -162,5 +160,4 @@ class Dorsale::BillingMachine::QuotationsController < ::Dorsale::BillingMachine:
162
160
  def quotation_params_for_update
163
161
  quotation_params
164
162
  end
165
-
166
163
  end
@@ -74,8 +74,9 @@ class Dorsale::CommentsController < ::Dorsale::ApplicationController
74
74
  [
75
75
  params[:form_url],
76
76
  request.referer,
77
- (main_app.root_path rescue "/"),
78
- ].select(&:present?).first
77
+ main_app.try(:root_path),
78
+ "/",
79
+ ].find(&:present?)
79
80
  end
80
81
 
81
82
  def model
@@ -72,5 +72,4 @@ class Dorsale::CustomerVault::ActivityTypesController < ::Dorsale::CustomerVault
72
72
  def activity_type_params_for_update
73
73
  activity_type_params
74
74
  end
75
-
76
75
  end
@@ -15,5 +15,4 @@ class Dorsale::CustomerVault::ApplicationController < ::Dorsale::ApplicationCont
15
15
  def set_form_variables
16
16
  @tags ||= customer_vault_tag_list
17
17
  end
18
-
19
18
  end
@@ -66,21 +66,32 @@ class Dorsale::CustomerVault::LinksController < ::Dorsale::CustomerVault::Applic
66
66
  end
67
67
 
68
68
  def set_objects
69
+ set_people
70
+ set_person
71
+ set_link
72
+ end
73
+
74
+ def set_people
69
75
  @people ||= person_scope.all
76
+ end
77
+
78
+ def set_person
70
79
  @person ||= person_scope.find(params[:person_id])
80
+ end
81
+
82
+ def set_link
83
+ return unless params.key?(:id)
71
84
 
72
- if params.key?(:id)
73
- @link ||= scope.find(params[:id])
85
+ @link ||= scope.find(params[:id])
74
86
 
75
- if @person == @link.alice
76
- @link.person = @link.alice
77
- @link.other_person = @link.bob
78
- end
87
+ if @person == @link.alice
88
+ @link.person = @link.alice
89
+ @link.other_person = @link.bob
90
+ end
79
91
 
80
- if @person == @link.bob
81
- @link.person = @link.bob
82
- @link.other_person = @link.alice
83
- end
92
+ if @person == @link.bob
93
+ @link.person = @link.bob
94
+ @link.other_person = @link.alice
84
95
  end
85
96
  end
86
97
 
@@ -97,12 +108,11 @@ class Dorsale::CustomerVault::LinksController < ::Dorsale::CustomerVault::Applic
97
108
  def link_params_for_create
98
109
  link_params.merge(
99
110
  :alice => @person,
100
- :bob_id => params.dig(:link, :bob_id)
111
+ :bob_id => params.dig(:link, :bob_id),
101
112
  )
102
113
  end
103
114
 
104
115
  def link_params_for_update
105
116
  link_params
106
117
  end
107
-
108
118
  end
@@ -72,5 +72,4 @@ class Dorsale::CustomerVault::OriginsController < ::Dorsale::CustomerVault::Appl
72
72
  def origin_params_for_update
73
73
  origin_params
74
74
  end
75
-
76
75
  end
@@ -155,7 +155,7 @@ class Dorsale::CustomerVault::PeopleController < ::Dorsale::CustomerVault::Appli
155
155
  :street_bis,
156
156
  :zip,
157
157
  :city,
158
- :country
158
+ :country,
159
159
  ],
160
160
  ]
161
161
  end
@@ -205,8 +205,7 @@ class Dorsale::CustomerVault::PeopleController < ::Dorsale::CustomerVault::Appli
205
205
  :author => current_user,
206
206
  :person => @person,
207
207
  :action => action,
208
- :text => ::Dorsale::CustomerVault::Event.t("text.#{action}")
208
+ :text => ::Dorsale::CustomerVault::Event.t("text.#{action}"),
209
209
  )
210
210
  end
211
-
212
211
  end
@@ -74,5 +74,4 @@ class Dorsale::ExpenseGun::CategoriesController < ::Dorsale::ExpenseGun::Applica
74
74
  def category_params_for_update
75
75
  category_params
76
76
  end
77
-
78
77
  end
@@ -145,5 +145,4 @@ class Dorsale::ExpenseGun::ExpensesController < Dorsale::ExpenseGun::Application
145
145
  def set_filters_variables
146
146
  @users ||= scope.preload(:user).map(&:user).uniq.compact
147
147
  end
148
-
149
148
  end
@@ -40,5 +40,4 @@ class Dorsale::Flyboy::TaskCommentsController < ::Dorsale::Flyboy::ApplicationCo
40
40
  def task_comment_params_for_create
41
41
  task_comment_params.merge(author: current_user)
42
42
  end
43
-
44
43
  end
@@ -24,23 +24,7 @@ class Dorsale::Flyboy::TasksController < ::Dorsale::Flyboy::ApplicationControlle
24
24
 
25
25
  @tasks ||= scope.all.preload(:taskable)
26
26
 
27
- @order ||= sortable_column_order do |column, direction|
28
- case column
29
- when :name, :status
30
- %(LOWER(dorsale_flyboy_tasks.#{column}) #{direction})
31
- when :progress, :term
32
- %(dorsale_flyboy_tasks.#{column} #{direction})
33
- when :taskable
34
- if direction == :asc
35
- proc { |a, b| a.taskable.to_s.downcase <=> b.taskable.to_s.downcase }
36
- else
37
- proc { |a, b| b.taskable.to_s.downcase <=> a.taskable.to_s.downcase }
38
- end
39
- else
40
- params["sort"] = "term"
41
- "term ASC"
42
- end
43
- end
27
+ @order ||= order_from_params
44
28
 
45
29
  @filters ||= ::Dorsale::Flyboy::SmallData::FilterForTasks.new(filters_jar)
46
30
 
@@ -90,7 +74,6 @@ class Dorsale::Flyboy::TasksController < ::Dorsale::Flyboy::ApplicationControlle
90
74
 
91
75
  def edit
92
76
  authorize @task, :update?
93
-
94
77
  end
95
78
 
96
79
  def update
@@ -123,7 +106,7 @@ class Dorsale::Flyboy::TasksController < ::Dorsale::Flyboy::ApplicationControlle
123
106
  :progress => 100,
124
107
  :description => t("messages.tasks.complete_ok"),
125
108
  :date => Time.zone.now,
126
- :author => current_user
109
+ :author => current_user,
127
110
  )
128
111
 
129
112
  if @task_comment.save
@@ -139,8 +122,13 @@ class Dorsale::Flyboy::TasksController < ::Dorsale::Flyboy::ApplicationControlle
139
122
  authorize @task, :snooze?
140
123
 
141
124
  if @task.snoozer.snooze
142
- comment = Dorsale::Flyboy::TaskComment.new(task: @task, progress: @task.progress, description: t("messages.tasks.snooze_ok"), author: current_user)
143
- comment.save!
125
+ Dorsale::Flyboy::TaskComment.create!(
126
+ :task => @task,
127
+ :progress => @task.progress,
128
+ :description => t("messages.tasks.snooze_ok"),
129
+ :author => current_user,
130
+ )
131
+
144
132
  flash[:success] = t("messages.tasks.snooze_ok")
145
133
  else
146
134
  flash[:danger] = t("messages.tasks.snooze_error")
@@ -212,4 +200,23 @@ class Dorsale::Flyboy::TasksController < ::Dorsale::Flyboy::ApplicationControlle
212
200
  params.fetch(:task, {}).permit(permitted_params)
213
201
  end
214
202
 
203
+ def order_from_params
204
+ sortable_column_order do |column, direction|
205
+ case column
206
+ when :name, :status
207
+ %(LOWER(dorsale_flyboy_tasks.#{column}) #{direction})
208
+ when :progress, :term
209
+ %(dorsale_flyboy_tasks.#{column} #{direction})
210
+ when :taskable
211
+ if direction == :asc
212
+ proc { |a, b| a.taskable.to_s.downcase <=> b.taskable.to_s.downcase }
213
+ else
214
+ proc { |a, b| b.taskable.to_s.downcase <=> a.taskable.to_s.downcase }
215
+ end
216
+ else
217
+ params["sort"] = "term"
218
+ "term ASC"
219
+ end
220
+ end
221
+ end
215
222
  end
@@ -81,5 +81,4 @@ class Dorsale::UsersController < ::Dorsale::ApplicationController
81
81
  def user_params_for_update
82
82
  user_params
83
83
  end
84
-
85
84
  end
@@ -3,15 +3,19 @@ class Dorsale::BillingMachine::SmallData::FilterStrategyByPaymentStatus < ::Agil
3
3
  table_name = query.model.table_name
4
4
 
5
5
  if value == "paid"
6
- return query.where("#{table_name}.paid = ?", true)
6
+ query.where(paid: true)
7
7
  elsif value == "unpaid"
8
- return query.where("#{table_name}.paid = ?", false)
8
+ query.where(paid: false)
9
9
  elsif value == "pending"
10
- return query.where("#{table_name}.paid = ? and #{table_name}.due_date >= ?", false, Time.zone.now.to_date)
10
+ query
11
+ .where(paid: false)
12
+ .where("#{table_name}.due_date >= ?", Date.current)
11
13
  elsif value == "late"
12
- return query.where("#{table_name}.paid = ? and (#{table_name}.due_date < ? or #{table_name}.due_date is null)", false, Time.zone.now.to_date)
14
+ query
15
+ .where(paid: false)
16
+ .where("#{table_name}.due_date < ? OR #{table_name}.due_date IS NULL)", Date.current)
13
17
  else
14
- return query
18
+ query
15
19
  end
16
20
  end
17
21
  end
@@ -1,7 +1,7 @@
1
1
  class Dorsale::BillingMachine::SmallData::FilterStrategyByState < ::Agilibox::SmallData::FilterStrategy
2
2
  def apply(query, value)
3
- if value.to_s.match(/not_(.+)/)
4
- query.where.not(state: $~[1])
3
+ if (m = value.to_s.match(/not_(.+)/))
4
+ query.where.not(state: m[1])
5
5
  else
6
6
  query.where(state: value)
7
7
  end
@@ -1,6 +1,6 @@
1
1
  class Dorsale::Flyboy::SmallData::FilterForTasks < ::Agilibox::SmallData::Filter
2
2
  STRATEGIES = {
3
3
  "fb_state" => ::Dorsale::Flyboy::SmallData::FilterStrategyByTaskState.new,
4
- "fb_owner" => ::Agilibox::SmallData::FilterStrategyByKeyValue.new(:owner_id)
4
+ "fb_owner" => ::Agilibox::SmallData::FilterStrategyByKeyValue.new(:owner_id),
5
5
  }
6
6
  end
@@ -9,10 +9,10 @@ module Dorsale::BillingMachine::ApplicationHelper
9
9
  end
10
10
 
11
11
  def billing_machine_quotation_states_for_filter_select
12
- [
13
- [::Dorsale::BillingMachine::Quotation.t("state.all"), ""],
14
- [::Dorsale::BillingMachine::Quotation.t("state.not_canceled"), "not_canceled"],
15
- ] + billing_machine_quotation_states_for_select
12
+ [
13
+ [::Dorsale::BillingMachine::Quotation.t("state.all"), ""],
14
+ [::Dorsale::BillingMachine::Quotation.t("state.not_canceled"), "not_canceled"],
15
+ ] + billing_machine_quotation_states_for_select
16
16
  end
17
17
 
18
18
  def billing_machine_payment_status_for_filter_select
@@ -27,9 +27,9 @@ module Dorsale::BillingMachine::ApplicationHelper
27
27
 
28
28
  def quotation_state_classes(quotation)
29
29
  if quotation.state == "pending" && quotation.date < 1.month.ago
30
- return "pending late"
30
+ "pending late"
31
31
  else
32
- return quotation.state
32
+ quotation.state
33
33
  end
34
34
  end
35
35