Class: DaySalesDecorator
- Inherits:
-
BuisnessDecorator
- Object
- BuisnessDecorator
- DaySalesDecorator
- Defined in:
- lib/sales_and_orders_decorator.rb
Overview
a concrete decorator for day sales stores the sales details calculated in the database with the below functionality
Instance Method Summary collapse
-
#initialize(root_sales) ⇒ DaySalesDecorator
constructor
method used to initialise the day sales object with component class object and the sales array.
-
#main_method ⇒ Object
this method provides the logical methods of sequencing the methods to calculate the sales details of the product for a single day.
Methods inherited from BuisnessDecorator
#check, #check_foodType, #check_offer, #check_profit, #common_method, #nonOfferedSale_counter_method, #nonVegCounter_method, #offeredSale_counter_method, #profit_counter_method, #sales_array, #totalSale_counter_method, #totalSale_quantity_method, #vegCounter_method
Constructor Details
#initialize(root_sales) ⇒ DaySalesDecorator
method used to initialise the day sales object with component class object and the sales array
180 181 182 183 |
# File 'lib/sales_and_orders_decorator.rb', line 180 def initialize(root_sales) super(root_sales) @product_sale = OrderItem.all end |
Instance Method Details
#main_method ⇒ Object
this method provides the logical methods of sequencing the methods to calculate the sales details of the product for a single day.
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/sales_and_orders_decorator.rb', line 186 def main_method common_method check_profit check_offer check_foodType @sale_on_order = Dsale.new @sale_on_order.day = Date.today @sale_on_order.totalSale = @totalSale_counter @sale_on_order.profit = @profit_counter @sale_on_order.nonVegSale = @nonVegCounter @sale_on_order.vegSale = @vegCounter @sale_on_order.offeredSale = @offeredSale_counter @sale_on_order.nonOfferedSale = @nonOfferedSale_counter @sale_on_order.save end |