Displaying 3 results from an estimated 3 matches for "price_per_week".
2008 Feb 05
0
prices (where to store them and how)
...ure out the bet way to manage pricing in my app and
basically the database design.
It''s a language school that also offers host family accomodation.
They therefore have
Courses which have to have the following prices
fixed fees
----------
exam fee
reg fee
recurring fees
--------------
price_per_week (1 to 2 weeks)
price_per_week (3 to 4 weeks)
price_per_week (5 to 6 weeks)
Accomodation has the following prices
fixed fees
----------
Accomodation Booking Fee
recurring fees
--------------
price_per_week (single summer)
price_per_week (shared summer)
price_per_week (single winter
price_per_week...
2008 Aug 25
2
maths not working (can't get this)
...> 100)
end
def discounted_price
factor = case @duration_in_weeks
when 1..4
1.0
when 5..12
0.9
when 13..24
0.8
when 25..47
0.7
else # from 48 and up
0.6
end
total_price * factor
end
def total_price
(@duration_in_weeks * price_per_week) + registration_fee
end
def duration_in_weeks=(duration_in_weeks)
@duration_in_weeks = duration_in_weeks.to_i
end
end
CONTROLLER
------------
class InvoiceController < ApplicationController
def index
@enquiry = Enquiry.new
@courses = Course.active_courses
@courses...
2008 Aug 31
6
why's my course_duration being reset
...tion
# set course_booking_fee from the Selected Course
self.course_booking_fee = course.registration_fee
self.accommodation_booking_fee = accomodation.booking_fee
end
def calculate_fees
# DO STUFF !
# self.blah_fee = blah_duration * whatever
self.course_fee = course.price_per_week * course_duration.to_i
self.accommodation_fee = accomodation.price_per_week *
accomodation_duration.to_i
@factor = case @duration_in_weeks
when 1..4
1.0
when 5..12
0.9
when 13..24
0.8
when 25..47
0.7
else # from 48 and up...