update reports
This commit is contained in:
@@ -725,19 +725,19 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty
|
||||
query = Sale.all
|
||||
if shift.present?
|
||||
|
||||
query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a)
|
||||
query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sales.payment_status= 'paid' and sale_payments.payment_amount != 0", shift.to_a)
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.group("sales.sale_id")
|
||||
|
||||
elsif shift_sale_range.present?
|
||||
|
||||
query = query.where("sale_status='completed' #{payment_type} and sale_payments.payment_amount != 0 and sales.shift_sale_id in (?)",shift_sale_range.to_a)
|
||||
query = query.where("sale_status='completed' #{payment_type} and sale_payments.payment_amount != 0 and sales.payment_status= 'paid' and sales.shift_sale_id in (?)",shift_sale_range.to_a)
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.group("sales.sale_id")
|
||||
|
||||
else
|
||||
|
||||
query = query.where("sale_status='completed' and sales.receipt_date between ? and ? #{payment_type} and sale_payments.payment_amount != 0",from,to)
|
||||
query = query.where("sale_status='completed' and sales.receipt_date between ? and ? #{payment_type} and sales.payment_status= 'paid' 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
|
||||
@@ -795,19 +795,19 @@ def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
|
||||
.joins("LEFT JOIN sales ON sales.sale_id = sale_taxes.sale_id")
|
||||
.where("sales.shift_sale_id in (?) and sale_status= 'completed'", shift.to_a)
|
||||
.group("sale_taxes.tax_name")
|
||||
.order("sale_taxes.sale_tax_id asc")
|
||||
.order("sale_taxes.tax_name desc")
|
||||
elsif shift_sale_range.present?
|
||||
query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
|
||||
.joins("LEFT JOIN sales ON sales.sale_id = sale_taxes.sale_id")
|
||||
.where("sales.shift_sale_id in (?) and sale_status= 'completed'", shift_sale_range.to_a)
|
||||
.group("sale_taxes.tax_name")
|
||||
.order("sale_taxes.sale_tax_id asc")
|
||||
.order("sale_taxes.tax_name desc")
|
||||
else
|
||||
query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
|
||||
.joins("LEFT JOIN sales ON sales.sale_id = sale_taxes.sale_id")
|
||||
.where("sales.receipt_date between ? and ? and sale_status= 'completed'", from,to)
|
||||
.group("sale_taxes.tax_name")
|
||||
.order("sale_taxes.sale_tax_id asc")
|
||||
.order("sale_taxes.tax_name desc")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ class SalePayment < ApplicationRecord
|
||||
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }'")
|
||||
|
||||
sale_items.each do|item|
|
||||
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
||||
SaleItem.update_existing_item(item.qty,item.item_instance_code, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
||||
end
|
||||
|
||||
self.payment_method = "foc"
|
||||
|
||||
Reference in New Issue
Block a user