From b06a984f276f306a0b7eaba0c1693053940667cd Mon Sep 17 00:00:00 2001 From: sungsu Date: Mon, 22 Jan 2024 13:04:18 +0900 Subject: [PATCH] =?UTF-8?q?#=EC=88=98=EC=A0=95=20=EC=9E=AC=EA=B3=A0?= =?UTF-8?q?=EB=9F=89=EC=9D=B4=20=EC=88=98=EC=A0=95=EB=90=98=EC=96=B4=20?= =?UTF-8?q?=EC=98=88=EC=95=BD=EB=90=9C=20=EC=B6=9C=EA=B3=A0=EB=9F=89?= =?UTF-8?q?=EB=B3=B4=EB=8B=A4=20=EB=82=AE=EC=95=84=EC=A7=80=EB=A9=B4=20?= =?UTF-8?q?=EC=A6=89=EC=8B=9C=20=EC=B6=9C=EA=B3=A0=20=EC=95=88=EB=90=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mappers/ProductOutMapper.xml | 11 ++++++----- src/main/webapp/WEB-INF/views/out/read.jsp | 19 +++++++++++++++---- src/main/webapp/WEB-INF/views/out/update.jsp | 18 +++++++++++++----- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/main/resources/mappers/ProductOutMapper.xml b/src/main/resources/mappers/ProductOutMapper.xml index a9b7abd..1e48e8e 100644 --- a/src/main/resources/mappers/ProductOutMapper.xml +++ b/src/main/resources/mappers/ProductOutMapper.xml @@ -37,10 +37,11 @@ @@ -103,7 +104,7 @@ update warehouse - set current_capacity = current_capacity - #{quantity} + set current_capacity = current_capacity - #{outQuantity} where id = #{warehouse_id}; @@ -116,13 +117,13 @@ update product_out - set quantity = #{quantity}, expected_delivery_date = #{expected_delivery_date}, delivery_date = #{delivery_date} + set quantity = #{outQuantity}, expected_delivery_date = #{expected_delivery_date}, delivery_date = #{delivery_date} where id = #{id}; update stock - set quantity = quantity - #{quantity} + set quantity = quantity - #{outQuantity} where product_id = #{product_id} and warehouse_id = #{warehouse_id}; diff --git a/src/main/webapp/WEB-INF/views/out/read.jsp b/src/main/webapp/WEB-INF/views/out/read.jsp index 463cf23..f485f7f 100644 --- a/src/main/webapp/WEB-INF/views/out/read.jsp +++ b/src/main/webapp/WEB-INF/views/out/read.jsp @@ -37,8 +37,13 @@
- 출고량 - + 재고량 + +
+ +
+ 출고량 +
@@ -214,7 +219,8 @@ function outNowUpdate() { var id = $("#id").val(); - var quantity = $("#quantity").val(); + var stockQuantity = parseInt($("#stockQuantity").val(), 10); + var outQuantity = parseInt($("#outQuantity").val(), 10); var product_id = $("#product_id").val() var warehouse_id = $("#warehouse_id").val(); var expected_delivery_date = $("#expected_delivery_date").val(); @@ -222,12 +228,17 @@ var now = new Date(); var delivery_date = now.toISOString().slice(0, 19).replace('T', ' '); + if (outQuantity > stockQuantity) { + alert("출고량이 재고량을 넘을 수 없습니다."); + return false; + } + $.ajax({ url: "/out/outNow", type: "put", data: { "id": id, - "quantity": quantity, + "outQuantity": outQuantity, "product_id":product_id, "warehouse_id": warehouse_id, "expected_delivery_date": expected_delivery_date, diff --git a/src/main/webapp/WEB-INF/views/out/update.jsp b/src/main/webapp/WEB-INF/views/out/update.jsp index 0dc409d..ac4de8d 100644 --- a/src/main/webapp/WEB-INF/views/out/update.jsp +++ b/src/main/webapp/WEB-INF/views/out/update.jsp @@ -34,10 +34,14 @@
- 출고량 - + 재고량 +
+
+ 출고량 + +
@@ -103,13 +107,17 @@ $("#updateBtn").on("click", function () { var id = $("#id").val(); var product_id = $("#product_id").val(); - var quantity = $("#quantity").val(); + var stockQuantity = parseInt($("#stockQuantity").val(), 10); + var outQuantity = parseInt($("#outQuantity").val(), 10); var expected_delivery_date = $("#expected_delivery_date").val(); var warehouse_id = $("#warehouse_id").val(); var note = $("#note").val(); var activation = $("#activation").val(); - + if (outQuantity > stockQuantity) { + alert("출고량이 재고량을 넘을 수 없습니다."); + return false; + } if (!product_id) { alert("제품을 선택해야 합니다."); @@ -130,7 +138,7 @@ "expected_delivery_date":expected_delivery_date, "note":note, "warehouse_id": warehouse_id, - "quantity": quantity, + "quantity": outQuantity, "activation": activation,