diff --git a/src/main/java/info/bukova/isspst/filters/InvoicingFilter.java b/src/main/java/info/bukova/isspst/filters/InvoicingFilter.java new file mode 100644 index 00000000..166f44f5 --- /dev/null +++ b/src/main/java/info/bukova/isspst/filters/InvoicingFilter.java @@ -0,0 +1,74 @@ +package info.bukova.isspst.filters; + +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.Workgroup; + +import org.hamcrest.Description; +import org.hamcrest.Factory; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; + +public class InvoicingFilter implements Filter +{ + + private Invoicing condition; + + public InvoicingFilter(Invoicing cond) + { + this.condition = cond; + } + + private static class InvoicingMatcher extends TypeSafeMatcher + { + + private Invoicing condition; + + public InvoicingMatcher(Invoicing cond) + { + this.condition = cond; + + if (condition.getRequirement() == null) { + condition.setRequirement(new Requirement()); + } + } + + @Override + public void describeTo(Description desc) + { + desc.appendText("Invoicing matches"); + } + + @Override + public boolean matchesSafely(Invoicing item) + { + boolean foundNumser = StringUtils.isEqualForFilter(item.getRequirement().getNumser(), condition.getRequirement().getNumser()); + 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 foundDescription = StringUtils.isEqualForFilter(item.getRequirement().getDescription(), condition.getRequirement().getDescription()); + return (foundNumser && foundReqDate && foundCenter && foundDescription && foundWorkgroup); + } + + @Factory + public static Matcher matchBuilding(Invoicing building) + { + return new InvoicingMatcher(building); + } + } + + @Override + public InvoicingMatcher matcher() + { + return new InvoicingMatcher(condition); + } + + @Override + public String queryString() + { + return ""; + } + +} diff --git a/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingForm.java b/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingForm.java index 09038f0b..978617d8 100644 --- a/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingForm.java +++ b/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingForm.java @@ -46,6 +46,7 @@ public class InvoicingForm extends FormViewModel { public void removeItem(@BindingParam("item") InvoicingItem item) { getDataBean().getItems().remove(item); selectItem(null); + calculate(); } @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 6a5c97e8..1c38b78a 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 @@ -1,7 +1,12 @@ package info.bukova.isspst.ui.main.invoicing; +import java.util.List; + import info.bukova.isspst.data.Invoicing; +import info.bukova.isspst.data.Workgroup; +import info.bukova.isspst.filters.InvoicingFilter; import info.bukova.isspst.services.invoicing.InvoicingService; +import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.ui.ListViewModel; import org.zkoss.bind.annotation.Init; @@ -11,13 +16,15 @@ public class InvoicingList extends ListViewModel { @WireVariable private InvoicingService invoicingService; + @WireVariable + private WorkgroupService workgroupService; @Init(superclass = true) public void initInvoicing() { service = invoicingService; dataClass = Invoicing.class; formZul = "invoicingForm.zul"; - //dataFilter = new BuildingFilter(getFilterTemplate()); + dataFilter = new InvoicingFilter(getFilterTemplate()); } @Override @@ -30,4 +37,12 @@ public class InvoicingList extends ListViewModel { return false; } + public List getCentres() { + return workgroupService.getCentres(); + } + + public List getWorkgroups() { + return workgroupService.getWorkgroups(); + } + } diff --git a/src/main/webapp/main/invoicing/invoicingForm.zul b/src/main/webapp/main/invoicing/invoicingForm.zul index 5f5d546a..9e72aa3e 100644 --- a/src/main/webapp/main/invoicing/invoicingForm.zul +++ b/src/main/webapp/main/invoicing/invoicingForm.zul @@ -113,7 +113,8 @@ + readonly="true" + style="@load(vm.dataBean.totalInvoiced gt vm.dataBean.requirement.sumTotal ? ' color: red;' : '' )"/> diff --git a/src/main/webapp/main/invoicing/invoicingGrid.zul b/src/main/webapp/main/invoicing/invoicingGrid.zul index bfa6f5f7..7daee89e 100644 --- a/src/main/webapp/main/invoicing/invoicingGrid.zul +++ b/src/main/webapp/main/invoicing/invoicingGrid.zul @@ -20,7 +20,16 @@ label="${labels.InvoicingRequirementNumber}" width="130px" /> + + + - + + + + + + + +