Sha256: c7c742fc5888792de77ccd7be771f02deb77d768acf5ccf57d1e73efc8936e45

Contents?: true

Size: 619 Bytes

Versions: 3

Compression:

Stored size: 619 Bytes

Contents

class Dorsale::BillingMachine::SmallData::FilterStrategyByPaymentStatus < ::Agilibox::SmallData::FilterStrategy
  def apply(query, value)
    table_name = query.model.table_name

    if value == "paid"
      query.where(paid: true)
    elsif value == "unpaid"
      query.where(paid: false)
    elsif value == "pending"
      query
        .where(paid: false)
        .where("#{table_name}.due_date >= ?", Date.current)
    elsif value == "late"
      query
        .where(paid: false)
        .where("#{table_name}.due_date < ? OR #{table_name}.due_date IS NULL)", Date.current)
    else
      query
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dorsale-3.9.2 app/filters/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-3.9.1 app/filters/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-3.9.0 app/filters/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb