Opraveno generovani vyuctovani sluzebni cesty spolucestujicich, pokud je pozadovana zaloha- zaloha se nyni neprenese.

closes #229
Po schvaleni pozadavku na sluzebni cestu se spolucestujicimi se posle mail o schvaleni i spolucestujicim.
closes #228
Verze_2.0
Josef Rokos 10 years ago
parent aaa89a2653
commit c2ca2e45ec

@ -14,6 +14,7 @@ public class SettingsData {
private MailMessage newReqTemplate; private MailMessage newReqTemplate;
private MailMessage authReqTemplate; private MailMessage authReqTemplate;
private MailMessage confReqTemplate; private MailMessage confReqTemplate;
private MailMessage confReqTripPassenger;
private Address mainAddress; private Address mainAddress;
private List<Address> shippingAddrs; private List<Address> shippingAddrs;
private String bankName; private String bankName;
@ -28,6 +29,7 @@ public class SettingsData {
newReqTemplate = new MailMessage(); newReqTemplate = new MailMessage();
authReqTemplate = new MailMessage(); authReqTemplate = new MailMessage();
confReqTemplate = new MailMessage(); confReqTemplate = new MailMessage();
confReqTripPassenger = new MailMessage();
mainAddress = new Address(); mainAddress = new Address();
shippingAddrs = new ArrayList<Address>(); shippingAddrs = new ArrayList<Address>();
vehicles = new ArrayList<Vehicle>(); vehicles = new ArrayList<Vehicle>();
@ -150,4 +152,12 @@ public class SettingsData {
{ {
this.logoFile = logoFile; this.logoFile = logoFile;
} }
public MailMessage getConfReqTripPassenger() {
return confReqTripPassenger;
}
public void setConfReqTripPassenger(MailMessage confReqTripPassenger) {
this.confReqTripPassenger = confReqTripPassenger;
}
} }

@ -7,10 +7,14 @@ import info.bukova.isspst.data.TripBill;
import info.bukova.isspst.data.TripBillApproval; import info.bukova.isspst.data.TripBillApproval;
import info.bukova.isspst.data.TripRequirement; import info.bukova.isspst.data.TripRequirement;
import info.bukova.isspst.data.User; import info.bukova.isspst.data.User;
import info.bukova.isspst.mail.MailMessage;
import info.bukova.isspst.mail.Mailer;
import info.bukova.isspst.mail.MessageBuilder;
import info.bukova.isspst.services.LazyLoader; import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.services.settings.GlobalSettingsService;
import info.bukova.isspst.services.tripbill.TripBillApprovalService; import info.bukova.isspst.services.tripbill.TripBillApprovalService;
import info.bukova.isspst.services.tripbill.TripBillService; import info.bukova.isspst.services.tripbill.TripBillService;
import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.services.users.UserService;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.LazyInitializationException; import org.hibernate.LazyInitializationException;
import org.hibernate.Query; import org.hibernate.Query;
@ -27,11 +31,17 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
@Autowired @Autowired
private RequirementTypeService reqTypeService; private RequirementTypeService reqTypeService;
@Autowired @Autowired
private WorkgroupService workgroupService;
@Autowired
private TripBillService tripBillService; private TripBillService tripBillService;
@Autowired @Autowired
private TripBillApprovalService tripBillApprovalService; private TripBillApprovalService tripBillApprovalService;
@Autowired
private Mailer mailer;
@Autowired
private MessageBuilder messageBuilder;
@Autowired
private GlobalSettingsService settingsService;
@Autowired
private UserService userService;
@Override @Override
protected TripRequirement createEntity() { protected TripRequirement createEntity() {
@ -125,12 +135,19 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
if (entity.getBillForPassengers() != null && entity.getBillForPassengers()) { 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.createPassengersBill(entity);
tripBillService.add(passBill); tripBillService.add(passBill);
passBill.setOwnedBy(u); passBill.setOwnedBy(u);
tripBillService.update(passBill); tripBillService.update(passBill);
} }
} }
if (!entity.getPassengers().isEmpty() && settingsService.getSettings().getConfReqTripPassenger() != null) {
MailMessage message = messageBuilder.buildMessage(settingsService.getSettings().getConfReqTripPassenger(), entity);
message.setFrom(userService.getCurrent().getEmail());
message.setTo(userService.getEmailsForSend(entity.getPassengers()));
mailer.send(message);
}
} }
} }
} }

@ -9,6 +9,7 @@ import java.util.List;
public interface TripBillService extends Service<TripBill> { public interface TripBillService extends Service<TripBill> {
public TripBill createTripBill(TripRequirement requirement); public TripBill createTripBill(TripRequirement requirement);
public TripBill createPassengersBill(TripRequirement requirement);
public void loadItems(TripBill bill); public void loadItems(TripBill bill);
public void calculate(TripBill bill); public void calculate(TripBill bill);
public List<TripBill> getMy(); public List<TripBill> getMy();

@ -33,13 +33,26 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
@Override @Override
public TripBill createTripBill(TripRequirement requirement) { public TripBill createTripBill(TripRequirement requirement) {
return createBill(requirement, false);
}
@Override
public TripBill createPassengersBill(TripRequirement requirement) {
return createBill(requirement, true);
}
private TripBill createBill(TripRequirement requirement, boolean passengers) {
TripBill bill = new TripBill(); TripBill bill = new TripBill();
bill.setRequirement(requirement); bill.setRequirement(requirement);
int daysCount = Days.daysBetween((new DateTime(requirement.getTripDate())).withTimeAtStartOfDay(), if (!passengers) {
bill.setDownPayment(requirement.getDownPayment());
}
int daysCount = Days.daysBetween((new DateTime(requirement.getTripDate())).withTimeAtStartOfDay(),
(new DateTime(requirement.getEndDate())).withTimeAtStartOfDay()).getDays() + 1; (new DateTime(requirement.getEndDate())).withTimeAtStartOfDay()).getDays() + 1;
for (int i = 0 ; i < daysCount ; i++) { for (int i = 0 ; i < daysCount ; i++) {
TripBillItem item = new TripBillItem(); TripBillItem item = new TripBillItem();
if (i == 0) { if (i == 0) {
@ -50,17 +63,17 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
item.setBack(requirement.getTo() + " - " + requirement.getFrom()); item.setBack(requirement.getTo() + " - " + requirement.getFrom());
item.setBackVehicle(requirement.getVehicle()); item.setBackVehicle(requirement.getVehicle());
} }
Calendar calTripDate = Calendar.getInstance(); Calendar calTripDate = Calendar.getInstance();
calTripDate.setTime(requirement.getTripDate()); calTripDate.setTime(requirement.getTripDate());
calTripDate.add(Calendar.DATE, i); calTripDate.add(Calendar.DATE, i);
item.setDate(calTripDate.getTime()); item.setDate(calTripDate.getTime());
bill.getBillItems().add(item); bill.getBillItems().add(item);
} }
this.calculate(bill); this.calculate(bill);
return bill; return bill;
} }
@ -102,8 +115,8 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
bill.setTotal(bill.getTotal().add(item.getTotal())); bill.setTotal(bill.getTotal().add(item.getTotal()));
} }
if (bill.getRequirement().getDownPayment() != null) { if (bill.getDownPayment() != null) {
bill.setTotal(bill.getTotal().subtract(bill.getRequirement().getDownPayment())); bill.setTotal(bill.getTotal().subtract(bill.getDownPayment()));
} }
} }

@ -396,7 +396,7 @@ Pending = Nevyřízené
Archive = Archiv Archive = Archiv
Completed = Vyřízeno Completed = Vyřízeno
GenerateBillingForPassengers = Generovat vyúčtování pro spolucestující GenerateBillingForPassengers = Generovat společný požadavek a vyúčtování
Passenger = Pasažér Passenger = Pasažér
ChooseThePasseger = Vyberte pasažéra ChooseThePasseger = Vyberte pasažéra
TransportMode = Způsob dopravy TransportMode = Způsob dopravy

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="tripBillItems" pageWidth="572" pageHeight="752" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="0bbe694d-dbb2-4b58-b789-2587f37c94a8"> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="tripBillItems" pageWidth="572" pageHeight="752" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="0bbe694d-dbb2-4b58-b789-2587f37c94a8">
<property name="ireport.zoom" value="2.0"/> <property name="ireport.zoom" value="2.0"/>
<property name="ireport.x" value="496"/> <property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/> <property name="ireport.y" value="0"/>
<queryString> <queryString>
<![CDATA[]]> <![CDATA[]]>
@ -381,28 +381,28 @@ výdaje]]></text>
</textElement> </textElement>
<textFieldExpression><![CDATA[$F{endWork}]]></textFieldExpression> <textFieldExpression><![CDATA[$F{endWork}]]></textFieldExpression>
</textField> </textField>
<textField pattern="HH:mm" isBlankWhenNull="true"> <textField pattern="###0.00;-###0.00" isBlankWhenNull="true">
<reportElement uuid="034668ea-fa09-4967-bf1a-32b937c04729" x="292" y="0" width="32" height="15"/> <reportElement uuid="034668ea-fa09-4967-bf1a-32b937c04729" x="292" y="0" width="32" height="15"/>
<textElement textAlignment="Center" verticalAlignment="Middle"> <textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<textFieldExpression><![CDATA[$F{distance}]]></textFieldExpression> <textFieldExpression><![CDATA[$F{distance}]]></textFieldExpression>
</textField> </textField>
<textField pattern="HH:mm" isBlankWhenNull="true"> <textField pattern="###0.00;-###0.00" isBlankWhenNull="true">
<reportElement uuid="d9ee1631-7830-44e2-a23d-63be94701d24" x="292" y="15" width="32" height="15"/> <reportElement uuid="d9ee1631-7830-44e2-a23d-63be94701d24" x="292" y="15" width="32" height="15"/>
<textElement textAlignment="Center" verticalAlignment="Middle"> <textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<textFieldExpression><![CDATA[$F{distanceAmount}]]></textFieldExpression> <textFieldExpression><![CDATA[$F{distanceAmount}]]></textFieldExpression>
</textField> </textField>
<textField pattern="HH:mm" isBlankWhenNull="true"> <textField pattern="###0.00;-###0.00" isBlankWhenNull="true">
<reportElement uuid="89be17a9-f8cc-4cb6-8254-2e660ab44807" x="324" y="0" width="32" height="15"/> <reportElement uuid="89be17a9-f8cc-4cb6-8254-2e660ab44807" x="324" y="0" width="32" height="15"/>
<textElement textAlignment="Center" verticalAlignment="Middle"> <textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/> <font size="8"/>
</textElement> </textElement>
<textFieldExpression><![CDATA[$F{fuelConsumption}]]></textFieldExpression> <textFieldExpression><![CDATA[$F{fuelConsumption}]]></textFieldExpression>
</textField> </textField>
<textField pattern="HH:mm" isBlankWhenNull="true"> <textField pattern="###0.00;-###0.00" isBlankWhenNull="true">
<reportElement uuid="5aceac93-7265-4937-b23f-ec83288f6f90" x="324" y="15" width="32" height="15"/> <reportElement uuid="5aceac93-7265-4937-b23f-ec83288f6f90" x="324" y="15" width="32" height="15"/>
<textElement textAlignment="Center" verticalAlignment="Middle"> <textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/> <font size="8"/>

@ -506,7 +506,7 @@
value="Záloha: " value="Záloha: "
style="font-size: 14px;" /> style="font-size: 14px;" />
<label <label
value="@load(vm.dataBean.requirement.downPayment) @converter(vm.standardBigDecimalConverter)" value="@load(vm.dataBean.downPayment) @converter(vm.standardBigDecimalConverter)"
style="font-size: 14px;" /> style="font-size: 14px;" />
</hbox> </hbox>
<hbox> <hbox>

@ -1,10 +1,13 @@
<?page title="email" contentType="text/html;charset=UTF-8"?> <?page title="email" contentType="text/html;charset=UTF-8"?>
<zk> <zk xmlns="http://www.zkoss.org/2005/zul"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
<tabbox> <tabbox>
<tabs> <tabs>
<tab label="${labels.NewRequirement}"/> <tab label="${labels.NewRequirement}"/>
<tab label="${labels.AuthRequirement}"/> <tab label="${labels.AuthRequirement}"/>
<tab label="${labels.ConfirmRequirement}"/> <tab label="${labels.ConfirmRequirement}"/>
<tab label="Scvaleni SC - spolucestujici"/>
</tabs> </tabs>
<tabpanels> <tabpanels>
<tabpanel> <tabpanel>
@ -88,6 +91,31 @@
</rows> </rows>
</grid> </grid>
</tabpanel> </tabpanel>
<tabpanel>
<grid>
<columns>
<column hflex="min"/>
<column/>
</columns>
<rows>
<row>
<label value="${labels.MailSubject}" />
<textbox
value="@bind(vm.settings.confReqTripPassenger.subject)"
width="100%"
maxlength="@load(vm.lengthText)"
readonly="@load(not vm.canSave)" />
</row>
<row spans="2">
<vbox>
<ckeditor toolbar="Basic" value="@bind(vm.settings.confReqTripPassenger.text)" width="460px" height="180px" if="${vm.canSave}" />
<html content="@load(vm.settings.confReqTemplate.text)" width="460px" height="180px" if="${not vm.canSave}"/>
<button label="${labels.InsertField}" popup="fieldsConfirmPass, position=after_start" disabled="@load(not vm.canSave)"/>
</vbox>
</row>
</rows>
</grid>
</tabpanel>
</tabpanels> </tabpanels>
</tabbox> </tabbox>
<menupopup id="fieldsNew" children="@load(vm.requirementFields)"> <menupopup id="fieldsNew" children="@load(vm.requirementFields)">
@ -105,4 +133,9 @@
<menuitem label="@load(each) @converter(vm.locConverter)" onClick="@command('insertField', field=each, message=vm.settings.confReqTemplate)"/> <menuitem label="@load(each) @converter(vm.locConverter)" onClick="@command('insertField', field=each, message=vm.settings.confReqTemplate)"/>
</template> </template>
</menupopup> </menupopup>
<menupopup id="fieldsConfirmPass" children="@load(vm.requirementFields)">
<template name="children">
<menuitem label="@load(each) @converter(vm.locConverter)" onClick="@command('insertField', field=each, message=vm.settings.confReqTripPassenger)"/>
</template>
</menupopup>
</zk> </zk>
Loading…
Cancel
Save