Sha256: c0da7ce32324154093bffa642fdeead27bf2c3b2074a1345052b07e35fd9f67e
Contents?: true
Size: 844 Bytes
Versions: 4
Compression:
Stored size: 844 Bytes
Contents
module Dorsale module BillingMachine module SmallData class FilterStrategyByPaymentStatus < ::Dorsale::SmallData::FilterStrategy def apply(query, value) table_name = query.model.table_name if value == "paid" return query.where("#{table_name}.paid = ?", true) elsif value == "unpaid" return query.where("#{table_name}.paid = ?", false) elsif value == "pending" return query.where("#{table_name}.paid = ? and #{table_name}.due_date >= ?", false, Time.zone.now.to_date) elsif value == "late" return query.where("#{table_name}.paid = ? and (#{table_name}.due_date < ? or #{table_name}.due_date is null)", false, Time.zone.now.to_date) else return query end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems