update report and view

This commit is contained in:
Aung Myo
2017-07-28 17:07:16 +06:30
parent 24fd399c17
commit 98c04f21d8
14 changed files with 815 additions and 29 deletions

View File

@@ -642,10 +642,36 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty
query = query.where("sale_status='completed' and sales.receipt_date between ? and ? #{payment_type} and sale_payments.payment_amount != 0",from,to)
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.group("sales.sale_id")
end
end
end
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to)
query = SalePayment.select("s.receipt_no, sale_payments.*,s.receipt_date as sale_date,
s.cashier_name as cashier_name")
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
if shift.present?
query = query.where("payment_method= 'creditnote' and s.sale_status = 'completed' and s.shift_sale_id in (?)",shift.to_a)
elsif shift_sale_range.present?
query = query.where("payment_method='creditnote' and s.sale_status = 'completed' and s.shift_sale_id in (?)",shift_sale_range.to_a)
else
query = query.where("payment_method='creditnote' and s.sale_status = 'completed' and s.receipt_date between ? and ? ",from,to)
end
end
def self.get_void_sale(shift,from,to)
sale_arr = Array.new
account= Sale.select("sales.receipt_no,sales.receipt_date, sales.payment_status, sales.sale_status,sales.total_amount,sales.grand_total, sales.rounding_adjustment")
.joins("INNER JOIN shift_sales sh ON sh.id = sales.shift_sale_id")
.where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ?
OR sh.shift_closed_at between ? and ? )", from ,to, from, to)
out = {:items => account}
sale_arr.push(out)
return sale_arr
end
def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
if payment_type.blank?
@@ -680,18 +706,6 @@ def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
.group("sale_taxes.tax_name")
.order("sale_taxes.sale_tax_id asc")
end
# query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
# .joins("INNER JOIN sales ON sales.sale_id = sale_taxes.sale_id")
# .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
# .group("sale_taxes.tax_name")
# .order("sale_taxes.sale_tax_id asc")
# if shift.present?
# query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed'", shift.to_a)
# else
# query = query.where("sales.receipt_date between ? and ? #{payment_type} and sale_status= 'completed' ",from,to)
# end
end
# def self.get_separate_tax(from,to,payment_method=nil)