Skip to content

Commit

Permalink
frontend: skip packaging w/out qty
Browse files Browse the repository at this point in the history
Do it on frontend as well to avoid errors from demo data
or from different backend sources.
  • Loading branch information
simahawk committed Jun 10, 2020
1 parent a12e06b commit ca6a8b9
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ export var PackagingQtyPickerMixin = {
// const min_unit = _.last(pkg_by_qty);
pkg_by_qty.forEach(function(pkg) {
let qty_per_pkg = 0;
if (!pkg.qty) {
console.error("Packaging with no quantity: skipping", pkg);
return {};
}
[qty_per_pkg, qty] = self._qty_by_pkg(pkg.qty, qty);
if (qty_per_pkg) res[pkg.id] = qty_per_pkg;
if (!qty) return;
Expand Down Expand Up @@ -178,10 +174,12 @@ export var PackagingQtyPickerMixin = {
return _.extend([], this.opts.available_packaging, unit);
},
/**
*
* Sort packaging by qty and exclude the ones w/ qty = 0
*/
sorted_packaging: function() {
return _.reverse(_.sortBy(this.packaging, _.property("qty")));
return _.reverse(
_.sortBy(_.filter(this.packaging, _.property("qty")), _.property("qty"))
);
},
/**
* Collect qty of contained packaging inside bigger packaging.
Expand Down

0 comments on commit ca6a8b9

Please sign in to comment.