tendril-framework / triage

Report incoming issues here if specific module is unknown
0 stars 0 forks source link

Location based freight in tendril #4

Open sumeetkd opened 4 years ago

sumeetkd commented 4 years ago

Freight fragmentation as per pincode can be done using the following code. We may have to add the ability to change the freight depending on the size of the product

chintal commented 4 years ago

This is generic and simple enough to be implemented as a python package independent of tendril and used from within tendril. See https://github.com/chintal/iec60063 for an example of a similar structure. The project structure there can be used as a rough template. If anyone wishes to take this up, assign yourself to this issue or let me know.

The package should probably only deal with pincodes and distance estimates and not explicitly manage freight estimations. The actual freight estimation will have to go into tendril because of the variability in weights, shipping vendors, etc.

Definitions of 'home' pincode and country can be injected though the tendril config. See https://github.com/tendril-framework/tendril-connector-tally/blob/master/src/tendril/connectors/tally/__init__.py#L45 for an example of how to escape this for independent use and during development. Also see https://github.com/tendril-framework/tendril-connector-tally/tree/master/src/tendril/config for an example of how to add config parameters. I can help with both these issues once the package is starting to take shape.

The package should probably provide some straightforward endpoints (functions), to

This should be future-compatible with non-domestic pincodes, so also accept a "country" keyword argument for all endpoints where it is relevant, which defaults to the home country.

Identity / addresses must provide access to pincode (and country). Tendril integration will be deferred to after resolution of #1 and tendril-framework/tendril-identity#1

Might consider including weight/volume in product definitions as well.

sumeetkd commented 4 years ago

I'll take this up.

The input of location = {"country":"", "Pincode":""} will be entered at user interface. The final output will be a freight cost. Will include a function calculate_freight(location, method)

Method will include current_method: based on my gist vendor_based method: which will use the Pincode based pricing provided by vendor.

chintal commented 4 years ago

The input of location = {"country":"", "Pincode":""}

You can use a namedtuple instead of a dictionary.

Will include a function calculate_freight(location, method)

This won't be possible. You will need to do either

calculate_freight(weight, volume, destination, source=home_location, method=default_method)

Or

calculate_distance(destination, source=home_location, method=default_method)

Where distance is some kind of metric like the distance buckets in your code and need not be an actual distance.