Fixed bug in progress bar when not using PaymentOptions

This commit is contained in:
Jarred Sumner
2013-01-30 10:10:11 -08:00
parent cc4adb2f17
commit da2d021c9e
2 changed files with 10 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ class Order < ActiveRecord::Base
before_validation :generate_uuid!, :on => :create
belongs_to :user
belongs_to :payment_option
scope :completed, where("token != ? OR token != ?", "", nil)
self.primary_key = 'uuid'
# This is where we create our Caller Reference for Amazon Payments, and prefill some other information.
@@ -66,13 +67,15 @@ class Order < ActiveRecord::Base
# See what it looks like when you have some backers! Drop in a number instead of Order.count
def self.backers
Order.where("token != ? OR token != ?", "", nil).count
Order.completed.count
end
def self.revenue
revenue = PaymentOption.joins(:orders).where("token != ? OR token != ?", "", nil).pluck('sum(amount)')[0]
return 0 if revenue.nil?
revenue
if Settings.use_payment_options
PaymentOption.joins(:orders).where("token != ? OR token != ?", "", nil).pluck('sum(amount)')[0].to_f
else
Order.completed.sum(:price).to_f
end
end
validates_presence_of :name, :price, :user_id

View File

@@ -14,14 +14,14 @@ project_goal: 100000
# This'll be both the page title (<title></title>) and the name in the header
product_name: "Selfstarter"
# This will be used in sentences like Hooray Youve just reserved product_description
# This will be used in sentences like Hooray You've just reserved product_description
product_description: "a set of widgets"
# An image showcasing your product -- it'll show up when you pin your product
# It should be in app/assets/images
product_image_path: "my-product-image.png"
# The message on the preorder page, Lockitron's
# The message on the preorder page, Lockitron's is ""
value_proposition: "Roll your own crowdfunding"
# YouTube or Vimeo Video URL (The embed URL, without the query string options)
@@ -58,7 +58,7 @@ charge_limit: 25.00
# On Lockitron, it's "backers"
primary_stat: "backers"
# This'll show up in the tweet as, "I'm forker number ..."
# This'll show up in the tweet as, "I'm backer number ..."
primary_stat_verb: 'backer'
# The 2nd call to action button, towards the middle-ish of the page