• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How would you do this?

#1
[eluser]ToddyBoy[/eluser]
I think I've been staring at this project for too long so that my brain has turned to mush. I can't think of the most efficient way to perform this task.

I am creating a site for a courier company. They would like a rates calculator on their site. Shouldn't be a problem if my brain wasn't mush.

The user selects a To and From location from a drop down list, which are both required fields and contain the same 15 locations. The other required field is a text box for weight of the package.

I have a hard copy of their rates sheet sitting in front of me and I can't work out how to best process the form submission to display the correct rate, tax and total which differ depending on the form input values entered by the user.

HELP!

Please and thank you.

#2
[eluser]Josh Bright[/eluser]
Can you give an example of what the rate sheet says?

#3
[eluser]Rok Biderman[/eluser]
Well, I'm afraid this will state the obvious, but still. How about you make a table with 17 colums (id, name and 15 destinations), then make 15 entries to cover all options. After that you just make a query that does essentially this: select (1st input dropdown value) from yourtable where (name = 2nd input dropdown value). I suppose the tax rate doesn't change, so it's easy to get the total. If they do you figure out whether it's based on the origin or destination and make another column and then select that as well. Hope it helps. Yell if you need more guidance on how to do it.

#4
[eluser]toopay[/eluser]
Hey ToddyBoy, dont make it sound like "PROGRAMMING MAKE YOUR BRAIN MUSH" Tongue
Don't be desperate... :lol:

I will do that this way :

1. Grab a glass of cold beer.

2. While starting smoked,
First, i'll make a database tables for handle that.
a. 'city' or 'location' table, containing city/location id, city/location code, city/location name.
b. 'rates' table, containing id, base currency (for converting stuff), rates based by weight, tax.
c. some pivot table, named it 'city_rates' or whatever you like, which contain id, from(city/location id), to(city/location id), rate_id. If you have 15 city or location, and the rates from, let say 'city/location A' -> 'city/location B' rates equal with 'city/location A' <- 'city/location B' rates, then based by 'variation algorithm'
Code:
15!/(15-2)!(2)! = 105
you will have : 105 rates id(at least).

3. Ok, the database part should be fine now. i'll create a model to handle above tables, writes several SOAP API of it, then... hey i'm running out my cigarete(i'll buy it first!).

4. Database is ok, model is ok, soap api is ok... Now i should be start write a controller, to retrieve database data, load validation class, building a rules and output all of this in view file.

5. i'll create unit testing, just for make sure everything is ok.

6. Done. The company should pay me for create an courier rates calculator apps right now, and i'll be buy a bunch of cold beer, cigarete and start other project... Smile

#5
[eluser]Rok Biderman[/eluser]
Meh, I'll follow step 1, then repeat it a couple of times,get stuck before step 2.

#6
[eluser]toopay[/eluser]
@Coccodrillo ;-)


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.