From 49319d80cc8bbdadac07b9c2f15a6dff405de4fd Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Mon, 14 May 2018 11:38:39 +0630 Subject: [PATCH] Pull from master --- app/controllers/origami/shifts_controller.rb | 2 ++ app/models/shift_sale.rb | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index acce6c65..2cea51a4 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -81,6 +81,8 @@ class Origami::ShiftsController < BaseOrigamiController #get tax shift_obj = ShiftSale.where('id =?',@shift.id) @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') + byebug + @total_waste = Sale.get_total_waste(@shift) #other payment details for mpu or visa like card @other_payment = ShiftSale.get_by_shift_other_payment(@shift) diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index 10b2de38..c2dac049 100755 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -94,6 +94,11 @@ class ShiftSale < ApplicationRecord end end + def self.get_total_waste(shift) + total_waste = Sale.select(" SUM(grand_total) as total_waste") + .where("sales.payment_status ='waste' and sale_status = 'waste'", shift.id) + end + def get_closing_balance(shift) shiftobj = ShiftSale.find(shift) closing_balance = shiftobj.grand_total + shiftobj.cash_in - shiftobj.cash_out + shiftobj.total_cash