Automatic calculation of freight charges

Description

Idea is to add in core a simple calculation of freight charges based on M_Freight table, preserving the ability to configure more complex cases.

xref:
https://mattermost.idempiere.org/idempiere/pl/hk6tjfkbxtyumbtup56nut5rec

Environment

None

Activity

Show:
Carlos Ruiz
September 25, 2020, 7:59 PM
Edited

Committed pull request 277

In the pull request two new columns are created:

  • M_Freight.MaxWeight

  • M_Freight.MaxDimension

    • with their corresponding fields in the Shipper window > Freight tab

  • added also two messages for the process

New records created in GardenWorld to configure the test cases:

  • new UOM Centimeter

  • new charge "Freight Charges"

  • configure Client Info > UOM Weight and UOM Length

  • assign weight and dimension for some products (including Azalea)

  • configure several records in the Freight table to simulate a table with max weight and max dimensions

  • add a Shipping Processor pointing to the new class org.adempiere.model.MFreightShipmentProcessor

  • add a Shipper Configuration

  • configure shipper UPS to use this processor/configuration

NOTES about the Freight configuration:

  • Shipper, Freight Category are used as filters

  • DateOrdered is used to get the most recent record that is valid for that date

  • MaxDimension is used to get records that are valid for such dimensions

  • Country/Region From/To are used to get the records, first valid is the more detailed defined


Test case finding freight in GardenWorld:

  • Create a Sales Order with

    • Target Document Type = Standard Order

    • Delivery Via = Shipper

    • Shipper = UPS

    • Freight Cost Rule = Calculated

    • Freight Category = Ground

    • one line containing 1 Azalea Bush

    • Push toolbar button "Online Shipping Sales Order Rate Inquiry"

    • or Prepare the order (the freight calculation is called on prepare)

  • Result

    • a Charge line is created with the freight price found US$20

    • a Shipping Transaction is created with one line - the response message register the freight found

    • a record is created in Online Transaction History

Test case not finding freight in GardenWorld:

  • Create a Sales Order with

    • Target Document Type = Standard Order

    • Delivery Via = Shipper

    • Shipper = UPS

    • Freight Cost Rule = Calculated

    • Freight Category = Ground

    • one line containing 3 Azalea Bush

    • Push toolbar button "Online Shipping Sales Order Rate Inquiry"

    • or Prepare the order

  • Result

    • the order cannot be prepared/completed because the freight is not found

    • a record is created in Online Transaction History registering the error

  • Note changing the quantity of Azalea to 2 then a freight is found with price US$23.90

Tested also the case with price list Export

  • The freight price is converted to Euros

Tested with a price list in a currency or date without conversion rate

  • The class throws an error informing the currency conversion not found and register the Shipping Transaction and Online Transaction History

Diego Ruiz
September 28, 2020, 11:56 AM

Hi ,

The first test case works as expected. The second case has a strange behavior.

a Charge line is created with the freight price found US$20

  1. I think that sentence in the result of the test case was just a copy/paste mistake. No line is created nor should be created.

  2. The error message looks extremely similar to the success message, which is very misleading. I first thought the process was creating a line, but nothing was happening.

  3. Additionally, I don’t know if it is related to this ticket but “Process completed successfully” and “Could not find freight defined …” sound like inconsistent messages when the process fails, especially because the user won’t be able to complete the order.

4. When you mix the two cases, first do the first one, which creates a freight line. But instead of creating a second sales order, you modify the existing one and increase the quantity to 3, and run the process again. Shouldn’t that freight line be modified, deleted, or something? you can’t complete the document (which is right) but you think the freight is correct because there is a line with that charge. This is just a question, I am not sure if what I am saying makes sense.

Best regards,

Diego Ruiz

Carlos Ruiz
September 28, 2020, 12:41 PM

1. I think that sentence in the result of the test case was just a copy/paste mistake. No line is created nor should be created.

Right, copy/paste error - fixed

2. The error message looks extremely similar to the success message, which is very misleading. I first thought the process was creating a line, but nothing was happening.

Changed the error message to call user attention

3. Additionally, I don’t know if it is related to this ticket but “Process completed successfully” and “Could not find freight defined …” sound like inconsistent messages when the process fails, especially because the user won’t be able to complete the order.

Improved in last commit. The Online Trx is saved even if the process fails.

4. When you mix the two cases, first do the first one, which creates a freight line. But instead of creating a second sales order, you modify the existing one and increase the quantity to 3, and run the process again. Shouldn’t that freight line be modified, deleted, or something? you can’t complete the document (which is right) but you think the freight is correct because there is a line with that charge. This is just a question, I am not sure if what I am saying makes sense.

I prefer not to touch this part - the user must take action, or fix the problem - or enter a fixed charge, so is something that user must solve.

Assignee

Carlos Ruiz

Reporter

Carlos Ruiz

Labels

None

Tested By

None

Fix versions

Priority

Major
Configure