xsys 0.12.0 → 0.13.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/model/product.rb +41 -11
- data/lib/xsys/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fb62153eeb269bd03c7b39b09742eae6a861d32
|
4
|
+
data.tar.gz: 67e032fb51aa2be9d634cbf8759a70b7cc1965ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 491249a982193eecb15d80fc61da96b4b87dc6fdb194b1d37f83684b175df6a8f70c970b7df685d5efaaddcd319763a095aa9dfc4e53b88f0368a91a034f411f
|
7
|
+
data.tar.gz: 224a735d55669453c63d5228a8d942cc3a63d1508d5b050bd41e06b327a020550f63e1264ec11ab529b0d24690a2029053da7a220b35854b26e9acb25cb30cbf
|
data/CHANGELOG.md
CHANGED
data/lib/xsys/model/product.rb
CHANGED
@@ -40,27 +40,39 @@ module Xsys
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
def stock_quantity(
|
44
|
-
if
|
43
|
+
def stock_quantity(shop_code_or_array=nil)
|
44
|
+
if shop_code_or_array.nil?
|
45
45
|
stocks.map(&:quantity).sum
|
46
|
+
elsif shop_code_or_array.is_a?(Array)
|
47
|
+
stocks.find_all { |s| shop_code_or_array.include?(s.code) }.map(&:quantity).sum
|
48
|
+
elsif shop_code_or_array.is_a?(String)
|
49
|
+
stocks.find_all { |s| shop_code_or_array.upcase == s.code }.map(&:quantity).sum
|
46
50
|
else
|
47
|
-
|
51
|
+
raise 'invalid input!'
|
48
52
|
end
|
49
53
|
end
|
50
54
|
|
51
|
-
def stock_available(
|
52
|
-
if
|
55
|
+
def stock_available(shop_code_or_array=nil)
|
56
|
+
if shop_code_or_array.nil?
|
53
57
|
stocks.map(&:available).sum
|
58
|
+
elsif shop_code_or_array.is_a?(Array)
|
59
|
+
stocks.find_all { |s| shop_code_or_array.include?(s.code) }.map(&:available).sum
|
60
|
+
elsif shop_code_or_array.is_a?(String)
|
61
|
+
stocks.find_all { |s| shop_code_or_array.upcase == s.code }.map(&:available).sum
|
54
62
|
else
|
55
|
-
|
63
|
+
raise 'invalid input!'
|
56
64
|
end
|
57
65
|
end
|
58
66
|
|
59
|
-
def stock_reserved(
|
60
|
-
if
|
67
|
+
def stock_reserved(shop_code_or_array=nil)
|
68
|
+
if shop_code_or_array.nil?
|
61
69
|
stocks.map(&:reserved).sum
|
70
|
+
elsif shop_code_or_array.is_a?(Array)
|
71
|
+
stocks.find_all { |s| shop_code_or_array.include?(s.code) }.map(&:reserved).sum
|
72
|
+
elsif shop_code_or_array.is_a?(String)
|
73
|
+
stocks.find_all { |s| shop_code_or_array.upcase == s.code }.map(&:reserved).sum
|
62
74
|
else
|
63
|
-
|
75
|
+
raise 'invalid input!'
|
64
76
|
end
|
65
77
|
end
|
66
78
|
|
@@ -74,7 +86,25 @@ module Xsys
|
|
74
86
|
stocks.find_all { |x| x.sellable }
|
75
87
|
end
|
76
88
|
|
77
|
-
def
|
89
|
+
def sellable_stocks_quantity
|
90
|
+
sellable_stocks.map(&:quantity).sum
|
91
|
+
end
|
92
|
+
|
93
|
+
def sellable_stocks_reserved
|
94
|
+
sellable_stocks.map(&:reserved).sum
|
95
|
+
end
|
96
|
+
|
97
|
+
def sellable_stocks_available
|
98
|
+
sellable_stocks.map(&:available).sum
|
99
|
+
end
|
100
|
+
|
101
|
+
def price_list(price_list_id)
|
102
|
+
prices.find { |p|
|
103
|
+
p.price_list_id.to_i == price_list_id.to_i
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
def price_date_with_list(price_list_id)
|
78
108
|
prices.find { |p|
|
79
109
|
p.price_list_id.to_i == price_list_id.to_i
|
80
110
|
}.try(:price_update_date)
|
@@ -86,7 +116,7 @@ module Xsys
|
|
86
116
|
}.try(:markup) || BigDecimal.new('0.0')
|
87
117
|
end
|
88
118
|
|
89
|
-
def
|
119
|
+
def total_price_with_list(price_list_id)
|
90
120
|
prices.find { |p|
|
91
121
|
p.price_list_id.to_i == price_list_id.to_i
|
92
122
|
}.try(:total_price) || BigDecimal.new('0.0')
|
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.
|
4
|
+
version: 0.13.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: 2017-02-
|
11
|
+
date: 2017-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|