credit payment function
This commit is contained in:
@@ -1238,7 +1238,7 @@ end
|
||||
credit = 0.0
|
||||
self.sale_payments.each do |pay|
|
||||
if pay.payment_method == 'creditnote'
|
||||
credit = pay.payment_amount
|
||||
credit += pay.payment_amount
|
||||
end
|
||||
end
|
||||
return credit
|
||||
@@ -2568,25 +2568,12 @@ def self.all_receipt_details
|
||||
return query
|
||||
end
|
||||
|
||||
def self.get_credit_sales(params)
|
||||
receipt_no = ""
|
||||
customer = ""
|
||||
if !params["receipt_no"].blank?
|
||||
receipt_no = " and s.receipt_no LIKE '%#{params["receipt_no"]}%'"
|
||||
end
|
||||
|
||||
if !params["customer_id"].blank?
|
||||
customer = " and s.customer_id = '#{params["customer_id"]}'"
|
||||
end
|
||||
|
||||
query = SalePayment.select("s.receipt_no, sale_payments.sale_payment_id, sale_payments.payment_method, sale_payments.payment_amount,s.receipt_date as sale_date,
|
||||
s.cashier_name as cashier_name, c.name as customer_name")
|
||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||
.joins("INNER JOIN customers c ON c.customer_id = s.customer_id")
|
||||
|
||||
query = query.where("payment_method='creditnote' and s.sale_status = 'completed' #{receipt_no} #{customer}")
|
||||
.order("s.receipt_date ASC, s.receipt_no ASC")
|
||||
|
||||
def self.get_sale_data_for_other_payment_credit(sale_id)
|
||||
query = Sale.select("sales.sale_id,sales.receipt_no,sales.customer_id,SUM(sp.payment_amount) as total_amount,SUM(sp.payment_amount) as grand_total")
|
||||
.joins(" JOIN sale_payments sp on sp.sale_id=sales.sale_id")
|
||||
.where("sp.payment_method ='creditnote' and sales.sale_id='#{sale_id}'")
|
||||
.group("sales.sale_id")
|
||||
.first
|
||||
return query
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user