update dashboard total credit and card

This commit is contained in:
Aung Myo
2017-10-24 11:42:48 +06:30
parent 59c38b2c96
commit f7d3920554
9 changed files with 68 additions and 47 deletions

View File

@@ -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