update dashboard total credit and card
This commit is contained in:
@@ -876,6 +876,25 @@ end
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).count
|
||||
end
|
||||
|
||||
def self.total_card_sale(today)
|
||||
payment_type = " and payment_method = 'mpu' or payment_method = 'visa' or payment_method = 'master' or payment_method = 'jcb' "
|
||||
# query = Sale.select("SUM(tax_payable_amount) AS st_amount,tax_name")
|
||||
# .where('sale_status = "completed" #{payment_type} and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
|
||||
# .joins("join sale_payments on sale_id = sales.sale_id")
|
||||
# .group("sales.sale_id")
|
||||
|
||||
query = SalePayment.where('s.sale_status = "completed" and payment_method = "mpu" or payment_method = "visa" or payment_method = "master" or payment_method = "jcb" and DATE_FORMAT(s.receipt_date,"%Y-%m-%d") = ?',today)
|
||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||
.sum("payment_amount")
|
||||
|
||||
end
|
||||
|
||||
def self.credit_payment(today)
|
||||
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(s.receipt_date,"%Y-%m-%d") = ?',today)
|
||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||
.sum("payment_amount")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_custom_id
|
||||
|
||||
Reference in New Issue
Block a user