Adding a scope on subscription_line_item.rb to select records where price estimate is nil

This commit is contained in:
georgethoppil
2022-05-11 13:45:13 -04:00
parent 5ff1c1c7c2
commit 6a9fcbdd0c

View File

@@ -9,6 +9,7 @@ class SubscriptionLineItem < ApplicationRecord
validates :quantity, presence: true, numericality: { only_integer: true }
default_scope { order('id ASC') }
scope :nil_price_estimate, -> { where(price_estimate: nil) }
def total_estimate
(price_estimate || 0) * (quantity || 0)