LocalOrbit / localorbit

Local Orbit is an open source web application and service that empowers food hubs to efficiently sell and distribute local food.
https://localorbit.com
MIT License
16 stars 11 forks source link

Error updating prices when Fee = 100%, Net Price = $0, Sale Price = $1 #3492

Open rbarreca opened 5 years ago

rbarreca commented 5 years ago

Describe the bug If you try to set product price with custom Fee % and net price = $0 (say it's a supplier freebie or something but buyer still pays) you'll get an app error

To Reproduce Steps to reproduce the behavior:

  1. Log in as market manager
  2. Go to Prices tab for a product
  3. Click Edit
  4. Set Fee % to Product and value = 100
  5. Set Net Price = 0
  6. Set Sale Price = 1
  7. Click Save
  8. See error like PG::NumericValueOutOfRange: ERROR: numeric field overflow DETAIL: A field with precision 5, scale 3 must round to an absolute value less than 10^2. : UPDATE "prices" SET "net_price" = $1, "product_fee_pct" = $2, "sale_price" = $3, "updated_at" = $4 WHERE "prices"."id" = 200782

Expected behavior This would save and work in the system correctly or at least provide a valid error message in short-term (if a $0.00 net price product is too high of effort to do at this time).

Screenshots

screen shot 2018-11-04 at 3 28 37 pm screen shot 2018-11-04 at 3 29 10 pm

Rollbar instances