diff --git a/src/main/java/info/bukova/isspst/filters/InvoicingFilter.java b/src/main/java/info/bukova/isspst/filters/InvoicingFilter.java index 166f44f5..8573b4a5 100644 --- a/src/main/java/info/bukova/isspst/filters/InvoicingFilter.java +++ b/src/main/java/info/bukova/isspst/filters/InvoicingFilter.java @@ -4,6 +4,7 @@ import info.bukova.isspst.DateTimeUtils; import info.bukova.isspst.StringUtils; import info.bukova.isspst.data.Invoicing; import info.bukova.isspst.data.Requirement; +import info.bukova.isspst.data.User; import info.bukova.isspst.data.Workgroup; import org.hamcrest.Description; @@ -48,8 +49,9 @@ public class InvoicingFilter implements Filter boolean foundReqDate = DateTimeUtils.isEqualByDateForFilter(item.getRequirement().getReqDate(), condition.getRequirement().getReqDate()); boolean foundCenter = Workgroup.isEqualByWorkgroupForFilter(item.getRequirement().getCentre(), condition.getRequirement().getCentre()); boolean foundWorkgroup = Workgroup.isEqualByWorkgroupForFilter(item.getRequirement().getWorkgroup(), condition.getRequirement().getWorkgroup()); + boolean foundUser = User.isEqualByUserForFilter(item.getRequirement().getOwnedBy(), condition.getRequirement().getOwnedBy()); boolean foundDescription = StringUtils.isEqualForFilter(item.getRequirement().getDescription(), condition.getRequirement().getDescription()); - return (foundNumser && foundReqDate && foundCenter && foundDescription && foundWorkgroup); + return (foundNumser && foundReqDate && foundCenter && foundDescription && foundWorkgroup && foundUser); } @Factory diff --git a/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java b/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java index 9fb504b9..d7263af3 100644 --- a/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java @@ -64,5 +64,13 @@ public class InvoicingServiceImpl extends AbstractOwnedService implem Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy order by rq.numser"); return q.list(); } + + @Transactional + @LazyLoader("form") + public void loadOwnedBy(Invoicing invoice) { + Invoicing inv = getById(invoice.getId()); + Hibernate.initialize(inv.getRequirement().getOwnedBy()); + invoice.getRequirement().setOwnedBy(inv.getRequirement().getOwnedBy()); + } } 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 42f5ab84..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,41 @@ 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); } + + @Override + @Transactional + @PreAuthorize("hasPermission(this, 'PERM_DELETE') or hasPermission(#entity, this.getDeleteEntityPermission())") + public void delete(Order order) { + for (OrderItem item : order.getItems()) + { + RequirementItem rItem = item.getReqItem(); + + if (rItem != null) + { + rItem.setOrderNum(null); + requirementItemDao.modify(rItem); + } + } + + super.delete(order); + } } diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementService.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementService.java index 770e69d1..6c99d859 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementService.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementService.java @@ -26,4 +26,6 @@ public interface RequirementService extends RequirementBaseService public RequirementItem calcItemValuesFromItemTotal(RequirementItem item); public BigDecimal calcSumTotalFromItems(List items); + + public BigDecimal getInvoicedAmount(Requirement req); } diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java index 87b3fdd6..a97f078d 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java @@ -16,6 +16,7 @@ import java.util.Date; import java.util.List; import org.hibernate.Hibernate; +import org.hibernate.Query; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; @@ -240,4 +241,15 @@ public class RequirementServiceImpl extends RequirementBaseServiceImpl public List getUsers() { - return this.userService.getAll(); + return this.userService.getUsersForCombo(); } @Command diff --git a/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingList.java b/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingList.java index 1c38b78a..2de94126 100644 --- a/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingList.java +++ b/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingList.java @@ -3,9 +3,11 @@ package info.bukova.isspst.ui.main.invoicing; import java.util.List; import info.bukova.isspst.data.Invoicing; +import info.bukova.isspst.data.User; import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.filters.InvoicingFilter; import info.bukova.isspst.services.invoicing.InvoicingService; +import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.ui.ListViewModel; @@ -18,6 +20,8 @@ public class InvoicingList extends ListViewModel { private InvoicingService invoicingService; @WireVariable private WorkgroupService workgroupService; + @WireVariable + private UserService userService; @Init(superclass = true) public void initInvoicing() { @@ -45,4 +49,8 @@ public class InvoicingList extends ListViewModel { return workgroupService.getWorkgroups(); } + public List getUsers() { + return userService.getUsersForCombo(); + } + } 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() { diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyAll.java b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyAll.java index e43b1ec2..f765fe66 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyAll.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyAll.java @@ -7,6 +7,7 @@ import info.bukova.isspst.services.requirement.RequirementService; import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.ui.requirement.RequirementSubpage; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; @@ -64,4 +65,18 @@ public class ReqListMyAll extends RequirementSubpage protected void beforeSelectViaUrl() { BindUtils.postGlobalCommand(null, null, "selectAll", null); } + + public BigDecimal getInvoicedAmount() { + if (getDataBean() != null) { + return requirementService.getInvoicedAmount(getDataBean()); + } else { + return null; + } + } + + @Override + @NotifyChange({ "dataBean", "ableToDelete", "canApprove", "invoicedAmount" }) + public void setDataBean(Requirement data) { + super.setDataBean(data); + } } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyCenters.java b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyCenters.java index 0c116134..af243b72 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyCenters.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyCenters.java @@ -7,6 +7,7 @@ import info.bukova.isspst.services.requirement.RequirementService; import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.ui.requirement.RequirementSubpage; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; @@ -64,4 +65,18 @@ public class ReqListMyCenters extends RequirementSubpage protected void beforeSelectViaUrl() { BindUtils.postGlobalCommand(null, null, "selectCentre", null); } + + public BigDecimal getInvoicedAmount() { + if (getDataBean() != null) { + return requirementService.getInvoicedAmount(getDataBean()); + } else { + return null; + } + } + + @Override + @NotifyChange({ "dataBean", "ableToDelete", "canApprove", "invoicedAmount" }) + public void setDataBean(Requirement data) { + super.setDataBean(data); + } } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyWorkgroups.java b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyWorkgroups.java index 90e0a2c2..22b7af87 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyWorkgroups.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyWorkgroups.java @@ -7,6 +7,7 @@ import info.bukova.isspst.services.requirement.RequirementService; import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.ui.requirement.RequirementSubpage; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; @@ -64,4 +65,18 @@ public class ReqListMyWorkgroups extends RequirementSubpage protected void beforeSelectViaUrl() { BindUtils.postGlobalCommand(null, null, "selectWorkgroup", null); } + + public BigDecimal getInvoicedAmount() { + if (getDataBean() != null) { + return requirementService.getInvoicedAmount(getDataBean()); + } else { + return null; + } + } + + @Override + @NotifyChange({ "dataBean", "ableToDelete", "canApprove", "invoicedAmount" }) + public void setDataBean(Requirement data) { + super.setDataBean(data); + } } diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index 3702bcbb..d6f65f62 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -40,6 +40,8 @@ RequirementItemUnitPrice=Jedn. cena RequirementItemTotal=Celkem RequirementItemDescription=Poznámka +RequirementInvoicedAmount=Fakturovaná částka: + AgendaMyOrders=Aktuální AgendaOrdersHistory=Ukončené @@ -362,8 +364,8 @@ WorkgroupFormCannotAddWorkgroup=Komisi nelze přidat WorkgroupFormOrderLimit=Limit nákupů WorkgroupIsInWorkgroup=Komisi nelze smazat, protože je členem některého střediska -Help=Příručka GoogleDriveUrl=Odkaz na Google Drive +Help=Příručka ModuleNotActive=Modul není aktivovaný diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 3939089e..c22c19b6 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -192,6 +192,10 @@ /error.zul + + 480 + + index.zul index.zhtml diff --git a/src/main/webapp/app/mainMenu.zul b/src/main/webapp/app/mainMenu.zul index 14f55811..1646e037 100644 --- a/src/main/webapp/app/mainMenu.zul +++ b/src/main/webapp/app/mainMenu.zul @@ -135,6 +135,9 @@ href="/j_spring_security_logout" /> + - + \ No newline at end of file diff --git a/src/main/webapp/main/invoicing/invoicingGrid.zul b/src/main/webapp/main/invoicing/invoicingGrid.zul index c2fdd775..53ae6fa6 100644 --- a/src/main/webapp/main/invoicing/invoicingGrid.zul +++ b/src/main/webapp/main/invoicing/invoicingGrid.zul @@ -123,6 +123,27 @@ + +
+
+ + + +
+
+ +
+
+
diff --git a/src/main/webapp/main/orders/approved/grid.zul b/src/main/webapp/main/orders/approved/grid.zul index 77bbc099..33d27a2d 100644 --- a/src/main/webapp/main/orders/approved/grid.zul +++ b/src/main/webapp/main/orders/approved/grid.zul @@ -32,6 +32,10 @@ + @@ -82,6 +86,21 @@ +
+
+ +
+
+ +
+
+
+
+ diff --git a/src/main/webapp/main/orders/requirements/reqListMyAll.zul b/src/main/webapp/main/orders/requirements/reqListMyAll.zul index 336536c8..7e827ccf 100644 --- a/src/main/webapp/main/orders/requirements/reqListMyAll.zul +++ b/src/main/webapp/main/orders/requirements/reqListMyAll.zul @@ -188,6 +188,14 @@
- + + + + + + +
diff --git a/src/main/webapp/main/orders/requirements/reqListMyCenters.zul b/src/main/webapp/main/orders/requirements/reqListMyCenters.zul index 336536c8..98582b47 100644 --- a/src/main/webapp/main/orders/requirements/reqListMyCenters.zul +++ b/src/main/webapp/main/orders/requirements/reqListMyCenters.zul @@ -188,6 +188,14 @@
- + + + + + + +
diff --git a/src/main/webapp/main/orders/requirements/reqListMyWorkgroups.zul b/src/main/webapp/main/orders/requirements/reqListMyWorkgroups.zul index 44a57fd7..12e32e86 100644 --- a/src/main/webapp/main/orders/requirements/reqListMyWorkgroups.zul +++ b/src/main/webapp/main/orders/requirements/reqListMyWorkgroups.zul @@ -188,6 +188,14 @@
- + + + + + + +