|
|
@@ -168,7 +168,11 @@ class CashOutsController < ApplicationController
|
|
|
@initial_cash = @opened_cash_register.initial_cash
|
|
|
@incomings = CashRegistersMove.where("open_cash_register_id = (?) and move_type = '1' and status = 1", @opened_cash_register.id).order('created_at')
|
|
|
@outgoings = CashRegistersMove.where("open_cash_register_id = (?) and move_type = '0' and status = 1", @opened_cash_register.id).order('created_at')
|
|
|
- all_sales = Sale.where("open_cash_register_id = (?) and status != 1", @opened_cash_register.id)
|
|
|
+
|
|
|
+ # all_sales = Sale.where("open_cash_register_id = (?) and status != 1", @opened_cash_register.id)
|
|
|
+ sales_ids = CashRegistersMove.where("open_cash_register_id = (?) and move_type = '1' and status = 1", @opened_cash_register.id).pluck("DISTINCT sale_id")
|
|
|
+ all_sales = Sale.activas.where("id IN (?)", sales_ids)
|
|
|
+
|
|
|
@cash_sales = CashRegistersMove.where("open_cash_register_id = (?) and move_type = '1' and status = 1 and sale_id IN (?)", @opened_cash_register.id, all_sales.where(saletype: 1).pluck(:id)).sum(:quantity)
|
|
|
@credit_sales = CashRegistersMove.where("open_cash_register_id = (?) and move_type = '1' and status = 1 and concept = 3", @opened_cash_register.id).sum(:quantity)
|
|
|
@reserved_sales = CashRegistersMove.where("open_cash_register_id = (?) and move_type = '1' and status = 1 and sale_id IN (?)", @opened_cash_register.id, all_sales.where(saletype: 2).pluck(:id)).sum(:quantity)
|