Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev1'
Browse files Browse the repository at this point in the history
  • Loading branch information
jmurighub committed Nov 1, 2021
2 parents d168efc + a103eea commit f9041ab
Show file tree
Hide file tree
Showing 8 changed files with 555 additions and 92 deletions.
4 changes: 3 additions & 1 deletion src/ch/xwr/seicentobilling/ui/desktop/ExpensePopup.java
Original file line number Diff line number Diff line change
Expand Up @@ -785,10 +785,12 @@ private void prepareProjectCombo(final Project bean) {
*/
private void chkExpFlagCostAccount_valueChange(final Property.ValueChangeEvent event) {
final Boolean val = (Boolean) event.getProperty().getValue();
if (! val.booleanValue()) {
if (val != null && ! val.booleanValue()) {
this.cmbCostAccountCompany.setRequired(true);
} else {
this.cmbCostAccountCompany.setRequired(false);
this.cmbCostAccountCompany.setNullSelectionAllowed(true);
this.cmbCostAccountCompany.setValue(null);
}


Expand Down
3 changes: 3 additions & 0 deletions src/ch/xwr/seicentobilling/ui/desktop/PeriodeDialogPopup.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ private Object[] getGridLine(final Expense expObj) {
final XdevCheckBox kst = new XdevCheckBox();
kst.setValue(expObj.getExpFlagCostAccount().booleanValue());
kst.setEnabled(false);
if (expObj.getExpFlagGeneric() == null) {
expObj.setExpFlagGeneric(LovState.ExpType.standard);
}
final XdevLabel type = new XdevLabel(expObj.getExpFlagGeneric().name());
final XdevLabel text = new XdevLabel(expObj.getExpText());

Expand Down
136 changes: 50 additions & 86 deletions src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
package ch.xwr.seicentobilling.ui.desktop;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;

import javax.persistence.PersistenceException;

import org.apache.poi.ss.formula.functions.T;

import com.google.common.collect.Lists;
import com.vaadin.data.Property;
import com.vaadin.data.validator.IntegerRangeValidator;
import com.vaadin.event.ItemClickEvent;
Expand Down Expand Up @@ -89,6 +83,7 @@
import ch.xwr.seicentobilling.entities.Vat;
import ch.xwr.seicentobilling.ui.desktop.crm.CustomerLookupPopup;
import ch.xwr.seicentobilling.ui.desktop.project.ProjectAllocationPopup;
import ch.xwr.seicentobilling.ui.desktop.project.ProjectEffortDefault;

public class ProjectTabView extends XdevView {
/** Logger initialized */
Expand Down Expand Up @@ -257,8 +252,6 @@ private void cmdNew_buttonClick(final Button.ClickEvent event) {

this.fieldGroup.setItemDataSource(bean);
setROFields();

calculateTargetHours();
}

/**
Expand Down Expand Up @@ -625,55 +618,6 @@ private void prepareCustomerCombo(final Customer bean) {
ProjectTabView.this.cmbCustomer.setValue(bean);
}

private void calculateTargetHours() {
if (this.dateProStartDate.isValid() && this.dateProEndDate.isValid()) {
final long days = getBusinessDaysDifference(this.dateProStartDate.getValue(), this.dateProEndDate.getValue());
int ihours = (int) (days * 8);

int ipercent= 0;
try {
ipercent = Integer.parseInt(this.txtProIntensityPercent.getValue());
} catch (final Exception e) {
//ignore
}

if (ipercent > 0) {
ihours = ihours * ipercent / 100;
}
if (ihours < 1) {
ihours = 1;
}

this.txtProHours.setValue("" + ihours);
//System.out.println("set hours: " + ihours);
}
}

private long getBusinessDaysDifference(final Date dFrom, final Date dTo) {

final LocalDate startDate = convertToLocalDateViaInstant(dFrom);
final LocalDate endDate = convertToLocalDateViaInstant(dTo);

final EnumSet<DayOfWeek> weekend = EnumSet.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY);
final List<LocalDate> list = Lists.newArrayList();

LocalDate start = startDate;
while (start.isBefore(endDate)) {
list.add(start);
start = start.plus(1, ChronoUnit.DAYS);
}

final long numberOfDays = list.stream().filter(d -> !weekend.contains(d.getDayOfWeek())).count();

return numberOfDays;
}

public LocalDate convertToLocalDateViaInstant(final Date dateToConvert) {
final java.util.Date utilDate = new java.util.Date(dateToConvert.getTime());
return utilDate.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
}

/**
* Event handler delegate method for the {@link XdevPopupDateField}
Expand All @@ -685,10 +629,6 @@ public LocalDate convertToLocalDateViaInstant(final Date dateToConvert) {
private void dateProEndDate_valueChange(final Property.ValueChangeEvent event) {
validateDateFromTo();

if (this.dateProEndDate.isModified()) {
calculateTargetHours();
}

}

private void validateDateFromTo() {
Expand All @@ -703,19 +643,6 @@ private void validateDateFromTo() {

}

/**
* Event handler delegate method for the {@link XdevTextField}
* {@link #txtProIntensityPercent}.
*
* @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
* @eventHandlerDelegate Do NOT delete, used by UI designer!
*/
private void txtProIntensityPercent_valueChange(final Property.ValueChangeEvent event) {
if (this.txtProIntensityPercent.isModified()) {
calculateTargetHours();
}
}

/**
* Event handler delegate method for the {@link XdevButton}
* {@link #cmdInfoAddress}.
Expand Down Expand Up @@ -896,6 +823,43 @@ private void dateProStartDate_valueChange(final Property.ValueChangeEvent event)
validateDateFromTo();
}

/**
* Event handler delegate method for the {@link XdevButton} {@link #cmdHours}.
*
* @see Button.ClickListener#buttonClick(Button.ClickEvent)
* @eventHandlerDelegate Do NOT delete, used by UI designer!
*/
private void cmdHours_buttonClick(final Button.ClickEvent event) {
final Project proDao = new Project();
proDao.setProStartDate(this.dateProStartDate.getValue());
proDao.setProEndDate(this.dateProEndDate.getValue());
proDao.setProIntensityPercent((Integer) this.txtProIntensityPercent.getConvertedValue());
proDao.setProHours((Integer) this.txtProHours.getConvertedValue());

UI.getCurrent().getSession().setAttribute("ProjectDao", proDao);

popupProjectEffortDefault();
}

private void popupProjectEffortDefault() {
final Window win = ProjectEffortDefault.getPopupWindow();

win.addCloseListener(new CloseListener() {
@Override
public void windowClose(final CloseEvent e) {
final Project proDao = (Project) UI.getCurrent().getSession().getAttribute("ProjectDao");

ProjectTabView.this.txtProHours.setValue(proDao.getProHours().toString());
ProjectTabView.this.dateProEndDate.setValue(proDao.getProEndDate());
ProjectTabView.this.txtProIntensityPercent.setValue(proDao.getProIntensityPercent().toString());

}

});
this.getUI().addWindow(win);

}

/*
* WARNING: Do NOT edit!<br>The content of this method is always regenerated by
* the UI designer.
Expand Down Expand Up @@ -932,7 +896,6 @@ private void initUI() {
this.dateProEndDate = new XdevPopupDateField();
this.lblProIntensityPercent = new XdevLabel();
this.txtProIntensityPercent = new XdevTextField();
this.label4 = new XdevLabel();
this.lblProHours = new XdevLabel();
this.txtProHours = new XdevTextField();
this.lblProHoursEffective = new XdevLabel();
Expand Down Expand Up @@ -981,6 +944,7 @@ private void initUI() {
this.horizontalLayout = new XdevHorizontalLayout();
this.cmdSave = new XdevButton();
this.cmdReset = new XdevButton();
this.cmdHours = new XdevButton();
this.fieldGroup = new XdevFieldGroup<>(Project.class);

this.horizontalSplitPanel.setStyleName("large");
Expand Down Expand Up @@ -1065,8 +1029,6 @@ private void initUI() {
this.dateProEndDate.setRequired(true);
this.lblProIntensityPercent
.setValue(StringResourceUtils.optLocalizeString("{$lblProIntensityPercent.value}", this));
this.label4.setIcon(FontAwesome.INFO_CIRCLE);
this.label4.setDescription("Stunden Soll wird vorgeschlagen, sobald Datum oder Intensität verändert wird.");
this.lblProHours.setValue("Stunden Soll");
this.txtProHours
.setConverter(ConverterBuilder.stringToDouble().minimumFractionDigits(2).maximumFractionDigits(2).build());
Expand Down Expand Up @@ -1168,6 +1130,8 @@ private void initUI() {
this.cmdSave.setCaption(StringResourceUtils.optLocalizeString("{$cmdSave.caption}", this));
this.cmdReset.setIcon(FontAwesome.UNDO);
this.cmdReset.setCaption(StringResourceUtils.optLocalizeString("{$cmdReset.caption}", this));
this.cmdHours.setIcon(FontAwesome.CLOCK_O);
this.cmdHours.setCaption("Stunden...");
this.fieldGroup.bind(this.cmbCustomer, Project_.customer.getName());
this.fieldGroup.bind(this.txtProName, Project_.proName.getName());
this.fieldGroup.bind(this.txtProExtReference, Project_.proExtReference.getName());
Expand Down Expand Up @@ -1271,9 +1235,6 @@ private void initUI() {
this.gridLayout.addComponent(this.lblProIntensityPercent, 0, 4);
this.txtProIntensityPercent.setSizeUndefined();
this.gridLayout.addComponent(this.txtProIntensityPercent, 1, 4);
this.label4.setWidth(100, Unit.PERCENTAGE);
this.label4.setHeight(-1, Unit.PIXELS);
this.gridLayout.addComponent(this.label4, 2, 4);
this.lblProHours.setSizeUndefined();
this.gridLayout.addComponent(this.lblProHours, 0, 5);
this.txtProHours.setSizeUndefined();
Expand Down Expand Up @@ -1383,11 +1344,11 @@ private void initUI() {
this.verticalLayoutRess.addComponent(verticalLayoutRess_spacer);
this.verticalLayoutRess.setExpandRatio(verticalLayoutRess_spacer, 1.0F);
this.gridLayoutRess.setColumns(1);
this.gridLayoutRess.setRows(2);
this.gridLayoutRess.setRows(1);
this.verticalLayoutRess.setSizeFull();
this.gridLayoutRess.addComponent(this.verticalLayoutRess, 0, 1);
this.gridLayoutRess.addComponent(this.verticalLayoutRess, 0, 0);
this.gridLayoutRess.setColumnExpandRatio(0, 10.0F);
this.gridLayoutRess.setRowExpandRatio(1, 10.0F);
this.gridLayoutRess.setRowExpandRatio(0, 10.0F);
this.tableOrder.setSizeFull();
this.verticalLayoutBill.addComponent(this.tableOrder);
this.verticalLayoutBill.setComponentAlignment(this.tableOrder, Alignment.MIDDLE_CENTER);
Expand Down Expand Up @@ -1421,6 +1382,9 @@ private void initUI() {
this.cmdReset.setSizeUndefined();
this.horizontalLayout.addComponent(this.cmdReset);
this.horizontalLayout.setComponentAlignment(this.cmdReset, Alignment.MIDDLE_CENTER);
this.cmdHours.setSizeUndefined();
this.horizontalLayout.addComponent(this.cmdHours);
this.horizontalLayout.setComponentAlignment(this.cmdHours, Alignment.MIDDLE_CENTER);
this.gridLayoutData.setColumns(1);
this.gridLayoutData.setRows(2);
this.tabSheet.setSizeFull();
Expand Down Expand Up @@ -1451,21 +1415,21 @@ private void initUI() {
this.btnSearch.addClickListener(event -> this.btnSearch_buttonClick(event));
this.dateProStartDate.addValueChangeListener(event -> this.dateProStartDate_valueChange(event));
this.dateProEndDate.addValueChangeListener(event -> this.dateProEndDate_valueChange(event));
this.txtProIntensityPercent.addValueChangeListener(event -> this.txtProIntensityPercent_valueChange(event));
this.cmdNewAddress.addClickListener(event -> this.cmdNewAddress_buttonClick(event));
this.cmdDeleteAddress.addClickListener(event -> this.cmdDeleteAddress_buttonClick(event));
this.cmdEditAddress.addClickListener(event -> this.cmdEditAddress_buttonClick(event));
this.cmdReloadAddress.addClickListener(event -> this.cmdReloadAddress_buttonClick(event));
this.cmdInfoAddress.addClickListener(event -> this.cmdInfoAddress_buttonClick(event));
this.cmdSave.addClickListener(event -> this.cmdSave_buttonClick(event));
this.cmdReset.addClickListener(event -> this.cmdReset_buttonClick(event));
this.cmdHours.addClickListener(event -> this.cmdHours_buttonClick(event));
} // </generated-code>

// <generated-code name="variables">
private XdevButton cmdNew, cmdDelete, cmdReload, cmdPlan, cmdReport, cmdInfo, btnSearch, cmdNewAddress,
cmdDeleteAddress, cmdEditAddress, cmdReloadAddress, cmdInfoAddress, cmdSave, cmdReset;
cmdDeleteAddress, cmdEditAddress, cmdReloadAddress, cmdInfoAddress, cmdSave, cmdReset, cmdHours;
private XdevLabel lblCustomer, lblProName, lblProExtReference, lblProContact, lblProStartDate, lblProEndDate,
lblProIntensityPercent, label4, lblProHours, lblProHoursEffective, lblProRate, lblVat, lblCostAccount,
lblProIntensityPercent, lblProHours, lblProHoursEffective, lblProRate, lblVat, lblCostAccount,
lblBillingAddress, lblProState, lblProModel, lblProOrderStrategy, lblProject, lblProDescription, lblProRemark,
lblProProjectState, lblProLastBill;
private XdevComboBox<CostAccount> cmbCostAccount;
Expand Down
10 changes: 5 additions & 5 deletions src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.ui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,7 @@
</XdevLabel>
<XdevTextField columns="5" x:name="txtProIntensityPercent">
<x:constraints gridx="2" gridy="5" weighty="0.0" weightx="1.0" width="-1px" height="0px" />
<x:event>valueChange.valueChange</x:event>
</XdevTextField>
<XdevLabel icon="FontAwesome.INFO_CIRCLE" description="Stunden Soll wird vorgeschlagen, sobald Datum oder Intensität verändert wird." x:name="label4">
<x:constraints gridx="3" gridy="5" weighty="0.0" weightx="0.0" width="100%" height="0px" />
</XdevLabel>
<XdevLabel x:name="lblProHours" value="Stunden Soll">
<x:constraints gridx="1" gridy="6" weighty="0.0" weightx="0.0" width="0px" height="0px" />
</XdevLabel>
Expand Down Expand Up @@ -309,7 +305,7 @@
<XdevGridLayout caption="Ressourcen" x:name="gridLayoutRess" margin="">
<x:constraints width="100%" height="100%" />
<XdevVerticalLayout x:name="verticalLayoutRess" margin="">
<x:constraints splitPos="FIRST" gridx="1" gridy="2" weighty="0.1" weightx="0.1" width="100%" height="100%" />
<x:constraints splitPos="FIRST" gridx="1" gridy="1" weighty="0.1" weightx="0.1" width="100%" height="100%" />
<XdevHorizontalLayout spacing="false" x:name="horizontalLayoutRess" margin="">
<x:constraints weighty="0.0" width="100%" height="0px" />
<XdevButton icon="FontAwesome.PLUS_CIRCLE" description="{$cmdNew.description}" x:name="cmdNewAddress">
Expand Down Expand Up @@ -415,6 +411,10 @@
<x:constraints weightx="0.0" width="0px" height="0px" />
<x:event>click.buttonClick</x:event>
</XdevButton>
<XdevButton icon="FontAwesome.CLOCK_O" caption="Stunden..." x:name="cmdHours">
<x:constraints weightx="0.0" width="0px" height="0px" />
<x:event>click.buttonClick</x:event>
</XdevButton>
</XdevHorizontalLayout>
<XdevFieldGroup x:name="fieldGroup" x:entityType="Project">
<x:typeArguments>
Expand Down
Loading

0 comments on commit f9041ab

Please sign in to comment.