没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
www.trustie.net/open_source_projects | 主页 > 开源项目社区 > rails-postman |
rails-postman
|
0 | 0 | 20 |
贡献者 | 讨论 | 代码提交 |
Postman is a simple rails plugin that calculates shipping rates based on data from the database. It is meant for cases where the postal service does not have an API for getting the shipping rates.
What Postman does is to get the values from the tables and calculate it out. The values are found in your database tables. You'd have to add the mailing rates into the tables for it to work.
The plugin is very simple. I've included some sql files to help put in the countries and mailing rates(in Singapore). You can use them as a reference.
And here's the original rates:
http://www.singpost.com.sg/quick_services/quicks_03postal_02overseas01.htm
The blog post is here
Installation
ruby script/plugin install http://rails-postman.googlecode.com/svn/trunk/postman
Before using it
Generate and apply the migration:
ruby script/generate postman_migration
rake db:migrate
Add values into the tables
countries destinations postage_mails step_rates step_weights transit_time weight_limit Definition of the tables
destinations
the term for the group of countries. Usually postal services group countries up by distance, and set different rates for each zone. postage_mails
corresponding rates for the weight weight_limit
the maximum weight limit for the rates from postage_mails step_rates
the unit rates for additional weight beyond the weight limit step_weight
the divisor used to divide up the additional weight transit_time
the time needed to ship to the destinations How to use it
Just call
Postman.postageCalculator("Singapore", 100)
the first argument is the coutry in text, the second argument is the weight in your base unit(which happens to be grams for me) Testing
Create a database called 'plugin_test'
Update the user/password in database.yml
And run 'rake test' from the plugin directory