optimize for dashboards

This commit is contained in:
Thein Lin Kyaw
2019-11-18 10:09:40 +06:30
parent d94dde63fe
commit a3e4cc8993
10 changed files with 321 additions and 807 deletions

View File

@@ -6,8 +6,13 @@ class SalePayment < ApplicationRecord
belongs_to :sale
has_one :sale_audit, -> { where "SUBSTRING_INDEX(sale_audits.remark,'||',1) = sale_payments.sale_payment_id" }, foreign_key: "sale_id", primary_key: "sale_id"
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status,:action_by
scope :credits, -> { where(payment_method: 'creditnote') }
scope :cards, -> { where(payment_method: ['mpu', 'visa', 'master', 'jcb', 'unionpay', 'alipay', 'paymal', 'dinga', 'JunctionPay', 'giftvoucher']) }
def self.sync_sale_payment_records(sale_payments)
if !sale_payments.nil?
sale_payments.each do |sp|