From 18920701a7b1cbf0df64493ca24691227bf41cc8 Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Wed, 15 Oct 2014 21:51:39 +0200 Subject: [PATCH] =?UTF-8?q?Fakturovan=C3=A1=20=C4=8D=C3=A1stka=20na=20obje?= =?UTF-8?q?dn=C3=A1vk=C3=A1ch=20se=20nyn=C3=AD=20po=C4=8D=C3=ADt=C3=A1=20z?= =?UTF-8?q?=20polo=C5=BEek.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #152, #154 --- .../java/info/bukova/isspst/data/Order.java | 5 ++-- .../info/bukova/isspst/data/OrderItem.java | 14 +++++++++ .../services/approved/OrderService.java | 2 ++ .../services/approved/OrderServiceImpl.java | 24 +++++++++++++++ .../ui/main/orders/created/OrderForm.java | 30 +++++++++++++++++++ .../lang-addons/CzechSortListheader.xml | 2 +- .../lang-addons/ckez-bind-lang-addon.xml | 1 + .../WEB-INF/lang-addons/mapa-lang-addon.xml | 1 + src/main/webapp/WEB-INF/security.tld | 1 + src/main/webapp/css/page.css | 10 ++++++- src/main/webapp/main/orders/created/grid.zul | 6 ++++ .../webapp/main/orders/created/orderForm.zul | 15 ++++++++++ 12 files changed, 107 insertions(+), 4 deletions(-) diff --git a/src/main/java/info/bukova/isspst/data/Order.java b/src/main/java/info/bukova/isspst/data/Order.java index c56e3c48..9bef5ca0 100644 --- a/src/main/java/info/bukova/isspst/data/Order.java +++ b/src/main/java/info/bukova/isspst/data/Order.java @@ -301,8 +301,9 @@ public class Order extends BaseData implements Cloneable if (rItem != null) { String orderNum = rItem.getOrderNum(); - boolean isIncluded = !((orderNum == null) || (orderNum.isEmpty())); - return isIncluded; + boolean isIncluded = ((orderNum != null) && !orderNum.isEmpty()); + boolean isFromAnotherOrder = (isIncluded && !this.numser.equals(orderNum)); + return isFromAnotherOrder; } } diff --git a/src/main/java/info/bukova/isspst/data/OrderItem.java b/src/main/java/info/bukova/isspst/data/OrderItem.java index c1b5a4fa..98baf1b9 100644 --- a/src/main/java/info/bukova/isspst/data/OrderItem.java +++ b/src/main/java/info/bukova/isspst/data/OrderItem.java @@ -45,6 +45,9 @@ public class OrderItem { @Column(name = "DESCRIPTION") private String description; + @Column(name = "TOTALINVOICE", precision = 15, scale = 4) + private BigDecimal totalInvoice; + @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "REQUIREMENT_ITEM_ID") private RequirementItem reqItem; @@ -68,6 +71,7 @@ public class OrderItem { this.munit = reqItem.getMunit(); this.total = reqItem.getTotal(); this.description = reqItem.getDescription(); + this.totalInvoice = BigDecimal.ZERO; } public int getId() { @@ -142,6 +146,16 @@ public class OrderItem { this.description = description; } + public BigDecimal getTotalInvoice() + { + return totalInvoice; + } + + public void setTotalInvoice(BigDecimal totalInvoice) + { + this.totalInvoice = totalInvoice; + } + public RequirementItem getReqItem() { return reqItem; } diff --git a/src/main/java/info/bukova/isspst/services/approved/OrderService.java b/src/main/java/info/bukova/isspst/services/approved/OrderService.java index 0966403c..483fbf64 100644 --- a/src/main/java/info/bukova/isspst/services/approved/OrderService.java +++ b/src/main/java/info/bukova/isspst/services/approved/OrderService.java @@ -22,5 +22,7 @@ public interface OrderService extends Service { public BigDecimal calcSumTotalFromItems(List items); + public BigDecimal calcSumTotalInvoiceFromItems(List items); + public void updateApprovedItems(Order order, boolean orderedChanged); } diff --git a/src/main/java/info/bukova/isspst/services/approved/OrderServiceImpl.java b/src/main/java/info/bukova/isspst/services/approved/OrderServiceImpl.java index 808e358f..86f2fa13 100644 --- a/src/main/java/info/bukova/isspst/services/approved/OrderServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/approved/OrderServiceImpl.java @@ -177,6 +177,30 @@ public class OrderServiceImpl extends AbstractOwnedService implements return sumTotal; } + @Override + public BigDecimal calcSumTotalInvoiceFromItems(List items) + { + BigDecimal sumTotal = BigDecimal.ZERO; + + if (items != null) + { + for (OrderItem item : items) + { + if (item != null) + { + BigDecimal total = item.getTotalInvoice(); + + if (total != null) + { + sumTotal = sumTotal.add(total); + } + } + } + } + + return sumTotal; + } + @Transactional public void updateApprovedItems(Order order, boolean orderedChanged) { 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 7177ed89..9935cc17 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 @@ -278,6 +278,36 @@ public class OrderForm extends FormViewModel this.calcAndUpdateFormTotalPrice(form); } + protected void calcAndUpdateFormTotalInvoicePrice(SimpleForm form) + { + if (form != null) + { + BigDecimal sumTotal = orderService.calcSumTotalInvoiceFromItems(this.getDataBean().getItems()); + form.setField("invoiceTotal", sumTotal); + BindUtils.postNotifyChange(null, null, form, "*"); + } + } + + @Command + @NotifyChange({ "selectedItem", "syncOrderItems" }) + public void recalculateTotalInvoice(@BindingParam("form") SimpleForm form, @BindingParam("changed") String source) + { + if (this.selectedItem == null) + { + log.warn("Zavolat z formuláře onFocus pro nastavení vybrané položky!"); + return; + } + + if ((source != null) && (source.equals("totalInvoice"))) + { + // Calculate total price at form + this.calcAndUpdateFormTotalInvoicePrice(form); + return; + } + + log.warn("Dopracovat přepočet fakturované částky objednávky i pro další případy!"); + } + @Override protected void doSave() { diff --git a/src/main/webapp/WEB-INF/lang-addons/CzechSortListheader.xml b/src/main/webapp/WEB-INF/lang-addons/CzechSortListheader.xml index a3ced572..2ec2ada1 100644 --- a/src/main/webapp/WEB-INF/lang-addons/CzechSortListheader.xml +++ b/src/main/webapp/WEB-INF/lang-addons/CzechSortListheader.xml @@ -1,5 +1,5 @@ - + CzechSortListheader xul/html diff --git a/src/main/webapp/WEB-INF/lang-addons/ckez-bind-lang-addon.xml b/src/main/webapp/WEB-INF/lang-addons/ckez-bind-lang-addon.xml index 44ea3165..64ae87f7 100644 --- a/src/main/webapp/WEB-INF/lang-addons/ckez-bind-lang-addon.xml +++ b/src/main/webapp/WEB-INF/lang-addons/ckez-bind-lang-addon.xml @@ -1,4 +1,5 @@ + ckezbind diff --git a/src/main/webapp/WEB-INF/lang-addons/mapa-lang-addon.xml b/src/main/webapp/WEB-INF/lang-addons/mapa-lang-addon.xml index dede21d7..970685f4 100644 --- a/src/main/webapp/WEB-INF/lang-addons/mapa-lang-addon.xml +++ b/src/main/webapp/WEB-INF/lang-addons/mapa-lang-addon.xml @@ -1,4 +1,5 @@ + mapa xul/html diff --git a/src/main/webapp/WEB-INF/security.tld b/src/main/webapp/WEB-INF/security.tld index 2ac85b0e..de1d268a 100644 --- a/src/main/webapp/WEB-INF/security.tld +++ b/src/main/webapp/WEB-INF/security.tld @@ -1,3 +1,4 @@ + http://www.zkoss.org/demo/integration/security diff --git a/src/main/webapp/css/page.css b/src/main/webapp/css/page.css index 98347b8d..afcdf363 100644 --- a/src/main/webapp/css/page.css +++ b/src/main/webapp/css/page.css @@ -66,7 +66,7 @@ html, body { overflow: hidden; } -.form-caption { +.form-caption, .form-caption-highlight { overflow: hidden; font-weight: bold; font-size: 20px; @@ -82,6 +82,14 @@ html, body { padding-right: 5px; } +.form-caption-highlight { + background-color: red; +} +.form-caption-highlight-content { + float: left; +} + + /* html, body { background-color: red; } #screen { background-color: lightgreen; } diff --git a/src/main/webapp/main/orders/created/grid.zul b/src/main/webapp/main/orders/created/grid.zul index cc048a46..9d9ab996 100644 --- a/src/main/webapp/main/orders/created/grid.zul +++ b/src/main/webapp/main/orders/created/grid.zul @@ -326,6 +326,11 @@ hflex="15" sort="czech(description)" label="${labels.RequirementItemDescription}" /> + + diff --git a/src/main/webapp/main/orders/created/orderForm.zul b/src/main/webapp/main/orders/created/orderForm.zul index 24db2ce0..547c13a1 100644 --- a/src/main/webapp/main/orders/created/orderForm.zul +++ b/src/main/webapp/main/orders/created/orderForm.zul @@ -120,6 +120,7 @@ @@ -542,6 +543,11 @@ hflex="15" sort="czech(description)" label="${labels.RequirementItemDescription}" /> + + + +