Commit Graph

28 Commits

Author SHA1 Message Date
Maikel Linke
4bcd665379 Handle all line items without unit_value in weight calculation 2020-03-26 17:13:29 +11:00
Luis Ramos
24c8f38111 Restructure spec to avoid variable names with numbers 2020-03-25 15:48:57 +01:00
Luis Ramos
9af4bb9757 Use create instead of build so that we test with callbacks 2020-03-25 11:22:40 +00:00
Matt-Yorkley
ef0fb18fda Fix calculations for weight when variant.unit_value is zero 2020-03-24 22:05:55 +01:00
Matt-Yorkley
87ee4bbebc Add spec for current problematic behaviour 2020-03-24 20:09:54 +01:00
Matt-Yorkley
54c3c73ed2 Fix duplicate key in hash 2020-03-24 12:46:21 +01:00
luisramos0
e9e6aa77d8 Make weight calculator work for SubscriptionLineItems by making it test if line_item responds to final_weight_volume field (final_weight_volume_present?)
We also add logic to weight_per_variant so that we use variant.unit_value if final_weight_volume is not available but variant_unit is weight
Adapt some test case to test unit_value (in grams) instead of weight (in kgs)
2019-12-08 17:36:21 +00:00
luisramos0
0e8f167ab9 Fix spec in weight calculator tests 2019-08-02 20:44:11 +01:00
Kristina Lim
e1fce8304d Update weight calculator and add specs 2019-07-23 23:24:00 +08:00
luisramos0
160b535e2f Make weight calculator compute 0 for variants with unit different from weight 2019-06-18 15:21:13 +01:00
luisramos0
82955b9fe5 Make weight calculator use line_item.final_weight_volume rather than variant.weight for cases where the final weight is set manually in the BOM 2019-05-31 19:55:17 +01:00
Maikel Linke
1ea2f37c18 Support international decimals in weight calculator
A previous pull request added support for flexible decimal characters
when editing money amounts.
https://github.com/openfoodfoundation/openfoodnetwork/pull/1831

This pull request applies the same principle to the weight calculator
which was missed in the previous pull request.
2019-03-21 12:49:19 +11:00
luisramos0
38ff99717a Fix bug on calculator_decorator line_items_for where input is line_item with an nil order. Adapted line_items_for so that weight_calculator.line_items_for could be removed. 2018-12-09 19:37:11 +00:00
luisramos0
9490da329a Move Calculator::Weight from models/open_food_network/calculator to models/calculator 2018-11-07 09:54:30 +00:00
luisramos0
bf55f50a7e Fix rubocop warnings on weight and weight_spec 2018-11-07 09:54:30 +00:00
luisramos0
275a192270 Convert specs to RSpec 3.7.1 syntax with Transpec
This conversion is done by Transpec 3.3.0 with the following command:
    transpec spec/models/calculator/weight_spec.rb

* 3 conversions
    from: == expected
      to: eq(expected)

* 3 conversions
    from: obj.should
      to: expect(obj).to

For more details: https://github.com/yujinakayama/transpec#supported-conversions
2018-11-07 09:54:30 +00:00
luisramos0
1ef04354fd Add capacity to weight calculator to calculate based on any object with an order (needed in spree 2 to calculate based on package) 2018-11-07 09:54:30 +00:00
Pierre de Lacroix
f67a8c1f2d Add tests 2017-12-01 13:37:24 +11:00
Rohan Mitchell
701c047a0a Move our customisations of FlatPercentItemTotal calculator to a new calc: FlatPercentPerItem 2016-08-26 09:28:29 +10:00
Rohan Mitchell
57f7d489ff Rename OpenFoodWeb namespace to OpenFoodNetwork 2013-10-18 17:29:55 +11:00
Rohan Mitchell
5f4313b588 Remove itemwise shipping calculator 2013-08-13 10:14:39 +10:00
Rohan Mitchell
239dd29511 Weight calculator will calculate against a single line item as well as an order 2013-08-09 15:27:52 +10:00
Rohan Mitchell
ec3e00c128 Refactor LineItem and clients for new fields 2013-08-06 13:47:17 +10:00
Rohan Mitchell
9dd94eaf57 Weight shipping calculator treats variants without weight defined as zero weight 2012-08-08 15:29:47 +10:00
Rohan Mitchell
e6ee6b5164 Itemwise shipping calculator returns 0 instead of nil when there are no items 2012-08-03 08:44:53 +10:00
Rohan Mitchell
06c6422591 Fix by-weight calculator to take line item quantity into account 2012-07-23 18:49:03 +10:00
Rohan Mitchell
28d2292de0 Add by-weight shipping calculator 2012-06-29 12:46:33 +10:00
Rohan Mitchell
eae05ea59c Add itemwise shipping cost calculator 2012-06-29 07:52:29 +10:00