stockor 0.1.9 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (313) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +254 -72
  4. data/Guardfile +1 -1
  5. data/README.md +24 -3
  6. data/app.json +28 -0
  7. data/client/skr/Extension.coffee +18 -0
  8. data/client/skr/components/BankAccountFinder.cjsx +34 -0
  9. data/client/skr/components/Currency.cjsx +19 -0
  10. data/client/skr/components/CustomerFinder.cjsx +37 -0
  11. data/client/skr/components/CustomerLink.cjsx +13 -0
  12. data/client/skr/components/CustomerProjectFinder.cjsx +49 -0
  13. data/client/skr/components/GlAccountChooser.cjsx +38 -0
  14. data/client/skr/components/InvoiceFinder.cjsx +37 -0
  15. data/client/skr/components/InvoiceLink.cjsx +13 -0
  16. data/client/skr/components/LocationChooser.cjsx +37 -0
  17. data/client/skr/components/PaymentCategoryFinder.cjsx +34 -0
  18. data/client/skr/components/PrintFormChooser.cjsx +29 -0
  19. data/client/skr/components/SalesOrderFinder.cjsx +38 -0
  20. data/client/skr/components/ScreenControls.cjsx +20 -0
  21. data/client/skr/components/SkuFinder.cjsx +30 -0
  22. data/client/skr/components/SkuLines.cjsx +76 -0
  23. data/client/skr/components/SystemSettings.cjsx +26 -0
  24. data/client/skr/components/TermsChooser.cjsx +40 -0
  25. data/client/skr/components/ToolbarButton.cjsx +7 -0
  26. data/client/skr/components/TotalsLine.cjsx +21 -0
  27. data/client/skr/components/TriStateIcon.cjsx +12 -0
  28. data/client/skr/components/UOMChooser.cjsx +24 -0
  29. data/client/skr/components/UserPreferences.cjsx +30 -0
  30. data/client/skr/components/VendorFinder.cjsx +40 -0
  31. data/client/skr/components/address/Address.cjsx +10 -10
  32. data/client/skr/components/styles.scss +16 -0
  33. data/client/skr/index.js +3 -1
  34. data/client/skr/models/Address.coffee +9 -1
  35. data/client/skr/models/BankAccount.coffee +17 -0
  36. data/client/skr/models/Base.coffee +6 -0
  37. data/client/skr/models/Customer.coffee +17 -10
  38. data/client/skr/models/CustomerProject.coffee +29 -0
  39. data/client/skr/models/GlAccount.coffee +22 -10
  40. data/client/skr/models/GlManualEntry.coffee +4 -2
  41. data/client/skr/models/GlPeriod.coffee +4 -6
  42. data/client/skr/models/GlPosting.coffee +7 -7
  43. data/client/skr/models/GlTransaction.coffee +3 -3
  44. data/client/skr/models/IaLine.coffee +9 -9
  45. data/client/skr/models/IaReason.coffee +4 -4
  46. data/client/skr/models/InvLine.coffee +30 -11
  47. data/client/skr/models/InventoryAdjustment.coffee +8 -6
  48. data/client/skr/models/Invoice.coffee +89 -18
  49. data/client/skr/models/Location.coffee +27 -6
  50. data/client/skr/models/Payment.coffee +36 -0
  51. data/client/skr/models/PaymentCategory.coffee +12 -0
  52. data/client/skr/models/PaymentTerm.coffee +17 -4
  53. data/client/skr/models/PickTicket.coffee +7 -5
  54. data/client/skr/models/PoLine.coffee +15 -15
  55. data/client/skr/models/PoReceipt.coffee +8 -6
  56. data/client/skr/models/PorLine.coffee +11 -11
  57. data/client/skr/models/PricingProvider.coffee +6 -0
  58. data/client/skr/models/PtLine.coffee +13 -13
  59. data/client/skr/models/PurchaseOrder.coffee +11 -9
  60. data/client/skr/models/SalesOrder.coffee +59 -22
  61. data/client/skr/models/Sku.coffee +17 -15
  62. data/client/skr/models/SkuLoc.coffee +14 -9
  63. data/client/skr/models/SkuTran.coffee +10 -10
  64. data/client/skr/models/SkuVendor.coffee +9 -9
  65. data/client/skr/models/SoLine.coffee +27 -20
  66. data/client/skr/models/TimeEntry.coffee +75 -0
  67. data/client/skr/models/Uom.coffee +27 -6
  68. data/client/skr/models/Vendor.coffee +14 -12
  69. data/client/skr/models/VoLine.coffee +11 -11
  70. data/client/skr/models/Voucher.coffee +7 -5
  71. data/client/skr/models/mixins/HasVisibleId.coffee +7 -0
  72. data/client/skr/models/mixins/PrintSupport.coffee +6 -0
  73. data/client/skr/models/mixins/SkuLine.coffee +61 -0
  74. data/client/skr/screens/Commands.coffee +29 -0
  75. data/client/skr/screens/bank-maint/BankMaint.cjsx +43 -0
  76. data/client/skr/screens/bank-maint/index.js +5 -0
  77. data/client/skr/screens/chart-of-accounts/ChartOfAccounts.cjsx +40 -0
  78. data/client/skr/screens/chart-of-accounts/index.js +1 -0
  79. data/client/skr/screens/chart-of-accounts/index.scss +12 -0
  80. data/client/skr/screens/customer-maint/CustomerMaint.cjsx +35 -36
  81. data/client/skr/screens/customer-projects/CustomerProjects.cjsx +70 -0
  82. data/client/skr/screens/customer-projects/index.js +5 -0
  83. data/client/skr/screens/customer-projects/index.scss +25 -0
  84. data/client/skr/screens/fresh-books-import/ApiInfo.cjsx +35 -0
  85. data/client/skr/screens/fresh-books-import/ChooseRecords.cjsx +116 -0
  86. data/client/skr/screens/fresh-books-import/FreshBooksImport.cjsx +31 -0
  87. data/client/skr/screens/fresh-books-import/Import.coffee +52 -0
  88. data/client/skr/screens/fresh-books-import/ViewRecords.cjsx +96 -0
  89. data/client/skr/screens/fresh-books-import/index.js +1 -0
  90. data/client/skr/screens/fresh-books-import/index.scss +39 -0
  91. data/client/skr/screens/gl-accounts/GlAccounts.cjsx +31 -0
  92. data/client/skr/screens/gl-accounts/index.js +5 -0
  93. data/client/skr/screens/gl-transactions/GlTransactions.cjsx +46 -0
  94. data/client/skr/screens/gl-transactions/index.js +1 -0
  95. data/client/skr/screens/gl-transactions/index.scss +12 -0
  96. data/client/skr/screens/invoice/Invoice.cjsx +92 -0
  97. data/client/skr/screens/invoice/Payment.cjsx +28 -0
  98. data/client/skr/screens/invoice/index.js +5 -0
  99. data/client/skr/screens/locations/Locations.cjsx +31 -0
  100. data/client/skr/screens/locations/index.js +5 -0
  101. data/client/skr/screens/payment-category/PaymentCategory.cjsx +28 -0
  102. data/client/skr/screens/payment-category/index.js +5 -0
  103. data/client/skr/screens/payment-category/index.scss +9 -0
  104. data/client/skr/screens/payment-terms/PaymentTerms.cjsx +28 -0
  105. data/client/skr/screens/payment-terms/index.js +5 -0
  106. data/client/skr/screens/payment-terms/index.scss +9 -0
  107. data/client/skr/screens/payments/Payments.cjsx +59 -0
  108. data/client/skr/screens/payments/index.js +5 -0
  109. data/client/skr/screens/sales-order/SalesOrder.cjsx +68 -0
  110. data/client/skr/screens/sales-order/index.js +1 -5
  111. data/client/skr/screens/sku-maint/SkuMaint.cjsx +53 -0
  112. data/client/skr/screens/sku-maint/SkuUomList.cjsx +209 -0
  113. data/client/skr/screens/sku-maint/index.js +2 -5
  114. data/client/skr/screens/sku-maint/index.scss +37 -6
  115. data/client/skr/screens/time-invoicing/TimeInvoicing.cjsx +156 -0
  116. data/client/skr/screens/time-invoicing/index.js +5 -0
  117. data/client/skr/screens/time-invoicing/index.scss +7 -0
  118. data/client/skr/screens/time-tracking/EditEntry.cjsx +54 -0
  119. data/client/skr/screens/time-tracking/Entries.coffee +132 -0
  120. data/client/skr/screens/time-tracking/Header.cjsx +71 -0
  121. data/client/skr/screens/time-tracking/Popover.cjsx +70 -0
  122. data/client/skr/screens/time-tracking/PopoverMiniControls.cjsx +25 -0
  123. data/client/skr/screens/time-tracking/TimeTracking.cjsx +63 -0
  124. data/client/skr/screens/time-tracking/WeekSummary.cjsx +16 -0
  125. data/client/skr/screens/time-tracking/index.js +1 -0
  126. data/client/skr/screens/time-tracking/index.scss +126 -0
  127. data/client/skr/screens/vendor-maint/VendorMaint.cjsx +45 -0
  128. data/client/skr/screens/vendor-maint/index.js +1 -5
  129. data/client/skr/styles.scss +1 -13
  130. data/config/puma.rb +4 -0
  131. data/config/routes.rb +21 -9
  132. data/config/screens.rb +147 -32
  133. data/db/migrate/20140202194700_create_skr_gl_transaction_details.rb +35 -0
  134. data/db/migrate/20140220031800_create_skr_locations.rb +2 -0
  135. data/db/migrate/20140220190836_create_skr_vendors.rb +1 -0
  136. data/db/migrate/20140220203029_create_skr_customers.rb +3 -2
  137. data/db/migrate/20140224034759_create_skr_skus.rb +2 -3
  138. data/db/migrate/20140322223912_create_skr_sales_orders.rb +4 -3
  139. data/db/migrate/20140322223920_create_skr_so_lines.rb +4 -5
  140. data/db/migrate/20140323001446_create_so_details_view.rb +7 -5
  141. data/db/migrate/20140327202209_create_skr_pt_lines.rb +2 -2
  142. data/db/migrate/20140327214000_create_customer_project.rb +16 -0
  143. data/db/migrate/20140327223002_create_time_entries.rb +17 -0
  144. data/db/migrate/20140327224000_create_skr_invoices.rb +5 -1
  145. data/db/migrate/20140327224002_create_skr_inv_lines.rb +3 -1
  146. data/db/migrate/20140422024010_create_skr_inv_details_view.rb +1 -1
  147. data/db/migrate/20151121211323_create_customer_project_details_views.rb +31 -0
  148. data/db/migrate/20160216142845_create_gl_account_balances_view.rb +20 -0
  149. data/db/migrate/20160229002044_create_bank_accounts.rb +18 -0
  150. data/db/migrate/20160229041711_create_payments.rb +33 -0
  151. data/db/migrate/20160307022705_create_create_combined_uom_views.rb +18 -0
  152. data/db/schema.sql +639 -140
  153. data/db/seed/chart_of_accounts.yml +8 -6
  154. data/db/seed/payment_categories.yml +12 -0
  155. data/db/seed/skus.yml +32 -0
  156. data/db/seed.rb +21 -0
  157. data/lib/skr/access_roles.rb +19 -6
  158. data/lib/skr/concerns/has_sku_loc_lines.rb +0 -16
  159. data/lib/skr/concerns/inv_extensions.rb +24 -0
  160. data/lib/skr/concerns/is_sku_loc_line.rb +3 -4
  161. data/lib/skr/concerns/so_extensions.rb +8 -0
  162. data/lib/skr/concerns/visible_id_identifier.rb +1 -1
  163. data/lib/skr/db/migration_helpers.rb +2 -4
  164. data/lib/skr/extension.rb +11 -4
  165. data/lib/skr/handlers/fresh_books_import.rb +20 -0
  166. data/lib/skr/handlers/invoice_from_time_entries.rb +49 -0
  167. data/lib/skr/jobs/fresh_books/base.rb +54 -0
  168. data/lib/skr/jobs/fresh_books/import.rb +151 -0
  169. data/lib/skr/jobs/fresh_books/retrieve.rb +62 -0
  170. data/lib/skr/model.rb +5 -0
  171. data/lib/skr/models/address.rb +1 -1
  172. data/lib/skr/models/bank_account.rb +13 -0
  173. data/lib/skr/models/business_entity.rb +3 -0
  174. data/lib/skr/models/customer.rb +1 -1
  175. data/lib/skr/models/customer_project.rb +22 -0
  176. data/lib/skr/models/gl_account.rb +13 -3
  177. data/lib/skr/models/gl_period.rb +6 -0
  178. data/lib/skr/models/gl_posting.rb +7 -4
  179. data/lib/skr/models/gl_transaction.rb +19 -33
  180. data/lib/skr/models/ia_line.rb +1 -1
  181. data/lib/skr/models/inv_line.rb +33 -15
  182. data/lib/skr/models/invoice.rb +47 -20
  183. data/lib/skr/models/location.rb +7 -1
  184. data/lib/skr/models/payment.rb +49 -0
  185. data/lib/skr/models/payment_category.rb +11 -0
  186. data/lib/skr/models/payment_term.rb +1 -1
  187. data/lib/skr/models/por_line.rb +1 -1
  188. data/lib/skr/models/pt_line.rb +1 -1
  189. data/lib/skr/models/sales_order.rb +9 -9
  190. data/lib/skr/models/sku_loc.rb +1 -1
  191. data/lib/skr/models/sku_tran.rb +6 -11
  192. data/lib/skr/models/so_line.rb +22 -12
  193. data/lib/skr/models/time_entry.rb +36 -0
  194. data/lib/skr/models/uom.rb +11 -10
  195. data/lib/skr/models/user_proxy.rb +1 -1
  196. data/lib/skr/number.rb +25 -0
  197. data/lib/skr/print/form.rb +46 -0
  198. data/lib/skr/print/template.rb +48 -0
  199. data/lib/skr/print.rb +11 -0
  200. data/lib/skr/string.rb +11 -0
  201. data/lib/skr/version.rb +1 -1
  202. data/lib/skr.rb +9 -0
  203. data/spec/fixtures/skr/address.yml +164 -4
  204. data/spec/fixtures/skr/bank_account.yml +8 -0
  205. data/spec/fixtures/skr/customer.yml +30 -4
  206. data/spec/fixtures/skr/customer_project.yml +20 -0
  207. data/spec/fixtures/skr/gl_account.yml +19 -1
  208. data/spec/fixtures/skr/gl_period.yml +3 -0
  209. data/spec/fixtures/skr/gl_posting.yml +22 -1
  210. data/spec/fixtures/skr/gl_transaction.yml +4 -1
  211. data/spec/fixtures/skr/inv_line.yml +35 -0
  212. data/spec/fixtures/skr/invoice.yml +13 -2
  213. data/spec/fixtures/skr/location.yml +5 -0
  214. data/spec/fixtures/skr/payment.yml +10 -0
  215. data/spec/fixtures/skr/payment_category.yml +8 -0
  216. data/spec/fixtures/skr/payment_term.yml +37 -3
  217. data/spec/fixtures/skr/sales_order.yml +12 -1
  218. data/spec/fixtures/skr/sku.yml +78 -1
  219. data/spec/fixtures/skr/sku_loc.yml +42 -1
  220. data/spec/fixtures/skr/sku_tran.yml +24 -1
  221. data/spec/fixtures/skr/so_line.yml +32 -0
  222. data/spec/fixtures/skr/time_entry.yml +82 -0
  223. data/spec/fixtures/skr/uom.yml +52 -1
  224. data/spec/fixtures/skr/vendor.yml +28 -1
  225. data/spec/fixtures/stockor.png +0 -0
  226. data/spec/server/bank_account_spec.rb +10 -0
  227. data/spec/server/customer_project_spec.rb +10 -0
  228. data/spec/server/handlers/invoice_from_time_entries_spec.rb +49 -0
  229. data/spec/server/jobs/fresh_books/import_spec.rb +69 -0
  230. data/spec/server/jobs/fresh_books/retrieve_spec.rb +37 -0
  231. data/spec/server/models/address_spec.rb +4 -3
  232. data/spec/server/models/gl_transaction_spec.rb +3 -3
  233. data/spec/server/models/inv_line_spec.rb +83 -3
  234. data/spec/server/models/invoice_spec.rb +32 -3
  235. data/spec/server/models/payment_spec.rb +40 -0
  236. data/spec/server/models/sales_order_spec.rb +1 -1
  237. data/spec/server/models/so_line_spec.rb +3 -3
  238. data/spec/server/models/spec_helper_spec.rb +1 -1
  239. data/spec/server/payment_spec.rb +10 -0
  240. data/spec/server/print/form_spec.rb +47 -0
  241. data/spec/server/print/template_spec.rb +36 -0
  242. data/spec/server/spec_helper.rb +14 -1
  243. data/spec/server/time_entry_spec.rb +10 -0
  244. data/spec/skr/components/SkuLinesSpec.coffee +61 -0
  245. data/spec/skr/models/BankAccountSpec.coffee +5 -0
  246. data/spec/skr/models/CustomerProjectSpec.coffee +5 -0
  247. data/spec/skr/models/CustomerSpec.coffee +2 -2
  248. data/spec/skr/models/PaymentSpec.coffee +5 -0
  249. data/spec/skr/models/SalesOrderSpec.coffee +21 -5
  250. data/spec/skr/models/SoLineSpec.coffee +7 -2
  251. data/spec/skr/models/TimeEntrySpec.coffee +5 -0
  252. data/spec/skr/screens/bank-maint/BankMaintSpec.coffee +5 -0
  253. data/spec/skr/screens/customer-projects/CustomerProjectsSpec.coffee +5 -0
  254. data/spec/skr/screens/fresh-books-import/FreshBooksImportSpec.coffee +1 -0
  255. data/spec/skr/screens/gl-accounts/GlAccountsSpec.coffee +5 -0
  256. data/spec/skr/screens/invoice/InvoiceSpec.coffee +5 -0
  257. data/spec/skr/screens/locations/LocationsSpec.coffee +5 -0
  258. data/spec/skr/screens/payment-category/PaymentCategorySpec.coffee +5 -0
  259. data/spec/skr/screens/payment-terms/PaymentTermsSpec.coffee +5 -0
  260. data/spec/skr/screens/payments/PaymentsSpec.coffee +5 -0
  261. data/spec/skr/screens/time-invoicing/TimeInvoicingSpec.coffee +5 -0
  262. data/spec/skr/screens/time-tracking/TimeTrackingSpec.coffee +14 -0
  263. data/spec/vcr/freshbooks.yml +698 -0
  264. data/stockor.gemspec +5 -1
  265. data/templates/print/fonts/GnuMICR.otf +0 -0
  266. data/templates/print/layout.tex.erb +39 -0
  267. data/templates/print/packages/booktabs.sty +182 -0
  268. data/templates/print/packages/fancybox.sty +966 -0
  269. data/templates/print/packages/fancyhdr.sty +485 -0
  270. data/templates/print/packages/graphbox.sty +129 -0
  271. data/templates/print/packages/lastpage.sty +283 -0
  272. data/templates/print/packages/lastpage209.sty +70 -0
  273. data/templates/print/packages/marginnote.sty +412 -0
  274. data/templates/print/packages/multirow.sty +159 -0
  275. data/templates/print/packages/rotating.sty +282 -0
  276. data/templates/print/packages/tabu.sty +2557 -0
  277. data/templates/print/packages/textpos.sty +361 -0
  278. data/templates/print/packages/varwidth.sty +318 -0
  279. data/templates/print/partials/address.tex.erb +6 -0
  280. data/templates/print/partials/bill_to_ship_to.tex.erb +13 -0
  281. data/templates/print/partials/header.tex.erb +13 -0
  282. data/templates/print/partials/invoice_paid_state.tex.erb +2 -0
  283. data/templates/print/partials/old/inv_lines_grouping.tex.erb +8 -0
  284. data/templates/print/partials/old/labor_lines_footer.tex.erb +18 -0
  285. data/templates/print/partials/skus_table.tex.erb +32 -0
  286. data/templates/print/partials/skus_table_col_hdr.tex.erb +8 -0
  287. data/templates/print/partials/skus_table_footer.tex.erb +5 -0
  288. data/templates/print/partials/skus_table_group_footer.tex.erb +4 -0
  289. data/templates/print/partials/skus_table_invoice_footer.tex.erb +25 -0
  290. data/templates/print/partials/skus_table_invoice_info_line.tex.erb +16 -0
  291. data/templates/print/partials/skus_table_labor_col_hdr.tex.erb +8 -0
  292. data/templates/print/partials/skus_table_labor_group_footer.tex.erb +7 -0
  293. data/templates/print/partials/skus_table_labor_line.tex.erb +11 -0
  294. data/templates/print/partials/skus_table_line.tex.erb +6 -0
  295. data/templates/print/partials/skus_table_other_charge_lines.tex.erb +7 -0
  296. data/templates/print/partials/so_info_line.tex.erb +14 -0
  297. data/templates/print/types/invoice/default.tex.erb +13 -0
  298. data/templates/print/types/invoice/labor.tex.erb +33 -0
  299. data/templates/print/types/payment/default.tex.erb +64 -0
  300. data/templates/print/types/sales-order/default.tex.erb +8 -0
  301. metadata +252 -15
  302. data/client/skr/components/address/address.html +0 -20
  303. data/client/skr/models/mixins/CodeField.coffee +0 -5
  304. data/client/skr/screens/customer-maint/index.scss +0 -11
  305. data/client/skr/screens/customer-maint/layout.html +0 -32
  306. data/client/skr/screens/sales-order/SalesOrder.coffee +0 -30
  307. data/client/skr/screens/sales-order/index.scss +0 -8
  308. data/client/skr/screens/sales-order/layout.html +0 -30
  309. data/client/skr/screens/sku-maint/SkuMaint.coffee +0 -18
  310. data/client/skr/screens/sku-maint/layout.html +0 -16
  311. data/client/skr/screens/vendor-maint/VendorMaint.coffee +0 -28
  312. data/client/skr/screens/vendor-maint/index.scss +0 -8
  313. data/client/skr/screens/vendor-maint/layout.html +0 -32
@@ -11,6 +11,7 @@ module Skr
11
11
  # end
12
12
  # so.save
13
13
  #
14
+
14
15
  # invoice = Invoice.new( sales_order: so )
15
16
  # invoice.lines.from_sales_order!
16
17
  # invoice.save
@@ -41,23 +42,20 @@ module Skr
41
42
  after_save :check_if_location_changed
42
43
  before_validation :set_defaults, on: :create
43
44
 
44
- delegate_and_export :customer_code, :customer_name
45
- delegate_and_export :location_code, :location_name
46
- delegate_and_export :terms_code, :terms_description
47
45
  delegate_and_export :billing_address_name
48
46
 
49
-
50
47
  # joins the so_amount_details view which includes additional fields:
51
48
  # customer_code, customer_name, bill_addr_name, total, num_lines, total_other_charge_amount,
52
49
  # total_tax_amount, total_shipping_amount,subtotal_amount
53
- scope :with_amount_details, lambda { | *args |
54
- compose_query_using_detail_view(view: 'so_amount_details', join_to: 'sales_order_id')
50
+
51
+ scope :with_details, lambda { | *args |
52
+ compose_query_using_detail_view(view: 'skr_so_details')
55
53
  }, export: true
56
54
 
57
55
  # joins the so_allocation_details which includes the additional fields:
58
56
  # number_of_lines, allocated_total, number_of_lines_allocated, number_of_lines_fully_allocated
59
57
  scope :with_allocation_details, lambda {
60
- compose_query_using_detail_view(view: 'so_allocation_details', join_to: 'sales_order_id')
58
+ compose_query_using_detail_view(view: 'skr_so_allocation_details')
61
59
  }
62
60
 
63
61
  # a open SalesOrder is one who's state is not "complete" or "canceled"
@@ -111,7 +109,8 @@ module Skr
111
109
 
112
110
  def initialize(attributes = {})
113
111
  super
114
- self.order_date = Date.today
112
+ # order date must be set, otherwise things like terms that are set from it fail
113
+ self.order_date ||= Date.today
115
114
  end
116
115
 
117
116
  private
@@ -157,7 +156,8 @@ module Skr
157
156
 
158
157
  def set_defaults
159
158
  if customer
160
- self.billing_address = customer.billing_address if self.billing_address.blank?
159
+ self.form ||= customer.get_form('invoice')
160
+ self.billing_address = customer.billing_address if self.billing_address.blank?
161
161
  self.shipping_address = customer.shipping_address if self.shipping_address.blank?
162
162
  end
163
163
  end
@@ -76,7 +76,7 @@ module Skr
76
76
  private
77
77
 
78
78
  def fire_after_save_events
79
- fire_event(:qty_change) if qty_changed?
79
+ fire_pubsub_event(:qty_change) if qty_changed?
80
80
  end
81
81
 
82
82
  # Caches the qty of skus that are allocated to sales orders in the {#qty_allocated} field
@@ -47,11 +47,6 @@ module Skr
47
47
  self.qty * ( self.uom_size || 1 )
48
48
  end
49
49
 
50
- # @return [String] a description intended for use by the #{GlTransaction}
51
- # def description_for_gl_transaction(gl)
52
- # self.origin_description
53
- # end
54
-
55
50
  private
56
51
 
57
52
  # sets {#mac} to the correct amount for the {SkuLoc}.
@@ -72,18 +67,19 @@ module Skr
72
67
 
73
68
  # If {#cost} is non-zero, then create a {GlTransaction}
74
69
  def create_needed_gl_transaction
75
- Skr::Core.logger.debug "Recording SkuTran in GL, mac is: #{self.mac}, cost = #{cost}"
70
+ Lanes.logger.debug "Recording SkuTran in GL, mac is: #{self.mac}, cost = #{cost}"
76
71
  return if self.cost.nil? || self.cost.zero?
77
72
  GlTransaction.push_or_save(
78
- owner: self, amount: cost,
79
- debit: debit_gl_account, credit: credit_gl_account
73
+ owner: self, amount: cost,
74
+ debit: debit_gl_account, credit: credit_gl_account,
75
+ options: {description: origin_description}
80
76
  )
81
77
  end
82
78
 
83
79
  # Adjusts {SkuLoc#qty} by {#ea_qty}
84
80
  def adjust_sku_loc_values
85
81
  sl = self.sku_loc
86
- Skr::Core.logger.debug "Adj +#{ea_qty} Sku #{sl.sku.code} location #{location.code} " +
82
+ Lanes.logger.debug "Adj +#{ea_qty} Sku #{sl.sku.code} location #{location.code} " +
87
83
  "from MAC: #{sl.mac} to #{self.mac}, qty: #{sl.qty} += #{ea_qty} #{combined_uom}"
88
84
  sl.unlock_fields( :qty, :mac ) do
89
85
  sl.mac = self.mac unless self.mac.nan? or self.mac.zero?
@@ -92,8 +88,7 @@ module Skr
92
88
  end
93
89
  sl.reload
94
90
  sl.allocate_available_qty! if self.allocate_after_save
95
-
96
- Skr::Core.logger.debug "After Adj Qty #{sl.qty}"
91
+ Lanes.logger.debug "After Adj Qty #{sl.qty}"
97
92
  end
98
93
 
99
94
  def ensure_cost_and_qty_present
@@ -10,9 +10,12 @@ module Skr
10
10
  has_one :sku, :through => :sku_loc, export: true
11
11
  has_one :location, :through => :sales_order
12
12
  has_many :pt_lines, :before_add=>:setup_new_pt_line, :inverse_of=>:so_line,
13
- extend: Concerns::PT::Lines, :listen=>{save:'update_qty_picking'}
13
+ extend: Concerns::PT::Lines, :listen=>{save: :update_qty_picking}
14
14
 
15
- # has_many :inv_lines, :before_add=>:setup_new_inv_line, :inverse_of=>:so_line
15
+ has_many :inv_lines, :before_add=>:setup_new_inv_line, :inverse_of=>:so_line,
16
+ extend: Concerns::INV::Lines, :listen=>{save: :update_qty_invoiced}
17
+
18
+ has_many :uom_choices, :through => :sku, :source => :uoms, export: true
16
19
 
17
20
  validates :sales_order, :sku_loc, set: true
18
21
 
@@ -23,7 +26,7 @@ module Skr
23
26
 
24
27
  has_additional_events :qty_change
25
28
 
26
- before_validation :set_defaults_from_associations
29
+ before_validation :set_defaults_from_associations
27
30
  before_create :allocate_max_available
28
31
  before_destroy :ensure_deleteable
29
32
 
@@ -70,21 +73,26 @@ module Skr
70
73
  pt_lines.picking.each{ |ptl| ptl.cancel! }
71
74
  end
72
75
 
76
+ def total
77
+ qty * price
78
+ end
79
+
73
80
  private
74
81
 
75
- def update_qty_shipped
76
- inv_qty = self.inv_lines.sum(:qty)
77
- update_attributes( :qty_invoiced=> inv_qty, :qty_allocated => [ qty_allocated - inv_qty, 0 ].max )
82
+ def update_qty_invoiced(inv = nil)
83
+ inv_qty = inv_lines.ea_qty/uom_size
84
+ update_attributes( :qty_invoiced=> inv_qty,
85
+ :qty_allocated => [ qty_allocated - inv_qty, 0 ].max )
78
86
  end
79
- def update_qty_picking( pt=nil )
87
+
88
+ def update_qty_picking(pt = nil)
80
89
  update_attributes( :qty_picking=> pt_lines.ea_picking_qty/uom_size )
81
90
  end
82
91
 
83
-
84
92
  def fire_after_save_events
85
93
  %w{ allocated picking invoiced canceled }.each do | event |
86
94
  if changes[ "qty_#{event}" ]
87
- fire_event( :qty_change )
95
+ fire_pubsub_event( :qty_change )
88
96
  break
89
97
  end
90
98
  end
@@ -93,10 +101,12 @@ module Skr
93
101
 
94
102
  def set_defaults_from_associations
95
103
  self.uom = sku.uoms.default if self.uom_code.blank?
96
- self.description = sku.description if self.description.blank?
97
- self.sku_code = sku.code if self.sku_code.blank?
104
+ self.description = sku.description if self.description.blank?
105
+ self.sku_code = sku.code
98
106
  if !price && sales_order && sales_order.customer && sku_loc && uom.present?
99
- self.price = Skr.config.pricing_provider.price(sku_loc:sku_loc, customer:sales_order.customer, uom:uom, qty:qty)
107
+ self.price = Skr.config.pricing_provider.price(
108
+ sku_loc:sku_loc, customer:sales_order.customer, uom:uom, qty:qty
109
+ )
100
110
  end
101
111
  true
102
112
  end
@@ -0,0 +1,36 @@
1
+ module Skr
2
+
3
+ class TimeEntry < Model
4
+
5
+ belongs_to :customer_project, inverse_of: :time_entries, export: true
6
+
7
+ belongs_to :lanes_user, class_name: 'Lanes::User', export: true
8
+
9
+ validates :start_at, :end_at, :description, presence: true
10
+
11
+ validates :customer_project, :lanes_user, set: true
12
+
13
+
14
+ has_one :inv_line, inverse_of: :time_entry, listen: { create: :mark_as_invoiced }
15
+
16
+ export_sort :hours do | q, dir |
17
+ q.order("end_at-start_at #{dir}")
18
+ end
19
+
20
+ def hours
21
+ (end_at - start_at) / 1.hour
22
+ end
23
+
24
+ scope :open, ->{
25
+ where(is_invoiced: false)
26
+ }
27
+
28
+ private
29
+
30
+ def mark_as_invoiced(inv_line)
31
+ update_attributes(is_invoiced: true)
32
+ end
33
+
34
+ end
35
+
36
+ end
@@ -12,6 +12,10 @@ module Skr
12
12
 
13
13
  export_methods :combined_uom, mandatory: true
14
14
 
15
+ scope :with_combined_uom, lambda { | *args |
16
+ compose_query_using_detail_view(view: 'skr_combined_uom')
17
+ }, export: true
18
+
15
19
  def combined_uom
16
20
  if self.size.nil? || self.code.nil?
17
21
  ''
@@ -47,17 +51,14 @@ module Skr
47
51
  Uom.new({ :code=>'EA',:size=>1, :price=>0.0 })
48
52
  end
49
53
 
54
+ export_scope :for_sku_loc, lambda{ | sku_loc_id = nil |
55
+ if sku_loc_id
56
+ Skr::Uom.joins(sku: [:sku_locs]).where(Skr::SkuLoc.table_name => {id: sku_loc_id})
57
+ else
58
+ Skr::Uom.none
59
+ end
60
+ }
50
61
  end
51
62
 
52
63
 
53
64
  end # Skr module
54
-
55
-
56
- __END__
57
-
58
- def for_public(user=nil,options={})
59
- as_json({
60
- :only=>%w{ code size base_price },
61
- :methods=>%w{ combined_uom dimensions volume }
62
- })
63
- end
@@ -1,7 +1,7 @@
1
1
  module Skr
2
2
 
3
3
  # The UserProxy is a stand-in for the real user
4
- # model that will be implementation specific by the user of Stockor Core
4
+ # model that will be implementation specific by the user of Stockor
5
5
  class UserProxy
6
6
 
7
7
  # The user who's currently interacting with Stockor.
data/lib/skr/number.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'numbers_in_words'
2
+
3
+ module Skr
4
+
5
+ module Number
6
+
7
+ def self.ordinalize(number)
8
+ if (11..13).include?(number % 100)
9
+ "#{number}th"
10
+ else
11
+ case number % 10
12
+ when 1; "#{number}st"
13
+ when 2; "#{number}nd"
14
+ when 3; "#{number}rd"
15
+ else "#{number}th"
16
+ end
17
+ end
18
+ end
19
+
20
+ def self.as_words(number)
21
+ NumbersInWords.in_words(number)
22
+ end
23
+ end
24
+
25
+ end
@@ -0,0 +1,46 @@
1
+ module Skr
2
+ module Print
3
+
4
+ class Form
5
+
6
+ def initialize(form, code)
7
+ @template = Template.get(form) || raise("Unable to find template for #{form}")
8
+ @record = @template.model.where(hash_code: code).first!
9
+ @latex = @template.path_for_record(@record)
10
+ unless @latex.exist?
11
+ raise("Unable to find template type for record")
12
+ end
13
+ Lanes.logger.debug "Printing #{form} #{code} using #{@latex}"
14
+ end
15
+
16
+ def as_pdf
17
+ template.to_stringio
18
+ end
19
+
20
+ def as_latex
21
+ template.compile_latex
22
+ end
23
+
24
+ def data
25
+ vars = {
26
+ @template.name.underscore => @record,
27
+ 'root_path' => ::Skr::Print::ROOT
28
+ }
29
+ if @record.respond_to?(:latex_template_variables)
30
+ vars.merge!(@record.latex_template_variables)
31
+ end
32
+ vars
33
+ end
34
+
35
+ def template
36
+ ErbLatex::Template.new( @latex,
37
+ data: data,
38
+ layout: ROOT.join('layout.tex.erb'),
39
+ partials_path: ROOT.join('partials'),
40
+ packages_path: ROOT.join('packages')
41
+ )
42
+ end
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,48 @@
1
+ module Skr
2
+ module Print
3
+ class Template
4
+
5
+ class Definition
6
+ def initialize(path)
7
+ @path = path
8
+ end
9
+ def name
10
+ @path.basename.to_s
11
+ end
12
+ def choices
13
+ Pathname.glob(@path.join('*.tex.erb')).map{|pn|
14
+ pn.basename('.tex.erb').to_s
15
+ }
16
+ end
17
+ def model
18
+ "skr/#{name}".underscore.classify.constantize
19
+ end
20
+ def path_for_record(record)
21
+ form = record.respond_to?(:form) ? record.form : 'default'
22
+ path = @path.join( form + '.tex.erb' )
23
+ path.exist? ? path : @path.join( 'default.tex.erb' )
24
+ end
25
+ end
26
+
27
+ def self.get(type)
28
+ Definition.new( Skr::Print::ROOT.join('types', type ) )
29
+ end
30
+
31
+ def self.definitions
32
+ Pathname.glob(Skr::Print::ROOT.join('types','*')).select { | type |
33
+ type.directory?
34
+ }.map { | type |
35
+ Definition.new( type )
36
+ }
37
+ end
38
+
39
+ def self.as_json
40
+ json={}
41
+ definitions.each do | definition |
42
+ json[definition.name] = definition.choices
43
+ end
44
+ json
45
+ end
46
+ end
47
+ end
48
+ end
data/lib/skr/print.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'erb_latex'
2
+ # need ordinalize
3
+ require 'active_support/core_ext/integer/inflections'
4
+ require_relative 'print/template'
5
+ require_relative 'print/form'
6
+
7
+ module Skr
8
+ module Print
9
+ ROOT = Pathname.new(__FILE__).dirname.join("../../templates/print")
10
+ end
11
+ end
data/lib/skr/string.rb ADDED
@@ -0,0 +1,11 @@
1
+ module Skr
2
+
3
+ module String
4
+
5
+ def self.number_with_delimiter(number)
6
+ ('%0.2f' % number).reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse
7
+ end
8
+
9
+ end
10
+
11
+ end
data/lib/skr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Skr
2
- VERSION='0.1.9'
2
+ VERSION='0.2'
3
3
  end
data/lib/skr.rb CHANGED
@@ -4,14 +4,23 @@ require "lanes/access"
4
4
  require_relative "skr/version"
5
5
  require_relative "skr/extension"
6
6
  require_rel "skr/configuration"
7
+ require_relative "skr/string"
8
+ require_relative "skr/number"
7
9
 
8
10
  # The main namespace for Skr
9
11
  module Skr
10
12
  def self.table_name_prefix
11
13
  "skr_"
12
14
  end
15
+
16
+ def self.system_settings
17
+ Lanes::SystemSettings.for_ext('skr')
18
+ end
13
19
  end
14
20
 
15
21
  require_rel "skr/concerns/*.rb"
22
+ require_rel "skr/jobs/fresh_books/*.rb"
23
+ require_relative "skr/print"
16
24
  require_relative "skr/model"
17
25
  require_relative "skr/access_roles"
26
+ require_rel "skr/handlers/*.rb"
@@ -1,10 +1,170 @@
1
1
  # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+ bigco:
3
+ name: Big Co Inc
4
+ email: biggy@huge.com
5
+ phone: "(746) 280-8087"
6
+ line1: 1 sweet spot
7
+ line2:
8
+ city: NY
9
+ state: NY
10
+ postal_code: '12345'
11
+
12
+ bigcobank:
13
+ name: Big Co First Federal Bankcorp
14
+ email: bigbank@biggybank.com
15
+ phone: "(888) 555-5555"
16
+ line1: 1 banking lane
17
+ line2:
18
+ city: NY
19
+ state: NY
20
+ postal_code: '12345'
21
+
22
+ surplus:
23
+ name: Big Co Surplus Location
24
+ email: biggy@huge.com
25
+ phone: "(746) 280-8087"
26
+ line1: 1 sour spot
27
+ line2:
28
+ city: NY
29
+ state: NY
30
+ postal_code: '12345'
2
31
 
3
32
  billy_billing:
4
- name: Billy Goat
33
+ name: Billy Goat Accounting Dept
34
+ email: yadira_greenholt@moorefeest.biz
35
+ phone: "(746) 280-8087"
36
+ line1: 59031 Hyatt Shores
37
+ line2:
38
+ city: West Marisoltown
39
+ state: SD
40
+ postal_code: '35962'
5
41
 
6
42
  billy_shipping:
7
- name: Billy Goat
43
+ name: Billy Goat Warehouse
44
+ email: lavina_gislason@kleincollier.org
45
+ phone: 1-589-299-1175 x4979
46
+ line1: 61852 Reina Prairie
47
+ line2:
48
+ city: Dylanland
49
+ state: DE
8
50
 
9
- bigco:
10
- name: BigCo
51
+ mh_billing:
52
+ name: Old Mother Hubbard Acct
53
+ email: carson_larkin@marquardtaltenwerth.com
54
+ phone: 524-543-4297 x9823
55
+ line1: 90025 Heller Route
56
+ line2:
57
+ city: Edwinfurt
58
+ state: CA
59
+ postal_code: '51050'
60
+
61
+ mh_shipping:
62
+ name: Old Mother Hubbard Shipping
63
+ name: Schuster Inc
64
+ email: sylvia.corwin@pagacdaniel.com
65
+ phone: 505-827-2322
66
+ line1: 65226 Considine Extension
67
+ line2:
68
+ city: Cassinstad
69
+ state: IA
70
+ postal_code: '59352'
71
+
72
+ rump_billing:
73
+ name: Rumpelstiltskin
74
+ email: camylle.ruecker@bogisichrenner.org
75
+ phone: 406.840.2304
76
+ line1: 2432 Lakin Flats
77
+ line2:
78
+ city: Prosaccofort
79
+ state: AR
80
+ postal_code: 26934-1306
81
+
82
+ rump_shipping:
83
+ name: Rumpelstiltskin WH
84
+ email: amara@lakin.info
85
+ phone: 470-901-2264 x4376
86
+ line1: 269 Rice Way
87
+ line2:
88
+ city: Joellemouth
89
+ state: SD
90
+ postal_code: '20381'
91
+
92
+ sb_billing:
93
+ name: Sleeping Beauty
94
+ email: sibyl_ratke@baumbach.net
95
+ phone: "(696) 093-4427 x318"
96
+ line1: 33001 Lorenz Tunnel
97
+ line2:
98
+ city: McCulloughborough
99
+ state: NH
100
+ postal_code: '39964'
101
+
102
+ sb_shipping:
103
+ name: Sleeping Beauty Industrial
104
+ email: cornelius.vonrueden@hegmann.name
105
+ phone: 1-572-456-4445 x145
106
+ line1: 2150 Muller Extension
107
+ line2:
108
+ city: Naderhaven
109
+ state: MA
110
+ postal_code: '94287'
111
+
112
+ sw_billing:
113
+ name: Snow White
114
+ email: kathlyn.effertz@luettgengulgowski.biz
115
+ phone: 1-198-363-0174 x619
116
+ line1: 199 Armstrong Lights
117
+ line2:
118
+ city: South Aida
119
+ state: SD
120
+ postal_code: 27528-6163
121
+
122
+ sw_shipping:
123
+ name: Snow White and Dwarfs
124
+ email: davonte@casperjast.net
125
+ phone: 853.834.6574 x86228
126
+ line1: 8887 Coty Vista
127
+ line2:
128
+ city: East Coralietown
129
+ state: HI
130
+ postal_code: '71157'
131
+
132
+ hg_billing:
133
+ name: Hansel and Gretel
134
+ email: schuyler@krajcik.name
135
+ phone: 379-772-4947 x945
136
+ line1: 499 Julianne Radial
137
+ line2:
138
+ city: South Timmyville
139
+ state: WI
140
+ postal_code: '38200'
141
+
142
+ hg_shipping:
143
+ name: Hansel and Gretel
144
+ email: marilie_haley@christiansen.name
145
+ phone: 158-160-0857
146
+ line1: 447 Mraz Port
147
+ line2:
148
+ city: North Markusborough
149
+ state: MS
150
+ postal_code: '51700'
151
+
152
+ cinder_billing:
153
+ name: Evil Stepmom Inc
154
+ email: cinderalla@mom.com
155
+ phone: 158-160-0857
156
+ line1: 4 City Way
157
+ line2:
158
+ city: Johnston City
159
+ state: IL
160
+ postal_code: '91500'
161
+
162
+ cinder_shipping:
163
+ name: Evl Stepmom WH
164
+ email: cinderalla@mom.com
165
+ phone: 158-160-0857
166
+ line1: 19th St WH District
167
+ line2:
168
+ city: Johnston City
169
+ state: IL
170
+ postal_code: '91500'
@@ -0,0 +1,8 @@
1
+ checking:
2
+ code: CHECKING
3
+ name: A test checking account
4
+ description: My test account
5
+ routing_number: 12345
6
+ account_number: 123456789
7
+ address: bigcobank
8
+ gl_account: bank_checking
@@ -1,9 +1,35 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
-
3
1
  billy:
4
2
  code: GOAT
5
3
  name: Billy Goat Gruff
6
- terms: cashy
7
- gl_receivables_account: recv
4
+ terms: cash
5
+ notes: Don't allow into the loading dock, eats all the things
6
+ gl_receivables_account: ar
8
7
  billing_address: billy_billing
9
8
  shipping_address: billy_shipping
9
+
10
+ hubbard:
11
+ code: HUBBARD
12
+ name: Old Mother Hubbard
13
+ terms: net30
14
+ notes: Always ask how her children are doing
15
+ gl_receivables_account: ar
16
+ billing_address: mh_billing
17
+ shipping_address: mh_shipping
18
+
19
+ sb:
20
+ code: SLEEPYB
21
+ name: Sleeping Beauty
22
+ terms: credcard
23
+ notes: Do not sell any sleep aids to
24
+ gl_receivables_account: ar
25
+ billing_address: sb_billing
26
+ shipping_address: sb_shipping
27
+
28
+ sw:
29
+ code: SNOWWHITE
30
+ name: Snow White
31
+ terms: check
32
+ notes: Mention gifts for Prince Charming
33
+ gl_receivables_account: ar
34
+ billing_address: sw_billing
35
+ shipping_address: sw_shipping
@@ -0,0 +1,20 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ goatpens:
4
+ code: PENS
5
+ description: Building goat pens
6
+ po_num: gruffy
7
+ sku: labor
8
+ customer: billy
9
+ options: { color: 2 }
10
+ rates: { 'hourly': 25.00 }
11
+
12
+
13
+ mirror:
14
+ code: MIRROR
15
+ description: Create magic mirror
16
+ po_num: STEP-MOM GIFT
17
+ sku: labor
18
+ customer: sb
19
+ options: { color: 4 }
20
+ rates: { 'hourly': 85.00 }