From f1ca2d11c8843a13b0ce3944bed135e1c7834e45 Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Fri, 24 Oct 2014 09:19:15 +0200 Subject: [PATCH] =?UTF-8?q?Pol=C3=AD=C4=8Dka=20s=20=C4=8D=C3=ADslem=20fakt?= =?UTF-8?q?ury=20a=20fakturovanou=20=C4=8D=C3=A1stkou=20odstran=C4=9Bna=20?= =?UTF-8?q?z=20objedn=C3=A1vek.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #163 --- .../java/info/bukova/isspst/data/Order.java | 27 ----- .../info/bukova/isspst/data/OrderItem.java | 109 ++++++++++-------- .../bukova/isspst/filters/OrderFilter.java | 5 - .../services/approved/OrderService.java | 2 - .../services/approved/OrderServiceImpl.java | 33 +----- .../info/bukova/isspst/ui/ListViewModel.java | 20 ---- .../ui/main/orders/created/OrderForm.java | 30 ----- .../renderers/OrderCreatedItemRenderer.java | 11 +- src/main/webapp/main/orders/created/grid.zul | 32 ----- .../webapp/main/orders/created/orderForm.zul | 35 ------ 10 files changed, 67 insertions(+), 237 deletions(-) diff --git a/src/main/java/info/bukova/isspst/data/Order.java b/src/main/java/info/bukova/isspst/data/Order.java index 9bef5ca0..c3879f25 100644 --- a/src/main/java/info/bukova/isspst/data/Order.java +++ b/src/main/java/info/bukova/isspst/data/Order.java @@ -113,17 +113,10 @@ public class Order extends BaseData implements Cloneable @Column(name = "INVOICED") private boolean invoiced; - @Column(name = "INVOICE_NUMBER") - private String invoiceNumber; - - @Column(name = "INVOICE_TOTAL", precision = 15, scale = 4) - private BigDecimal invoiceTotal; - public Order() { this.items = new ArrayList(); this.total = BigDecimal.ZERO; - this.invoiceTotal = BigDecimal.ZERO; } public String getNumser() @@ -242,16 +235,6 @@ public class Order extends BaseData implements Cloneable this.invoiced = invoiced; } - public String getInvoiceNumber() - { - return invoiceNumber; - } - - public void setInvoiceNumber(String invoiceNumber) - { - this.invoiceNumber = invoiceNumber; - } - public boolean isOrdered() { return ordered; @@ -282,16 +265,6 @@ public class Order extends BaseData implements Cloneable this.total = total; } - public BigDecimal getInvoiceTotal() - { - return invoiceTotal; - } - - public void setInvoiceTotal(BigDecimal invoiceTotal) - { - this.invoiceTotal = invoiceTotal; - } - public boolean isIcludedRequirementItemFromAnotherOrder() { for (OrderItem oItem : this.getItems()) diff --git a/src/main/java/info/bukova/isspst/data/OrderItem.java b/src/main/java/info/bukova/isspst/data/OrderItem.java index 98baf1b9..16f26a24 100644 --- a/src/main/java/info/bukova/isspst/data/OrderItem.java +++ b/src/main/java/info/bukova/isspst/data/OrderItem.java @@ -14,53 +14,53 @@ import javax.persistence.Table; @Entity @Table(name = "ORDER_ITEM") -public class OrderItem { - +public class OrderItem +{ + @Id - @Column(name="ID") - @GeneratedValue + @Column(name = "ID") + @GeneratedValue private int id; - + @Column(name = "CODE") private String code; - + @Column(name = "NAME") private String name; @Column(name = "TEXTITEM") private String textItem; - @Column(name = "QUANTITY", precision=15, scale=4) + @Column(name = "QUANTITY", precision = 15, scale = 4) private BigDecimal quantity; - + @Embedded private MUnitEmb munit; - @Column(name = "UNITPRICE", precision=15, scale=4) + @Column(name = "UNITPRICE", precision = 15, scale = 4) private BigDecimal unitPrice; - @Column(name = "TOTAL", precision=15, scale=4) + @Column(name = "TOTAL", precision = 15, scale = 4) private BigDecimal total; @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; - + @ManyToOne @JoinColumn(name = "ORDER_ID") private Order order; - - public OrderItem() { + + public OrderItem() + { super(); } - public OrderItem(RequirementItem reqItem) { + public OrderItem(RequirementItem reqItem) + { super(); this.reqItem = reqItem; this.code = reqItem.getCode(); @@ -71,104 +71,115 @@ public class OrderItem { this.munit = reqItem.getMunit(); this.total = reqItem.getTotal(); this.description = reqItem.getDescription(); - this.totalInvoice = BigDecimal.ZERO; } - public int getId() { + public int getId() + { return id; } - public void setId(int id) { + public void setId(int id) + { this.id = id; } - public String getCode() { + public String getCode() + { return code; } - public void setCode(String code) { + public void setCode(String code) + { this.code = code; } - public String getName() { + public String getName() + { return name; } - public void setName(String name) { + public void setName(String name) + { this.name = name; } - public String getTextItem() { + public String getTextItem() + { return textItem; } - public void setTextItem(String textItem) { + public void setTextItem(String textItem) + { this.textItem = textItem; } - public BigDecimal getQuantity() { + public BigDecimal getQuantity() + { return quantity; } - public void setQuantity(BigDecimal quantity) { + public void setQuantity(BigDecimal quantity) + { this.quantity = quantity; } - public MUnitEmb getMunit() { + public MUnitEmb getMunit() + { return munit; } - public void setMunit(MUnitEmb munit) { + public void setMunit(MUnitEmb munit) + { this.munit = munit; } - public BigDecimal getUnitPrice() { + public BigDecimal getUnitPrice() + { return unitPrice; } - public void setUnitPrice(BigDecimal unitPrice) { + public void setUnitPrice(BigDecimal unitPrice) + { this.unitPrice = unitPrice; } - public BigDecimal getTotal() { + public BigDecimal getTotal() + { return total; } - public void setTotal(BigDecimal total) { + public void setTotal(BigDecimal total) + { this.total = total; } - public String getDescription() { + public String getDescription() + { return description; } - public void setDescription(String description) { - this.description = description; - } - - public BigDecimal getTotalInvoice() + public void setDescription(String description) { - return totalInvoice; + this.description = description; } - public void setTotalInvoice(BigDecimal totalInvoice) + public RequirementItem getReqItem() { - this.totalInvoice = totalInvoice; - } - - public RequirementItem getReqItem() { return reqItem; } - public void setReqItem(RequirementItem reqItem) { + public void setReqItem(RequirementItem reqItem) + { this.reqItem = reqItem; } - public Order getOrder() { + public Order getOrder() + { return order; } - public void setOrder(Order order) { + public void setOrder(Order order) + { this.order = order; } diff --git a/src/main/java/info/bukova/isspst/filters/OrderFilter.java b/src/main/java/info/bukova/isspst/filters/OrderFilter.java index a23b62f0..6190314e 100644 --- a/src/main/java/info/bukova/isspst/filters/OrderFilter.java +++ b/src/main/java/info/bukova/isspst/filters/OrderFilter.java @@ -49,9 +49,6 @@ public class OrderFilter implements Filter // condition.getTotal()); boolean foundDeliveryDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveryDate(), condition.getDeliveryDate()); boolean foundDeliveredDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveredDate(), condition.getDeliveredDate()); - boolean foundInvoiceNumber = StringUtils.isEqualForFilter(item.getInvoiceNumber(), condition.getInvoiceNumber()); - boolean foundInvoiceTotal = true;// BigDecimalUtils.isEqualByDecimalForFilter(item.getInvoiceTotal(), - // condition.getInvoiceTotal()); boolean foundSupplierAddr = AddressEmb.isEqualByAddressEmbForFilter(item.getSuplier(), condition.getSuplier()); boolean foundDeliveryAddr = AddressEmb.isEqualByAddressEmbForFilter(item.getDeliveryAddress(), condition.getDeliveryAddress()); boolean foundInvoiceAddr = AddressEmb.isEqualByAddressEmbForFilter(item.getAddress(), condition.getAddress()); @@ -63,8 +60,6 @@ public class OrderFilter implements Filter && foundTotal && foundDeliveryDate && foundDeliveredDate - && foundInvoiceNumber - && foundInvoiceTotal && foundSupplierAddr && foundDeliveryAddr && foundInvoiceAddr 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 483fbf64..0966403c 100644 --- a/src/main/java/info/bukova/isspst/services/approved/OrderService.java +++ b/src/main/java/info/bukova/isspst/services/approved/OrderService.java @@ -22,7 +22,5 @@ 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 bb3113aa..7d4cf2b6 100644 --- a/src/main/java/info/bukova/isspst/services/approved/OrderServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/approved/OrderServiceImpl.java @@ -52,10 +52,13 @@ public class OrderServiceImpl extends AbstractOwnedService implements @Override @Transactional - public BigDecimal totalOrderedForWorkgroup(Workgroup workgroup) { - Query q = dao.getQuery("select sum(oi.totalInvoice) from OrderItem oi join oi.reqItem ri join ri.requirement rq join rq.workgroup w where (ri.orderNum is not null or ri.orderNum = '') and w = :workgroup "); + public BigDecimal totalOrderedForWorkgroup(Workgroup workgroup) + { + Query q = dao.getQuery("select sum(oi.total) " + + "from OrderItem oi join oi.reqItem ri join ri.requirement rq join rq.workgroup w " + + "where (ri.orderNum is not null or ri.orderNum = '') and w = :workgroup "); q.setParameter("workgroup", workgroup); - return (BigDecimal)q.uniqueResult(); + return (BigDecimal) q.uniqueResult(); } @Override @@ -177,30 +180,6 @@ 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/ListViewModel.java b/src/main/java/info/bukova/isspst/ui/ListViewModel.java index 1d517e79..37cda51e 100644 --- a/src/main/java/info/bukova/isspst/ui/ListViewModel.java +++ b/src/main/java/info/bukova/isspst/ui/ListViewModel.java @@ -335,26 +335,6 @@ public class ListViewModel extends DocumentViewModel } } - // private void loadFromDb() { - // Thread fillThread = new Thread(new Runnable() { - // - // @Override - // public void run() { - // tmpList = service.getAll(); - // - // try { - // Thread.sleep(200); - // } catch (InterruptedException e) { - // e.printStackTrace(); - // } - // - // fullFill = true; - // } - // }); - // - // fillThread.start(); - // } - @Command public void onPrint() { Map params = new HashMap(); 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 9935cc17..7177ed89 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,36 +278,6 @@ 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/java/info/bukova/isspst/ui/renderers/OrderCreatedItemRenderer.java b/src/main/java/info/bukova/isspst/ui/renderers/OrderCreatedItemRenderer.java index 60d73c50..24b6324e 100644 --- a/src/main/java/info/bukova/isspst/ui/renderers/OrderCreatedItemRenderer.java +++ b/src/main/java/info/bukova/isspst/ui/renderers/OrderCreatedItemRenderer.java @@ -2,8 +2,6 @@ package info.bukova.isspst.ui.renderers; import info.bukova.isspst.data.Order; -import java.math.BigDecimal; - import org.zkoss.zul.Listbox; import org.zkoss.zul.Listitem; @@ -17,19 +15,12 @@ public class OrderCreatedItemRenderer extends GenericListitemRenderer boolean objednano = order.isOrdered(); - BigDecimal invoiceTotal = order.getInvoiceTotal(); - boolean zakoupeno = ((invoiceTotal != null) && (invoiceTotal.compareTo(BigDecimal.ZERO) != 0)); - - boolean doruceno = (zakoupeno && (order.getDeliveredDate() != null)); + boolean doruceno = (order.getDeliveredDate() != null); if (doruceno) { li.setSclass("order-select-delivered"); } - else if (zakoupeno) - { - li.setSclass("order-select-invoiced"); - } else if (objednano) { li.setSclass("order-select-ordered"); diff --git a/src/main/webapp/main/orders/created/grid.zul b/src/main/webapp/main/orders/created/grid.zul index 0ba90053..ca342978 100644 --- a/src/main/webapp/main/orders/created/grid.zul +++ b/src/main/webapp/main/orders/created/grid.zul @@ -52,15 +52,6 @@ hflex="10" sort="auto(deliveredDate))" label="${labels.OrderFormDeliveredDate}" /> - - - -
-
- -
-
- -
-
-
-
@@ -275,8 +251,6 @@ - - @@ -327,11 +301,6 @@ 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 547c13a1..e8c1c874 100644 --- a/src/main/webapp/main/orders/created/orderForm.zul +++ b/src/main/webapp/main/orders/created/orderForm.zul @@ -104,27 +104,6 @@ format="${labels.DateFormat}" /> - - ${labels.OrderFormInvoiceNumber} : - - - - - - ${labels.OrderFormInvoiceTotal} : - - - - ${labels.OrderFormDescription} : @@ -543,11 +522,6 @@ hflex="15" sort="czech(description)" label="${labels.RequirementItemDescription}" /> - - - -