xsys 0.11.1 → 0.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d78e68798930dc67a4590142a2e7f0f02cb8a3a9
4
- data.tar.gz: 2fbdb77c23c7756b89d85cde9e3ad01b38c41335
3
+ metadata.gz: a827bdbae0d2ad9595a966e968404f083f61b5ab
4
+ data.tar.gz: 21f0a0a3917fcac505deaa3e44625842729d6bdd
5
5
  SHA512:
6
- metadata.gz: cb8021a9bc5bb0c870287f3c1be956efd9dc7a17e192de9243e9e67766481a078ee6f6359f7b7bfb27696a9716ae7214de16a424d372de238b5fe5f0efd084d1
7
- data.tar.gz: 91a8ef879e029b56100f03c0bec1e3feaeb1c08d25b0b93be12e71479ad023bdc00fbdefe1fe11d24393d2733b4d11e1769a14f16f476a22951a7820cb8283cb
6
+ metadata.gz: a1f6e51742a4d44094f8bf14d0332356e7a1afe7e3d9d21978c312644a5ea05cc45fcbacdcda8c411153fe940d30f51cd8d0f1c2f315bac64e41c118486ec2d2
7
+ data.tar.gz: bd9dc492e2315e52630e516275ac7146e5ffcb9a5aacdf692968b42bfbeba7502cb9124547f43979b20bf75ca70209b735b18d1912ede0087bebd02dacb09167
data/CHANGELOG.md CHANGED
@@ -302,10 +302,14 @@
302
302
 
303
303
  * Added has availability_date attribute to products
304
304
 
305
- ## v0.11
305
+ ## v0.11.0
306
306
 
307
307
  * Changed stock to show reserved, available quantity and removed shop fields
308
308
 
309
309
  ## v0.11.1
310
310
 
311
311
  * Added shop_service
312
+
313
+ ## v0.12.0
314
+
315
+ * Fixes for products and stocks
@@ -2,15 +2,13 @@ module Xsys
2
2
  module Model
3
3
  class Product
4
4
  def self.attr_list
5
- [:id, :name, :sellable, :product_category_id,
6
- :product_provider_id, :vat_rate, :taxed_cost, :vat_cost, :total_cost,
7
- :pending_ordered_quantity, :stocks, :prices, :category, :provider,
8
- :last_total_cost, :last_taxed_cost, :cost_update_date, :cost_update_time,
9
- :last_cost_update_date, :last_cost_update_time, :price_update_date, :price_update_time,
10
- :online_stock, :product_size_code, :weight, :length, :width, :height, :packages_quantity,
11
- :ean, :packages, :regular_price, :reduced_price, :credit_card_price, :brand, :model,
12
- :has_stock_on_hold, :availability_date
13
- ]
5
+ [:id, :name, :sellable, :product_category_id, :product_provider_id, :vat_rate,
6
+ :taxed_cost, :vat_cost, :total_cost, :pending_ordered_quantity, :stocks, :prices,
7
+ :category, :provider, :last_total_cost, :last_taxed_cost, :cost_update_date,
8
+ :cost_update_time, :last_cost_update_date, :last_cost_update_time, :price_update_date,
9
+ :price_update_time, :online_stock, :product_size_code, :weight, :length, :width,
10
+ :height, :packages_quantity, :ean, :packages, :regular_price, :reduced_price,
11
+ :credit_card_price, :brand, :model, :has_stock_on_hold, :availability_date]
14
12
  end
15
13
 
16
14
  attr_reader *attr_list
@@ -42,46 +40,38 @@ module Xsys
42
40
  end
43
41
  end
44
42
 
45
- def sellable_stocks
46
- stocks.find_all { |s| !s.shop_service }
47
- end
48
-
49
- def sellable_stocks_quantity(options={})
50
- result = 0
51
-
52
- sellable_stocks.each do |stock|
53
- result += stock.quantity
43
+ def stock_quantity(shop_codes=[])
44
+ if shop_codes.empty?
45
+ stocks.map(&:quantity).sum
46
+ else
47
+ stocks.find_all { |s| shop_codes.include?(s.code) }.map(&:quantity).sum
54
48
  end
55
-
56
- result
57
- end
58
-
59
- def service_stocks
60
- stocks.find_all { |s| s.shop_service }
61
49
  end
62
50
 
63
- def service_stocks_quantity
64
- service_stocks.map(&:quantity).sum
65
- end
66
-
67
- def stocks_quantity
68
- stocks.map(&:quantity).sum
51
+ def stock_available(shop_codes=[])
52
+ if shop_codes.empty?
53
+ stocks.map(&:available).sum
54
+ else
55
+ stocks.find_all { |s| shop_codes.include?(s.code) }.map(&:available).sum
56
+ end
69
57
  end
70
58
 
71
- def stock_sum(shop_codes)
72
- formatted_shop_codes = shop_codes.map(&:to_s).map(&:upcase)
73
-
74
- stocks.find_all { |s|
75
- formatted_shop_codes.include?(s.shop_code.to_s.upcase)
76
- }.map(&:quantity).sum
59
+ def stock_reserved(shop_codes=[])
60
+ if shop_codes.empty?
61
+ stocks.map(&:reserved).sum
62
+ else
63
+ stocks.find_all { |s| shop_codes.include?(s.code) }.map(&:reserved).sum
64
+ end
77
65
  end
78
66
 
79
- def stock_at(shop_code, options={})
80
- stock = stocks.find { |s|
67
+ def stock_at(shop_code)
68
+ stocks.find { |s|
81
69
  s.shop_code.to_s.upcase == shop_code.to_s.upcase
82
70
  }
71
+ end
83
72
 
84
- stock.quantity
73
+ def sellable_stocks
74
+ stocks.find_all { |x| x.sellable }
85
75
  end
86
76
 
87
77
  def price_date_for_list(price_list_id)
@@ -2,10 +2,8 @@ module Xsys
2
2
  module Model
3
3
  class Shop
4
4
  def self.attr_list
5
- [:id, :code, :name, :stock_description, :commercial,
6
- :virtual, :stockable, :has_target, :service, :physical_shop_code,
7
- :position, :has_stock_control, :has_exhibition, :stock_sellable,
8
- :stock_sellable, :enabled, :physical_shop_id, :last_update]
5
+ [:id, :code, :name, :commercial, :virtual, :stockable, :has_target,
6
+ :position, :has_stock_control, :stock_sellable, :enabled, :kind]
9
7
  end
10
8
 
11
9
  attr_reader *attr_list
@@ -32,16 +30,12 @@ module Xsys
32
30
  stockable == true
33
31
  end
34
32
 
35
- def service?
36
- service == true
37
- end
38
-
39
33
  def has_target?
40
34
  has_target == true
41
35
  end
42
36
 
43
- def has_exhibition?
44
- has_exhibition == true
37
+ def has_stock_control?
38
+ has_stock_control == true
45
39
  end
46
40
 
47
41
  def stock_sellable?
@@ -11,7 +11,7 @@ module Xsys
11
11
  :quantity_update_date,
12
12
  :reserved_update_time,
13
13
  :reserved_update_date,
14
- :shop_service
14
+ :sellable
15
15
  ]
16
16
  end
17
17
 
data/lib/xsys/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Xsys
2
- VERSION = "0.11.1"
2
+ VERSION = "0.12.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xsys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias Hick