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
@@ -0,0 +1,19 @@
1
+ module Dorsale
2
+ module Flyboy
3
+ module SmallData
4
+ class FilterForFolders < ::Dorsale::SmallData::Filter
5
+ STRATEGIES = {
6
+ 'status' => FilterStrategyByStatus.new("folders")
7
+ }
8
+
9
+ def strategy key
10
+ STRATEGIES[key]
11
+ end
12
+
13
+ def target
14
+ "folders"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module Dorsale
2
+ module Flyboy
3
+ module SmallData
4
+ class FilterForTasks < ::Dorsale::SmallData::Filter
5
+ STRATEGIES = {
6
+ 'status' => FilterStrategyByDone.new("tasks")
7
+ }
8
+
9
+ def strategy key
10
+ STRATEGIES[key]
11
+ end
12
+
13
+ def target
14
+ "tasks"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ module Dorsale
2
+ module Flyboy
3
+ module SmallData
4
+ class FilterStrategyByDone < ::Dorsale::SmallData::FilterStrategy
5
+ def do_apply query
6
+ value = (@value == 'closed')
7
+ query.where(done: value)
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ module Dorsale
2
+ module Flyboy
3
+ module SmallData
4
+ class FilterStrategyByNothing < ::Dorsale::SmallData::FilterStrategy
5
+ def do_apply query
6
+ return query
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module Dorsale
2
+ module Flyboy
3
+ module SmallData
4
+ class FilterStrategyByStatus < ::Dorsale::SmallData::FilterStrategy
5
+ def do_apply query
6
+ if @value == "closed"
7
+ query.where(status: "closed")
8
+ else
9
+ query.where.not(status: "closed")
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,97 @@
1
+ require "dorsale/search"
2
+ require "dorsale/polymorphic_id"
3
+
4
+ module Dorsale
5
+ module Flyboy
6
+ class Task < ActiveRecord::Base
7
+ self.table_name = "dorsale_flyboy_tasks"
8
+
9
+ include ::Dorsale::Search
10
+
11
+ paginates_per 50
12
+
13
+ belongs_to :taskable, polymorphic: true
14
+ has_many :comments, class_name: ::Dorsale::Flyboy::TaskComment, inverse_of: :task, dependent: :destroy
15
+ polymorphic_id_for :taskable
16
+
17
+ validates :taskable, presence: true
18
+ validates :name, presence: true
19
+ validates :term, presence: true
20
+ validates :reminder, presence: true
21
+
22
+ validate :validates_reminder_and_term
23
+
24
+ def validates_reminder_and_term
25
+ if reminder && term && reminder > term
26
+ # errors.add(:reminder, "La date de relance doit être antérieure ou égale à la date d'échéance")
27
+ errors.add(:reminder, :less_than, count: term)
28
+ end
29
+ end
30
+
31
+ def initialize(*args)
32
+ super
33
+ self.done = false if done.nil?
34
+ self.reminder = Date.today + snooze_default_reminder if reminder.nil?
35
+ self.term = Date.today + snooze_default_term if term.nil?
36
+ self.progress = 0 if progress.nil?
37
+ end
38
+
39
+ after_save :update_taskable_progress!
40
+ after_destroy :update_taskable_progress!
41
+
42
+ def update_taskable_progress!
43
+ taskable.try(:update_progress!)
44
+ end
45
+
46
+ def snooze
47
+ if term_not_passed_yet
48
+ if self.reminder + snooze_default_reminder > Date.today
49
+ self.reminder += snooze_default_reminder
50
+ self.term += snooze_default_term
51
+ else
52
+ self.reminder = Date.today + 1
53
+ end
54
+ else
55
+ self.reminder = Date.today + snooze_default_reminder
56
+ self.term = Date.today + snooze_default_term
57
+ end
58
+ end
59
+
60
+ def snooze_default_reminder
61
+ 7
62
+ end
63
+
64
+ def snooze_default_term
65
+ 30
66
+ end
67
+
68
+ def self.to_csv(options = {})
69
+ CSV.generate(options) do |csv|
70
+ csv << [
71
+ "Taskable",
72
+ "Type",
73
+ "Avancement taskable",
74
+ "Tâche",
75
+ "Avancement tâche",
76
+ "Echéance"
77
+ ]
78
+
79
+ all.each do |task|
80
+ csv << [
81
+ task.taskable.name,
82
+ task.taskable.class.t,
83
+ "#{task.taskable.try(:progress)} %",
84
+ task.name,
85
+ "#{task.progress} %",
86
+ I18n.l(task.term),
87
+ ]
88
+ end
89
+ end
90
+ end
91
+
92
+ def term_not_passed_yet
93
+ self.term > Date.today
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,35 @@
1
+ module Dorsale
2
+ module Flyboy
3
+ class TaskComment < ActiveRecord::Base
4
+ self.table_name = "dorsale_flyboy_task_comments"
5
+
6
+ belongs_to :task
7
+
8
+ validates :task, presence: true
9
+ validates :date, presence: true
10
+ validates :description, presence: true
11
+ validates :progress, inclusion: {in: 0..100}
12
+
13
+ default_scope -> { order("created_at DESC") }
14
+
15
+ def initialize(*args)
16
+ super
17
+
18
+ self.date = Time.now if date.nil?
19
+
20
+ if progress.nil?
21
+ self.progress = task ? task.progress : 0
22
+ end
23
+ end
24
+
25
+ after_create :update_task_progress
26
+
27
+ def update_task_progress
28
+ task.update_attributes(
29
+ :progress => progress,
30
+ :done => progress.equal?(100)
31
+ )
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,209 @@
1
+ module Dorsale
2
+ module BillingMachine
3
+ class InvoicePdf < Prawn::Document
4
+ include Dorsale::Alexandrie::Prawn
5
+ include ActionView::Helpers::NumberHelper
6
+ attr_reader :main_document
7
+
8
+ GREY = "808080"
9
+ LIGHT_GREY = "C0C0C0"
10
+ WHITE = "FFFFFF"
11
+ DEBUG = false
12
+ FRENCH_MONTH_NAMES = [nil, 'janvier', 'février', 'mars', 'avril', 'mai',
13
+ 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre']
14
+
15
+ def main_document_type
16
+ "Facture"
17
+ end
18
+
19
+ def initialize(main_document)
20
+ super(:page_size => 'A4')
21
+ @main_document = main_document
22
+ @id_card = @main_document.id_card
23
+ end
24
+
25
+ def build
26
+
27
+ build_logo
28
+ build_legal_infos
29
+ build_header
30
+ build_contact_infos
31
+ build_customer_infos
32
+ build_label
33
+ build_table
34
+ build_comments
35
+ build_footer
36
+ end
37
+
38
+ def build_logo
39
+ image @main_document.id_card.logo.path , at: [45, 765], :width => 150 if @main_document.id_card.logo.present?
40
+ end
41
+
42
+ def build_legal_infos
43
+ bounding_box [235, 735], :width => 235, :height => 110 do
44
+ draw_bounds_debug
45
+ font_size 8
46
+ text @id_card.entity_name, align: :right, style: :bold
47
+ write_legal_line 'SIRET ' + @id_card.siret.to_s + ' APE ' + @id_card.ape_naf.to_s
48
+ write_legal_line @id_card.legal_form.to_s + ' au capital de ' + number_with_delimiter(@id_card.capital, :delimiter => '.').to_s + ' euros'
49
+ write_legal_line @id_card.registration_city.to_s + ' ' + @id_card.registration_number.to_s
50
+ move_down 5
51
+ write_legal_line 'N° TVA ' + @id_card.intracommunity_vat.to_s
52
+ move_down 15
53
+ write_legal_line @id_card.address1.to_s
54
+ write_legal_line @id_card.zip.to_s + " " + @id_card.city.to_s
55
+ end
56
+ end
57
+
58
+ def build_header
59
+ bounding_box [300, 585], :width => 170, :height => 50 do
60
+ draw_bounds_debug
61
+ font_size 10
62
+ document_type = main_document_type
63
+ text "<font size='16'><b>#{document_type}</b></font> N°" + @main_document.tracking_id,
64
+ :inline_format => true,
65
+ :align => :right
66
+ font_size 11.5
67
+ text @id_card.city.to_s + ' le ' + french_date(@main_document.date), :align => :right
68
+ end
69
+ end
70
+
71
+ def build_contact_infos
72
+ bounding_box [50, 585], :width => 235, :height => 50 do
73
+ draw_bounds_debug
74
+ font_size 10
75
+ text '<b>Contact :</b> ' + @id_card.contact_full_name.to_s, :inline_format => true
76
+ text '<b>Tél :</b> ' + @id_card.contact_phone.to_s, :inline_format => true
77
+ text '<b>Fax:</b> ' + @id_card.contact_fax.to_s, :inline_format => true
78
+ text '<b>Email:</b> ' + @id_card.contact_email.to_s, :inline_format => true
79
+ end
80
+ end
81
+
82
+ def build_customer_infos
83
+ unless @main_document.customer.nil?
84
+ bounding_box [50, 530], :width => 420, :height => 105 do
85
+ draw_bounds_debug
86
+ font_size 11.5
87
+ text 'A l’attention de :', :style => :bold
88
+ text @main_document.customer.name
89
+ text @main_document.customer.address.street
90
+ text @main_document.customer.address.street_bis
91
+ text @main_document.customer.address.zip.to_s + ' ' + @main_document.customer.address.city.to_s
92
+ text @main_document.customer.address.country
93
+ end
94
+ end
95
+ end
96
+
97
+ def build_label
98
+ bounding_box [50, 425], :width => 350, :height => 30 do
99
+ draw_bounds_debug
100
+ font_size 11
101
+ text '<b>Objet :</b> ' + @main_document.label, :inline_format => true
102
+ end
103
+ end
104
+
105
+ def build_table
106
+ bounding_box [50, 400], :width => 450 do
107
+ @table_matrix = [['Prestation', 'Prix unitaire', 'Quantité', 'Total HT']]
108
+ build_lines
109
+ build_synthesis
110
+ build_expiry
111
+ build_payment_terms
112
+ build_bank_infos
113
+ end
114
+ end
115
+
116
+ def build_lines
117
+ @main_document.lines.each do |line|
118
+ @table_matrix.push [line.label, french_number(euros(line.unit_price), 2),
119
+ french_number(line.quantity),
120
+ french_number(euros(line.total), 2)]
121
+ end
122
+ end
123
+
124
+ def build_synthesis
125
+ font_size 10
126
+ @table_matrix.push ['Net HT', '', '', euros(@main_document.total_duty)]
127
+ vat_rate = french_number(@main_document.vat_rate)
128
+ @table_matrix.push ["TVA #{vat_rate} %", '', '', euros(@main_document.vat_amount)]
129
+ @table_matrix.push ['Total TTC', '', '', euros(@main_document.total_all_taxes)]
130
+ if (@main_document.advance && @main_document.advance != 0.0)
131
+ @table_matrix.push ['Acompte reçu sur commande', '', '', euros(@main_document.advance)]
132
+ @table_matrix.push ['Solde à payer', '', '', euros(@main_document.balance)]
133
+ end
134
+ write_table_from_matrix(@table_matrix)
135
+ end
136
+
137
+ def build_payment_terms
138
+ move_down 15
139
+ text 'Conditions de paiement :'
140
+ text @main_document.payment_term.try(:label)
141
+ end
142
+
143
+ def build_bank_infos
144
+ move_down 10
145
+ text 'Coordonnées bancaires :'
146
+ text 'IBAN : ' + @id_card.iban.to_s
147
+ text 'BIC / SWIFT : ' + @id_card.bic_swift.to_s
148
+ end
149
+
150
+ def build_expiry
151
+ end
152
+
153
+ def build_comments
154
+ end
155
+
156
+ def build_footer
157
+ bounding_box [50, 37], :width => 425 do
158
+ font "Times-Roman"
159
+ font_size 8.5
160
+ text @id_card.custom_info_1, :color => GREY
161
+ end
162
+ end
163
+
164
+
165
+ def write_table_from_matrix matrix
166
+ table matrix,
167
+ :column_widths => [215, 65, 60, 80],
168
+ :cell_style => {:align => :right, :border_width => 0.5} do
169
+ row(0).style :background_color => LIGHT_GREY # make first row grey
170
+ row(0).style :size => 11
171
+ # reduce font size of invoice lines
172
+ invoice_lines_range = Range.new(1,(matrix.length - 6))
173
+ row(invoice_lines_range).style :size => 9
174
+ end
175
+ end
176
+
177
+ def draw_bounds_debug
178
+ transparent(0.5) { stroke_bounds } if DEBUG
179
+ end
180
+
181
+ def write_legal_line text
182
+ text text, :align => :right, :color => GREY
183
+ end
184
+
185
+ def french_date date
186
+ french_month = FRENCH_MONTH_NAMES[date.month]
187
+ return date.day.to_s + ' ' + french_month + ' ' + date.year.to_s
188
+ end
189
+
190
+ def euros amount
191
+ amount ||= 0
192
+ french_number(amount, 2).to_s + " €"
193
+ end
194
+
195
+ def french_number amount, precision = -1
196
+ if precision >= 0
197
+ number_with_precision(amount, :precision => precision, :delimiter => '.', :separator => ",")
198
+ else
199
+ number_with_delimiter(amount, :delimiter => '.', :separator => ",")
200
+ end
201
+ end
202
+
203
+ def number_without_trailling_zero number
204
+ return ("%g" % number)
205
+ end
206
+
207
+ end # InvoicePdf
208
+ end # BillingMachine
209
+ end # Dorsale
@@ -0,0 +1,53 @@
1
+ module Dorsale
2
+ module BillingMachine
3
+ class QuotationPdf < ::Dorsale::BillingMachine::InvoicePdf
4
+ def build
5
+ super
6
+ build_attachments
7
+ end
8
+
9
+ def build_attachments
10
+ @main_document.attachments.each do |attachment|
11
+ next unless File.extname(attachment.file.path) == ".pdf"
12
+
13
+ file = attachment.file.path
14
+ nb_pages = ::CombinePDF.load(file).pages.count
15
+
16
+ nb_pages.times do |i|
17
+ start_new_page template: file, template_page: (i+1)
18
+ end
19
+ end
20
+ end
21
+
22
+ def main_document_type
23
+ "Devis"
24
+ end
25
+
26
+ def build_bank_infos
27
+ end
28
+
29
+ def build_synthesis
30
+ font_size 10
31
+ @table_matrix.push ['Net HT', '', '', euros(@main_document.total_duty)]
32
+ vat_rate = french_number(@main_document.vat_rate)
33
+ @table_matrix.push ["TVA #{vat_rate} %", '', '', euros(@main_document.vat_amount)]
34
+ @table_matrix.push ['Total TTC', '', '', euros(@main_document.total_all_taxes)]
35
+ write_table_from_matrix(@table_matrix)
36
+ end
37
+
38
+ def build_expiry
39
+ return if @main_document.expires_at.nil?
40
+ move_down 15
41
+ text "Date d'expiration : " + I18n.l(@main_document.expires_at)
42
+ end
43
+
44
+ def build_comments
45
+ bounding_box [50, 140], :width => 445, :height => 50 do
46
+ draw_bounds_debug
47
+ font_size 9
48
+ text @main_document.comments
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end