Copy link to clipboard
Copied
Hi all,
I am trying to think of the best way to discount a number from an access db.
Basically it's an online hotel room tariff. So if someone clicks they want to stay 5 nights I want to be able to call the base price from the db and then times it by 5 and then discount a percentage per night. Or have I just made this way too complicated and over looked an easier solution.
Thanks
Jonathan
Copy link to clipboard
Copied
The logic seems to be OK. I hope you are following the below steps.
1. Get the Base price from DB(100 for example)
2. Multiply it by 5(100 * 5 = 500)
3. Multiply the discount price by 5(10 * 5 = 50)
4. Get the difference(500-50 - 450)
In this way if you want you can display the Total Price, Discount Price and Actual Price to your customer.
Copy link to clipboard
Copied
Hi mate,
Thanks for you reply. sorry i did not make it clear but what i want is if they stay for say 2 nights they can have a discount of say 10% and if they stay for say 4 nights they can have a discount of 15% so on and so on.
maybe i could do what you have done and then wrap it in a CFIF and then do a few of them with differnt percentage's do you think that would work?
Thanks
Jonathan
Copy link to clipboard
Copied
How many discount tiers are you going to have? You could put them in a table and do a look up - eg; 2 (nights) 10 (%), 4 (nights) 15 (%) etc. This would save doing a bunch of if/else statements and having to hard code the values in there.
Copy link to clipboard
Copied
Sounds like a good idea but i am not sure how i would use it could to do a little example.
Thanks
Jonathan Hemmings
Copy link to clipboard
Copied
Why not start with the design of your new table. What fields and datatypes sound appropriate?
Copy link to clipboard
Copied
Without sitting down and planning, one way would be...
Table: Discounts (3 cols)
ID Nights DiscountRate
1 2 10
2 3 10
3 4 15
4 5 15
5 6 20
etc etc - you wouldn't need to go more then 30 nights I wouldn't think.
Code: (I'll just keep it brief)
NumberOfNights = 4
TotalStayBeforeDiscount = 400 ($100 per night = $400)
Select DiscountRate from Discounts where Nights = NumberOfNights
TotalStayDiscount = TotalStayBeforeDiscount * query.DiscountRate / 100 (should = $60)
TotalStay = TotalStayBeforeDiscount - TotalStayDiscount
With the above you could then display the rate before discount, the discount, and the final total.
You should also do some validation to make sure the query returns something, if it doesn't, then no discount is applied (or displayed).
Hope this helps.
Copy link to clipboard
Copied
By keeping your nights/discounts in a database table, it also makes it easier to adjust the table by date range. So, if your
busy season allows you to offer a lesser discount than the off-season, you can apply a date range to your
pricing table to allow for a 5 percent discount between x and y dates, and a 10 percent discount between some other range of dates.
The database table will make your life easier down the road, in ways that you probably have not imagined yet.
Copy link to clipboard
Copied
The other thing that occurred to me... are you taking the discount off the total bill, or are you discounting JUST the nights that are in excess of the
X number of nights?
If you discount 10 percent for three nights, do you pay full price for nights one and two, and then take 10 percent off for night three, or do you take 10 percent off the total for the three nights?
This is the kind of logic you need to sort through.