Skip to content

Commit

Permalink
Unit conversion fixes for receive form
Browse files Browse the repository at this point in the history
  • Loading branch information
lentschi committed Jul 17, 2022
1 parent 045e0d1 commit def95de
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions HACKATHON_TODOS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Replace all remaining occurrences of `.unit_quantity`
4 changes: 2 additions & 2 deletions app/assets/javascripts/receive-order-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
}

convertFieldUnit(field$, fromUnit, toUnit) {
const units = parseFloat(field$.val());
const units = parseFloat(field$.val().replace(',', '.'));
if (isNaN(units)) {
return;
}
Expand All @@ -45,7 +45,7 @@
}

convertToBillingUnit(field$) {
field$.val(this.convertFieldUnit(field$, field$.data('supplier-order-unit'), field$.data('billing-unit')));
field$.val(round(this.convertFieldUnit(field$, field$.data('supplier-order-unit'), field$.data('billing-unit'))));
}

convertFromBillingUnit(field$) {
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/orders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ def update_order_amounts
if oa.units_received_changed?
counts[0] += 1
unless oa.units_received.blank?
cunits[0] += oa.units_received * oa.article.unit_quantity
oacounts = oa.redistribute oa.units_received * oa.price.unit_quantity, rest_to
cunits[0] += oa.units_received
oacounts = oa.redistribute oa.units_received, rest_to
oacounts.each_with_index { |c, i| cunits[i + 1] += c; counts[i + 1] += 1 if c > 0 }
end
end
Expand Down

0 comments on commit def95de

Please sign in to comment.