Show USPS Rate On Sales Header

Savatage
Member Posts: 7,142
We ship many small internet orders via US Mail. We've been setting up all kinds of software to simplify the process & now my brain is fried!
All orders over 20 lbs will go UPS - e-ship takes care of that.
I have created a chart of all zip codes in US and what their postage will be by pound. This table will be 50010 USPS Rate table.
See chart here
http://savatage99.googlepages.com/ZIPCO ... CHART1.xls
The goal is On Release of the order to show what the Mail rate will be.
So I need to get the Ship-To Zip Code (no prob) and calculate the order weight (rounded up). Now with these two fields I should be able to get the price from the new USPS rate table.
The rate table has a min & max zip per zone & weight. I need to setrange or filter - and would like some suggestions on the best way to accomplish this task.
All orders over 20 lbs will go UPS - e-ship takes care of that.
I have created a chart of all zip codes in US and what their postage will be by pound. This table will be 50010 USPS Rate table.
See chart here
http://savatage99.googlepages.com/ZIPCO ... CHART1.xls
The goal is On Release of the order to show what the Mail rate will be.
So I need to get the Ship-To Zip Code (no prob) and calculate the order weight (rounded up). Now with these two fields I should be able to get the price from the new USPS rate table.
The rate table has a min & max zip per zone & weight. I need to setrange or filter - and would like some suggestions on the best way to accomplish this task.
TotalOrderWeight := ROUND(SalesHeader."Total Order Weight", 1, '>'); USPSRATETABLE.GET(SalesHeader."Ship-to ZIP Code",SalesHeader."Ship-To Zip Code", TotalOrderWeight); If TotalOrderWeight < 21 THEN SETFILTER(USPSRateTable.ToMinZipCode,'>=%1',SalesHeader."Ship-To Zip CODE") ; SETFILTER(USPSRateTable.ToMaxZipCode,'<=%1',SalesHeader."Ship-To Zip Code"); SETFILTER(USPSRateTable.Weight,'=%1',TotalOrderWeight); SalesHeader.USPSOrderPostage := USPSRateTabel.Price ELSE SalesHeader.USPSOrderPostage := 0;Am I in the ballpark here? or does somone know of a better way?
0
Answers
-
Try this:
TotalOrderWeight := ROUND(SalesHeader."Total Order Weight", 1, '>'); If TotalOrderWeight <= 20 THEN BEGIN USPSRATETABLE.RESET; USPSRATETABLE.SETCURRENTKEY(ToMinZipCode,ToMaxZipCode,Weight); USPSRATETABLE.SETRANGE(ToMinZipCode,'00000',SalesHeader."Ship-To Zip CODE") ; USPSRATETABLE.SETRANGE(ToMaxZipCode,SalesHeader."Ship-To Zip CODE",'99999') ; USPSRATETABLE.SETRANGE(Weight,TotalOrderWeight - 0.0001,TotalOrderWeight + 0.0001); // to avoid rounding problems when filtering IF USPSRATETABLE.FINDFIRST THEN // OR USPSRATETABLE.FIND('-'); SalesHeader.USPSOrderPostage := USPSRateTabel.Price ELSE SalesHeader.USPSOrderPostage := 0; end;
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Kriki you are a god of Heavy Metal!!!
A little tweaking and the final code usedTotalOrderWeight := ROUND("Total Net Weight", 1, '>'); IF "Ship-to Country Code" = 'US' THEN BEGIN IF TotalOrderWeight <= 20 THEN BEGIN UspsRateTable.RESET; UspsRateTable.SETCURRENTKEY(ToMinZipCode,ToMaxZipCode,Weight); UspsRateTable.SETRANGE(ToMinZipCode,'00000',"Ship-to ZIP Code") ; UspsRateTable.SETRANGE(ToMaxZipCode,"Ship-to ZIP Code",'99999') ; UspsRateTable.SETRANGE(Weight,TotalOrderWeight - 0.0001,TotalOrderWeight + 0.0001); IF UspsRateTable.FIND('-') THEN SalesHeader.UspsOrderPostage := UspsRateTable.Price ELSE SalesHeader.UspsOrderPostage := 0; END END;
0 -
At your serviceRegards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions