foodcourt apis for app
This commit is contained in:
@@ -154,9 +154,9 @@ class ShiftSale < ApplicationRecord
|
||||
|
||||
shift_other_payments = Sale.select("sales.sale_id, sale_payments.payment_method as name")
|
||||
if payment_methods.present?
|
||||
shift_other_payments = shift_other_payments.select("#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as `#{method == 'paypar' ? 'redeem' : method}`"}.join(', ')}")
|
||||
shift_other_payments = shift_other_payments.select("#{payment_methods.map { |method| "IFNULL(SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end), 0) as `#{method == 'paypar' ? 'redeem' : method}`"}.join(', ')}")
|
||||
end
|
||||
shift_other_payments.select("SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
shift_other_payments.select("IFNULL(SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end), 0) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.shift_sale_id =? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.id)
|
||||
end
|
||||
@@ -204,7 +204,7 @@ class ShiftSale < ApplicationRecord
|
||||
# end
|
||||
|
||||
def self.get_total_other_charges(shift)
|
||||
query = SaleItem.select("sum(sale_items.qty * sale_items.unit_price) as total_other_charges_amount")
|
||||
query = SaleItem.select("IFNULL(sum(sale_items.qty * sale_items.unit_price), 0) as total_other_charges_amount")
|
||||
.joins("JOIN sales as s ON s.sale_id = sale_items.sale_id")
|
||||
.where('shift_sale_id =? and s.sale_status = "completed" and sale_items.product_code = "Other Charges" and sale_items.item_instance_code is null',shift.id)
|
||||
.first()
|
||||
|
||||
Reference in New Issue
Block a user