Created
September 9, 2011 23:12
-
-
Save brandon-beacher/1207571 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## BEFORE | |
def listing_fee | |
fee = 0 | |
if self.seller.commercial? | |
fee += 400 # $4.00 listing fee | |
elsif self.seller.partner? | |
fee += 500 # $5.00 listing fee | |
else # seller is private seller | |
fee += 400 # $4.00 listing fee | |
fee += ((self.images.count - 3) * 50) if self.images.count > 3 # $0.50 per image fee for more than 3 images | |
end | |
fee += 500 if self.bold? # $5.00 bold fee | |
fee += 2000 if self.featured? # $20.00 featured fee | |
fee | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## AFTER | |
def image_fee | |
50 # $0.50 | |
end | |
def commercial_listing_fee | |
400 # $4.00 | |
end | |
def partner_listing_fee | |
500 # $5.00 | |
end | |
def default_listing_fee | |
400 # $4.00 | |
end | |
def bold_fee | |
bold? ? 500 : 0 # $5.00 | |
end | |
def featured_fee | |
featured? ? 2000 : 0 # $20.00 | |
end | |
def listing_fee | |
return commercial_listing_fee if seller.commercial? | |
return partner_listing_fee if seller.partner? | |
default_listing_fee | |
end | |
def free_images_count | |
3 | |
end | |
def paid_images_count | |
return 0 if images.count <= free_images_count | |
images.count - free_images_count | |
end | |
def images_fee | |
return 0 if seller.commercial? || seller.partner? | |
paid_images_count * image_fee | |
end | |
def total_fee | |
listing_fee + images_fee + bold_fee + featured_fee | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment