xsys 0.0.27 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/xsys.rb +1 -12
- data/lib/xsys/api.rb +87 -120
- data/lib/xsys/model/price_list.rb +10 -2
- data/lib/xsys/model/product.rb +46 -9
- data/lib/xsys/model/product_category.rb +10 -2
- data/lib/xsys/model/product_price_list.rb +22 -0
- data/lib/xsys/model/product_provider.rb +11 -3
- data/lib/xsys/model/seller.rb +10 -2
- data/lib/xsys/model/shop.rb +22 -11
- data/lib/xsys/model/stock.rb +10 -2
- data/lib/xsys/model/user.rb +10 -2
- data/lib/xsys/pagination.rb +11 -3
- data/lib/xsys/version.rb +1 -1
- metadata +3 -14
- data/lib/xsys/model/grouped_purchase_order_item.rb +0 -13
- data/lib/xsys/model/grouped_sale_item.rb +0 -13
- data/lib/xsys/model/provider_kind.rb +0 -17
- data/lib/xsys/model/purchase_order_item.rb +0 -14
- data/lib/xsys/model/purchases_position.rb +0 -18
- data/lib/xsys/model/sale_item.rb +0 -15
- data/lib/xsys/model/sales_period.rb +0 -13
- data/lib/xsys/model/sales_position.rb +0 -26
- data/lib/xsys/model/stock_control.rb +0 -19
- data/lib/xsys/model/stock_control_item.rb +0 -14
- data/lib/xsys/model/transaction.rb +0 -25
- data/lib/xsys/model/transaction_item.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 826298b8c134e49c3d58189f54f059a3b30c517a
|
4
|
+
data.tar.gz: 253f5c3ebfb231a47f338dc7871bdde24e8bf746
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b57b454a874dcd148e00e14a86fd465c9e1677f5918daa4ca9f7c9c75ccdf8461127daf8132540e76c4c389b684e4b85c34000f946a07bd9758114413913bc30
|
7
|
+
data.tar.gz: c0d85281b1eb0fe5fb6ed40168929c7bf9df5282775d163b8cc40404add6f9e0fedb1db9cdd06ce98f54dedf14662df4a467756eeea9d581c9affc003ef133f6
|
data/CHANGELOG.md
CHANGED
data/lib/xsys.rb
CHANGED
@@ -1,22 +1,11 @@
|
|
1
|
-
require 'xsys/model/grouped_purchase_order_item'
|
2
|
-
require 'xsys/model/grouped_sale_item'
|
3
1
|
require 'xsys/model/price_list'
|
4
2
|
require 'xsys/model/product'
|
5
3
|
require 'xsys/model/product_category'
|
4
|
+
require 'xsys/model/product_price_list'
|
6
5
|
require 'xsys/model/product_provider'
|
7
|
-
require 'xsys/model/provider_kind'
|
8
|
-
require 'xsys/model/purchase_order_item'
|
9
|
-
require 'xsys/model/purchases_position'
|
10
|
-
require 'xsys/model/sale_item'
|
11
|
-
require 'xsys/model/sales_period'
|
12
|
-
require 'xsys/model/sales_position'
|
13
6
|
require 'xsys/model/seller'
|
14
7
|
require 'xsys/model/shop'
|
15
8
|
require 'xsys/model/stock'
|
16
|
-
require 'xsys/model/stock_control'
|
17
|
-
require 'xsys/model/stock_control_item'
|
18
|
-
require 'xsys/model/transaction'
|
19
|
-
require 'xsys/model/transaction_item'
|
20
9
|
require 'xsys/model/user'
|
21
10
|
|
22
11
|
require 'xsys/api'
|
data/lib/xsys/api.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Xsys
|
2
2
|
class Api
|
3
3
|
def self.configure(args={})
|
4
|
-
@endpoint = (args[:endpoint] || 'https://
|
4
|
+
@endpoint = (args[:endpoint] || 'https://gestion.lhconfort.com.ar/api')
|
5
5
|
@access_token = args[:access_token]
|
6
6
|
end
|
7
7
|
|
@@ -9,158 +9,125 @@ module Xsys
|
|
9
9
|
get_request('/price_lists').map { |r| Model::PriceList.new(r) }
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.get_provider_kinds(filters={})
|
13
|
-
request = get_request('/provider_kinds', filters)
|
14
|
-
request[:results] = request[:results].map { |r| Model::ProviderKind.new(r) }
|
15
|
-
request
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.get_provider_kind(id)
|
19
|
-
Model::ProviderKind.new(get_request("/provider_kinds/#{id}"))
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.get_product_providers(filters={})
|
23
|
-
request = get_request('/product_providers', filters)
|
24
|
-
request[:results] = request[:results].map { |r| Model::ProductProvider.new(r) }
|
25
|
-
request
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.get_product_provider(id)
|
29
|
-
Model::ProductProvider.new(get_request("/product_providers/#{id}"))
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.get_product_categories(filters={})
|
33
|
-
request = get_request('/product_categories', filters)
|
34
|
-
request[:results] = request[:results].map { |r| Model::ProductCategory.new(r) }
|
35
|
-
request
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.get_product_category(id)
|
39
|
-
Model::ProductCategory.new(get_request("/product_categories/#{id}"))
|
40
|
-
end
|
41
|
-
|
42
12
|
def self.get_products(filters={})
|
43
|
-
|
44
|
-
request[:results] = request[:results].map { |r| Model::Product.new(r) }
|
45
|
-
request
|
46
|
-
end
|
13
|
+
response = get_request('/products', filters)
|
47
14
|
|
48
|
-
|
49
|
-
|
15
|
+
if response[:headers][:link]
|
16
|
+
{
|
17
|
+
pagination: Pagination.new(JSON.parse(response.headers[:link])),
|
18
|
+
results: response[:body].map { |r| Model::Product.new(r) }
|
19
|
+
}
|
20
|
+
else
|
21
|
+
response[:body].map { |r| Model::Product.new(r) }
|
22
|
+
end
|
50
23
|
end
|
51
24
|
|
52
|
-
def self.
|
53
|
-
|
54
|
-
get_request(shops_url).map { |r| Model::Shop.new(r) }
|
25
|
+
def self.get_product(product_code)
|
26
|
+
Model::Product.new(get_request("/products/#{product_code}")[:body])
|
55
27
|
end
|
56
28
|
|
57
|
-
def self.
|
58
|
-
get_request('/
|
59
|
-
end
|
29
|
+
def self.get_product_providers(filters={})
|
30
|
+
response = get_request('/product_providers', filters)
|
60
31
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
32
|
+
if response[:headers][:link]
|
33
|
+
{
|
34
|
+
pagination: Pagination.new(JSON.parse(response.headers[:link])),
|
35
|
+
results: response[:body].map { |r| Model::ProductProvider.new(r) }
|
36
|
+
}
|
37
|
+
else
|
38
|
+
response[:body].map { |r| Model::ProductProvider.new(r) }
|
39
|
+
end
|
68
40
|
end
|
69
41
|
|
70
|
-
def self.
|
71
|
-
|
72
|
-
request[:results] = request[:results].map { |r| Model::PurchaseOrderItem.new(r) }
|
73
|
-
request
|
42
|
+
def self.get_product_provider(provider_code)
|
43
|
+
Model::ProductProvider.new(get_request("/product_providers/#{provider_code}"))
|
74
44
|
end
|
75
45
|
|
76
|
-
def self.
|
77
|
-
|
78
|
-
request[:results] = request[:results].map { |r| Model::GroupedPurchaseOrderItem.new(r) }
|
79
|
-
request
|
80
|
-
end
|
46
|
+
def self.get_product_categories(filters={})
|
47
|
+
response = get_request('/product_categories', filters)
|
81
48
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
49
|
+
if response[:headers][:link]
|
50
|
+
{
|
51
|
+
pagination: Pagination.new(JSON.parse(response.headers[:link])),
|
52
|
+
results: response[:body].map { |r| Model::ProductCategory.new(r) }
|
53
|
+
}
|
54
|
+
else
|
55
|
+
response[:body].map { |r| Model::ProductCategory.new(r) }
|
56
|
+
end
|
86
57
|
end
|
87
58
|
|
88
|
-
def self.
|
89
|
-
|
90
|
-
request[:results] = request[:results].map { |r| Model::GroupedSaleItem.new(r) }
|
91
|
-
request
|
59
|
+
def self.get_product_category(category_code)
|
60
|
+
Model::ProductCategory.new(get_request("/product_categories/#{category_code}"))
|
92
61
|
end
|
93
62
|
|
94
|
-
def self.
|
95
|
-
|
96
|
-
request.map { |r| Model::SalesPosition.new(r) }
|
97
|
-
end
|
63
|
+
def self.get_product_price_lists(filters={})
|
64
|
+
response = get_request('/product_price_lists', filters)
|
98
65
|
|
99
|
-
|
100
|
-
|
101
|
-
|
66
|
+
if response[:headers][:link]
|
67
|
+
{
|
68
|
+
pagination: Pagination.new(JSON.parse(response.headers[:link])),
|
69
|
+
results: response[:body].map { |r| Model::ProductPriceList.new(r) }
|
70
|
+
}
|
71
|
+
else
|
72
|
+
response[:body].map { |r| Model::ProductPriceList.new(r) }
|
73
|
+
end
|
102
74
|
end
|
103
75
|
|
104
|
-
def self.
|
105
|
-
|
106
|
-
request[:results] = request[:results].map { |r| Model::StockControl.new(r) }
|
107
|
-
request
|
76
|
+
def self.get_sellers
|
77
|
+
get_request('/sellers')[:body].map { |r| Model::Seller.new(r) }
|
108
78
|
end
|
109
79
|
|
110
|
-
def self.
|
111
|
-
|
112
|
-
shop_code: params[:shop_code],
|
113
|
-
category_id: params[:category_id]
|
114
|
-
})
|
80
|
+
def self.get_shops(kind=nil)
|
81
|
+
shop_kinds = [:commercial, :virtual, :physical, :stockable, :service, :with_target]
|
115
82
|
|
116
|
-
|
83
|
+
if kind.nil?
|
84
|
+
get_request('/shops')[:body].map { |r| Model::Shop.new(r) }
|
85
|
+
elsif shop_kinds.include?(kind.to_sym)
|
86
|
+
get_request("/shops/#{kind}")[:body].map { |r| Model::Shop.new(r) }
|
87
|
+
else
|
88
|
+
[]
|
89
|
+
end
|
117
90
|
end
|
118
91
|
|
119
|
-
def self.
|
120
|
-
|
121
|
-
shop_code: params[:shop_code],
|
122
|
-
category_id: params[:category_id]
|
123
|
-
})
|
124
|
-
|
125
|
-
request.map { |r| Model::StockControlItem.new(r) }
|
92
|
+
def self.get_users
|
93
|
+
get_request('/users')[:body].map { |r| Model::User.new(r) }
|
126
94
|
end
|
127
95
|
|
128
|
-
|
129
|
-
request = get_request('/transactions', params)
|
96
|
+
private
|
130
97
|
|
131
|
-
|
132
|
-
|
98
|
+
def self.get_request(action, params={}, headers={})
|
99
|
+
begin
|
100
|
+
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
101
|
+
parse_response(RestClient.get("#{@endpoint_url}#{action}", {params: params}.merge(headers)))
|
102
|
+
rescue => e
|
103
|
+
parse_response(e.response)
|
104
|
+
end
|
133
105
|
end
|
134
106
|
|
135
|
-
def self.
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
107
|
+
def self.post_request(action, params={}, headers={})
|
108
|
+
begin
|
109
|
+
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
110
|
+
parse_response(RestClient.post("#{@endpoint_url}#{action}", params, headers))
|
111
|
+
rescue => e
|
112
|
+
parse_response(e.response)
|
113
|
+
end
|
141
114
|
end
|
142
115
|
|
143
|
-
def self.
|
144
|
-
|
116
|
+
def self.put_request(action, params={}, headers={})
|
117
|
+
begin
|
118
|
+
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
119
|
+
parse_response(RestClient.put("#{@endpoint_url}#{action}", params, headers))
|
120
|
+
rescue => e
|
121
|
+
parse_response(e.response)
|
122
|
+
end
|
145
123
|
end
|
146
124
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
}.merge({ authorization: "Token token=\"#{@access_token}\"" })
|
154
|
-
)
|
155
|
-
|
156
|
-
if response.headers[:link]
|
157
|
-
{
|
158
|
-
pagination: Pagination.new(JSON.parse(response.headers[:link])),
|
159
|
-
results: JSON.parse(response.body)
|
160
|
-
}
|
161
|
-
else
|
162
|
-
JSON.parse(response.body)
|
163
|
-
end
|
125
|
+
def self.parse_response(response)
|
126
|
+
{
|
127
|
+
headers: response.headers,
|
128
|
+
body: (JSON.parse(response.body) rescue response.body),
|
129
|
+
status_code: response.code
|
130
|
+
}
|
164
131
|
end
|
165
132
|
end
|
166
133
|
end
|
@@ -1,13 +1,21 @@
|
|
1
1
|
module Xsys
|
2
2
|
module Model
|
3
3
|
class PriceList
|
4
|
-
|
4
|
+
def self.attr_list
|
5
|
+
[:code, :name]
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader *attr_list
|
5
9
|
|
6
10
|
def initialize(attributes={})
|
7
|
-
attributes.each do |k,v|
|
11
|
+
attributes.each do |k, v|
|
8
12
|
self.send("#{k}=", v) if self.respond_to?(k)
|
9
13
|
end
|
10
14
|
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_writer *attr_list
|
11
19
|
end
|
12
20
|
end
|
13
21
|
end
|
data/lib/xsys/model/product.rb
CHANGED
@@ -1,32 +1,69 @@
|
|
1
1
|
module Xsys
|
2
2
|
module Model
|
3
3
|
class Product
|
4
|
-
|
5
|
-
:
|
6
|
-
|
7
|
-
|
4
|
+
def self.attr_list
|
5
|
+
[:code, :name, :cost_updated_at, :sellable, :product_category_code,
|
6
|
+
:product_provider_code, :vat_rate, :taxed_cost, :vat_cost, :total_cost,
|
7
|
+
:pending_ordered_quantity, :stocks, :prices, :category, :provider]
|
8
|
+
end
|
9
|
+
|
10
|
+
attr_reader *attr_list
|
8
11
|
|
9
12
|
def initialize(attributes={})
|
10
|
-
attributes.each do |k,v|
|
13
|
+
attributes.each do |k, v|
|
11
14
|
if k == 'category'
|
12
15
|
@category = ProductCategory.new(v)
|
13
16
|
elsif k == 'provider'
|
14
17
|
@provider = ProductProvider.new(v)
|
15
18
|
elsif k == 'stocks'
|
16
19
|
@stocks = v.map { |s| Stock.new(s) }
|
20
|
+
elsif k == 'prices'
|
21
|
+
@prices = v.map { |s| ProductListPrice.new(s) }
|
17
22
|
else
|
18
23
|
self.send("#{k}=", v) if self.respond_to?(k)
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
23
|
-
def
|
24
|
-
stocks.
|
28
|
+
def stock_total
|
29
|
+
stocks.map(&:quantity).sum
|
30
|
+
end
|
31
|
+
|
32
|
+
def stock_sum(shop_codes)
|
33
|
+
formatted_shop_codes = shop_codes.map(&:to_s).map(&:upcase)
|
34
|
+
|
35
|
+
stocks.find_all { |s|
|
36
|
+
formatted_shop_codes.include?(s.shop_code.to_s.upcase)
|
37
|
+
}.map(&:quantity).sum
|
38
|
+
end
|
39
|
+
|
40
|
+
def stock_at(shop_code)
|
41
|
+
stocks.find { |s|
|
42
|
+
s.shop_code.to_s.upcase == shop_code.to_s.upcase
|
43
|
+
}.try(:quantity).to_i
|
25
44
|
end
|
26
45
|
|
27
|
-
def
|
28
|
-
|
46
|
+
def price_date_for_list(price_list_code)
|
47
|
+
prices.find { |p|
|
48
|
+
p.price_list_code.to_i == price_list_code.to_i
|
49
|
+
}.try(:price_updated_at)
|
29
50
|
end
|
51
|
+
|
52
|
+
def markup_with_list(price_list_code)
|
53
|
+
prices.find { |p|
|
54
|
+
p.price_list_code.to_i == price_list_code.to_i
|
55
|
+
}.try(:markup) || 0.0
|
56
|
+
end
|
57
|
+
|
58
|
+
def price_with_list(price_list_code)
|
59
|
+
prices.find { |p|
|
60
|
+
p.price_list_code.to_i == price_list_code.to_i
|
61
|
+
}.try(:total_price) || 0.0
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
attr_writer *attr_list
|
30
67
|
end
|
31
68
|
end
|
32
69
|
end
|
@@ -1,13 +1,21 @@
|
|
1
1
|
module Xsys
|
2
2
|
module Model
|
3
3
|
class ProductCategory
|
4
|
-
|
4
|
+
def self.attr_list
|
5
|
+
[:code, :name]
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader *attr_list
|
5
9
|
|
6
10
|
def initialize(attributes={})
|
7
|
-
attributes.each do |k,v|
|
11
|
+
attributes.each do |k, v|
|
8
12
|
self.send("#{k}=", v) if self.respond_to?(k)
|
9
13
|
end
|
10
14
|
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_writer *attr_list
|
11
19
|
end
|
12
20
|
end
|
13
21
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Xsys
|
2
|
+
module Model
|
3
|
+
class ProductPriceList
|
4
|
+
def self.attr_list
|
5
|
+
[:product_code, :product_name, :price_list_code,
|
6
|
+
:total_price, :markup, :price_updated_at]
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader *attr_list
|
10
|
+
|
11
|
+
def initialize(attributes={})
|
12
|
+
attributes.each do |k, v|
|
13
|
+
self.send("#{k}=", v) if self.respond_to?(k)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_writer *attr_list
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,14 +1,22 @@
|
|
1
1
|
module Xsys
|
2
2
|
module Model
|
3
3
|
class ProductProvider
|
4
|
-
|
5
|
-
:
|
4
|
+
def self.attr_list
|
5
|
+
[:code, :name, :address, :zip_code, :phone,
|
6
|
+
:cuit, :email, :province, :locality, :vat_kind]
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader *attr_list
|
6
10
|
|
7
11
|
def initialize(attributes={})
|
8
|
-
attributes.each do |k,v|
|
12
|
+
attributes.each do |k, v|
|
9
13
|
self.send("#{k}=", v) if self.respond_to?(k)
|
10
14
|
end
|
11
15
|
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_writer *attr_list
|
12
20
|
end
|
13
21
|
end
|
14
22
|
end
|
data/lib/xsys/model/seller.rb
CHANGED
@@ -1,13 +1,21 @@
|
|
1
1
|
module Xsys
|
2
2
|
module Model
|
3
3
|
class Seller
|
4
|
-
|
4
|
+
def self.attr_list
|
5
|
+
[:code, :shop_code, :name]
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader *attr_list
|
5
9
|
|
6
10
|
def initialize(attributes={})
|
7
|
-
attributes.each do |k,v|
|
11
|
+
attributes.each do |k, v|
|
8
12
|
self.send("#{k}=", v) if self.respond_to?(k)
|
9
13
|
end
|
10
14
|
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_writer *attr_list
|
11
19
|
end
|
12
20
|
end
|
13
21
|
end
|
data/lib/xsys/model/shop.rb
CHANGED
@@ -1,35 +1,46 @@
|
|
1
1
|
module Xsys
|
2
2
|
module Model
|
3
3
|
class Shop
|
4
|
-
|
5
|
-
:
|
6
|
-
|
4
|
+
def self.attr_list
|
5
|
+
[:id, :code, :name, :stock_description, :commercial,
|
6
|
+
:virtual, :stockable, :has_target, :service, :physical_shop_code]
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader *attr_list
|
7
10
|
|
8
11
|
def initialize(attributes={})
|
9
|
-
attributes.each do |k,v|
|
12
|
+
attributes.each do |k, v|
|
10
13
|
self.send("#{k}=", v) if self.respond_to?(k)
|
11
14
|
end
|
12
15
|
end
|
13
16
|
|
14
17
|
def commercial?
|
15
|
-
|
18
|
+
commercial == true
|
16
19
|
end
|
17
20
|
|
18
21
|
def virtual?
|
19
|
-
|
22
|
+
virtual == true
|
20
23
|
end
|
21
24
|
|
22
|
-
def
|
23
|
-
|
25
|
+
def physical?
|
26
|
+
!virtual?
|
24
27
|
end
|
25
28
|
|
26
|
-
def
|
27
|
-
|
29
|
+
def stockable?
|
30
|
+
stockable == true
|
28
31
|
end
|
29
32
|
|
30
33
|
def service?
|
31
|
-
|
34
|
+
service == true
|
32
35
|
end
|
36
|
+
|
37
|
+
def with_target?
|
38
|
+
with_target == true
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
attr_writer *attr_list
|
33
44
|
end
|
34
45
|
end
|
35
46
|
end
|
data/lib/xsys/model/stock.rb
CHANGED
@@ -1,13 +1,21 @@
|
|
1
1
|
module Xsys
|
2
2
|
module Model
|
3
3
|
class Stock
|
4
|
-
|
4
|
+
def self.attr_list
|
5
|
+
[:shop_code, :quantity]
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader *attr_list
|
5
9
|
|
6
10
|
def initialize(attributes={})
|
7
|
-
attributes.each do |k,v|
|
11
|
+
attributes.each do |k, v|
|
8
12
|
self.send("#{k}=", v) if self.respond_to?(k)
|
9
13
|
end
|
10
14
|
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_writer *attr_list
|
11
19
|
end
|
12
20
|
end
|
13
21
|
end
|
data/lib/xsys/model/user.rb
CHANGED
@@ -1,13 +1,21 @@
|
|
1
1
|
module Xsys
|
2
2
|
module Model
|
3
3
|
class User
|
4
|
-
|
4
|
+
def self.attr_list
|
5
|
+
[:code, :name, :shop_code]
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader *attr_list
|
5
9
|
|
6
10
|
def initialize(attributes={})
|
7
|
-
attributes.each do |k,v|
|
11
|
+
attributes.each do |k, v|
|
8
12
|
self.send("#{k}=", v) if self.respond_to?(k)
|
9
13
|
end
|
10
14
|
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_writer *attr_list
|
11
19
|
end
|
12
20
|
end
|
13
21
|
end
|
data/lib/xsys/pagination.rb
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
module Xsys
|
2
2
|
class Pagination
|
3
|
-
|
3
|
+
def self.attr_list
|
4
|
+
[:page_index, :page_size, :pages_count, :records_count, :total_records_count]
|
5
|
+
end
|
6
|
+
|
7
|
+
attr_reader *attr_list
|
4
8
|
|
5
9
|
def initialize(attributes={})
|
6
|
-
attributes.each do |k,v|
|
7
|
-
self.send("#{k}=", v)
|
10
|
+
attributes.each do |k, v|
|
11
|
+
self.send("#{k}=", v) if self.respond_to?(k)
|
8
12
|
end
|
9
13
|
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
attr_writer *attr_list
|
10
18
|
end
|
11
19
|
end
|
data/lib/xsys/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xsys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matias Hick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -64,25 +64,14 @@ files:
|
|
64
64
|
- README.md
|
65
65
|
- lib/xsys.rb
|
66
66
|
- lib/xsys/api.rb
|
67
|
-
- lib/xsys/model/grouped_purchase_order_item.rb
|
68
|
-
- lib/xsys/model/grouped_sale_item.rb
|
69
67
|
- lib/xsys/model/price_list.rb
|
70
68
|
- lib/xsys/model/product.rb
|
71
69
|
- lib/xsys/model/product_category.rb
|
70
|
+
- lib/xsys/model/product_price_list.rb
|
72
71
|
- lib/xsys/model/product_provider.rb
|
73
|
-
- lib/xsys/model/provider_kind.rb
|
74
|
-
- lib/xsys/model/purchase_order_item.rb
|
75
|
-
- lib/xsys/model/purchases_position.rb
|
76
|
-
- lib/xsys/model/sale_item.rb
|
77
|
-
- lib/xsys/model/sales_period.rb
|
78
|
-
- lib/xsys/model/sales_position.rb
|
79
72
|
- lib/xsys/model/seller.rb
|
80
73
|
- lib/xsys/model/shop.rb
|
81
74
|
- lib/xsys/model/stock.rb
|
82
|
-
- lib/xsys/model/stock_control.rb
|
83
|
-
- lib/xsys/model/stock_control_item.rb
|
84
|
-
- lib/xsys/model/transaction.rb
|
85
|
-
- lib/xsys/model/transaction_item.rb
|
86
75
|
- lib/xsys/model/user.rb
|
87
76
|
- lib/xsys/pagination.rb
|
88
77
|
- lib/xsys/version.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Xsys
|
2
|
-
module Model
|
3
|
-
class GroupedPurchaseOrderItem
|
4
|
-
attr_accessor :quantity, :remaining_quantity, :product_id
|
5
|
-
|
6
|
-
def initialize(attributes={})
|
7
|
-
attributes.each do |k,v|
|
8
|
-
self.send("#{k}=", v) if self.respond_to?(k)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Xsys
|
2
|
-
module Model
|
3
|
-
class GroupedSaleItem
|
4
|
-
attr_accessor :shop_code, :product_id, :seller_id, :quantity, :amount_total
|
5
|
-
|
6
|
-
def initialize(attributes={})
|
7
|
-
attributes.each do |k,v|
|
8
|
-
self.send("#{k}=", v) if self.respond_to?(k)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Xsys
|
2
|
-
module Model
|
3
|
-
class ProviderKind
|
4
|
-
attr_accessor :id, :name
|
5
|
-
|
6
|
-
def initialize(attributes={})
|
7
|
-
attributes.each do |k,v|
|
8
|
-
if k == 'kind'
|
9
|
-
@kind = ProviderKind.new(v)
|
10
|
-
else
|
11
|
-
self.send("#{k}=", v) if self.respond_to?(k)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module Xsys
|
2
|
-
module Model
|
3
|
-
class PurchaseOrderItem
|
4
|
-
attr_accessor :product_id, :quantity, :remaining_quantity,
|
5
|
-
:transaction_date, :transaction_status_id, :transaction_kind_id
|
6
|
-
|
7
|
-
def initialize(attributes={})
|
8
|
-
attributes.each do |k,v|
|
9
|
-
self.send("#{k}=", v) if self.respond_to?(k)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Xsys
|
2
|
-
module Model
|
3
|
-
class PurchasesPosition
|
4
|
-
attr_accessor :business_unit, :amount_taxes_21, :amount_taxes_27,
|
5
|
-
:amount_taxes_10_5, :amount_total, :amount_iva_perception, :amount_iva_retention
|
6
|
-
|
7
|
-
def initialize(attributes={})
|
8
|
-
attributes.each do |k,v|
|
9
|
-
self.send("#{k}=", v) if self.respond_to?(k)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def taxes_grand_total
|
14
|
-
amount_taxes_27 + amount_taxes_21 + amount_taxes_10_5 + amount_iva_perception + amount_iva_retention
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/xsys/model/sale_item.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
module Xsys
|
2
|
-
module Model
|
3
|
-
class SaleItem
|
4
|
-
attr_accessor :shop_code, :product_id, :seller_id, :quantity, :amount_total,
|
5
|
-
:client_id, :transaction_date, :receipt_number, :transaction_id,
|
6
|
-
:transaction_kind_id, :transaction_status_id
|
7
|
-
|
8
|
-
def initialize(attributes={})
|
9
|
-
attributes.each do |k,v|
|
10
|
-
self.send("#{k}=", v) if self.respond_to?(k)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Xsys
|
2
|
-
module Model
|
3
|
-
class SalesPeriod
|
4
|
-
attr_accessor :shop_code, :seller_id, :transaction_period, :amount_total, :amount_taxes
|
5
|
-
|
6
|
-
def initialize(attributes={})
|
7
|
-
attributes.each do |k,v|
|
8
|
-
self.send("#{k}=", v) if self.respond_to?(k)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Xsys
|
2
|
-
module Model
|
3
|
-
class SalesPosition
|
4
|
-
attr_accessor :shop_code, :business_unit, :amount_taxes_21,
|
5
|
-
:amount_taxes_10_5, :amount_total, :extra_payments_total
|
6
|
-
|
7
|
-
def initialize(attributes={})
|
8
|
-
attributes.each do |k,v|
|
9
|
-
self.send("#{k}=", v) if self.respond_to?(k)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def sales_grand_total
|
14
|
-
amount_total + extra_payments_total
|
15
|
-
end
|
16
|
-
|
17
|
-
def extra_payments_avg
|
18
|
-
(extra_payments_total / sales_grand_total).round(2)
|
19
|
-
end
|
20
|
-
|
21
|
-
def taxes_grand_total
|
22
|
-
amount_taxes_21 + amount_taxes_10_5
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Xsys
|
2
|
-
module Model
|
3
|
-
class StockControl
|
4
|
-
attr_accessor :shop_code, :transaction_id, :receipt_number,
|
5
|
-
:transaction_date, :product_category_id, :product_category_name,
|
6
|
-
:user_id, :user_name, :errors_count
|
7
|
-
|
8
|
-
def initialize(attributes={})
|
9
|
-
attributes.each do |k,v|
|
10
|
-
if k.to_s == 'transaction_date'
|
11
|
-
self.transaction_date = Date.parse(v) unless v.nil?
|
12
|
-
else
|
13
|
-
self.send("#{k}=", v) if self.respond_to?(k)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module Xsys
|
2
|
-
module Model
|
3
|
-
class StockControlItem
|
4
|
-
attr_accessor :shop_code, :transaction_id, :product_category_id,
|
5
|
-
:product_id, :quantity, :miles, :packages
|
6
|
-
|
7
|
-
def initialize(attributes={})
|
8
|
-
attributes.each do |k,v|
|
9
|
-
self.send("#{k}=", v) if self.respond_to?(k)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Xsys
|
2
|
-
module Model
|
3
|
-
class Transaction
|
4
|
-
attr_accessor :id, :shop_id, :transaction_kind_id,
|
5
|
-
:receipt_number, :product_id, :client_id, :workshop_id,
|
6
|
-
:product_provider_id, :transaction_status_id, :transaction_date,
|
7
|
-
:logical_section_id, :physical_section_id, :seller_id, :user_id,
|
8
|
-
:shop_code, :user, :items
|
9
|
-
|
10
|
-
def initialize(attributes={})
|
11
|
-
attributes.each do |k,v|
|
12
|
-
if k.to_s == 'transaction_date'
|
13
|
-
self.transaction_date = Date.parse(v) unless v.nil?
|
14
|
-
elsif k.to_s == 'user'
|
15
|
-
self.user = User.new(v) unless v.nil?
|
16
|
-
elsif k.to_s == 'items'
|
17
|
-
self.items = v.map { |x| TransactionItem.new(x) }
|
18
|
-
else
|
19
|
-
self.send("#{k}=", v) if self.respond_to?(k)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Xsys
|
2
|
-
module Model
|
3
|
-
class TransactionItem
|
4
|
-
attr_accessor :product_id, :transaction_status_id,
|
5
|
-
:quantity, :remaining_quantity, :qa_flag, :qa_date,
|
6
|
-
:amount_total, :cost, :packages, :miles
|
7
|
-
|
8
|
-
def initialize(attributes={})
|
9
|
-
attributes.each do |k,v|
|
10
|
-
self.send("#{k}=", v) if self.respond_to?(k)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|