diff --git a/src/main/java/info/bukova/isspst/BigDecimalUtils.java b/src/main/java/info/bukova/isspst/BigDecimalUtils.java index e7c40aa1..c16f8804 100644 --- a/src/main/java/info/bukova/isspst/BigDecimalUtils.java +++ b/src/main/java/info/bukova/isspst/BigDecimalUtils.java @@ -2,8 +2,13 @@ package info.bukova.isspst; import java.math.BigDecimal; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class BigDecimalUtils { + private final static Logger log = LoggerFactory.getLogger(BigDecimalUtils.class.getName()); + public static boolean isEqualByDecimalForFilter(BigDecimal value, BigDecimal search) { if (search == null) @@ -11,14 +16,18 @@ public class BigDecimalUtils return true; } - else if (value != null) + if (value == null) { - String valueS = value.toPlainString(); - String searchS = search.toPlainString(); - return valueS.startsWith(searchS); - // return (value.compareTo(search) == 0); + value = BigDecimal.ZERO; } - return false; + String valueS = value.toPlainString(); + String searchS = search.toPlainString(); + boolean result = (valueS.compareTo(searchS) == 0); + + String s = "search='" + searchS + "', value='" + valueS + "', equal=" + (result ? "true" : "false"); + log.info(s); + + return result; } } diff --git a/src/main/java/info/bukova/isspst/data/Order.java b/src/main/java/info/bukova/isspst/data/Order.java index 60bc8614..d8862f46 100644 --- a/src/main/java/info/bukova/isspst/data/Order.java +++ b/src/main/java/info/bukova/isspst/data/Order.java @@ -19,232 +19,277 @@ import org.hibernate.annotations.LazyCollectionOption; @Entity @Table(name = "ORDERS") -public class Order extends BaseData { +public class Order extends BaseData +{ @Column(name = "NUMSER") private String numser; - + @Column(name = "ORDER_DATE") private Date orderDate; - + @Embedded @AttributeOverrides({ @AttributeOverride(name = "id", column = @Column(name = "SUPPLIER_ID")), - @AttributeOverride(name = "city", column = @Column(name = "SUPPLIER_CITY")), - @AttributeOverride(name = "company", column = @Column(name = "SUPPLIER_COMPANY")), - @AttributeOverride(name = "contactName", column = @Column(name = "SUPPLIER_CONTACT_NAME")), - @AttributeOverride(name = "department", column = @Column(name = "SUPPLIER_DEPARTMENT")), - @AttributeOverride(name = "description", column = @Column(name = "SUPPLIER_DESCRIPTION")), - @AttributeOverride(name = "dic", column = @Column(name = "SUPPLIER_DIC")), - @AttributeOverride(name = "email", column = @Column(name = "SUPPLIER_EMAIL")), - @AttributeOverride(name = "houseNumber", column = @Column(name = "SUPPLIER_HOUSENUMBER")), - @AttributeOverride(name = "ic", column = @Column(name = "SUPPLIER_IC")), - @AttributeOverride(name = "phone", column = @Column(name = "SUPPLIER_PHONE")), - @AttributeOverride(name = "state", column = @Column(name = "SUPPLIER_STATE")), - @AttributeOverride(name = "street", column = @Column(name = "SUPPLIER_STREET")), - @AttributeOverride(name = "web", column = @Column(name = "SUPPLIER_WEB")), - @AttributeOverride(name = "zipCode", column = @Column(name = "SUPPLIER_ZIP_CODE")) - }) + @AttributeOverride(name = "city", column = @Column(name = "SUPPLIER_CITY")), + @AttributeOverride(name = "company", column = @Column(name = "SUPPLIER_COMPANY")), + @AttributeOverride(name = "contactName", column = @Column(name = "SUPPLIER_CONTACT_NAME")), + @AttributeOverride(name = "department", column = @Column(name = "SUPPLIER_DEPARTMENT")), + @AttributeOverride(name = "description", column = @Column(name = "SUPPLIER_DESCRIPTION")), + @AttributeOverride(name = "dic", column = @Column(name = "SUPPLIER_DIC")), + @AttributeOverride(name = "email", column = @Column(name = "SUPPLIER_EMAIL")), + @AttributeOverride(name = "houseNumber", column = @Column(name = "SUPPLIER_HOUSENUMBER")), + @AttributeOverride(name = "ic", column = @Column(name = "SUPPLIER_IC")), + @AttributeOverride(name = "phone", column = @Column(name = "SUPPLIER_PHONE")), + @AttributeOverride(name = "state", column = @Column(name = "SUPPLIER_STATE")), + @AttributeOverride(name = "street", column = @Column(name = "SUPPLIER_STREET")), + @AttributeOverride(name = "web", column = @Column(name = "SUPPLIER_WEB")), + @AttributeOverride(name = "zipCode", column = @Column(name = "SUPPLIER_ZIP_CODE")) }) private AddressEmb suplier; - + @Embedded @AttributeOverrides({ @AttributeOverride(name = "id", column = @Column(name = "INVOICE_ID")), - @AttributeOverride(name = "city", column = @Column(name = "INVOICE_CITY")), - @AttributeOverride(name = "company", column = @Column(name = "INVOICE_COMPANY")), - @AttributeOverride(name = "contactName", column = @Column(name = "INVOICE_CONTACT_NAME")), - @AttributeOverride(name = "department", column = @Column(name = "INVOICE_DEPARTMENT")), - @AttributeOverride(name = "description", column = @Column(name = "INVOICE_DESCRIPTION")), - @AttributeOverride(name = "dic", column = @Column(name = "INVOICE_DIC")), - @AttributeOverride(name = "email", column = @Column(name = "INVOICE_EMAIL")), - @AttributeOverride(name = "houseNumber", column = @Column(name = "INVOICE_HOUSENUMBER")), - @AttributeOverride(name = "ic", column = @Column(name = "INVOICE_IC")), - @AttributeOverride(name = "phone", column = @Column(name = "INVOICE_PHONE")), - @AttributeOverride(name = "state", column = @Column(name = "INVOICE_STATE")), - @AttributeOverride(name = "street", column = @Column(name = "INVOICE_STREET")), - @AttributeOverride(name = "web", column = @Column(name = "INVOICE_WEB")), - @AttributeOverride(name = "zipCode", column = @Column(name = "INVOICE_ZIP_CODE")) - }) + @AttributeOverride(name = "city", column = @Column(name = "INVOICE_CITY")), + @AttributeOverride(name = "company", column = @Column(name = "INVOICE_COMPANY")), + @AttributeOverride(name = "contactName", column = @Column(name = "INVOICE_CONTACT_NAME")), + @AttributeOverride(name = "department", column = @Column(name = "INVOICE_DEPARTMENT")), + @AttributeOverride(name = "description", column = @Column(name = "INVOICE_DESCRIPTION")), + @AttributeOverride(name = "dic", column = @Column(name = "INVOICE_DIC")), + @AttributeOverride(name = "email", column = @Column(name = "INVOICE_EMAIL")), + @AttributeOverride(name = "houseNumber", column = @Column(name = "INVOICE_HOUSENUMBER")), + @AttributeOverride(name = "ic", column = @Column(name = "INVOICE_IC")), + @AttributeOverride(name = "phone", column = @Column(name = "INVOICE_PHONE")), + @AttributeOverride(name = "state", column = @Column(name = "INVOICE_STATE")), + @AttributeOverride(name = "street", column = @Column(name = "INVOICE_STREET")), + @AttributeOverride(name = "web", column = @Column(name = "INVOICE_WEB")), + @AttributeOverride(name = "zipCode", column = @Column(name = "INVOICE_ZIP_CODE")) }) private AddressEmb address; - + @Embedded @AttributeOverrides({ @AttributeOverride(name = "id", column = @Column(name = "DELIVERY_ID")), - @AttributeOverride(name = "city", column = @Column(name = "DELIVERY_CITY")), - @AttributeOverride(name = "company", column = @Column(name = "DELIVERY_COMPANY")), - @AttributeOverride(name = "contactName", column = @Column(name = "DELIVERY_CONTACT_NAME")), - @AttributeOverride(name = "department", column = @Column(name = "DELIVERY_DEPARTMENT")), - @AttributeOverride(name = "description", column = @Column(name = "DELIVERY_DESCRIPTION")), - @AttributeOverride(name = "dic", column = @Column(name = "DELIVERY_DIC")), - @AttributeOverride(name = "email", column = @Column(name = "DELIVERY_EMAIL")), - @AttributeOverride(name = "houseNumber", column = @Column(name = "DELIVERY_HOUSENUMBER")), - @AttributeOverride(name = "ic", column = @Column(name = "DELIVERY_IC")), - @AttributeOverride(name = "phone", column = @Column(name = "DELIVERY_PHONE")), - @AttributeOverride(name = "state", column = @Column(name = "DELIVERY_STATE")), - @AttributeOverride(name = "street", column = @Column(name = "DELIVERY_STREET")), - @AttributeOverride(name = "web", column = @Column(name = "DELIVERY_WEB")), - @AttributeOverride(name = "zipCode", column = @Column(name = "DELIVERY_ZIP_CODE")) - }) + @AttributeOverride(name = "city", column = @Column(name = "DELIVERY_CITY")), + @AttributeOverride(name = "company", column = @Column(name = "DELIVERY_COMPANY")), + @AttributeOverride(name = "contactName", column = @Column(name = "DELIVERY_CONTACT_NAME")), + @AttributeOverride(name = "department", column = @Column(name = "DELIVERY_DEPARTMENT")), + @AttributeOverride(name = "description", column = @Column(name = "DELIVERY_DESCRIPTION")), + @AttributeOverride(name = "dic", column = @Column(name = "DELIVERY_DIC")), + @AttributeOverride(name = "email", column = @Column(name = "DELIVERY_EMAIL")), + @AttributeOverride(name = "houseNumber", column = @Column(name = "DELIVERY_HOUSENUMBER")), + @AttributeOverride(name = "ic", column = @Column(name = "DELIVERY_IC")), + @AttributeOverride(name = "phone", column = @Column(name = "DELIVERY_PHONE")), + @AttributeOverride(name = "state", column = @Column(name = "DELIVERY_STATE")), + @AttributeOverride(name = "street", column = @Column(name = "DELIVERY_STREET")), + @AttributeOverride(name = "web", column = @Column(name = "DELIVERY_WEB")), + @AttributeOverride(name = "zipCode", column = @Column(name = "DELIVERY_ZIP_CODE")) }) private AddressEmb deliveryAddress; - + @Column(name = "DELIVERY_DATE") private Date deliveryDate; - + @Column(name = "DELIVERED_DATE") private Date deliveredDate; - + @Column(name = "DELIVERY_TYPE") private String deliveryType; - + @Column(name = "DESCRIPTION") private String description; - + @OneToMany(cascade = CascadeType.ALL, mappedBy = "order", orphanRemoval = true) @LazyCollection(LazyCollectionOption.TRUE) private List items; - - @Column(name = "TOTAL", precision=15, scale=4) + + @Column(name = "TOTAL", precision = 15, scale = 4) private BigDecimal total; - + @Column(name = "ORDERED") private boolean ordered; - + @Column(name = "DELIVERED") private boolean delivered; - + @Column(name = "INVOICED") private boolean invoiced; - + @Column(name = "INVOICE_NUMBER") private String invoiceNumber; - - public Order() { - items = new ArrayList(); + + @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() { + + public String getNumser() + { return numser; } - public void setNumser(String numser) { + public void setNumser(String numser) + { this.numser = numser; } - public AddressEmb getSuplier() { + public AddressEmb getSuplier() + { return suplier; } - public void setSuplier(AddressEmb suplier) { + public void setSuplier(AddressEmb suplier) + { this.suplier = suplier; } - public AddressEmb getAddress() { + public AddressEmb getAddress() + { return address; } - public void setAddress(AddressEmb address) { + public void setAddress(AddressEmb address) + { this.address = address; } - public Date getDeliveryDate() { + public Date getDeliveryDate() + { return deliveryDate; } - public void setDeliveryDate(Date deliveryDate) { + public void setDeliveryDate(Date deliveryDate) + { this.deliveryDate = deliveryDate; } - public String getDeliveryType() { + public String getDeliveryType() + { return deliveryType; } - public void setDeliveryType(String deliveryType) { + public void setDeliveryType(String deliveryType) + { this.deliveryType = deliveryType; } - public String getDescription() { + public String getDescription() + { return description; } - public void setDescription(String description) { + public void setDescription(String description) + { this.description = description; } - public AddressEmb getDeliveryAddress() { + public AddressEmb getDeliveryAddress() + { return deliveryAddress; } - public void setDeliveryAddress(AddressEmb deliveryAddress) { + public void setDeliveryAddress(AddressEmb deliveryAddress) + { this.deliveryAddress = deliveryAddress; } - public Date getDeliveredDate() { + public Date getDeliveredDate() + { return deliveredDate; } - public void setDeliveredDate(Date deliveredDate) { + public void setDeliveredDate(Date deliveredDate) + { this.deliveredDate = deliveredDate; } - public List getItems() { + public List getItems() + { return items; } - - public void addItem(OrderItem item) { + + public void addItem(OrderItem item) + { item.setOrder(this); items.add(item); } - public void setItems(List items) { + public void setItems(List items) + { this.items = items; } - public boolean isDelivered() { + public boolean isDelivered() + { return delivered; } - public void setDelivered(boolean delivered) { + public void setDelivered(boolean delivered) + { this.delivered = delivered; } - public boolean isInvoiced() { + public boolean isInvoiced() + { return invoiced; } - public void setInvoiced(boolean invoiced) { + public void setInvoiced(boolean invoiced) + { this.invoiced = invoiced; } - public String getInvoiceNumber() { + public String getInvoiceNumber() + { return invoiceNumber; } - public void setInvoiceNumber(String invoiceNumber) { + public void setInvoiceNumber(String invoiceNumber) + { this.invoiceNumber = invoiceNumber; } - public boolean isOrdered() { + public boolean isOrdered() + { return ordered; } - public void setOrdered(boolean ordered) { + public void setOrdered(boolean ordered) + { this.ordered = ordered; } - public Date getOrderDate() { + public Date getOrderDate() + { return orderDate; } - public void setOrderDate(Date orderDate) { + public void setOrderDate(Date orderDate) + { this.orderDate = orderDate; } - public BigDecimal getTotal() { + public BigDecimal getTotal() + { return total; } - public void setTotal(BigDecimal total) { + public void setTotal(BigDecimal total) + { this.total = total; } + public BigDecimal getInvoiceTotal() + { + return invoiceTotal; + } + + public void setInvoiceTotal(BigDecimal invoiceTotal) + { + this.invoiceTotal = invoiceTotal; + } + } diff --git a/src/main/java/info/bukova/isspst/filters/JoinedItemFilter.java b/src/main/java/info/bukova/isspst/filters/JoinedItemFilter.java index 8955ad8a..f3a2ca75 100644 --- a/src/main/java/info/bukova/isspst/filters/JoinedItemFilter.java +++ b/src/main/java/info/bukova/isspst/filters/JoinedItemFilter.java @@ -1,6 +1,5 @@ package info.bukova.isspst.filters; -import info.bukova.isspst.BigDecimalUtils; import info.bukova.isspst.StringUtils; import info.bukova.isspst.data.JoinedItem; import info.bukova.isspst.data.MUnitEmb; @@ -46,10 +45,13 @@ public class JoinedItemFilter implements Filter boolean foundCode = StringUtils.isEqualForFilter(item.getCode(), condition.getCode()); boolean foundName = StringUtils.isEqualForFilter(item.getName(), condition.getName()); boolean foundTextItem = StringUtils.isEqualForFilter(item.getTextItem(), condition.getTextItem()); - boolean foundQuantity = BigDecimalUtils.isEqualByDecimalForFilter(item.getQuantity(), condition.getQuantity()); - boolean foundUnitPrice = BigDecimalUtils.isEqualByDecimalForFilter(item.getUnitPrice(), condition.getUnitPrice()); + boolean foundQuantity = true;// BigDecimalUtils.isEqualByDecimalForFilter(item.getQuantity(), + // condition.getQuantity()); + boolean foundUnitPrice = true; // BigDecimalUtils.isEqualByDecimalForFilter(item.getUnitPrice(), + // condition.getUnitPrice()); boolean foundMUnit = MUnitEmb.isEqualMUnitEmbForFilter(item.getMunit(), condition.getMunit()); - boolean foundTotal = BigDecimalUtils.isEqualByDecimalForFilter(item.getTotal(), condition.getTotal()); + boolean foundTotal = true;// BigDecimalUtils.isEqualByDecimalForFilter(item.getTotal(), + // condition.getTotal()); boolean foundWorkgroup = Workgroup.isEqualByWorkgroupForFilter(item.getWorkgroup(), condition.getWorkgroup()); boolean foundCenter = Workgroup.isEqualByWorkgroupForFilter(item.getCentre(), condition.getCentre()); boolean foundOwner = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy()); diff --git a/src/main/java/info/bukova/isspst/filters/OrderFilter.java b/src/main/java/info/bukova/isspst/filters/OrderFilter.java index 77bbdb72..376cea1e 100644 --- a/src/main/java/info/bukova/isspst/filters/OrderFilter.java +++ b/src/main/java/info/bukova/isspst/filters/OrderFilter.java @@ -1,6 +1,5 @@ package info.bukova.isspst.filters; -import info.bukova.isspst.BigDecimalUtils; import info.bukova.isspst.DateTimeUtils; import info.bukova.isspst.StringUtils; import info.bukova.isspst.data.AddressEmb; @@ -45,10 +44,13 @@ public class OrderFilter implements Filter { boolean foundNumSer = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser()); boolean foundOrderDate = DateTimeUtils.isEqualByDateForFilter(item.getOrderDate(), condition.getOrderDate()); - boolean foundTotal = BigDecimalUtils.isEqualByDecimalForFilter(item.getTotal(), condition.getTotal()); + boolean foundTotal = true;// BigDecimalUtils.isEqualByDecimalForFilter(item.getTotal(), + // 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()); @@ -60,6 +62,7 @@ public class OrderFilter implements Filter && foundDeliveryDate && foundDeliveredDate && foundInvoiceNumber + && foundInvoiceTotal && foundSupplierAddr && foundDeliveryAddr && foundInvoiceAddr diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index 8c126320..bdcb007c 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -326,6 +326,7 @@ OrderFormDescription=Popis OrderFormOrdered=Objednáno OrderFormDeliveredDate=Dodáno dne OrderFormInvoiceNumber=Číslo faktury +OrderFormInvoiceTotal=Částka faktury HandleComboKeyFilter=#del HandleComboKey=$#del diff --git a/src/main/webapp/main/orders/created/grid.zul b/src/main/webapp/main/orders/created/grid.zul index fa191a72..c23dde74 100644 --- a/src/main/webapp/main/orders/created/grid.zul +++ b/src/main/webapp/main/orders/created/grid.zul @@ -51,6 +51,11 @@ hflex="10" sort="auto(invoiceNumber)" label="${labels.OrderFormInvoiceNumber}" /> + +
@@ -251,6 +257,7 @@ + diff --git a/src/main/webapp/main/orders/created/orderForm.zul b/src/main/webapp/main/orders/created/orderForm.zul index e9eb0e5c..7adb2f24 100644 --- a/src/main/webapp/main/orders/created/orderForm.zul +++ b/src/main/webapp/main/orders/created/orderForm.zul @@ -103,6 +103,15 @@ readonly="@load(empty fx.created)" /> + + ${labels.OrderFormInvoiceTotal} : + + + + ${labels.OrderFormDescription} :