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,