dorsale 1.2.6 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/accounting.js +413 -0
  3. data/app/assets/javascripts/dorsale/billing_machine/all.coffee +20 -0
  4. data/app/assets/javascripts/dorsale/billing_machine/invoices.coffee +39 -0
  5. data/app/assets/javascripts/dorsale/billing_machine/quotations.coffee +38 -0
  6. data/app/assets/javascripts/dorsale/comments.coffee +4 -0
  7. data/app/assets/javascripts/dorsale/customer_vault/all.coffee +9 -0
  8. data/app/assets/javascripts/dorsale/datepicker.coffee +1 -1
  9. data/app/assets/javascripts/dorsale/flyboy/all.coffee +0 -0
  10. data/app/assets/javascripts/dorsale/forms.coffee +20 -6
  11. data/app/assets/stylesheets/dorsale/billing_machine/all.sass +15 -0
  12. data/app/assets/stylesheets/dorsale/bootstrap_nav_left.sass +34 -0
  13. data/app/assets/stylesheets/dorsale/comments.sass +25 -3
  14. data/app/assets/stylesheets/dorsale/customer_vault/all.sass +89 -0
  15. data/app/assets/stylesheets/dorsale/filters.sass +4 -1
  16. data/app/assets/stylesheets/dorsale/flyboy/all.sass +52 -0
  17. data/app/assets/stylesheets/dorsale/forms.sass +19 -0
  18. data/app/controllers/dorsale/alexandrie/attachments_controller.rb +52 -0
  19. data/app/controllers/dorsale/billing_machine/application_controller.rb +15 -0
  20. data/app/controllers/dorsale/billing_machine/invoices_controller.rb +180 -0
  21. data/app/controllers/dorsale/billing_machine/quotations_controller.rb +151 -0
  22. data/app/controllers/dorsale/comments_controller.rb +64 -17
  23. data/app/controllers/dorsale/customer_vault/application_controller.rb +26 -0
  24. data/app/controllers/dorsale/customer_vault/corporations_controller.rb +100 -0
  25. data/app/controllers/dorsale/customer_vault/individuals_controller.rb +104 -0
  26. data/app/controllers/dorsale/customer_vault/links_controller.rb +92 -0
  27. data/app/controllers/dorsale/customer_vault/people_controller.rb +42 -0
  28. data/app/controllers/dorsale/flyboy/application_controller.rb +9 -0
  29. data/app/controllers/dorsale/flyboy/folders_controller.rb +124 -0
  30. data/app/controllers/dorsale/flyboy/task_comments_controller.rb +29 -0
  31. data/app/controllers/dorsale/flyboy/tasks_controller.rb +171 -0
  32. data/app/controllers/dorsale/small_data/filters_controller.rb +7 -0
  33. data/app/helpers/dorsale/alexandrie/attachments_helper.rb +17 -0
  34. data/app/helpers/dorsale/all_helpers.rb +12 -9
  35. data/app/helpers/dorsale/button_helper.rb +23 -3
  36. data/app/helpers/dorsale/comments_helper.rb +4 -0
  37. data/app/helpers/dorsale/customer_vault/application_helper.rb +98 -0
  38. data/app/helpers/dorsale/flyboy/application_helper.rb +44 -0
  39. data/app/helpers/dorsale/form_helper.rb +7 -0
  40. data/app/helpers/dorsale/link_helper.rb +3 -2
  41. data/app/helpers/dorsale/routes_helper.rb +5 -3
  42. data/app/helpers/dorsale/text_helper.rb +28 -1
  43. data/app/models/dorsale/ability_helper.rb +7 -0
  44. data/app/models/dorsale/alexandrie/ability_helper.rb +9 -0
  45. data/app/models/dorsale/alexandrie/attachment.rb +18 -0
  46. data/app/models/dorsale/billing_machine/ability_helper.rb +10 -0
  47. data/app/models/dorsale/billing_machine/id_card.rb +18 -0
  48. data/app/models/dorsale/billing_machine/invoice.rb +126 -0
  49. data/app/models/dorsale/billing_machine/invoice_line.rb +27 -0
  50. data/app/models/dorsale/billing_machine/payment_term.rb +12 -0
  51. data/app/models/dorsale/billing_machine/quotation.rb +66 -0
  52. data/app/models/dorsale/billing_machine/quotation_line.rb +25 -0
  53. data/app/models/dorsale/billing_machine/small_data/filter_for_invoices.rb +21 -0
  54. data/app/models/dorsale/billing_machine/small_data/filter_for_quotations.rb +20 -0
  55. data/app/models/dorsale/billing_machine/small_data/filter_strategy_by_customer.rb +12 -0
  56. data/app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb +23 -0
  57. data/app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb +27 -0
  58. data/app/models/dorsale/comment.rb +6 -2
  59. data/app/models/dorsale/customer_vault/ability_helper.rb +9 -0
  60. data/app/models/dorsale/customer_vault/corporation.rb +12 -0
  61. data/app/models/dorsale/customer_vault/individual.rb +17 -0
  62. data/app/models/dorsale/customer_vault/link.rb +10 -0
  63. data/app/models/dorsale/customer_vault/person.rb +35 -0
  64. data/app/models/dorsale/customer_vault/small_data/filter_for_people.rb +19 -0
  65. data/app/models/dorsale/customer_vault/small_data/filter_strategy_by_tags.rb +18 -0
  66. data/app/models/dorsale/flyboy/ability_helper.rb +41 -0
  67. data/app/models/dorsale/flyboy/folder.rb +77 -0
  68. data/app/models/dorsale/flyboy/small_data/filter_for_folders.rb +19 -0
  69. data/app/models/dorsale/flyboy/small_data/filter_for_tasks.rb +19 -0
  70. data/app/models/dorsale/flyboy/small_data/filter_strategy_by_done.rb +12 -0
  71. data/app/models/dorsale/flyboy/small_data/filter_strategy_by_nothing.rb +11 -0
  72. data/app/models/dorsale/flyboy/small_data/filter_strategy_by_status.rb +15 -0
  73. data/app/models/dorsale/flyboy/task.rb +97 -0
  74. data/app/models/dorsale/flyboy/task_comment.rb +35 -0
  75. data/app/pdfs/dorsale/billing_machine/invoice_pdf.rb +209 -0
  76. data/app/pdfs/dorsale/billing_machine/quotation_pdf.rb +53 -0
  77. data/app/pdfs/dorsale/flyboy/roadmap.rb +51 -0
  78. data/app/uploaders/dorsale/alexandrie/file_uploader.rb +6 -0
  79. data/app/uploaders/dorsale/file_uploader.rb +9 -0
  80. data/app/uploaders/dorsale/image_uploader.rb +7 -0
  81. data/app/views/dorsale/_contextual.html.slim +3 -0
  82. data/app/views/dorsale/alexandrie/attachments/_form.html.slim +13 -0
  83. data/app/views/dorsale/alexandrie/attachments/_form_and_list.html.slim +2 -0
  84. data/app/views/dorsale/alexandrie/attachments/_list.html.slim +7 -0
  85. data/app/views/dorsale/billing_machine/invoices/_data_context.html.slim +10 -0
  86. data/app/views/dorsale/billing_machine/invoices/_filters.html.slim +16 -0
  87. data/app/views/dorsale/billing_machine/invoices/_form.html.slim +62 -0
  88. data/app/views/dorsale/billing_machine/invoices/_line_fields.html.slim +23 -0
  89. data/app/views/dorsale/billing_machine/invoices/_list.html.slim +30 -0
  90. data/app/views/dorsale/billing_machine/invoices/edit.html.slim +2 -0
  91. data/app/views/dorsale/billing_machine/invoices/index.html.slim +15 -0
  92. data/app/views/dorsale/billing_machine/invoices/new.html.slim +2 -0
  93. data/app/views/dorsale/billing_machine/invoices/show.html.slim +53 -0
  94. data/app/views/dorsale/billing_machine/quotations/_data_context.html.slim +10 -0
  95. data/app/views/dorsale/billing_machine/quotations/_filters.html.slim +13 -0
  96. data/app/views/dorsale/billing_machine/quotations/_form.html.slim +55 -0
  97. data/app/views/dorsale/billing_machine/quotations/_line_fields.html.slim +23 -0
  98. data/app/views/dorsale/billing_machine/quotations/_list.html.slim +30 -0
  99. data/app/views/dorsale/billing_machine/quotations/edit.html.slim +2 -0
  100. data/app/views/dorsale/billing_machine/quotations/index.html.slim +14 -0
  101. data/app/views/dorsale/billing_machine/quotations/new.html.slim +2 -0
  102. data/app/views/dorsale/billing_machine/quotations/show.html.slim +61 -0
  103. data/app/views/dorsale/comments/_comment.html.slim +23 -9
  104. data/app/views/dorsale/comments/_comments.html.slim +2 -2
  105. data/app/views/dorsale/comments/_form.html.slim +1 -1
  106. data/app/views/dorsale/comments/_list.html.slim +2 -0
  107. data/app/views/dorsale/comments/edit.html.slim +5 -0
  108. data/app/views/dorsale/customer_vault/_breadcrumb.html.slim +4 -0
  109. data/app/views/dorsale/customer_vault/corporations/_context.html.slim +20 -0
  110. data/app/views/dorsale/customer_vault/corporations/_form.html.slim +21 -0
  111. data/app/views/dorsale/customer_vault/corporations/_list_details.html.slim +20 -0
  112. data/app/views/dorsale/customer_vault/corporations/edit.html.slim +14 -0
  113. data/app/views/dorsale/customer_vault/corporations/new.html.slim +14 -0
  114. data/app/views/dorsale/customer_vault/corporations/show.html.slim +1 -0
  115. data/app/views/dorsale/customer_vault/individuals/_context.html.slim +15 -0
  116. data/app/views/dorsale/customer_vault/individuals/_form.html.slim +22 -0
  117. data/app/views/dorsale/customer_vault/individuals/_list_details.html.slim +20 -0
  118. data/app/views/dorsale/customer_vault/individuals/edit.html.slim +14 -0
  119. data/app/views/dorsale/customer_vault/individuals/new.html.slim +14 -0
  120. data/app/views/dorsale/customer_vault/individuals/show.html.slim +1 -0
  121. data/app/views/dorsale/customer_vault/links/_title.html.slim +7 -0
  122. data/app/views/dorsale/customer_vault/links/edit.html.slim +19 -0
  123. data/app/views/dorsale/customer_vault/links/new.html.slim +15 -0
  124. data/app/views/dorsale/customer_vault/people/_activity_tab.html.slim +5 -0
  125. data/app/views/dorsale/customer_vault/people/_comment.html.slim +1 -0
  126. data/app/views/dorsale/customer_vault/people/_context.html.slim +4 -0
  127. data/app/views/dorsale/customer_vault/people/_data_context.html.slim +32 -0
  128. data/app/views/dorsale/customer_vault/people/_filters.html.slim +15 -0
  129. data/app/views/dorsale/customer_vault/people/_index_tabs.html.slim +7 -0
  130. data/app/views/dorsale/customer_vault/people/_links_tab.html.slim +16 -0
  131. data/app/views/dorsale/customer_vault/people/_new_people_contexts.html.slim +7 -0
  132. data/app/views/dorsale/customer_vault/people/_show.html.slim +31 -0
  133. data/app/views/dorsale/customer_vault/people/_tasks_tab.html.slim +1 -0
  134. data/app/views/dorsale/customer_vault/people/activity.slim +20 -0
  135. data/app/views/dorsale/customer_vault/people/list.html.slim +27 -0
  136. data/app/views/dorsale/flyboy/_filters.html.slim +12 -0
  137. data/app/views/dorsale/flyboy/folders/_actions.html.slim +15 -0
  138. data/app/views/dorsale/flyboy/folders/_context.html.slim +18 -0
  139. data/app/views/dorsale/flyboy/folders/_form.html.slim +22 -0
  140. data/app/views/dorsale/flyboy/folders/_list.html.slim +30 -0
  141. data/app/views/dorsale/flyboy/folders/edit.html.slim +2 -0
  142. data/app/views/dorsale/flyboy/folders/index.html.slim +8 -0
  143. data/app/views/dorsale/flyboy/folders/new.html.slim +2 -0
  144. data/app/views/dorsale/flyboy/folders/show.html.slim +9 -0
  145. data/app/views/dorsale/flyboy/task_comments/_list.html.slim +31 -0
  146. data/app/views/dorsale/flyboy/tasks/_actions.html.slim +9 -0
  147. data/app/views/dorsale/flyboy/tasks/_context.html.slim +15 -0
  148. data/app/views/dorsale/flyboy/tasks/_form.html.slim +29 -0
  149. data/app/views/dorsale/flyboy/tasks/_list.html.slim +43 -0
  150. data/app/views/dorsale/flyboy/tasks/_tasks_for_taskable.html.slim +6 -0
  151. data/app/views/dorsale/flyboy/tasks/edit.html.slim +2 -0
  152. data/app/views/dorsale/flyboy/tasks/index.html.slim +10 -0
  153. data/app/views/dorsale/flyboy/tasks/index.xls.erb +29 -0
  154. data/app/views/dorsale/flyboy/tasks/new.html.slim +2 -0
  155. data/app/views/dorsale/flyboy/tasks/show.html.slim +14 -0
  156. data/app/views/dorsale/search/_form.html.slim +6 -0
  157. data/config/locales/alexandrie.fr.yml +8 -0
  158. data/config/locales/billing_machine.fr.yml +50 -0
  159. data/config/locales/common.fr.yml +142 -0
  160. data/config/locales/customer_vault.fr.yml +69 -0
  161. data/config/locales/flyboy.fr.yml +66 -0
  162. data/config/locales/fr.yml +8 -87
  163. data/config/routes.rb +50 -1
  164. data/db/migrate/20141010140200_create_dorsale_addresses.rb +1 -1
  165. data/db/migrate/20150312083147_create_dorsale_comments.rb +3 -3
  166. data/db/migrate/20150616074852_create_dorsale_alexandrie_attachments.rb +9 -0
  167. data/db/migrate/20150622075000_create_flyboy.rb +50 -0
  168. data/db/migrate/20150622075038_create_billing_machine.rb +121 -0
  169. data/db/migrate/20150622105217_create_customer_vault.rb +49 -0
  170. data/db/migrate/20150623093218_dorsale_v2_changes.rb +68 -0
  171. data/db/migrate/20150625093326_billing_machine_quotations_add_expires_at.rb +5 -0
  172. data/db/migrate/20150625131155_billing_machine_add_tracking_ids.rb +6 -0
  173. data/lib/active_record_comma_type_cast.rb +12 -0
  174. data/lib/dorsale/alexandrie/prawn.rb +17 -0
  175. data/lib/dorsale/engine.rb +19 -0
  176. data/lib/dorsale/file_loader.rb +10 -0
  177. data/lib/dorsale/model_i18n.rb +21 -0
  178. data/lib/dorsale/model_to_s.rb +13 -0
  179. data/lib/dorsale/polymorphic_id.rb +2 -0
  180. data/lib/dorsale/version.rb +1 -1
  181. data/spec/controllers/dorsale/alexandrie/attachments_controller_spec.rb +47 -0
  182. data/spec/controllers/dorsale/comments_controller_spec.rb +45 -0
  183. data/spec/controllers/dorsale/customer_vault/corporations_controller_spec.rb +132 -0
  184. data/spec/controllers/dorsale/customer_vault/individuals_controller_spec.rb +130 -0
  185. data/spec/controllers/dorsale/customer_vault/people_controller_spec.rb +59 -0
  186. data/spec/controllers/dorsale/flyboy/folders_controller_spec.rb +111 -0
  187. data/spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb +16 -0
  188. data/spec/controllers/dorsale/flyboy/tasks_controller_spec.rb +234 -0
  189. data/spec/dummy/app/assets/javascripts/application.coffee +10 -0
  190. data/spec/dummy/app/assets/stylesheets/application.sass +9 -0
  191. data/spec/dummy/app/controllers/application_controller.rb +4 -0
  192. data/spec/dummy/app/models/ability.rb +16 -0
  193. data/spec/dummy/app/models/dummy_model.rb +2 -0
  194. data/spec/dummy/app/views/layouts/application.html.erb +10 -3
  195. data/spec/dummy/config/application.rb +4 -2
  196. data/spec/dummy/db/development.sqlite3 +0 -0
  197. data/spec/dummy/db/migrate/20150616082916_create_dorsale_dummy_models.rb +8 -0
  198. data/spec/dummy/db/migrate/20150624081204_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +31 -0
  199. data/spec/dummy/db/migrate/20150624081205_add_missing_unique_indices.acts_as_taggable_on_engine.rb +20 -0
  200. data/spec/dummy/db/migrate/20150624081206_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +15 -0
  201. data/spec/dummy/db/migrate/20150624081207_add_missing_taggable_index.acts_as_taggable_on_engine.rb +10 -0
  202. data/spec/dummy/db/migrate/20150624081208_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +10 -0
  203. data/spec/dummy/db/schema.rb +243 -5
  204. data/spec/dummy/db/seed.rb +1 -0
  205. data/spec/dummy/db/test.sqlite3 +0 -0
  206. data/spec/dummy/log/development.log +227 -0
  207. data/spec/dummy/log/test.log +2740 -25
  208. data/spec/dummy/{app/assets/stylesheets/application.css → tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705} +0 -0
  209. data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  210. data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  211. data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  212. data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  213. data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  214. data/spec/factories/alexandrie_attachments.rb +12 -0
  215. data/spec/factories/billing_machine_id_cards.rb +26 -0
  216. data/spec/factories/billing_machine_invoice_lines.rb +11 -0
  217. data/spec/factories/billing_machine_invoices.rb +12 -0
  218. data/spec/factories/billing_machine_payment_terms.rb +5 -0
  219. data/spec/factories/billing_machine_quotation_lines.rb +12 -0
  220. data/spec/factories/billing_machine_quotations.rb +12 -0
  221. data/spec/factories/customer_vault_corporations.rb +14 -0
  222. data/spec/factories/customer_vault_individuals.rb +19 -0
  223. data/spec/factories/customer_vault_links.rb +7 -0
  224. data/spec/factories/dorsale_addresses.rb +6 -8
  225. data/spec/factories/dorsale_comments.rb +8 -0
  226. data/spec/factories/flyboy_folders.rb +7 -0
  227. data/spec/factories/flyboy_task_comments.rb +8 -0
  228. data/spec/factories/flyboy_tasks.rb +12 -0
  229. data/spec/files/pdf.pdf +0 -0
  230. data/spec/helpers/dorsale/flyboy/application_helper_spec.rb +91 -0
  231. data/spec/helpers/dorsale/link_helper_spec.rb +1 -0
  232. data/spec/helpers/dorsale/text_helper_spec.rb +33 -9
  233. data/spec/models/dorsale/ability_helper_spec.rb +11 -0
  234. data/spec/models/dorsale/alexandrie/ability_helper_spec.rb +10 -0
  235. data/spec/models/dorsale/alexandrie/attachment_spec.rb +12 -0
  236. data/spec/models/dorsale/billing_machine/id_card_spec.rb +12 -0
  237. data/spec/models/dorsale/billing_machine/invoice_line_spec.rb +50 -0
  238. data/spec/models/dorsale/billing_machine/invoice_spec.rb +156 -0
  239. data/spec/models/dorsale/billing_machine/quotation_line_spec.rb +36 -0
  240. data/spec/models/dorsale/billing_machine/quotation_spec.rb +91 -0
  241. data/spec/models/dorsale/comment_spec.rb +11 -0
  242. data/spec/models/dorsale/customer_vault/corporation_spec.rb +17 -0
  243. data/spec/models/dorsale/customer_vault/individual_spec.rb +17 -0
  244. data/spec/models/dorsale/customer_vault/link_spec.rb +12 -0
  245. data/spec/models/dorsale/customer_vault/person_spec.rb +44 -0
  246. data/spec/models/dorsale/flyboy/ability_spec.rb +148 -0
  247. data/spec/models/dorsale/flyboy/folder_spec.rb +103 -0
  248. data/spec/models/dorsale/flyboy/task_comment_spec.rb +52 -0
  249. data/spec/models/dorsale/flyboy/task_spec.rb +83 -0
  250. data/spec/pdfs/dorsale/billing_machine/invoice_pdf_spec.rb +252 -0
  251. data/spec/pdfs/dorsale/billing_machine/quotation_pdf_spec.rb +255 -0
  252. data/spec/rails_helper.rb +11 -11
  253. data/spec/routing/dorsale/alexandrie/attachments_routing_spec.rb +19 -0
  254. data/spec/routing/dorsale/billing_machine/invoices_routing_spec.rb +53 -0
  255. data/spec/routing/dorsale/billing_machine/quotations_routing_spec.rb +43 -0
  256. data/spec/routing/dorsale/comments_routing_spec.rb +25 -0
  257. data/spec/routing/dorsale/customer_vault/corporations_routing_spec.rb +66 -0
  258. data/spec/routing/dorsale/customer_vault/individual_routing_spec.rb +66 -0
  259. data/spec/routing/dorsale/customer_vault/people_routing_spec.rb +22 -0
  260. data/spec/routing/dorsale/flyboy/folders_routing_spec.rb +44 -0
  261. data/spec/routing/dorsale/flyboy/task_comments_routing_spec.rb +12 -0
  262. data/spec/routing/dorsale/flyboy/tasks_routing_spec.rb +44 -0
  263. data/spec/spec_helper.rb +0 -6
  264. metadata +439 -10
  265. data/MIT-LICENSE +0 -20
  266. data/README.rdoc +0 -3
  267. data/spec/dummy/app/assets/javascripts/application.js +0 -13
@@ -13,6 +13,13 @@ module Dorsale
13
13
  new_filters = filters.read.merge(new_filters)
14
14
  filters.store(new_filters)
15
15
 
16
+ # Rewrite cookie with 1 year expiry
17
+ cookies[:filters] = {
18
+ :value => cookies[:filters],
19
+ :expires => 1.year.from_now,
20
+ :path => "/",
21
+ }
22
+
16
23
  urls = [
17
24
  params[:back_url],
18
25
  request.referer,
@@ -0,0 +1,17 @@
1
+ module Dorsale
2
+ module Alexandrie
3
+ module AttachmentsHelper
4
+ def attachment_form_for(attachable)
5
+ render "dorsale/alexandrie/attachments/form", attachable: attachable
6
+ end
7
+
8
+ def attachments_list_for(attachable)
9
+ render "dorsale/alexandrie/attachments/list", attachable: attachable
10
+ end
11
+
12
+ def attachments_for(attachable)
13
+ render "dorsale/alexandrie/attachments/form_and_list", attachable: attachable
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,13 +1,16 @@
1
1
  module Dorsale
2
2
  module AllHelpers
3
- include ButtonHelper
4
- include CommentsHelper
5
- include ContextHelper
6
- include FiltersHelper
7
- include FormHelper
8
- include LinkHelper
9
- include PaginationHelper
10
- include RoutesHelper
11
- include TextHelper
3
+ include ::Dorsale::ButtonHelper
4
+ include ::Dorsale::CommentsHelper
5
+ include ::Dorsale::ContextHelper
6
+ include ::Dorsale::FiltersHelper
7
+ include ::Dorsale::FormHelper
8
+ include ::Dorsale::LinkHelper
9
+ include ::Dorsale::PaginationHelper
10
+ include ::Dorsale::RoutesHelper
11
+ include ::Dorsale::TextHelper
12
+
13
+ include ::Dorsale::Alexandrie::AttachmentsHelper
14
+ include ::Dorsale::Flyboy::ApplicationHelper
12
15
  end
13
16
  end
@@ -3,12 +3,14 @@ module Dorsale
3
3
  def dorsale_button(url, options = {})
4
4
  action = options.delete(:action)
5
5
  icon = options.delete(:icon)
6
+ text = options.delete(:text) || t("actions.#{action}")
7
+ title = options.delete(:title) || text
6
8
 
7
- text = options.delete(:text) || t("actions.#{action}")
8
- text = "#{icon icon} #{text}"
9
+ text = "#{icon icon} <span>#{text}</span>".html_safe
9
10
 
10
11
  options = {
11
- :class => "btn btn-xs link_#{action}"
12
+ :class => "btn btn-xs link_#{action}",
13
+ :title => title,
12
14
  }.deep_merge(options)
13
15
 
14
16
  if confirm = options.delete(:confirm)
@@ -43,6 +45,15 @@ module Dorsale
43
45
  dorsale_button(url, options)
44
46
  end
45
47
 
48
+ def download_button(url, options = {})
49
+ options = {
50
+ :icon => "cloud-download",
51
+ :action => :download
52
+ }.merge(options)
53
+
54
+ dorsale_button(url, options)
55
+ end
56
+
46
57
  def update_button(url, options = {})
47
58
  options = {
48
59
  :icon => :pencil,
@@ -64,6 +75,15 @@ module Dorsale
64
75
  dorsale_button(url, options)
65
76
  end
66
77
 
78
+ def copy_button(url, options = {})
79
+ options = {
80
+ :icon => :copy,
81
+ :action => :copy,
82
+ }.merge(options)
83
+
84
+ dorsale_button(url, options)
85
+ end
86
+
67
87
  def complete_button(url, options = {})
68
88
  options = {
69
89
  :icon => :check,
@@ -4,6 +4,10 @@ module Dorsale
4
4
  render partial: "dorsale/comments/form", locals: {commentable: commentable}
5
5
  end
6
6
 
7
+ def comments_list_for(commentable)
8
+ render partial: "dorsale/comments/list", locals: {commentable: commentable}
9
+ end
10
+
7
11
  def comments_for(commentable)
8
12
  render partial: "dorsale/comments/comments", locals: {commentable: commentable}
9
13
  end
@@ -0,0 +1,98 @@
1
+ module Dorsale
2
+ module CustomerVault
3
+ module ApplicationHelper
4
+ def customer_vault_breadcrumb
5
+ breadcrumb = []
6
+
7
+ breadcrumb << link_to(icon(:home), "/")
8
+
9
+ breadcrumb << link_to(t("customer_vault"), dorsale.customer_vault_people_path)
10
+
11
+ person = @person || @individual || @corporation
12
+ breadcrumb << link_to(person.name, person) if person.present? && person.persisted?
13
+
14
+ if params[:controller].to_s.include?("links")
15
+ breadcrumb << ::Dorsale::CustomerVault::Link.t.pluralize
16
+ breadcrumb << @link.title if @link.try(:title).present?
17
+ end
18
+
19
+ # Add action
20
+ action = params[:action]
21
+ action_name = t("actions.#{action}")
22
+ breadcrumb << action_name unless action == "show"
23
+
24
+ # Last element is not a link
25
+ breadcrumb << strip_tags(breadcrumb.pop)
26
+
27
+ breadcrumb
28
+ end
29
+
30
+ def person_tags(person)
31
+ return if person.tag_list.empty?
32
+
33
+ person.tag_list.map { |tag|
34
+ content_tag(:span, class: "tag label label-primary"){
35
+ "#{icon :tag} #{tag}".html_safe
36
+ }
37
+ }.join(" ").html_safe
38
+ end
39
+
40
+
41
+
42
+ # Routes fix
43
+
44
+ def customer_vault_corporation_customer_vault_link_path(person, link)
45
+ dorsale.url_for(
46
+ :controller => "dorsale/customer_vault/links",
47
+ :action => "show",
48
+ :corporation_id => person.id,
49
+ :id => link.id,
50
+ )
51
+ end
52
+
53
+ def edit_customer_vault_corporation_customer_vault_link_path(person, link)
54
+ dorsale.url_for(
55
+ :controller => "dorsale/customer_vault/links",
56
+ :action => "edit",
57
+ :corporation_id => person.id,
58
+ :id => link.id,
59
+ )
60
+ end
61
+
62
+ def customer_vault_individual_customer_vault_link_path(person, link)
63
+ dorsale.url_for(
64
+ :controller => "dorsale/customer_vault/links",
65
+ :action => "show",
66
+ :corporation_id => person.id,
67
+ :id => link.id,
68
+ )
69
+ end
70
+
71
+ def edit_customer_vault_individual_customer_vault_link_path(person, link)
72
+ dorsale.url_for(
73
+ :controller => "dorsale/customer_vault/links",
74
+ :action => "edit",
75
+ :corporation_id => person.id,
76
+ :id => link.id,
77
+ )
78
+ end
79
+
80
+ def customer_vault_individual_customer_vault_links_path(person)
81
+ dorsale.url_for(
82
+ :controller => "dorsale/customer_vault/links",
83
+ :action => "create",
84
+ :id => person.id,
85
+ )
86
+ end
87
+
88
+ def customer_vault_corporation_customer_vault_links_path(person)
89
+ dorsale.url_for(
90
+ :controller => "dorsale/customer_vault/links",
91
+ :action => "create",
92
+ :id => person.id,
93
+ )
94
+ end
95
+
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,44 @@
1
+ module Dorsale
2
+ module Flyboy
3
+ module ApplicationHelper
4
+ include ::Handles::SortableColumns::InstanceMethods
5
+
6
+ def tasks_for(taskable)
7
+ @filters = ::Dorsale::Flyboy::SmallData::FilterForTasks.new(cookies)
8
+
9
+ order ||= sortable_column_order do |column, direction|
10
+ case column
11
+ when "name", "status"
12
+ %(LOWER(dorsale_flyboy_tasks.#{column}) #{direction})
13
+ when "progress", "term"
14
+ %(dorsale_flyboy_tasks.#{column} #{direction})
15
+ else
16
+ params["sort"] = "term"
17
+ "dorsale_flyboy_tasks.term ASC"
18
+ end
19
+ end
20
+
21
+ tasks = ::Dorsale::Flyboy::Task.where(taskable: taskable)
22
+ tasks = @filters.apply(tasks)
23
+ tasks = tasks.order(order)
24
+
25
+ render "dorsale/flyboy/tasks/tasks_for_taskable", tasks: tasks, taskable: taskable
26
+ end
27
+
28
+ def task_color(task)
29
+ return "finished" if task.done
30
+ return "ontime" if task.reminder > Date.today
31
+ return "onalert" if task.term < Date.today
32
+ return "onwarning"
33
+ end
34
+
35
+ def folder_color(folder)
36
+ return "onalert" if ::Dorsale::Flyboy::Task.where(taskable: folder).where('done = ? AND term < ?', false, Date.today).count > 0
37
+ return "onwarning" if ::Dorsale::Flyboy::Task.where(taskable: folder).where('done = ? AND term > ? AND reminder < ?', false, Date.today, Date.today).count > 0
38
+ return "finished" if folder.closed?
39
+ return "ontime"
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -39,5 +39,12 @@ module Dorsale
39
39
 
40
40
  simple_form_for(obj, opts, &block)
41
41
  end
42
+
43
+ def search_form(opts = {})
44
+ action = opts.delete(:action) || request.fullpath
45
+
46
+ render "dorsale/search/form", action: action
47
+ end
48
+
42
49
  end
43
50
  end
@@ -1,7 +1,7 @@
1
1
  module Dorsale
2
2
  module LinkHelper
3
3
  def icon_link_to(icon, name, options = nil, html_options = nil, &block)
4
- name = "#{icon(icon)} #{name}"
4
+ name = "#{icon(icon)} #{name}".html_safe
5
5
  link_to(name, options, html_options, &block)
6
6
  end
7
7
 
@@ -25,7 +25,8 @@ module Dorsale
25
25
  def tel_link(text, opts = {})
26
26
  return if text.to_s.blank?
27
27
 
28
- href = "tel:#{text}"
28
+ value = text.gsub(" ", "")
29
+ href = "tel:#{value}"
29
30
 
30
31
  link_to(text, href, opts)
31
32
  end
@@ -1,14 +1,16 @@
1
1
  module Dorsale
2
2
  module RoutesHelper
3
3
  def engine_polymorphic_path(obj, opts = {})
4
- if obj.class.parent == Object
4
+ engine = obj.class.parents[-2]
5
+
6
+ if engine.nil?
5
7
  routes = main_app
6
8
  else
7
- routes = obj.class.parent::Engine.routes
9
+ routes = engine::Engine.routes
8
10
  end
9
11
 
10
12
  opts = {
11
- :controller => obj.class.model_name.collection,
13
+ :controller => "/#{obj.class.to_s.tableize}",
12
14
  :action => :show,
13
15
  :id => obj.to_param,
14
16
  :only_path => true
@@ -1,5 +1,8 @@
1
1
  module Dorsale
2
2
  module TextHelper
3
+ include ::ActionView::Helpers::TextHelper
4
+ include ::ActionView::Helpers::SanitizeHelper
5
+
3
6
  def euros(n)
4
7
  return if n.nil?
5
8
 
@@ -29,6 +32,11 @@ module Dorsale
29
32
  number_with_precision(n, opts)
30
33
  end
31
34
 
35
+ def date(d)
36
+ return if d.nil?
37
+ I18n.l(d)
38
+ end
39
+
32
40
  def hours(n)
33
41
  return if n.nil?
34
42
 
@@ -39,7 +47,26 @@ module Dorsale
39
47
  end
40
48
 
41
49
  def text2html(str)
42
- h(str).gsub("\r", "").gsub("\n", "<br />").html_safe
50
+ return if str.to_s.blank?
51
+
52
+ str = str.gsub("\r", "").strip
53
+ strip_tags(str).gsub("\n", "<br />").html_safe
54
+ end
55
+
56
+ def info(object, attribute, text = nil)
57
+ label = content_tag(:strong) do
58
+ object.t(attribute)
59
+ end
60
+
61
+ span_css_class = "#{object.class.model_name.element}-#{attribute}"
62
+
63
+ value = content_tag(:span, class: span_css_class) do
64
+ ( text || object.send(attribute) ).to_s
65
+ end
66
+
67
+ content_tag(:div, class: "info") do
68
+ "#{label} : #{value}".html_safe
69
+ end
43
70
  end
44
71
  end
45
72
  end
@@ -0,0 +1,7 @@
1
+ module Dorsale
2
+ module AbilityHelper
3
+ def define_dorsale_comment_abilities
4
+ can [:create, :update, :delete], ::Dorsale::Comment
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module Dorsale
2
+ module Alexandrie
3
+ module AbilityHelper
4
+ def define_alexandrie_abilities
5
+ can [:create, :delete], ::Dorsale::Alexandrie::Attachment
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ module Dorsale
2
+ module Alexandrie
3
+ class Attachment < ActiveRecord::Base
4
+ self.table_name = "dorsale_alexandrie_attachments"
5
+
6
+ belongs_to :attachable, polymorphic: true
7
+
8
+ validates :attachable, presence: true
9
+ validates :file, presence: true
10
+
11
+ mount_uploader :file, ::Dorsale::Alexandrie::FileUploader
12
+
13
+ def to_s
14
+ file_identifier
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ module Dorsale
2
+ module BillingMachine
3
+ module AbilityHelper
4
+ def define_dorsale_billing_machine_abilities
5
+ can [:list, :create, :read, :update, :pay, :copy], ::Dorsale::BillingMachine::Invoice
6
+ can [:list, :create, :read, :update, :delete], ::Dorsale::BillingMachine::Quotation
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ module Dorsale
2
+ module BillingMachine
3
+ class IdCard < ActiveRecord::Base
4
+ self.table_name = "dorsale_billing_machine_id_cards"
5
+
6
+ has_many :invoices
7
+ has_many :quotations
8
+
9
+ validates :id_card_name, presence: true
10
+
11
+ def name
12
+ id_card_name
13
+ end
14
+
15
+ mount_uploader :logo, ::Dorsale::ImageUploader
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,126 @@
1
+ module Dorsale
2
+ module BillingMachine
3
+ class Invoice < ActiveRecord::Base
4
+ self.table_name = "dorsale_billing_machine_invoices"
5
+
6
+ belongs_to :customer, polymorphic: true
7
+ belongs_to :payment_term
8
+ belongs_to :id_card
9
+
10
+ has_many :lines, inverse_of: :invoice, dependent: :destroy, class_name: ::Dorsale::BillingMachine::InvoiceLine
11
+
12
+ accepts_nested_attributes_for :lines, allow_destroy: true
13
+
14
+ polymorphic_id_for :customer
15
+
16
+ validates :id_card, presence: true
17
+ validates :date, presence: true
18
+
19
+ # simple_form
20
+ validates :id_card_id, presence: true
21
+
22
+ def initialize(*args)
23
+ super
24
+ self.date = Date.today if date.nil?
25
+ self.due_date = 30.days.from_now if due_date.nil?
26
+ self.vat_rate = 20 if vat_rate.nil?
27
+ self.advance = 0 if advance.nil?
28
+ self.paid = false if paid.nil?
29
+ end
30
+
31
+ before_create :assign_unique_index
32
+ before_create :assign_tracking_id
33
+
34
+ def assign_unique_index
35
+ if unique_index.nil?
36
+ self.unique_index = self.class.all.pluck(:unique_index).max.to_i.next
37
+ end
38
+ end
39
+
40
+ def assign_tracking_id
41
+ self.tracking_id = date.year.to_s + "-" + unique_index.to_s.rjust(2, "0")
42
+ end
43
+
44
+ before_save :update_balance
45
+
46
+ def update_balance
47
+ self.vat_rate = 0 if vat_rate.nil?
48
+ self.advance = 0 if advance.nil?
49
+ self.total_duty = lines.pluck(:total).sum
50
+ self.vat_amount = total_duty * vat_rate / 100.0
51
+ self.total_all_taxes = total_duty + vat_amount
52
+ self.balance = total_all_taxes - advance
53
+ end
54
+
55
+ def pdf
56
+ pdf = ::Dorsale::BillingMachine::InvoicePdf.new(self)
57
+ pdf.build
58
+ pdf
59
+ end
60
+
61
+ def payment_status
62
+ if paid?
63
+ return :paid
64
+ elsif due_date == nil
65
+ return :on_alert
66
+ elsif Date.today >= due_date + 15
67
+ return :on_alert
68
+ elsif Date.today > due_date
69
+ return :late
70
+ else
71
+ return :pending
72
+ end
73
+ end
74
+
75
+ def self.to_csv(options = { :force_quotes => true, :col_sep => ";" })
76
+ CSV.generate(options) do |csv|
77
+ column_names = [
78
+ "Date",
79
+ "Numéro",
80
+ "Objet",
81
+ "Client",
82
+ "Adresse 1",
83
+ "Adresse 2",
84
+ "Code postal",
85
+ "Ville",
86
+ "Pays",
87
+ "Montant HT",
88
+ "Taux TVA",
89
+ "Montant TVA",
90
+ "Montant TTC",
91
+ "Acompte",
92
+ "Solde à payer"
93
+ ]
94
+
95
+ csv << column_names
96
+
97
+ all.each do |invoice|
98
+ csv << [
99
+ invoice.date,
100
+ invoice.tracking_id,
101
+ invoice.label,
102
+ invoice.customer.try(:name),
103
+ invoice.customer.try(:address).try(:street),
104
+ invoice.customer.try(:address).try(:street_bis),
105
+ invoice.customer.try(:address).try(:zip),
106
+ invoice.customer.try(:address).try(:city),
107
+ invoice.customer.try(:address).try(:country),
108
+ french_number(invoice.total_duty),
109
+ french_number(invoice.vat_rate),
110
+ french_number(invoice.vat_amount),
111
+ french_number(invoice.total_all_taxes),
112
+ french_number(invoice.advance),
113
+ french_number(invoice.balance)
114
+ ]
115
+ end
116
+ end
117
+ end
118
+
119
+ def self.french_number amount
120
+ extend ActionView::Helpers::NumberHelper
121
+ number_with_precision(amount, :delimiter => '', :separator => ",", :precision => 2)
122
+ end
123
+
124
+ end # Invoice
125
+ end # BillingMachine
126
+ end # Dorsale