Sha256: 7a5f823647ff9e42724dc8e257ba9ee048a4a3c0281efd5fb0f8dc36302290b9

Contents?: true

Size: 822 Bytes

Versions: 18

Compression:

Stored size: 822 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, Date.today)
          elsif value == "late"
            return query.where("#{table_name}.paid = ? and (#{table_name}.due_date < ? or #{table_name}.due_date is null)", false, Date.today)
          else
            return query
          end
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
dorsale-2.7.3 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.7.2 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.7.1 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.7.0 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.6.8 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.6.7 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.6.6 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.6.5 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.6.4 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.6.3 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.6.2 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.6.1 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.6.0 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.5.0 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.4.3 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.4.2 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.4.1 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
dorsale-2.4.0 app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb