stockor 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/Gemfile +11 -0
  4. data/Gemfile.lock +220 -0
  5. data/Guardfile +13 -0
  6. data/README.md +7 -0
  7. data/Rakefile +7 -0
  8. data/client/skr/Extension.coffee +12 -0
  9. data/client/skr/components/.gitkeep +0 -0
  10. data/client/skr/components/address/Address.coffee +21 -0
  11. data/client/skr/components/address/address.html +20 -0
  12. data/client/skr/index.js +21 -0
  13. data/client/skr/models/Address.coffee +17 -0
  14. data/client/skr/models/Base.coffee +8 -0
  15. data/client/skr/models/Customer.coffee +26 -0
  16. data/client/skr/models/GlAccount.coffee +10 -0
  17. data/client/skr/models/GlManualEntry.coffee +11 -0
  18. data/client/skr/models/GlPeriod.coffee +10 -0
  19. data/client/skr/models/GlPosting.coffee +15 -0
  20. data/client/skr/models/GlTransaction.coffee +16 -0
  21. data/client/skr/models/IaLine.coffee +19 -0
  22. data/client/skr/models/IaReason.coffee +12 -0
  23. data/client/skr/models/InvLine.coffee +27 -0
  24. data/client/skr/models/InventoryAdjustment.coffee +17 -0
  25. data/client/skr/models/Invoice.coffee +31 -0
  26. data/client/skr/models/Location.coffee +15 -0
  27. data/client/skr/models/PaymentTerm.coffee +11 -0
  28. data/client/skr/models/PickTicket.coffee +19 -0
  29. data/client/skr/models/PoLine.coffee +27 -0
  30. data/client/skr/models/PoReceipt.coffee +20 -0
  31. data/client/skr/models/PorLine.coffee +26 -0
  32. data/client/skr/models/PtLine.coffee +27 -0
  33. data/client/skr/models/PurchaseOrder.coffee +23 -0
  34. data/client/skr/models/SalesOrder.coffee +32 -0
  35. data/client/skr/models/Sku.coffee +21 -0
  36. data/client/skr/models/SkuLoc.coffee +21 -0
  37. data/client/skr/models/SkuTran.coffee +23 -0
  38. data/client/skr/models/SkuVendor.coffee +19 -0
  39. data/client/skr/models/SoLine.coffee +27 -0
  40. data/client/skr/models/Uom.coffee +17 -0
  41. data/client/skr/models/Vendor.coffee +28 -0
  42. data/client/skr/models/VoLine.coffee +23 -0
  43. data/client/skr/models/Voucher.coffee +22 -0
  44. data/client/skr/models/mixins/CodeField.coffee +5 -0
  45. data/client/skr/screens/.gitkeep +0 -0
  46. data/client/skr/screens/Base.coffee +3 -0
  47. data/client/skr/screens/base/index.js +5 -0
  48. data/client/skr/screens/base/index.scss +9 -0
  49. data/client/skr/screens/base/layout.html +3 -0
  50. data/client/skr/screens/customer-maint/CustomerMaint.coffee +49 -0
  51. data/client/skr/screens/customer-maint/index.js +5 -0
  52. data/client/skr/screens/customer-maint/index.scss +9 -0
  53. data/client/skr/screens/customer-maint/layout.html +32 -0
  54. data/client/skr/styles.scss +1 -0
  55. data/client/skr/views/.gitkeep +0 -0
  56. data/client/skr/views/Base.coffee +5 -0
  57. data/config/database.yml +9 -0
  58. data/config/lanes.rb +7 -0
  59. data/config/routes.rb +39 -0
  60. data/config/screens.rb +17 -0
  61. data/config.ru +5 -0
  62. data/db/.gitkeep +0 -0
  63. data/db/migrate/20120110142845_create_skr_sequential_ids.rb +35 -0
  64. data/db/migrate/20140202185309_create_skr_gl_accounts.rb +15 -0
  65. data/db/migrate/20140202193316_create_skr_gl_periods.rb +16 -0
  66. data/db/migrate/20140202193318_create_skr_gl_transactions.rb +14 -0
  67. data/db/migrate/20140202193319_create_skr_gl_postings.rb +16 -0
  68. data/db/migrate/20140202193700_create_skr_gl_manual_entries.rb +13 -0
  69. data/db/migrate/20140213040608_create_skr_payment_terms.rb +16 -0
  70. data/db/migrate/20140220031700_create_skr_addresses.rb +19 -0
  71. data/db/migrate/20140220031800_create_skr_locations.rb +19 -0
  72. data/db/migrate/20140220190836_create_skr_vendors.rb +22 -0
  73. data/db/migrate/20140220203029_create_skr_customers.rb +22 -0
  74. data/db/migrate/20140224034759_create_skr_skus.rb +22 -0
  75. data/db/migrate/20140225032853_create_skr_sku_locs.rb +21 -0
  76. data/db/migrate/20140320030501_create_skr_uoms.rb +19 -0
  77. data/db/migrate/20140321031604_create_skr_sku_vendors.rb +18 -0
  78. data/db/migrate/20140322012143_create_skr_ia_reasons.rb +14 -0
  79. data/db/migrate/20140322014401_create_skr_inventory_adjustments.rb +16 -0
  80. data/db/migrate/20140322023453_create_skr_ia_lines.rb +18 -0
  81. data/db/migrate/20140322035024_create_skr_sku_trans.rb +21 -0
  82. data/db/migrate/20140322223912_create_skr_sales_orders.rb +27 -0
  83. data/db/migrate/20140322223920_create_skr_so_lines.rb +25 -0
  84. data/db/migrate/20140323001446_create_so_details_view.rb +81 -0
  85. data/db/migrate/20140327202102_create_skr_purchase_orders.rb +20 -0
  86. data/db/migrate/20140327202107_create_skr_po_lines.rb +25 -0
  87. data/db/migrate/20140327202207_create_skr_pick_tickets.rb +16 -0
  88. data/db/migrate/20140327202209_create_skr_pt_lines.rb +23 -0
  89. data/db/migrate/20140327224000_create_skr_invoices.rb +25 -0
  90. data/db/migrate/20140327224002_create_skr_inv_lines.rb +23 -0
  91. data/db/migrate/20140330232808_create_skr_sku_loc_details_view.rb +31 -0
  92. data/db/migrate/20140330232810_create_skr_sku_qty_details_view.rb +48 -0
  93. data/db/migrate/20140400164729_create_skr_vouchers.rb +22 -0
  94. data/db/migrate/20140400164733_create_skr_vo_lines.rb +21 -0
  95. data/db/migrate/20140401164729_create_skr_po_receipt.rb +16 -0
  96. data/db/migrate/20140401164740_create_skr_por_line.rb +21 -0
  97. data/db/migrate/20140422024010_create_skr_inv_details_view.rb +42 -0
  98. data/db/schema.sql +2662 -0
  99. data/db/seed/chart_of_accounts.yml +168 -0
  100. data/db/seed/payment_terms.yml +60 -0
  101. data/db/seed.rb +29 -0
  102. data/lib/skr/access_roles.rb +28 -0
  103. data/lib/skr/concerns/acts_as_uom.rb +47 -0
  104. data/lib/skr/concerns/code_identifier.rb +43 -0
  105. data/lib/skr/concerns/gl_tran_extensions.rb +18 -0
  106. data/lib/skr/concerns/has_gl_transaction.rb +67 -0
  107. data/lib/skr/concerns/has_sku_loc_lines.rb +47 -0
  108. data/lib/skr/concerns/immutable_model.rb +32 -0
  109. data/lib/skr/concerns/inv_extensions.rb +24 -0
  110. data/lib/skr/concerns/is_order_like.rb +47 -0
  111. data/lib/skr/concerns/is_sku_loc_line.rb +65 -0
  112. data/lib/skr/concerns/locked_fields.rb +84 -0
  113. data/lib/skr/concerns/pt_extensions.rb +22 -0
  114. data/lib/skr/concerns/random_hash_code.rb +40 -0
  115. data/lib/skr/concerns/so_extensions.rb +30 -0
  116. data/lib/skr/concerns/state_machine.rb +61 -0
  117. data/lib/skr/concerns/visible_id_identifier.rb +53 -0
  118. data/lib/skr/configuration.rb +68 -0
  119. data/lib/skr/db/migration_helpers.rb +178 -0
  120. data/lib/skr/extension.rb +23 -0
  121. data/lib/skr/model.rb +19 -0
  122. data/lib/skr/models/address.rb +97 -0
  123. data/lib/skr/models/business_entity.rb +29 -0
  124. data/lib/skr/models/customer.rb +35 -0
  125. data/lib/skr/models/gl_account.rb +56 -0
  126. data/lib/skr/models/gl_manual_entry.rb +31 -0
  127. data/lib/skr/models/gl_period.rb +13 -0
  128. data/lib/skr/models/gl_posting.rb +54 -0
  129. data/lib/skr/models/gl_transaction.rb +175 -0
  130. data/lib/skr/models/ia_line.rb +129 -0
  131. data/lib/skr/models/ia_reason.rb +16 -0
  132. data/lib/skr/models/inv_line.rb +90 -0
  133. data/lib/skr/models/inventory_adjustment.rb +60 -0
  134. data/lib/skr/models/invoice.rb +159 -0
  135. data/lib/skr/models/location.rb +31 -0
  136. data/lib/skr/models/payment_term.rb +30 -0
  137. data/lib/skr/models/pick_ticket.rb +71 -0
  138. data/lib/skr/models/po_line.rb +69 -0
  139. data/lib/skr/models/po_receipt.rb +51 -0
  140. data/lib/skr/models/por_line.rb +80 -0
  141. data/lib/skr/models/pt_line.rb +74 -0
  142. data/lib/skr/models/purchase_order.rb +112 -0
  143. data/lib/skr/models/sales_order.rb +159 -0
  144. data/lib/skr/models/sequential_id.rb +23 -0
  145. data/lib/skr/models/sku.rb +99 -0
  146. data/lib/skr/models/sku_loc.rb +94 -0
  147. data/lib/skr/models/sku_tran.rb +111 -0
  148. data/lib/skr/models/sku_vendor.rb +26 -0
  149. data/lib/skr/models/so_line.rb +159 -0
  150. data/lib/skr/models/uom.rb +63 -0
  151. data/lib/skr/models/user_proxy.rb +60 -0
  152. data/lib/skr/models/vendor.rb +33 -0
  153. data/lib/skr/models/vo_line.rb +35 -0
  154. data/lib/skr/models/voucher.rb +119 -0
  155. data/lib/skr/standard_pricing_provider.rb +14 -0
  156. data/lib/skr/version.rb +3 -0
  157. data/lib/skr.rb +18 -0
  158. data/lib/stockor.rb +4 -0
  159. data/lib/tasks/debug-activity.rake +58 -0
  160. data/log/test.log +0 -0
  161. data/spec/fixtures/skr/address.yml +2 -0
  162. data/spec/fixtures/skr/customer.yml +2 -0
  163. data/spec/fixtures/skr/gl_account.yml +2 -0
  164. data/spec/fixtures/skr/gl_manual_entry.yml +2 -0
  165. data/spec/fixtures/skr/gl_period.yml +2 -0
  166. data/spec/fixtures/skr/gl_posting.yml +2 -0
  167. data/spec/fixtures/skr/gl_transaction.yml +2 -0
  168. data/spec/fixtures/skr/ia_line.yml +2 -0
  169. data/spec/fixtures/skr/ia_reason.yml +2 -0
  170. data/spec/fixtures/skr/inv_line.yml +2 -0
  171. data/spec/fixtures/skr/inventory_adjustment.yml +2 -0
  172. data/spec/fixtures/skr/invoice.yml +2 -0
  173. data/spec/fixtures/skr/location.yml +2 -0
  174. data/spec/fixtures/skr/payment_term.yml +2 -0
  175. data/spec/fixtures/skr/pick_ticket.yml +2 -0
  176. data/spec/fixtures/skr/po_line.yml +2 -0
  177. data/spec/fixtures/skr/po_receipt.yml +2 -0
  178. data/spec/fixtures/skr/por_line.yml +2 -0
  179. data/spec/fixtures/skr/pt_line.yml +2 -0
  180. data/spec/fixtures/skr/purchase_order.yml +2 -0
  181. data/spec/fixtures/skr/sales_order.yml +2 -0
  182. data/spec/fixtures/skr/sku.yml +2 -0
  183. data/spec/fixtures/skr/sku_loc.yml +2 -0
  184. data/spec/fixtures/skr/sku_tran.yml +2 -0
  185. data/spec/fixtures/skr/sku_vendor.yml +2 -0
  186. data/spec/fixtures/skr/so_line.yml +2 -0
  187. data/spec/fixtures/skr/uom.yml +2 -0
  188. data/spec/fixtures/skr/vendor.yml +2 -0
  189. data/spec/fixtures/skr/vo_line.yml +2 -0
  190. data/spec/fixtures/skr/voucher.yml +2 -0
  191. data/spec/skr/address.rb +10 -0
  192. data/spec/skr/concerns/code_identifier_spec.rb +45 -0
  193. data/spec/skr/customer.rb +10 -0
  194. data/spec/skr/gl_account.rb +10 -0
  195. data/spec/skr/gl_manual_entry.rb +10 -0
  196. data/spec/skr/gl_period.rb +10 -0
  197. data/spec/skr/gl_posting.rb +10 -0
  198. data/spec/skr/gl_transaction.rb +10 -0
  199. data/spec/skr/ia_line.rb +10 -0
  200. data/spec/skr/ia_reason.rb +10 -0
  201. data/spec/skr/inv_line.rb +10 -0
  202. data/spec/skr/inventory_adjustment.rb +10 -0
  203. data/spec/skr/invoice.rb +10 -0
  204. data/spec/skr/location.rb +10 -0
  205. data/spec/skr/models/AddressSpec.coffee +5 -0
  206. data/spec/skr/models/CustomerSpec.coffee +5 -0
  207. data/spec/skr/models/GlAccountSpec.coffee +5 -0
  208. data/spec/skr/models/GlManualEntrySpec.coffee +5 -0
  209. data/spec/skr/models/GlPeriodSpec.coffee +5 -0
  210. data/spec/skr/models/GlPostingSpec.coffee +5 -0
  211. data/spec/skr/models/GlTransactionSpec.coffee +5 -0
  212. data/spec/skr/models/IaLineSpec.coffee +5 -0
  213. data/spec/skr/models/IaReasonSpec.coffee +5 -0
  214. data/spec/skr/models/InvLineSpec.coffee +5 -0
  215. data/spec/skr/models/InventoryAdjustmentSpec.coffee +5 -0
  216. data/spec/skr/models/InvoiceSpec.coffee +5 -0
  217. data/spec/skr/models/LocationSpec.coffee +5 -0
  218. data/spec/skr/models/PaymentTermSpec.coffee +5 -0
  219. data/spec/skr/models/PickTicketSpec.coffee +5 -0
  220. data/spec/skr/models/PoLineSpec.coffee +5 -0
  221. data/spec/skr/models/PoReceiptSpec.coffee +5 -0
  222. data/spec/skr/models/PorLineSpec.coffee +5 -0
  223. data/spec/skr/models/PtLineSpec.coffee +5 -0
  224. data/spec/skr/models/PurchaseOrderSpec.coffee +5 -0
  225. data/spec/skr/models/SalesOrderSpec.coffee +5 -0
  226. data/spec/skr/models/SkuLocSpec.coffee +5 -0
  227. data/spec/skr/models/SkuSpec.coffee +5 -0
  228. data/spec/skr/models/SkuTranSpec.coffee +5 -0
  229. data/spec/skr/models/SkuVendorSpec.coffee +5 -0
  230. data/spec/skr/models/SoLineSpec.coffee +5 -0
  231. data/spec/skr/models/UomSpec.coffee +5 -0
  232. data/spec/skr/models/VendorSpec.coffee +5 -0
  233. data/spec/skr/models/VoLineSpec.coffee +5 -0
  234. data/spec/skr/models/VoucherSpec.coffee +5 -0
  235. data/spec/skr/payment_term.rb +10 -0
  236. data/spec/skr/pick_ticket.rb +10 -0
  237. data/spec/skr/po_line.rb +10 -0
  238. data/spec/skr/po_receipt.rb +10 -0
  239. data/spec/skr/por_line.rb +10 -0
  240. data/spec/skr/pt_line.rb +10 -0
  241. data/spec/skr/purchase_order.rb +10 -0
  242. data/spec/skr/sales_order.rb +10 -0
  243. data/spec/skr/screens/Base.coffee +7 -0
  244. data/spec/skr/screens/CustomerMaint.coffee +7 -0
  245. data/spec/skr/screens/vendor-maint/VendorMaintSpec.coffee +5 -0
  246. data/spec/skr/sku.rb +10 -0
  247. data/spec/skr/sku_loc.rb +10 -0
  248. data/spec/skr/sku_tran.rb +10 -0
  249. data/spec/skr/sku_vendor.rb +10 -0
  250. data/spec/skr/so_line.rb +10 -0
  251. data/spec/skr/spec_helper.rb +26 -0
  252. data/spec/skr/uom.rb +10 -0
  253. data/spec/skr/vendor.rb +10 -0
  254. data/spec/skr/views/AddressSpec.coffee +5 -0
  255. data/spec/skr/vo_line.rb +10 -0
  256. data/spec/skr/voucher.rb +10 -0
  257. data/stockor.gemspec +38 -0
  258. data/tmp/.gitkeep +0 -0
  259. metadata +414 -0
@@ -0,0 +1,168 @@
1
+ # Asset Accounts
2
+ -
3
+ number: 1000
4
+ name: Cash
5
+ description: Cash on hand and held in bank accounts
6
+ -
7
+ number: 1010
8
+ name: Deposit Holding
9
+ description: Cash and equivalent waiting for deposit
10
+ -
11
+ number: 1110
12
+ name: Inventory
13
+ description: Inventory on hand and awaiting sale
14
+ -
15
+ number: 1115
16
+ name: Inventory in Transist
17
+ description: Inventory on a transfer between locations
18
+
19
+ -
20
+ number: 1200
21
+ name: Accounts Receivable
22
+ description: Amounts owed to the company for services performed or products sold but not yet paid for.
23
+ -
24
+ number: 1300
25
+ name: Prepayment Revenue
26
+ description: Amounts received in advance of providing goods and services but not yet delivered.
27
+ -
28
+ number: 1750
29
+ name: Buildings
30
+ description: Cost to purchase or construct buildings for use by the company.
31
+ -
32
+ number: 1800
33
+ name: Equipment
34
+ description: Cost to acquire and prepare equipment for use by the company.
35
+ -
36
+ number: 1900
37
+ name: Sales Tax Received
38
+ description: Amount received for sales tax.
39
+
40
+ # Liability Accounts
41
+
42
+ -
43
+ number: 2100
44
+ name: Notes Payable
45
+ description: Balance due on outstanding loans
46
+ -
47
+ number: 2200
48
+ name: Accounts Payable
49
+ description: Amount owed to suppliers for goods and services
50
+ -
51
+ number: 2300
52
+ name: Wages Payable
53
+ description: Amount owed to employees for hours worked but not yet paid.
54
+
55
+ -
56
+ number: 2400
57
+ name: Sales Tax
58
+ description: Sales tax expense
59
+
60
+ -
61
+ number: 2500
62
+ name: Interest Payable
63
+ description: Amount owed for interest on Notes Payable.
64
+
65
+ -
66
+ number: 2600
67
+ name: Inventory Receipts Clearing
68
+ description: Inventory received but vendor invoice not yet confirmed
69
+
70
+ # Equity Accounts
71
+
72
+ -
73
+ number: 3100
74
+ name: Capital
75
+ description: Amount the invested in the company (through cash or other assets) plus earnings of the company not withdrawn by the owner.
76
+ -
77
+ number: 3200
78
+ name: Drawing
79
+ description: Profit draws by owner
80
+
81
+ # Revenue Accounts
82
+ -
83
+ number: 4100
84
+ name: Sales
85
+ description: Amounts earned from selling physical goods.
86
+
87
+ -
88
+ number: 4200
89
+ name: Service Revenues
90
+ description: Amounts earned from providing services to clients.
91
+
92
+ # Cost of Goods
93
+ -
94
+ number: 5100
95
+ name: Inventory Costs
96
+ description: Cost of Goods Sold
97
+
98
+ -
99
+ number: 5150
100
+ name: Transfer Costs
101
+ description: Goods in transit on a transfer
102
+
103
+ # Expenses
104
+ -
105
+ number: 6100
106
+ name: Advertising Expense
107
+ description: Costs incurred by the company during the accounting period for ads, promotions, and other selling and expenses (other than salaries).
108
+
109
+ -
110
+ number: 6200
111
+ name: Salaries Expense
112
+ description: Expenses incurred for the work performed by employees.
113
+ -
114
+ number: 6300
115
+ name: Supplies Expense
116
+ description: Cost of supplies used up during the accounting period.
117
+ -
118
+ number: 6310
119
+ name: Lost Supplies Expense
120
+ description: Supplies that have been physicaly misplaced and cannot be found
121
+ -
122
+ number: 6320
123
+ name: Damaged Supplies Expense
124
+ description: Supplies that have been damaged and were disposed of
125
+ -
126
+ number: 6410
127
+ name: Outbound Shipping Expense
128
+ description: Cost of shipping goods to customers
129
+
130
+ -
131
+ number: 6420
132
+ name: Inbound Shipping Expense
133
+ description: Cost of vendors shipping goods to us
134
+
135
+ -
136
+ number: 6500
137
+ name: Depreciation Expense
138
+ description: Cost of long-term assets allocated to expense during the current accounting period.
139
+
140
+ -
141
+ number: 6600
142
+ name: Rent Expense
143
+ description: Cost of occupying rented facilities during the accounting period.
144
+ -
145
+ number: 6700
146
+ name: Utilities Expense
147
+ description: Costs for electricity, heat, water, and sewer that were used during the accounting period.
148
+ -
149
+ number: 6750
150
+ name: IT Expense
151
+ description: Cost of maintaining information systems
152
+ -
153
+ number: 6760
154
+ name: Telephone Expense
155
+ description: Cost of telephone used during the current accounting period.
156
+
157
+ # Other Revenues
158
+ -
159
+ number: 7100
160
+ name: Non operating Revenue
161
+ description: Revenue realized by other means
162
+
163
+ # Other Expense
164
+ -
165
+ number: 8100
166
+ name: Non operating Expense
167
+ description: Expense incurred by other means
168
+
@@ -0,0 +1,60 @@
1
+ -
2
+ code: CREDCARD
3
+ description: Payment due at time of sale with credit card
4
+ days: 0
5
+ discount_days: 0
6
+ discount_amount: 0
7
+ -
8
+ code: CHECK
9
+ description: Payment due at time of sale by check
10
+ days: 0
11
+ discount_days: 0
12
+ discount_amount: 0
13
+ -
14
+ code: CASH
15
+ description: Payment due at time of sale with cash
16
+ days: 0
17
+ discount_days: 0
18
+ discount_amount: 0
19
+ -
20
+ code: NET10
21
+ description: Payment due in 10 days, no discount for early payment
22
+ days: 10
23
+ discount_days: 0
24
+ discount_amount: 0
25
+
26
+ -
27
+ code: NET15
28
+ description: Payment due in 15 days, no discount for early payment
29
+ days: 15
30
+ discount_days: 0
31
+ discount_amount: 0
32
+
33
+ -
34
+ code: NET30
35
+ description: Payment due in 30 days, no discount for early payment
36
+ days: 30
37
+ discount_days: 0
38
+ discount_amount: 0
39
+
40
+ -
41
+ code: NET45
42
+ description: Payment due in 45 days, no discount for early payment
43
+ days: 45
44
+ discount_days: 0
45
+ discount_amount: 0
46
+
47
+ -
48
+ code: NET60
49
+ description: Payment due in 60 days, no discount for early payment
50
+ days: 60
51
+ discount_days: 0
52
+ discount_amount: 0
53
+
54
+ -
55
+ code: 2P10NET30
56
+ description: Payment due in 30 days, 2 % discount if payed with 10 days
57
+ days: 30
58
+ discount_days: 10
59
+ discount_amount: 2
60
+
data/db/seed.rb ADDED
@@ -0,0 +1,29 @@
1
+ require 'pathname'
2
+ require 'yaml'
3
+ require_relative '../lib/skr'
4
+
5
+
6
+ module Skr
7
+
8
+ user = Lanes::User.where(login: 'admin').first!
9
+ Lanes::User.scoped_to(user) do
10
+ seeds_path = Pathname.new(__FILE__).dirname.join('seed')
11
+
12
+ unless Location.default
13
+ Location.create( code: Skr.config.default_location_code, name: "System default",
14
+ address: Address.new(name:"System default")
15
+ )
16
+ end
17
+
18
+ YAML::load( seeds_path.join('chart_of_accounts.yml').read ).each do | acct_data |
19
+ GlAccount.where(number: acct_data['number'].to_s).any? || GlAccount.create!(acct_data)
20
+ end
21
+
22
+ YAML::load( seeds_path.join('payment_terms.yml').read ).each do | acct_data |
23
+ PaymentTerm.where(code: acct_data['code'].to_s).any? || PaymentTerm.create!(acct_data)
24
+ end
25
+
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,28 @@
1
+ require 'lanes/access'
2
+
3
+ module Lanes::Access
4
+ module Roles
5
+
6
+
7
+ # re-open the exising Support role
8
+ class Support
9
+ grant Skr::Customer
10
+ end
11
+
12
+
13
+ class Accounting < Lanes::Access::Role
14
+ grant Skr::Customer, Skr::PaymentTerm
15
+
16
+ lock_writes Skr::Customer, :terms_id
17
+ end
18
+
19
+
20
+ class Purchasing < Lanes::Access::Role
21
+ self.read << Skr::Customer
22
+ end
23
+
24
+ end
25
+
26
+ Role.grant_global_access(:read, Skr::PaymentTerm)
27
+
28
+ end
@@ -0,0 +1,47 @@
1
+ module Skr
2
+ module Concerns
3
+
4
+ # @see ClassMethods
5
+ module ActsAsUOM
6
+
7
+ extend ActiveSupport::Concern
8
+
9
+ module ClassMethods
10
+ def acts_as_uom( opts = {})
11
+ include InstanceMethods
12
+
13
+ export_methods :ea_qty, :combined_uom, :optional=>false
14
+ end
15
+ end
16
+
17
+ module InstanceMethods
18
+ def combined_uom
19
+ if self.uom_size.nil? || self.uom_code.nil?
20
+ ''
21
+ elsif 1 == self.uom_size
22
+ self.uom_code
23
+ else
24
+ "#{self.uom_code}/#{self.uom_size}"
25
+ end
26
+ end
27
+
28
+ def ea_qty
29
+ self.uom_size * self.qty
30
+ end
31
+
32
+ def uom=(uom)
33
+ self.uom_size = uom.size
34
+ self.uom_code = uom.code
35
+ end
36
+
37
+ def uom
38
+ Uom.new({ size: self.uom_size, code: self.uom_code })
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+
47
+ end
@@ -0,0 +1,43 @@
1
+ module Skr
2
+ module Concerns
3
+
4
+ # @see ClassMethods
5
+ module CodeIdentifier
6
+
7
+ extend ActiveSupport::Concern
8
+
9
+ # ### Code Identifier Concern
10
+ # This adds the {#has_code_identifier} class method
11
+ module ClassMethods
12
+
13
+ # A 2-10 character string that identifies an entity, such as a Customer, Vendor, or SKU.
14
+ # The code is often assigned by the user, but may also
15
+ # be auto-generated by {Skr::Strings.code_identifier}
16
+ #
17
+ # @param max_length [Integer] how long the code is allowed to be
18
+ # @param from [Symbol], method to call for a string to base the code upon
19
+ def has_code_identifier( from: nil, max_length: 10 )
20
+
21
+ validates :code, :length=>2..max_length, :presence=>true, :uniqueness=>true
22
+
23
+ alias_attribute :record_identifier, :code
24
+
25
+ if from
26
+ before_validation(:on=>:create) do
27
+ source = self[from]
28
+ unless source.blank?
29
+ self.code ||= Skr::Strings.code_identifier( source, length:max_length )
30
+ end
31
+ end
32
+ end
33
+
34
+ before_validation do
35
+ self.code = self.code.upcase unless self.code.blank?
36
+ end
37
+ end
38
+
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,18 @@
1
+ module Skr
2
+ module Concerns
3
+
4
+ module GlTran
5
+
6
+ module Postings
7
+
8
+ def total
9
+ total = BigDecimal.new('0')
10
+ each{ |pst| total+=pst.amount }
11
+ total
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,67 @@
1
+ require 'active_record/validations'
2
+
3
+ module Skr
4
+
5
+ class InvalidGlTransaction < ActiveRecord::RecordInvalid
6
+ end
7
+
8
+
9
+ module Concerns
10
+
11
+ module HasGlTransaction
12
+
13
+ extend ActiveSupport::Concern
14
+
15
+ module InstanceMethods
16
+
17
+ # N.B. We are overriding ActiveRecord::Base#save
18
+ # This is so we can wrap the save call inside a {GlTransaction.record} block
19
+ # which will collect any GlPostings and then collapse them down at the end of the block
20
+ # in order to prevent multiple postings to the same account.
21
+ def save(*)
22
+ opts = options_for_gl_transaction
23
+ # do nothing if the options specified an if clause and the method returns false
24
+ if opts.present? and opts.has_key?(:if) and self.send( opts[:if] ) == false
25
+ super
26
+ else
27
+ save_status = false
28
+ # First we wrap it up in our transaction since we don't have the benefit of
29
+ # save's rollback_active_record_state! block
30
+ # I'm tempted to appropriate it's usage, but am not since it's not documented (that I've found)
31
+ # and is thus likely to change
32
+ GlTransaction.transaction( requires_new: true ) do
33
+ # Enclose in GlTransaction#record block
34
+ gl_transaction = GlTransaction.record do
35
+ save_status = super # ActiveRecord::Base#save
36
+ # If save was successfull, pass attributes back to GlTransaction#record.
37
+ # Otherwise pass false back so it knows to not save the GlTransaction
38
+ save_status ? { attributes: self.send( opts[:attributes] ) } : false
39
+ end
40
+ # if we saved successfully, but the GlTransaction did not;
41
+ # Copy the errors to the model and abort the transaction
42
+ if save_status && gl_transaction.errors.any?
43
+ self.errors[:gl_transaction] += gl_transaction.errors.full_messages
44
+ save_status = false
45
+ raise InvalidGlTransaction.new(gl_transaction)
46
+ end
47
+ end
48
+ return save_status
49
+ end
50
+ end
51
+
52
+ end
53
+
54
+ module ClassMethods
55
+
56
+ def has_gl_transaction( options={} )
57
+ options.merge!( attributes: :attributes_for_gl_transaction )
58
+ cattr_accessor :options_for_gl_transaction
59
+ self.options_for_gl_transaction = options unless options.empty?
60
+ self.send :include, InstanceMethods
61
+ end
62
+
63
+ end
64
+
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,47 @@
1
+ module Skr
2
+ module Concerns
3
+
4
+ module HasSkuLocLines
5
+
6
+ extend ActiveSupport::Concern
7
+
8
+ module InstanceMethods
9
+
10
+ def other_charge_lines
11
+ self.lines.select{|l| l.sku.is_other_charge? }
12
+ end
13
+
14
+ def regular_lines
15
+ self.lines.reject{|l| l.sku.is_other_charge? }
16
+ end
17
+
18
+ def regular_lines_total
19
+ self.regular_lines.sum{|l|l.extended_price}
20
+ end
21
+
22
+ def subtotal
23
+ self.regular_lines.inject(0){|sum,line| sum + line.extended_price }
24
+ end
25
+
26
+ def total
27
+ if total = self.read_attribute('total')
28
+ BigDecimal.new(total)
29
+ elsif self.new_record? || self.association(:lines).loaded?
30
+ self.lines.inject( BigDecimal.new('0') ){|sum,line| sum += line.extended_price }
31
+ else
32
+ BigDecimal.new( self.lines.sum('price*qty') )
33
+ end
34
+ end
35
+ end
36
+
37
+ module ClassMethods
38
+
39
+ def has_sku_loc_lines
40
+ self.send :include, InstanceMethods
41
+ export_methods :total
42
+ end
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,32 @@
1
+ module Skr
2
+ module Concerns
3
+
4
+ module ImmutableModel
5
+
6
+ extend ActiveSupport::Concern
7
+
8
+ module ClassMethods
9
+
10
+ # Once it's created it may not be updated or destroyed.
11
+ # @raise [ActiveRecord::ReadOnlyRecord] if destroy, delete or save is called after it's been created.
12
+ def is_immutable(options = {})
13
+
14
+ options[:except] = [*options[:except]].map{|name| name.to_s } # make sure except is present and an array
15
+
16
+ before_destroy do
17
+ raise ActiveRecord::ReadOnlyRecord.new( "Can not destroy #{self.class.model_name}, only create is allowed" )
18
+ end
19
+
20
+ before_update do
21
+ unless ( changes.keys - change_tracking_fields - options[:except] ).blank?
22
+ raise ActiveRecord::ReadOnlyRecord.new( "Can not update, only create #{self.class.model_name}" )
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,24 @@
1
+ module Skr
2
+ module Concerns
3
+
4
+ module INV
5
+
6
+ module Lines
7
+
8
+ def from_pick_ticket!
9
+ proxy_association.owner.pick_ticket.lines.each do | line |
10
+ build({ pt_line: line, qty: line.qty_to_ship })
11
+ end
12
+ end
13
+
14
+ def from_sales_order!
15
+ proxy_association.owner.sales_order.lines.each do | line |
16
+ build({ so_line: line, qty: line.qty_allocated })
17
+ end
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,47 @@
1
+ module Skr
2
+ module Concerns
3
+
4
+ module IsOrderLike
5
+ extend ActiveSupport::Concern
6
+
7
+ module InstanceMethods
8
+
9
+
10
+ # Set's the customer. It also defaults the terms, addresses,and tax_exempt status to the customer's defaults
11
+ # @param cust [Customer]
12
+ # @return Customer
13
+ def customer=(cust)
14
+ super
15
+ self.terms ||= cust.terms
16
+ self.is_tax_exempt = cust.is_tax_exempt if self.is_tax_exempt.nil?
17
+ self.billing_address = cust.billing_address.dup unless self.billing_address.present?
18
+ self.shipping_address = cust.shipping_address.dup unless self.shipping_address.present?
19
+ end
20
+
21
+ protected
22
+
23
+ def set_order_defaults
24
+ self.location ||= Location.default
25
+ self.terms ||= customer.terms if self.customer
26
+ true
27
+ end
28
+
29
+ end
30
+
31
+ module ClassMethods
32
+
33
+ def is_order_like
34
+ self.send :include, InstanceMethods
35
+ has_sku_loc_lines # pull in the sku_loc_lines module
36
+
37
+ validates_associated :lines
38
+
39
+ before_validation :set_order_defaults, :on=>:create
40
+
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,65 @@
1
+ module Skr
2
+ module Concerns
3
+
4
+ module IsSkuLocLine
5
+
6
+ extend ActiveSupport::Concern
7
+
8
+ module InstanceMethods
9
+ def uom_record
10
+ if self.association(:sku).loaded? && self.sku.association(:uoms).loaded?
11
+ self.sku.uoms.detect{|uom| uom.code == self.uom_code }
12
+ else
13
+ self.sku.uoms.where({ code: self.uom_code }).first
14
+ end
15
+ end
16
+
17
+ def ea_qty
18
+ self.qty*self.uom_size
19
+ end
20
+
21
+ def is_other_charge?
22
+ self.sku.is_other_charge?
23
+ end
24
+
25
+ def extended_price
26
+ self.price && self.qty ? self.price * self.qty : BigDecimal.new(0)
27
+ end
28
+
29
+ private
30
+
31
+ def ensure_sku_does_not_change
32
+ errors.add(:sku, "can not be updated") if changes['sku_code']
33
+ if change = changes['sku_loc_id']
34
+ # allow if the sku_id is the same on both old & new locations
35
+ unless 1 == SkuLoc.where( id: change ).pluck('sku_id').uniq.length
36
+ errors.add(:sku, "must be the same in both locations") if sku_code_changed?
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ module ClassMethods
43
+
44
+ def is_sku_loc_line( parent: nil )
45
+ self.send :include, InstanceMethods
46
+
47
+ validate :ensure_sku_does_not_change, :on=>:update
48
+
49
+ if parent
50
+ before_create do
51
+ self.position ||= ( self.send( parent ).lines.maximum(:position) || 0 ) + 1
52
+ end
53
+ end
54
+
55
+ export_methods :extended_price, :optional=>false
56
+
57
+ end
58
+
59
+
60
+ end
61
+
62
+ end
63
+
64
+ end
65
+ end