From 884bc8267d050a5e848e73b4c5e10828c429e9d0 Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Mon, 9 Feb 2015 13:27:32 +0100 Subject: [PATCH] =?UTF-8?q?U=20nov=C3=BDch=20objedn=C3=A1vek=20lze=20nyn?= =?UTF-8?q?=C3=AD=20zatrhout,=20=C5=BEe=20je=20rovnou=20objedn=C3=A1no...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #196 --- .../isspst/services/orders/OrderService.java | 2 ++ .../services/orders/OrderServiceImpl.java | 22 +++++++++++++++---- .../ui/main/orders/created/OrderForm.java | 11 ++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/main/java/info/bukova/isspst/services/orders/OrderService.java b/src/main/java/info/bukova/isspst/services/orders/OrderService.java index 1fe1e0c2..89a99112 100644 --- a/src/main/java/info/bukova/isspst/services/orders/OrderService.java +++ b/src/main/java/info/bukova/isspst/services/orders/OrderService.java @@ -22,5 +22,7 @@ public interface OrderService extends Service { public BigDecimal calcSumTotalFromItems(List items); + public void addApprovedItems(Order order, boolean orderedChanged); + public void updateApprovedItems(Order order, boolean orderedChanged); } diff --git a/src/main/java/info/bukova/isspst/services/orders/OrderServiceImpl.java b/src/main/java/info/bukova/isspst/services/orders/OrderServiceImpl.java index 2e0b1e69..801cf13c 100644 --- a/src/main/java/info/bukova/isspst/services/orders/OrderServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/orders/OrderServiceImpl.java @@ -180,16 +180,14 @@ public class OrderServiceImpl extends AbstractOwnedService implements return sumTotal; } - @Transactional - @PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())") - public void updateApprovedItems(Order order, boolean orderedChanged) + protected void setApprovedItems(Order order, boolean orderedChanged) { if (orderedChanged) { for (OrderItem item : order.getItems()) { RequirementItem rItem = item.getReqItem(); - + if (rItem != null) { rItem.setOrderNum(order.isOrdered() ? order.getNumser() : null); @@ -197,7 +195,23 @@ public class OrderServiceImpl extends AbstractOwnedService implements } } } + } + + @Override + @Transactional + @PreAuthorize("hasPermission(this, 'PERM_ADD')") + public void addApprovedItems(Order order, boolean orderedChanged) + { + this.add(order); + this.setApprovedItems(order, orderedChanged); + } + @Override + @Transactional + @PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())") + public void updateApprovedItems(Order order, boolean orderedChanged) + { + this.setApprovedItems(order, orderedChanged); super.update(order); } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/created/OrderForm.java b/src/main/java/info/bukova/isspst/ui/main/orders/created/OrderForm.java index a2773232..e0a82d1a 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/created/OrderForm.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/created/OrderForm.java @@ -297,6 +297,17 @@ public class OrderForm extends FormViewModel this.calcAndUpdateFormTotalPrice(form); } + @Override + protected void doAdd() + { + // Zjisti, zda se změnil příznak objednávky (objednáno/neobjednáno) + boolean orderedChanged = (this.recordBeforeEdit.isOrdered() != this.getDataBean().isOrdered()); + // Aktualizovat příznak schválených položek, aby se nemohli vložit do + // jiných objednávek + orderService.addApprovedItems(this.getDataBean(), orderedChanged); + BindUtils.postGlobalCommand(null, null, "reload", null); + } + @Override protected void doSave() {