sales_and_orders_decorator 0.1.3 → 0.1.4

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: 52adf7fb40aeb25b51267d302b98ad4b35a18a13
4
- data.tar.gz: d1dddc8bb4f81b293b746de28cc902fd99aa292c
3
+ metadata.gz: 05e350dd6294e496a203c49be9ca501263219294
4
+ data.tar.gz: 2d2a90b80ad02d6f91dd21cce03bd0ad68f67b3b
5
5
  SHA512:
6
- metadata.gz: 396aff77d56ab42d12564b4e4feeb40d5ab291465bef8f7ecadd88994dc1079797a4a103d2341744ccd45698351c4af44c6586dc3111bd4b6992f286b68ef512
7
- data.tar.gz: 0b5017cb0f6645d8a3c87cc21ce2cdd51621364c4ee3d45d3f64d36fd672d900e36965ad572ec0b7f2b1906f535ddbaa53b0398151543f58fba620128c8cbece
6
+ metadata.gz: 4ca8161027b04abe0824c641237964ca0d6fc86adb358003f01dc5f9edbedfd3449f1430f8c8943d01fc6a0b493b4ad0396175e05399da5380f667ba80b723c8
7
+ data.tar.gz: b8a816093ffd9ca29ce74bf75b2f9647b9b5936bf436f2a478e0c4e24856c394cca532dbdb773031f432dad757ec52d6e57647cf5ba005332b3427a1da72c6b9
@@ -1,40 +1,48 @@
1
1
  require "sales_and_orders_decorator/version"
2
2
 
3
- # the concret component we would like to decorate, a car in our example
3
+ #This component class initialises an empty sales array to store the sales details for each docrators
4
4
  class BasicSales
5
+ #initialises an empty array for the decorator
5
6
  def initialize
6
7
  @sales_array = []
7
8
  end
8
9
 
9
- # getter method
10
+ # returns sales array
10
11
  def sales_array
11
12
  return @sales_array
12
13
  end
13
14
 
15
+ #returns total sale value
14
16
  def totalSale_counter_method
15
17
  return @totalSale_order
16
18
  end
17
19
 
20
+ #returns total quantity sold value
18
21
  def totalSale_quantity_method
19
22
  return @totalSale_quantity
20
23
  end
21
24
 
25
+ #returns total veg pizza quantity sold value
22
26
  def vegCounter_method
23
27
  return @vegCounter
24
28
  end
25
29
 
30
+ #returns total non veg pizza quantity sold value
26
31
  def nonVegCounter_method
27
32
  return @nonVegCounter
28
33
  end
29
34
 
35
+ #returns total offered pizza quantity sold value
30
36
  def offeredSale_counter_method
31
37
  return @offeredSale_counter
32
38
  end
33
39
 
40
+ #returns total non offered pizza quantity sold value
34
41
  def nonOfferedSale_counter_method
35
42
  return @nonOfferedSale_counter
36
43
  end
37
44
 
45
+ #a common method to define a logic of selecting the datas for the last 24 hours where the products sold in the specific time line.
38
46
  def common_method
39
47
  product_sale.each do |product|
40
48
  sale_boolean = product.created_at.between?(Time.now.midnight-1.day,Time.now.midnight)
@@ -46,9 +54,10 @@ class BasicSales
46
54
 
47
55
  end
48
56
 
49
- # decorator class -- this serves as the superclass for all the concrete decorators
50
- # the base/super class decorator (i.e. no actual decoration yet), each concrete decorator (i.e. subclass) will add its own decoration
57
+ # decorator class -- this serves as the superclass for all the concrete decorators.
58
+ #This class provides the structure to all decorator class to define the logic
51
59
  class BuisnessDecorator
60
+ #initialise all the values required to calculate the sales expenditure for the previous day.
52
61
  def initialize(root_sales)
53
62
  @root_sales = root_sales
54
63
  @totalSale_counter = 0
@@ -60,38 +69,47 @@ class BuisnessDecorator
60
69
  @profit_counter = 0
61
70
  end
62
71
 
72
+ #returns the sales array from the component class
63
73
  def sales_array
64
74
  return @root_sales.sales_array
65
75
  end
66
76
 
77
+ #returns the total sales with the root class total sales which is calculated already
67
78
  def totalSale_counter_method
68
79
  @totalSale_counter += sd.totalSale
69
80
  end
70
81
 
82
+ #returns the total quantity sales with the root class total quantity sales sold which is calculated already
71
83
  def totalSale_quantity_method
72
84
  return @totalSale_quantity
73
85
  end
74
86
 
87
+ #returns the total profit sales with the root class total profit of the sales sold which is calculated already
75
88
  def profit_counter_method
76
89
  @profit_counter += sd.profit
77
90
  end
78
91
 
92
+ #returns the total veg type quantity sales with the root class total veg pizza quantity sales sold that is calculated already
79
93
  def vegCounter_method
80
94
  @vegCounter += sd.vegSale
81
95
  end
82
96
 
97
+ #returns the total non veg type quantity sales with the root class total veg pizza quantity sales sold that is calculated already
83
98
  def nonVegCounter_method
84
99
  @nonVegCounter += sd.nonVegSale
85
100
  end
86
101
 
102
+ #returns the total offered type quantity sales with the root class total offered pizza quantity sales sold that is calculated already
87
103
  def offeredSale_counter_method
88
104
  @offeredSale_counter += sd.offeredSale
89
105
  end
90
106
 
107
+ #returns the total non offered type quantity sales with the root class total non offered pizza quantity sales sold that is calculated already
91
108
  def nonOfferedSale_counter_method
92
109
  @nonOfferedSale_counter += sd.nonOfferedSale
93
110
  end
94
111
 
112
+ #returns the total profit sales with the root class total profit sales sold that is calculated already with the quantity of products sold
95
113
  def check_profit
96
114
  @root_sales.sales_array.each do |sd|
97
115
  @totalSale_counter += sd.total_price
@@ -101,6 +119,7 @@ class BuisnessDecorator
101
119
  @profit_counter = @totalSale_counter - @totalProductSold
102
120
  end
103
121
 
122
+ #to check thte offer availability and calculate the total sales of offered and non offered
104
123
  def check_offer
105
124
  @root_sales.sales_array.each do |sd|
106
125
  prod = Product.find(sd.product_id)
@@ -112,6 +131,7 @@ class BuisnessDecorator
112
131
  end
113
132
  end
114
133
 
134
+ #to check thte food type sales and calculate the total sales of veg and non veg ordered
115
135
  def check_foodType
116
136
  @root_sales.sales_array.each do |sd|
117
137
  prod = Product.find(sd.product_id)
@@ -127,6 +147,7 @@ class BuisnessDecorator
127
147
 
128
148
  end
129
149
 
150
+ #Common logic to sort the products for the previous 24 hrs time line.
130
151
  def common_method
131
152
  @product_sale.each do |product|
132
153
  sale_boolean = product.created_at.between?(Time.now.midnight-1.day,Time.now.midnight)
@@ -136,6 +157,7 @@ class BuisnessDecorator
136
157
  end
137
158
  end
138
159
 
160
+ #main method provides the sequence of all other method followed to generate a sales calculation
139
161
  def main_method
140
162
  common_method
141
163
  check_profit
@@ -152,13 +174,15 @@ class BuisnessDecorator
152
174
  end
153
175
 
154
176
 
155
- # a concrete decorator
177
+ # a concrete decorator for day sales stores the sales details calculated in the database with the below functionality
156
178
  class DaySalesDecorator < BuisnessDecorator
179
+ #method used to initialise the day sales object with component class object and the sales array
157
180
  def initialize(root_sales)
158
181
  super(root_sales)
159
182
  @product_sale = OrderItem.all
160
183
  end
161
184
 
185
+ #this method provides the logical methods of sequencing the methods to calculate the sales details of the product for a single day.
162
186
  def main_method
163
187
  common_method
164
188
  check_profit
@@ -176,13 +200,15 @@ class DaySalesDecorator < BuisnessDecorator
176
200
  end
177
201
  end
178
202
 
179
- # another concrete decorator
203
+ # a concrete decorator for week sales stores the sales details calculated in the database with the below functionality
180
204
  class WeekSalesDecorator < BuisnessDecorator
205
+ #method used to initialise the week sales object with component class object and the sales array
181
206
  def initialize(root_sales)
182
207
  super(root_sales)
183
208
  @product_sale = Dsale.all
184
209
  end
185
210
 
211
+ #Common logic to sort the products for a week time line.
186
212
  def common_method
187
213
  @product_sale.each do |product|
188
214
  sale_boolean = product.created_at.between?(Time.now.midnight-7.day,Time.now.midnight)
@@ -192,6 +218,7 @@ class WeekSalesDecorator < BuisnessDecorator
192
218
  end
193
219
  end
194
220
 
221
+ #this method provides the logical methods of sequencing the methods to calculate the sales details of the product for the last one week.
195
222
  def main_method
196
223
  common_method
197
224
  @root_sales.sales_array.each do |sd|
@@ -222,13 +249,15 @@ class WeekSalesDecorator < BuisnessDecorator
222
249
 
223
250
  end
224
251
 
225
- # another concrete decorator
252
+ # a concrete decorator for a month sale stores the sales details calculated in the database with the below functionality
226
253
  class MonthSalesDecorator < BuisnessDecorator
254
+ #method used to initialise the month sales object with component class object and the sales array
227
255
  def initialize(root_sales)
228
256
  super(root_sales)
229
257
  @product_sale = Wsale.all
230
258
  end
231
259
 
260
+ #Common logic to sort the products for a period of last one month time line.
232
261
  def common_method
233
262
  @product_sale.each do |product|
234
263
  sale_boolean = product.created_at.between?(Time.now.midnight-1.month,Time.now.midnight)
@@ -238,6 +267,7 @@ class MonthSalesDecorator < BuisnessDecorator
238
267
  end
239
268
  end
240
269
 
270
+ #this method provides the logical methods of sequencing the methods to calculate the sales details of the product for one month.
241
271
  def main_method
242
272
  common_method
243
273
  @root_sales.sales_array.each do |sd|
@@ -1,3 +1,3 @@
1
1
  module SalesAndOrdersDecorator
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -6,7 +6,7 @@ require 'sales_and_orders_decorator/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "sales_and_orders_decorator"
8
8
  spec.version = SalesAndOrdersDecorator::VERSION
9
- spec.authors = ["Subit Benny"]
9
+ spec.authors = ["Kishore Kumar"]
10
10
  spec.email = ["x16103602@student.ncirl.ie"]
11
11
 
12
12
  spec.summary = %q{This is sales decorator which provides and stores the resultant data into day, week, month sales into database}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sales_and_orders_decorator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
- - Subit Benny
7
+ - Kishore Kumar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2017-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler