webERP Forum

Full Version: User Override of Auto-Calc Freight Cost
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have implemented automatic Freight calculation for Sales Orders but in some cases we must be able to override the value. I notice if I overwrite the auto-calc result it always reverts back to the auto-calc value.

I may have to alter the code, which is fine, but I want to check with the rest of you before I proceed. Perhaps I have missed a setting or missed a procedure? Is this the expected functionality?

Any help or thoughts are greatly appreciated.

By the way... This feature is very slick!
I am pretty sure that needs changing in the code.

That feature was written by Ricard if I remember correctly. I haven't seen him around for a while.

I'm happy to help with testing and trunk commits if a fix for this is coded.

Thank you both for your input and timely response.

I was able to fulfill this small change by adding just one logic condition. What I have now is:

+ If the user enters "0" for the Freight Charge the "Recalc Shipping Cost" button will perform as expected and apply a value
+ If the user enters "0" for the Freight Charge the "Commit Order Lines" button will perform as expected and apply a value
+ if the user enters a value other than "0" the "Recalc Shipping Cost" and "Commit Order Lines" buttons apply no value

Now we have the out-of-the-box functionality (which is awesome) as well as the ability to override for special cases. If for some reason the user decides his Freight Cost is no longer valid he or she can simply set it back to "0" and the system will perform as usual. We need this ability if a customer:

+ Reduces a large order to a small order (auto-calc freight charge)
+ Increases a small order to a large order (special freight charge)

I will share the small change in just a bit when I SCP back over to the server...
Here is all I did to enable this feature: In DeliveryDetails.php change line 122

if($_SESSION['DoFreightCalc']==True) {

if($_SESSION['DoFreightCalc']==True AND $_POST['FreightCost']==0) {

Not too sure if you guys prefer "AND" or "&&" so I will leave that up to you. It appears "AND" is preferred from my quick interrogation of the code.

So far I have only had to change nine files to meet our needs and most of the changes are very small. The most work occurred at PO_Items.php where I do a lookup to populate the description with the Branch address when entering a Non-Stock item to our PO for freight charge.
The only reason I got it to update was if the order had changed then the freight would not be recalculated... in this case if a super large heavy/bulky item was added to the order after the order had initially been entered then there would be scope for undercharging.
When the order is invoiced there is scope for over-riding the freight charged at this point.
Glad you like this functionality ... it was used extensively when first developed but is a bit miserable to maintain the data and the slicker way really is to use the freight company's APIs which are more available now than was the case when this was written.
Reference URL's