From ee7c7c262fb7ceafdb7a47610b20b3f05320b25b Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 14 Oct 2015 17:02:06 +0200 Subject: [PATCH] Ahora el disponible tiene en cuenta la tabla order_row --- debian/changelog | 2 +- web/forms/ecomerce/catalog/catalog.js | 16 ++++++++++------ web/forms/ecomerce/catalog/ui.xml | 10 +--------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9b49bccd..9888e6e7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.229-deb8) stable; urgency=low +hedera-web (1.230-deb8) stable; urgency=low * Initial Release. diff --git a/web/forms/ecomerce/catalog/catalog.js b/web/forms/ecomerce/catalog/catalog.js index 14d4daf6..aa63e24d 100755 --- a/web/forms/ecomerce/catalog/catalog.js +++ b/web/forms/ecomerce/catalog/catalog.js @@ -244,18 +244,22 @@ Vn.Catalog = new Class var model = this.$('item-lots'); var grouping = model.get (row, 'grouping'); var warehouse = model.get (row, 'warehouse_id'); + var available = model.get (row, 'available'); var lotAmount = this.items[warehouse]; - + if (lotAmount === undefined) lotAmount = 0; - - lotAmount += grouping; - if (lotAmount <= model.get (row, 'available')) + if (lotAmount < available) { - this.items[warehouse] = lotAmount; - this.$('amount').value += grouping; + var newAmount = lotAmount + grouping; + + if (newAmount > available) + newAmount = available; + + this.items[warehouse] = newAmount; + this.$('amount').value += newAmount - lotAmount; } else Htk.Toast.showError (_('NoMoreAmountAvailable')); diff --git a/web/forms/ecomerce/catalog/ui.xml b/web/forms/ecomerce/catalog/ui.xml index d30454fc..73a61e66 100755 --- a/web/forms/ecomerce/catalog/ui.xml +++ b/web/forms/ecomerce/catalog/ui.xml @@ -44,18 +44,10 @@ CALL bionic_from_item (#item); - SELECT p.warehouse_id, p.grouping, p.price, p.rate, - t.amount, l.available - IFNULL(t.amount, 0) available + SELECT p.warehouse_id, p.grouping, p.price, p.rate, l.available FROM tmp.bionic_lot l JOIN tmp.bionic_price p ON p.warehouse_id = l.warehouse_id - LEFT JOIN ( - SELECT warehouse_id, SUM(amount) amount - FROM basket_item - WHERE item_id = #item - GROUP BY warehouse_id - ) t - ON t.warehouse_id = l.warehouse_id ORDER BY warehouse_id, grouping;