Na formulář požadavku na služební byl přidán checkbox pro vygenerování vyúčtování služební cesty i pro spolucestující. Spolucestující nemůžou vyúčtování měnit.

closes #212
Verze_2.0
Josef Rokos 10 years ago
parent 42deec695a
commit 9b8bfe2228

@ -2,15 +2,14 @@ package info.bukova.isspst.data;
import info.bukova.isspst.Constants; import info.bukova.isspst.Constants;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.AttributeOverride; import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides; import javax.persistence.AttributeOverrides;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Embedded; import javax.persistence.Embedded;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;
@Entity @Entity
@Table(name = "TRIP_BILL_ITEMS") @Table(name = "TRIP_BILL_ITEMS")
@ -65,6 +64,35 @@ public class TripBillItem extends BaseData {
@Column(name = "ADJUSTED_TOTAL", precision = 15, scale = 4) @Column(name = "ADJUSTED_TOTAL", precision = 15, scale = 4)
private BigDecimal adjustedTotal; private BigDecimal adjustedTotal;
public TripBillItem() {
}
public TripBillItem(TripBillItem src) {
date = src.getDate();
to = src.getTo();
back = src.getBack();
toDeparture = src.getToDeparture();
toArrival = src.getToArrival();
backDeparture = src.getBackDeparture();
backArrival = src.getBackArrival();
toVehicle = src.getToVehicle();
backVehicle = src.getBackVehicle();
beginWork = src.getBeginWork();
endWork = src.getEndWork();
freeMealsCount = src.getFreeMealsCount();
distance = src.getDistance();
fuelConsumption = src.getFuelConsumption();
distanceAmount = src.getDistanceAmount();
fuelAmount = src.getFuelAmount();
carefare = src.getCarefare();
housing = src.getHousing();
meals = src.getMeals();
otherExpenses = src.getOtherExpenses();
total = src.getTotal();
adjustedTotal = src.getAdjustedTotal();
}
public Date getDate() { public Date getDate() {
return date; return date;
} }

@ -42,6 +42,8 @@ public class TripRequirement extends RequirementBase implements EntityWithAttach
@LazyCollection(LazyCollectionOption.TRUE) @LazyCollection(LazyCollectionOption.TRUE)
@IndexedEmbedded @IndexedEmbedded
private List<FileMetainfo> attachedFiles; private List<FileMetainfo> attachedFiles;
@Column(name = "BILL_FOR_PASSENGERS")
private Boolean billForPassengers;
public TripRequirement() { public TripRequirement() {
this.setOwnedBy(new User()); this.setOwnedBy(new User());
@ -140,4 +142,11 @@ public class TripRequirement extends RequirementBase implements EntityWithAttach
attachedFiles.remove(metainfo); attachedFiles.remove(metainfo);
} }
public Boolean getBillForPassengers() {
return billForPassengers;
}
public void setBillForPassengers(Boolean billForPassengers) {
this.billForPassengers = billForPassengers;
}
} }

@ -111,6 +111,7 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
bill.setOwnedBy(entity.getOwnedBy()); bill.setOwnedBy(entity.getOwnedBy());
tripBillService.update(bill); tripBillService.update(bill);
if (entity.getBillForPassengers() != null && entity.getBillForPassengers()) {
for (User u : entity.getPassengers()) { for (User u : entity.getPassengers()) {
if (!u.equals(entity.getOwnedBy())) { if (!u.equals(entity.getOwnedBy())) {
TripBill passBill = tripBillService.createTripBill(entity); TripBill passBill = tripBillService.createTripBill(entity);
@ -121,6 +122,7 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
} }
} }
} }
}
@Override @Override
protected String getNumberSerie() { protected String getNumberSerie() {

@ -178,11 +178,13 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
@Override @Override
@Transactional @Transactional
@LazyLoader("print") @LazyLoader({"print", "form"})
public void loadOwner(TripBill bill) { public void loadOwner(TripBill bill) {
TripBill tb = dao.getById(bill.getId()); TripBill tb = dao.getById(bill.getId());
tb.getOwnedBy().getFirstName(); tb.getOwnedBy().getFirstName();
tb.getRequirement().getOwnedBy().getFirstName();
bill.setOwnedBy(tb.getOwnedBy()); bill.setOwnedBy(tb.getOwnedBy());
bill.getRequirement().setOwnedBy(tb.getRequirement().getOwnedBy());
} }
@Override @Override
@ -196,4 +198,31 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
bill.getRequirement().setPassengers(tr.getPassengers()); bill.getRequirement().setPassengers(tr.getPassengers());
} }
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
public void update(TripBill entity) {
super.update(entity);
TripRequirement req = entity.getRequirement();
Query q = dao.getQuery("from TripBill where requirement = :req and id != :id");
q.setParameter("req", req);
q.setParameter("id", entity.getId());
List<TripBill> bills = q.list();
for (TripBill tb : bills) {
tb.getBillItems().clear();
for (TripBillItem item : entity.getBillItems()) {
tb.getBillItems().add(new TripBillItem(item));
}
tb.setFreeCarfare(entity.isFreeCarfare());
tb.setFreeHousing(entity.isFreeHousing());
tb.setFreeMeals(entity.isFreeMeals());
calculate(tb);
super.update(tb);
}
}
} }

@ -38,4 +38,14 @@ public class TripBillForm extends FormWithUpload<TripBill> {
return vehicles; return vehicles;
} }
public boolean isBillDisabled() {
if (getDataBean().getRequirement().getBillForPassengers() != null
&& getDataBean().getRequirement().getBillForPassengers()
&& !getDataBean().getOwnedBy().equals(getDataBean().getRequirement().getOwnedBy())) {
return true;
}
return false;
}
} }

@ -16,7 +16,9 @@
<hbox hflex="1" align="center"> <hbox hflex="1" align="center">
<div align="center" hflex="1"> <div align="center" hflex="1">
<vbox> <vbox>
<image src="/img/lucene_logo.png"/> <div align="center">
<image src="/img/search-072.png"/>
</div>
<hbox> <hbox>
<textbox value="@bind(vm.keyWord)" instant="true" width="250px" onCreate="self.setFocus(true)" <textbox value="@bind(vm.keyWord)" instant="true" width="250px" onCreate="self.setFocus(true)"
onOK="@command('doSearch')"/> onOK="@command('doSearch')"/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

@ -147,6 +147,9 @@
sclass="nicebutton" sclass="nicebutton"
disabled="@load(vm.selUser eq null)"/> disabled="@load(vm.selUser eq null)"/>
</hbox> </hbox>
<checkbox label="Generovat vyúčtování pro spolucestující"
checked="@bind(vm.dataBean.billForPassengers)"
disabled="@load(empty vm.passengers)"/>
<grid model="@load(vm.passengers)" width="700px"> <grid model="@load(vm.passengers)" width="700px">
<columns> <columns>
<column/> <column/>

@ -21,7 +21,7 @@
zclass="form-caption" zclass="form-caption"
label="${labels.TravelOrdersFormTitle}" /> label="${labels.TravelOrdersFormTitle}" />
<vlayout vflex="1"> <vlayout vflex="1">
<include src="../tripBillInterior.zul"/> <include src="../tripBillInterior.zul" vflex="1"/>
<vlayout <vlayout
vflex="min" vflex="min"
hflex="max"> hflex="max">

@ -56,21 +56,21 @@
<checkbox label="${labels.TripBillFreeMeals}" <checkbox label="${labels.TripBillFreeMeals}"
checked="@bind(vm.dataBean.freeMeals)" checked="@bind(vm.dataBean.freeMeals)"
onCheck="@command('calculate')" onCheck="@command('calculate')"
disabled="${disabled}"/> disabled="@load(vm.billDisabled or disabled)"/>
</cell> </cell>
</row> </row>
<row> <row>
<cell colspan="2"> <cell colspan="2">
<checkbox label="${labels.TripBillFreeHousing}" <checkbox label="${labels.TripBillFreeHousing}"
checked="@bind(vm.dataBean.freeHousing)" checked="@bind(vm.dataBean.freeHousing)"
disabled="${disabled}" /> disabled="@load(vm.billDisabled or disabled)" />
</cell> </cell>
</row> </row>
<row> <row>
<cell colspan="2"> <cell colspan="2">
<checkbox label="${labels.TripBillFreeCarfare}" <checkbox label="${labels.TripBillFreeCarfare}"
checked="@bind(vm.dataBean.freeCarfare)" checked="@bind(vm.dataBean.freeCarfare)"
disabled="${disabled}" /> disabled="@load(vm.billDisabled or disabled)" />
</cell> </cell>
</row> </row>
</rows> </rows>
@ -237,12 +237,12 @@
value="@load(each.to)" value="@load(each.to)"
maxlength="@load(vm.lengthText)" maxlength="@load(vm.lengthText)"
sclass="grid-textbox-max-left" sclass="grid-textbox-max-left"
readonly="${disabled}"/> readonly="@load(vm.billDisabled or disabled)"/>
<textbox inplace="true" <textbox inplace="true"
value="@load(each.back)" value="@load(each.back)"
maxlength="@load(vm.lengthText)" maxlength="@load(vm.lengthText)"
sclass="grid-textbox-max-left" sclass="grid-textbox-max-left"
readonly="${disabled}"/> readonly="@load(vm.billDisabled or disabled)"/>
</vbox> </vbox>
<vbox> <vbox>
<timebox inplace="true" <timebox inplace="true"
@ -250,13 +250,13 @@
value="@bind(each.toArrival)" value="@bind(each.toArrival)"
onChange="@command('calculate')" onChange="@command('calculate')"
format="short" format="short"
disabled="${disabled}"/> disabled="@load(vm.billDisabled or disabled)"/>
<timebox inplace="true" <timebox inplace="true"
width="68px" width="68px"
value="@bind(each.backArrival)" value="@bind(each.backArrival)"
onChange="@command('calculate')" onChange="@command('calculate')"
format="short" format="short"
disabled="${disabled}"/> disabled="@load(vm.billDisabled or disabled)"/>
</vbox> </vbox>
<vbox> <vbox>
<timebox inplace="true" <timebox inplace="true"
@ -264,13 +264,13 @@
value="@bind(each.toDeparture)" value="@bind(each.toDeparture)"
onChange="@command('calculate')" onChange="@command('calculate')"
format="short" format="short"
disabled="${disabled}"/> disabled="@load(vm.billDisabled or disabled)"/>
<timebox inplace="true" <timebox inplace="true"
width="68px" width="68px"
value="@bind(each.backDeparture)" value="@bind(each.backDeparture)"
onChange="@command('calculate')" onChange="@command('calculate')"
format="short" format="short"
disabled="${disabled}"/> disabled="@load(vm.billDisabled or disabled)"/>
</vbox> </vbox>
<vbox> <vbox>
<combobox inplace="true" <combobox inplace="true"
@ -278,7 +278,7 @@
selectedItem="@bind(each.toVehicle)" selectedItem="@bind(each.toVehicle)"
width="67px" width="67px"
readonly="true" readonly="true"
disabled="${disabled}"> disabled="@load(vm.billDisabled or disabled)">
<template name="model"> <template name="model">
<comboitem label="@load(each.code)"/> <comboitem label="@load(each.code)"/>
</template> </template>
@ -289,7 +289,7 @@
selectedItem="@bind(each.backVehicle)" selectedItem="@bind(each.backVehicle)"
width="67px" width="67px"
readonly="true" readonly="true"
disabled="${disabled}"> disabled="@load(vm.billDisabled or disabled)">
<template name="model"> <template name="model">
<comboitem label="@load(each.code)"/> <comboitem label="@load(each.code)"/>
</template> </template>
@ -300,12 +300,12 @@
width="68px" width="68px"
value="@bind(each.beginWork)" value="@bind(each.beginWork)"
format="short" format="short"
disabled="${disabled}"/> disabled="@load(vm.billDisabled or disabled)"/>
<timebox inplace="true" <timebox inplace="true"
width="68px" width="68px"
value="@bind(each.endWork)" value="@bind(each.endWork)"
format="short" format="short"
disabled="${disabled}"/> disabled="@load(vm.billDisabled or disabled)"/>
</vbox> </vbox>
<vbox> <vbox>
<textbox <textbox
@ -313,14 +313,14 @@
width="68px" width="68px"
maxlength="@load(vm.lengthText)" maxlength="@load(vm.lengthText)"
value="@bind(each.distance) @converter(vm.standardBigDecimalConverter)" value="@bind(each.distance) @converter(vm.standardBigDecimalConverter)"
readonly="${disabled}"/> readonly="@load(vm.billDisabled or disabled)"/>
<textbox <textbox
inplace="true" inplace="true"
width="68px" width="68px"
value="@bind(each.distanceAmount) @converter(vm.standardBigDecimalConverter)" value="@bind(each.distanceAmount) @converter(vm.standardBigDecimalConverter)"
maxlength="@load(vm.lengthText)" maxlength="@load(vm.lengthText)"
onChange="@command('calculate')" onChange="@command('calculate')"
readonly="${disabled}"/> readonly="@load(vm.billDisabled or disabled)"/>
</vbox> </vbox>
<vbox> <vbox>
<textbox <textbox
@ -328,30 +328,30 @@
width="68px" width="68px"
maxlength="@load(vm.lengthText)" maxlength="@load(vm.lengthText)"
value="@bind(each.fuelConsumption) @converter(vm.standardBigDecimalConverter)" value="@bind(each.fuelConsumption) @converter(vm.standardBigDecimalConverter)"
readonly="${disabled}"/> readonly="@load(vm.billDisabled or disabled)"/>
<textbox <textbox
inplace="true" inplace="true"
width="68px" width="68px"
value="@bind(each.fuelAmount) @converter(vm.standardBigDecimalConverter)" value="@bind(each.fuelAmount) @converter(vm.standardBigDecimalConverter)"
maxlength="@load(vm.lengthText)" maxlength="@load(vm.lengthText)"
onChange="@command('calculate')" onChange="@command('calculate')"
readonly="${disabled}"/> readonly="@load(vm.billDisabled or disabled)"/>
</vbox> </vbox>
<textbox <textbox
inplace="true" inplace="true"
value="@bind(each.carefare) @converter(vm.standardBigDecimalConverter)" value="@bind(each.carefare) @converter(vm.standardBigDecimalConverter)"
maxlength="@load(vm.lengthText)" maxlength="@load(vm.lengthText)"
onChange="@command('calculate')" onChange="@command('calculate')"
readonly="${disabled}"/> readonly="@load(vm.billDisabled or disabled)"/>
<textbox <textbox
inplace="true" inplace="true"
value="@bind(each.housing) @converter(vm.standardBigDecimalConverter)" value="@bind(each.housing) @converter(vm.standardBigDecimalConverter)"
maxlength="@load(vm.lengthText)" maxlength="@load(vm.lengthText)"
onChange="@command('calculate')" onChange="@command('calculate')"
readonly="${disabled}"/> readonly="@load(vm.billDisabled or disabled)"/>
<combobox inplace="true" selectedIndex="@bind(each.freeMealsCount)" <combobox inplace="true" selectedIndex="@bind(each.freeMealsCount)"
readonly="true" readonly="true"
disabled="${disabled}" disabled="@load(vm.billDisabled or disabled)"
width="60px" width="60px"
onBlur="@command('calculate')"> onBlur="@command('calculate')">
@ -366,7 +366,7 @@
value="@bind(each.otherExpenses) @converter(vm.standardBigDecimalConverter)" value="@bind(each.otherExpenses) @converter(vm.standardBigDecimalConverter)"
maxlength="@load(vm.lengthText)" maxlength="@load(vm.lengthText)"
onChange="@command('calculate')" onChange="@command('calculate')"
readonly="${disabled}"/> readonly="@load(vm.billDisabled or disabled)"/>
<label value="@load(each.total) @converter(vm.standardBigDecimalConverter)"/> <label value="@load(each.total) @converter(vm.standardBigDecimalConverter)"/>
<label value="@load(each.adjustedTotal) @converter(vm.standardBigDecimalConverter)"/> <label value="@load(each.adjustedTotal) @converter(vm.standardBigDecimalConverter)"/>
</row> </row>

Loading…
Cancel
Save