xsys 0.2.7 → 0.2.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e48b74cf123cff4e26ecffc9dd96885045b1e2fe
4
- data.tar.gz: 8c2de280c5e5c89d5b8ce96920007e931dd4d901
3
+ metadata.gz: 1cde467a27a16527e89a57b0ff8d4c80366c6128
4
+ data.tar.gz: 0788677211a261ecf945b3bd61ec3c277c178536
5
5
  SHA512:
6
- metadata.gz: ebc8122153abdfcf4b2ad95c5e77fc8e23f008fd8de8ce3037c401d3bb90a7cc8b6b6fc5f2f1873a432296104d6205d4b77c280e5349aad241b9ecd41c653832
7
- data.tar.gz: dc063ef9bfa181ebc36371301c6ee0fa687599b69b7dc8b15d598fa198a7ce1d10e5c712d2e550562ded76b200cca2be26dc9b801bffbd8c52c20ae13a7b20da
6
+ metadata.gz: db341f31056282d1a739bf57928f69d244598c959a80a4c372ef32ba783647333ce2be4d7710e290c19e63868e8f76aa5f45f97390fddcd0251d07c23ae33988
7
+ data.tar.gz: 3cea83104970aa39cd52730ca35de29ec4efe2e180a28187ed211a237326ca88d3a922c80e620756e578968bd706ea35625b506c940a192bb1a3965058cefedf
data/CHANGELOG.md CHANGED
@@ -145,3 +145,7 @@
145
145
  ## v0.2.7
146
146
 
147
147
  * Bugfixed param cash withdrawal items
148
+
149
+ ## v0.2.8
150
+
151
+ * Changed interface API
data/lib/xsys/api.rb CHANGED
@@ -35,8 +35,8 @@ module Xsys
35
35
  end
36
36
  end
37
37
 
38
- def self.get_product(product_code)
39
- Model::Product.new(get_request("/api/products/#{product_code}")[:body])
38
+ def self.get_product(product_id)
39
+ Model::Product.new(get_request("/api/products/#{product_id}")[:body])
40
40
  end
41
41
 
42
42
  def self.get_product_providers(filters={})
@@ -52,8 +52,8 @@ module Xsys
52
52
  end
53
53
  end
54
54
 
55
- def self.get_product_provider(provider_code)
56
- Model::ProductProvider.new(get_request("/api/product_providers/#{provider_code}")[:body])
55
+ def self.get_product_provider(provider_id)
56
+ Model::ProductProvider.new(get_request("/api/product_providers/#{provider_id}")[:body])
57
57
  end
58
58
 
59
59
  def self.get_product_categories(filters={})
@@ -69,8 +69,8 @@ module Xsys
69
69
  end
70
70
  end
71
71
 
72
- def self.get_product_category(category_code)
73
- Model::ProductCategory.new(get_request("/api/product_categories/#{category_code}")[:body])
72
+ def self.get_product_category(category_id)
73
+ Model::ProductCategory.new(get_request("/api/product_categories/#{category_id}")[:body])
74
74
  end
75
75
 
76
76
  def self.get_product_price_lists(filters={})
@@ -2,7 +2,7 @@ module Xsys
2
2
  module Model
3
3
  class PriceList
4
4
  def self.attr_list
5
- [:code, :name]
5
+ [:id, :name]
6
6
  end
7
7
 
8
8
  attr_reader *attr_list
@@ -2,8 +2,8 @@ module Xsys
2
2
  module Model
3
3
  class Product
4
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,
5
+ [:id, :name, :cost_updated_at, :sellable, :product_category_id,
6
+ :product_provider_id, :vat_rate, :taxed_cost, :vat_cost, :total_cost,
7
7
  :pending_ordered_quantity, :stocks, :prices, :category, :provider]
8
8
  end
9
9
 
@@ -27,7 +27,17 @@ module Xsys
27
27
  end
28
28
  end
29
29
 
30
- def stock_total
30
+ def sellable_stocks_quantity
31
+ stocks.find_all { |s|
32
+ !['SER', 'EXT'].include?(s.shop_code)
33
+ }.map(&:quantity).sum
34
+ end
35
+
36
+ def service_stocks_quantity
37
+ stocks_quantity - sellable_stocks_quantity
38
+ end
39
+
40
+ def stocks_quantity
31
41
  stocks.map(&:quantity).sum
32
42
  end
33
43
 
@@ -45,21 +55,21 @@ module Xsys
45
55
  }.try(:quantity).to_i
46
56
  end
47
57
 
48
- def price_date_for_list(price_list_code)
58
+ def price_date_for_list(price_list_id)
49
59
  prices.find { |p|
50
- p.price_list_code.to_i == price_list_code.to_i
60
+ p.price_list_id.to_i == price_list_id.to_i
51
61
  }.try(:price_updated_at)
52
62
  end
53
63
 
54
- def markup_with_list(price_list_code)
64
+ def markup_with_list(price_list_id)
55
65
  prices.find { |p|
56
- p.price_list_code.to_i == price_list_code.to_i
66
+ p.price_list_id.to_i == price_list_id.to_i
57
67
  }.try(:markup) || 0.0
58
68
  end
59
69
 
60
- def price_in_list(price_list_code)
70
+ def price_in_list(price_list_id)
61
71
  prices.find { |p|
62
- p.price_list_code.to_i == price_list_code.to_i
72
+ p.price_list_id.to_i == price_list_id.to_i
63
73
  }.try(:total_price) || 0.0
64
74
  end
65
75
 
@@ -2,7 +2,7 @@ module Xsys
2
2
  module Model
3
3
  class ProductCategory
4
4
  def self.attr_list
5
- [:code, :name]
5
+ [:id, :name]
6
6
  end
7
7
 
8
8
  attr_reader *attr_list
@@ -2,7 +2,7 @@ module Xsys
2
2
  module Model
3
3
  class ProductPriceList
4
4
  def self.attr_list
5
- [:product_code, :product_name, :price_list_code,
5
+ [:product_id, :product_name, :price_list_id,
6
6
  :total_price, :markup, :price_updated_at]
7
7
  end
8
8
 
@@ -2,7 +2,7 @@ module Xsys
2
2
  module Model
3
3
  class ProductProvider
4
4
  def self.attr_list
5
- [:code, :name, :address, :zip_code, :phone,
5
+ [:id, :name, :address, :zip_code, :phone,
6
6
  :cuit, :email, :province, :locality, :vat_kind]
7
7
  end
8
8
 
data/lib/xsys/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Xsys
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
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.2.7
4
+ version: 0.2.8
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-05-04 00:00:00.000000000 Z
11
+ date: 2014-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -74,7 +74,6 @@ files:
74
74
  - lib/xsys/model/seller.rb
75
75
  - lib/xsys/model/shop.rb
76
76
  - lib/xsys/model/stock.rb
77
- - lib/xsys/model/user.rb
78
77
  - lib/xsys/pagination.rb
79
78
  - lib/xsys/version.rb
80
79
  homepage: https://github.com/unformattmh/xsys
@@ -1,21 +0,0 @@
1
- module Xsys
2
- module Model
3
- class User
4
- def self.attr_list
5
- [:code, :name, :shop_code]
6
- end
7
-
8
- attr_reader *attr_list
9
-
10
- def initialize(attributes={})
11
- attributes.each do |k, v|
12
- self.send("#{k}=", v) if self.respond_to?(k)
13
- end
14
- end
15
-
16
- private
17
-
18
- attr_writer *attr_list
19
- end
20
- end
21
- end