axis 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/.gitignore +4 -0
  2. data/.rspec +0 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +20 -0
  6. data/README.markdown +10 -0
  7. data/Rakefile +5 -0
  8. data/VERSION +1 -0
  9. data/axis.gemspec +31 -0
  10. data/db/schema/v_customers.sql +228 -0
  11. data/db/schema/v_deliveries.sql +146 -0
  12. data/db/schema/v_nominal_account_transactions.sql +179 -0
  13. data/db/schema/v_sales_order_lines.sql +156 -0
  14. data/db/schema/v_sales_orders.sql +256 -0
  15. data/db/schema/v_stock_records.sql +243 -0
  16. data/lib/axis.rb +15 -0
  17. data/lib/axis/base.rb +5 -0
  18. data/lib/axis/config.rb +28 -0
  19. data/lib/axis/document.rb +74 -0
  20. data/lib/axis/models/addressee.rb +6 -0
  21. data/lib/axis/models/component_record.rb +5 -0
  22. data/lib/axis/models/customer.rb +6 -0
  23. data/lib/axis/models/delivery.rb +7 -0
  24. data/lib/axis/models/goods_on_account.rb +8 -0
  25. data/lib/axis/models/goods_on_account_line.rb +8 -0
  26. data/lib/axis/models/invoice.rb +11 -0
  27. data/lib/axis/models/nominal_account_transaction.rb +47 -0
  28. data/lib/axis/models/sales_order.rb +7 -0
  29. data/lib/axis/models/sales_order_line.rb +8 -0
  30. data/lib/axis/models/stock_level.rb +6 -0
  31. data/lib/axis/models/stock_record.rb +10 -0
  32. data/lib/axis/models/stock_record_location.rb +6 -0
  33. data/lib/axis/models/supplier_price.rb +6 -0
  34. data/lib/axis/version.rb +3 -0
  35. data/lib/cli.rb +25 -0
  36. data/spec/axis/document_spec.rb +98 -0
  37. data/spec/fixtures/ATTACH/Documents/INV/123456_0_20110101_163350_2C16B3CB_P.pdf +0 -0
  38. data/spec/fixtures/ATTACH/Documents/INV/123456_0_20120101_163350_2C16B3CB_P.pdf +0 -0
  39. data/spec/fixtures/ATTACH/Documents/INV/123456_0_20121002_163350_2C16B3CB_P.pdf +0 -0
  40. data/spec/fixtures/ATTACH/Documents/INV/296621_0_20121001_163350_2C16B3CB_P.pdf +0 -0
  41. data/spec/spec_helper.rb +1 -0
  42. metadata +175 -0
@@ -0,0 +1,243 @@
1
+ USE [AXIS33238CO1]
2
+ GO
3
+
4
+ /****** Object: View [dbo].[v_stock_records] Script Date: 06/01/2011 10:01:36 ******/
5
+ SET ANSI_NULLS ON
6
+ GO
7
+
8
+ SET QUOTED_IDENTIFIER ON
9
+ GO
10
+
11
+ CREATE VIEW [dbo].[v_stock_records]
12
+ AS
13
+ SELECT ref AS stock_reference, drc AS date_record_created, atp AS pointer_to_first_archive_trn, uwi AS unit_weight_of_item, pnmqty AS pick_and_mix_quantity,
14
+ uom AS unit_of_measure, acn AS nominal_purchase_account_number, sac AS sales_group_order, pgc AS product_group_code, trt AS traceability_record_type,
15
+ sbi AS sold_by_indicator, cst AS standard_cost, trd AS trade_of_first_quantity_price, rtl AS retail_price, soh AS stock_on_hand, ord AS total_stock_on_order,
16
+ bck AS overdue_sales_order, alc AS total_allocations, box AS case_quantity, tubs AS tubs_unit_for_this_item, sper AS selling_price, qtp AS issues_this_period,
17
+ qlp AS issues_last_period, ytd AS issues_year_to_date, lst AS issues_last_year, saf AS safety_stock, rol AS re_order_level, roq AS re_order_qty,
18
+ msq AS maximum_stock_quantity, dis AS product_discount, dl1 AS description_line_1, dl2 AS description_line_2, dsc AS qty_break_disc_matrix_group,
19
+ psc AS price_matrix_group_code, castr AS case_trade_price, cct AS current_cost, dcu AS date_current_cost_last_updated, dsu AS date_standard_cost_updated,
20
+ qcf AS quantity_conversion_factor, ctt AS cost_type, ohr AS overhead_rate, ccp4 AS component_chain_pointer, unv AS unit_volume, com AS commodity_code,
21
+ lscd AS last_stock_check_date, label AS a_label_format_number, nuw AS net_unit_weight, alt AS alternative_stock_reference, altm AS acquisation_lead_time,
22
+ ttmh AS time_to_manufacture, ebg AS ebusiness_group, bper AS buying_per, mref AS machine_reference, sst AS machine_setup_time,
23
+ slref AS setup_labour_reference, cstyp AS labour_non_labour, oecod AS operation_expenditure_code, ctcod AS cost_type_code, oscod AS operator_skill_code,
24
+ pycod AS paycode, shpno AS shop_number, rlref AS runetime_labour_reference, pdep AS production_department, area AS production_area,
25
+ mbs AS manufacturing_batch_size, csac AS contract_sales_analysis_code, crtl AS contract_retail_price, ccst AS contract_cost_price, tdq AS total_despatch_quantity,
26
+ ssr AS superseded_stock_ref, sdt AS superseded_stock_date, ddd AS default_delivery_in_days, binno AS bin_number, img AS image_number,
27
+ qinw AS goods_inward_quantity, scst AS supplementary_cost, casrt AS case_retail_price, atype AS assembly_type, vsdimg AS site_to_upload_stock_images_to,
28
+ cdsc AS matrix_group_for_contract_item, itype AS picture_type, ttype AS thumbnail_type, axnum AS axis_user_number, tds AS trade_discount,
29
+ fsu AS forcast_stock_usage, dep AS depreciation_percentage, pft AS pointer_to_first_transaction, plt AS pointer_to_last_transaction,
30
+ pfo AS pointer_to_first_open_receipt, record AS record_number
31
+ FROM dbo.accstk00
32
+
33
+ GO
34
+
35
+ EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
36
+ Begin DesignProperties =
37
+ Begin PaneConfigurations =
38
+ Begin PaneConfiguration = 0
39
+ NumPanes = 4
40
+ Configuration = "(H (1[40] 4[20] 2[20] 3) )"
41
+ End
42
+ Begin PaneConfiguration = 1
43
+ NumPanes = 3
44
+ Configuration = "(H (1 [50] 4 [25] 3))"
45
+ End
46
+ Begin PaneConfiguration = 2
47
+ NumPanes = 3
48
+ Configuration = "(H (1 [50] 2 [25] 3))"
49
+ End
50
+ Begin PaneConfiguration = 3
51
+ NumPanes = 3
52
+ Configuration = "(H (4 [30] 2 [40] 3))"
53
+ End
54
+ Begin PaneConfiguration = 4
55
+ NumPanes = 2
56
+ Configuration = "(H (1 [56] 3))"
57
+ End
58
+ Begin PaneConfiguration = 5
59
+ NumPanes = 2
60
+ Configuration = "(H (2 [66] 3))"
61
+ End
62
+ Begin PaneConfiguration = 6
63
+ NumPanes = 2
64
+ Configuration = "(H (4 [50] 3))"
65
+ End
66
+ Begin PaneConfiguration = 7
67
+ NumPanes = 1
68
+ Configuration = "(V (3))"
69
+ End
70
+ Begin PaneConfiguration = 8
71
+ NumPanes = 3
72
+ Configuration = "(H (1[56] 4[18] 2) )"
73
+ End
74
+ Begin PaneConfiguration = 9
75
+ NumPanes = 2
76
+ Configuration = "(H (1 [75] 4))"
77
+ End
78
+ Begin PaneConfiguration = 10
79
+ NumPanes = 2
80
+ Configuration = "(H (1[66] 2) )"
81
+ End
82
+ Begin PaneConfiguration = 11
83
+ NumPanes = 2
84
+ Configuration = "(H (4 [60] 2))"
85
+ End
86
+ Begin PaneConfiguration = 12
87
+ NumPanes = 1
88
+ Configuration = "(H (1) )"
89
+ End
90
+ Begin PaneConfiguration = 13
91
+ NumPanes = 1
92
+ Configuration = "(V (4))"
93
+ End
94
+ Begin PaneConfiguration = 14
95
+ NumPanes = 1
96
+ Configuration = "(V (2))"
97
+ End
98
+ ActivePaneConfig = 0
99
+ End
100
+ Begin DiagramPane =
101
+ Begin Origin =
102
+ Top = 0
103
+ Left = 0
104
+ End
105
+ Begin Tables =
106
+ Begin Table = "accstk00"
107
+ Begin Extent =
108
+ Top = 0
109
+ Left = 38
110
+ Bottom = 334
111
+ Right = 247
112
+ End
113
+ DisplayFlags = 280
114
+ TopColumn = 218
115
+ End
116
+ End
117
+ End
118
+ Begin SQLPane =
119
+ End
120
+ Begin DataPane =
121
+ Begin ParameterDefaults = ""
122
+ End
123
+ Begin ColumnWidths = 91
124
+ Width = 284
125
+ Width = 1500
126
+ Width = 1500
127
+ Width = 1500
128
+ Width = 1500
129
+ Width = 1500
130
+ Width = 1500
131
+ Width = 1500
132
+ Width = 1500
133
+ Width = 1500
134
+ Width = 1500
135
+ Width = 1500
136
+ Width = 1500
137
+ Width = 1500
138
+ Width = 1500
139
+ Width = 1500
140
+ Width = 1500
141
+ Width = 1500
142
+ Width = 1500
143
+ Width = 1500
144
+ Width = 1500
145
+ Width = 1500
146
+ Width = 1500
147
+ Width = 1500
148
+ Width = 1500
149
+ Width = 1500
150
+ Width = 1500
151
+ Width = 1500
152
+ Width = 1500
153
+ Width = 1500
154
+ Width = 1500
155
+ Width = 1500
156
+ Width = 1500
157
+ Width = 1500
158
+ Width = 1500
159
+ Width = 1500
160
+ Width = 1500
161
+ Width = 1500
162
+ Width = 1500
163
+ Width = 1500
164
+ Width = 1500
165
+ Width = 1500
166
+ Width = 1500
167
+ Width = 1500
168
+ Width = 1500
169
+ Width = 1500
170
+ Width = 1500
171
+ Width = 1500
172
+ Width = 1500
173
+ Width = 1500
174
+ Width = 1500
175
+ Width = 1500
176
+ Width = 1500
177
+ Width = 1500
178
+ Width = 1500
179
+ Width = 1500
180
+ Width = 1500
181
+ Width = 1500
182
+ Width = 1500
183
+ Width = 1500
184
+ ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_stock_records'
185
+ GO
186
+
187
+ EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane2', @value=N' Width = 1500
188
+ Width = 1500
189
+ Width = 1500
190
+ Width = 1500
191
+ Width = 1500
192
+ Width = 1500
193
+ Width = 1500
194
+ Width = 1500
195
+ Width = 1500
196
+ Width = 1500
197
+ Width = 1500
198
+ Width = 1500
199
+ Width = 1500
200
+ Width = 1500
201
+ Width = 1500
202
+ Width = 1500
203
+ Width = 1500
204
+ Width = 1500
205
+ Width = 1500
206
+ Width = 1500
207
+ Width = 1500
208
+ Width = 1500
209
+ Width = 1500
210
+ Width = 1500
211
+ Width = 1500
212
+ Width = 1500
213
+ Width = 1500
214
+ Width = 1500
215
+ Width = 1500
216
+ Width = 1500
217
+ Width = 1500
218
+ End
219
+ End
220
+ Begin CriteriaPane =
221
+ Begin ColumnWidths = 11
222
+ Column = 1440
223
+ Alias = 900
224
+ Table = 1170
225
+ Output = 720
226
+ Append = 1400
227
+ NewValue = 1170
228
+ SortType = 1350
229
+ SortOrder = 1410
230
+ GroupBy = 1350
231
+ Filter = 1350
232
+ Or = 1350
233
+ Or = 1350
234
+ Or = 1350
235
+ End
236
+ End
237
+ End
238
+ ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_stock_records'
239
+ GO
240
+
241
+ EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=2 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_stock_records'
242
+ GO
243
+
@@ -0,0 +1,15 @@
1
+ #require 'axis/version'
2
+
3
+ # Require third party gems.
4
+ require 'active_record'
5
+
6
+ require 'axis/config'
7
+ require 'axis/document'
8
+
9
+ # Require ActiveRecord models.
10
+ require 'axis/base'
11
+
12
+ Dir.glob(File.join(File.dirname(__FILE__), 'axis/models/*')).each { |f| require f }
13
+
14
+ # Include after models.
15
+ require 'squeel'
@@ -0,0 +1,5 @@
1
+ module Axis
2
+ class Base < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ module Axis
2
+
3
+ class << self
4
+ attr_accessor :base_path,
5
+ :dataserver,
6
+ :host,
7
+ :database,
8
+ :username,
9
+ :password
10
+
11
+ def configure(&block)
12
+ class_eval(&block)
13
+ end
14
+ end
15
+
16
+ ##
17
+ # Defaults
18
+
19
+ # Axis ATTACH/Documents Directory
20
+ self.base_path = "./spec/fixtures/ATTACH/Documents"
21
+
22
+ # ActiveRecord SQL Settings
23
+ self.dataserver = '192.168.254.118'
24
+ self.host = '192.168.254.118'
25
+ self.database = 'AXIS33238CO1'
26
+ self.username = 'sa'
27
+ self.password = 'St1nky1nk'
28
+ end
@@ -0,0 +1,74 @@
1
+ module Axis
2
+
3
+ module Document
4
+
5
+ TYPES = {
6
+ invoice: "INV"
7
+ }
8
+
9
+ class DocumentNotFound < StandardError;end
10
+
11
+
12
+ module FinderMethods
13
+ def find(id)
14
+ id = id.to_s
15
+ raise ArgumentError, "id cannot be empty" if id == ""
16
+
17
+ Pathname.new(type_path).each_child do |file_path|
18
+ doc = new(file_path)
19
+ return doc if doc.id == id
20
+ end
21
+
22
+ raise DocumentNotFound, "with id #{id} in #{type_path}"
23
+ end
24
+
25
+ def find_by_date(year, month = nil, day = nil)
26
+ docs = []
27
+ Pathname.new(type_path).each_child do |file_path|
28
+ doc = new(file_path)
29
+
30
+ next if doc.created_on.year != year
31
+ next if doc.created_on.month != month if month
32
+ next if doc.created_on.day != day if day
33
+
34
+ docs << doc
35
+ end
36
+ docs
37
+ end
38
+
39
+ protected
40
+ def type_path
41
+ File.join(Axis.base_path, Axis::Document::TYPES[@type])
42
+ end
43
+ end
44
+
45
+ class Base
46
+
47
+ extend FinderMethods
48
+
49
+ attr_reader :path
50
+
51
+ def initialize(path)
52
+ @path = Pathname.new(path)
53
+ @filename_split = @path.basename.to_s.split("_")
54
+ @dirname_split = @path.dirname.split
55
+ end
56
+
57
+ def id
58
+ @filename_split.first
59
+ end
60
+
61
+ def type
62
+ Axis::Document::TYPES.key(@dirname_split.last.to_s)
63
+ end
64
+
65
+ def created_on
66
+ Date.parse(@filename_split[2])
67
+ end
68
+ end
69
+
70
+ class Invoice < Base
71
+ @type = :invoice
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,6 @@
1
+ module Axis
2
+ class Addressee < Base
3
+ self.primary_key = 'id'
4
+ belongs_to :customer, :foreign_key => 'customer_reference'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Axis
2
+ class ComponentRecord < Base
3
+ belongs_to :stock_record
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module Axis
2
+ class Customer < Base
3
+ has_many :goods_on_accounts
4
+ has_many :addressees, :primary_key => 'customer_reference', :foreign_key => 'customer_reference'
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ module Axis
2
+ class Delivery < Base
3
+ self.primary_key = "id"
4
+ belongs_to :customer
5
+ belongs_to :goods_on_account
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ module Axis
2
+ class GoodsOnAccount < Base
3
+ self.primary_key = "id"
4
+ belongs_to :customer
5
+ has_many :deliveries
6
+ has_many :goods_on_account_lines
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Axis
2
+ class GoodsOnAccountLine < Base
3
+ self.primary_key = "id"
4
+ belongs_to :customer
5
+ belongs_to :goods_on_account
6
+ belongs_to :stock_record
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ module Axis
2
+ class Invoice < Base
3
+ self.primary_key = "id"
4
+
5
+ belongs_to :sales_order
6
+
7
+ def document
8
+ Axis::Document::Invoice.find(id)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,47 @@
1
+ module Axis
2
+ class NominalAccountTransaction < Base
3
+ #set_table_name "accntr00"
4
+ #set_primary_key "record_number"
5
+
6
+ #alias_attribute :document_reference , :drf
7
+ #alias_attribute :transaction_type , :typ
8
+ #alias_attribute :vat_code , :vcd
9
+ #alias_attribute :net_amount , :amt
10
+ #alias_attribute :date , :dat
11
+ #alias_attribute :nominal_account_number , :acn
12
+ #alias_attribute :customer_supplier_group , :sgd
13
+ #alias_attribute :order_code , :osd
14
+ #alias_attribute :contra_account_rrn , :csn
15
+ #alias_attribute :vat_amount , :vat
16
+ #alias_attribute :batch_number , :bno
17
+ #alias_attribute :cost_of_sales , :cos
18
+ #alias_attribute :internal_reference , :iref
19
+ #alias_attribute :comment , :des
20
+ #alias_attribute :department_code , :dcd
21
+ #alias_attribute :next_transaction_pointer , :ntp4
22
+ #alias_attribute :cost_centre_code , :ccc
23
+ #alias_attribute :period_number , :per
24
+ #alias_attribute :year_number , :yrn
25
+ #alias_attribute :vat_for_ec_transaction , :ecv
26
+ #alias_attribute :ec_nature_of_transaction_code, :notc
27
+ #alias_attribute :vat_on_cash_transations , :cshv
28
+ #alias_attribute :internal_reference_6 , :iref6
29
+ #alias_attribute :comment_line_2 , :des2
30
+ #alias_attribute :contra_account_number , :cacno
31
+ #alias_attribute :transaction_unique_id , :tuid
32
+ #alias_attribute :transaction_clock , :tclk
33
+ #alias_attribute :operation_id , :opid
34
+ #alias_attribute :exchange_rate , :xrt
35
+ #alias_attribute :currency_value , :curr
36
+ #alias_attribute :ec_county_code , :eccc
37
+ #alias_attribute :commodity_code , :com
38
+ #alias_attribute :delivery_terms , :dtc
39
+ #alias_attribute :country_of_dispatch , :codis
40
+ #alias_attribute :vat_rate , :vrt
41
+ #alias_attribute :primary_key_for_table , :pkey
42
+ #alias_attribute :record_number , :record
43
+ #alias_attribute :file_variant , :fno
44
+ #alias_attribute :net_mass , :mass
45
+ #alias_attribute :supplementary_reference , :sup
46
+ end
47
+ end