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 authReqTemplate;
private MailMessage confReqTemplate;
private MailMessage confReqTripPassenger;
private Address mainAddress;
private List<Address> shippingAddrs;
private String bankName;
@ -28,6 +29,7 @@ public class SettingsData {
newReqTemplate = new MailMessage();
authReqTemplate = new MailMessage();
confReqTemplate = new MailMessage();
confReqTripPassenger = new MailMessage();
mainAddress = new Address();
shippingAddrs = new ArrayList<Address>();
vehicles = new ArrayList<Vehicle>();
@ -150,4 +152,12 @@ public class SettingsData {
{
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.TripRequirement;
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.settings.GlobalSettingsService;
import info.bukova.isspst.services.tripbill.TripBillApprovalService;
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.LazyInitializationException;
import org.hibernate.Query;
@ -27,11 +31,17 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
@Autowired
private RequirementTypeService reqTypeService;
@Autowired
private WorkgroupService workgroupService;
@Autowired
private TripBillService tripBillService;
@Autowired
private TripBillApprovalService tripBillApprovalService;
@Autowired
private Mailer mailer;
@Autowired
private MessageBuilder messageBuilder;
@Autowired
private GlobalSettingsService settingsService;
@Autowired
private UserService userService;
@Override
protected TripRequirement createEntity() {
@ -125,12 +135,19 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
if (entity.getBillForPassengers() != null && entity.getBillForPassengers()) {
for (User u : entity.getPassengers()) {
if (!u.equals(entity.getOwnedBy())) {
TripBill passBill = tripBillService.createTripBill(entity);
TripBill passBill = tripBillService.createPassengersBill(entity);
tripBillService.add(passBill);
passBill.setOwnedBy(u);
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 TripBill createTripBill(TripRequirement requirement);
public TripBill createPassengersBill(TripRequirement requirement);
public void loadItems(TripBill bill);
public void calculate(TripBill bill);
public List<TripBill> getMy();

@ -33,13 +33,26 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
@Override
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();
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;
for (int i = 0 ; i < daysCount ; i++) {
TripBillItem item = new TripBillItem();
if (i == 0) {
@ -50,17 +63,17 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
item.setBack(requirement.getTo() + " - " + requirement.getFrom());
item.setBackVehicle(requirement.getVehicle());
}
Calendar calTripDate = Calendar.getInstance();
calTripDate.setTime(requirement.getTripDate());
calTripDate.add(Calendar.DATE, i);
item.setDate(calTripDate.getTime());
bill.getBillItems().add(item);
}
this.calculate(bill);
return bill;
}
@ -102,8 +115,8 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
bill.setTotal(bill.getTotal().add(item.getTotal()));
}
if (bill.getRequirement().getDownPayment() != null) {
bill.setTotal(bill.getTotal().subtract(bill.getRequirement().getDownPayment()));
if (bill.getDownPayment() != null) {
bill.setTotal(bill.getTotal().subtract(bill.getDownPayment()));
}
}

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

@ -1,7 +1,7 @@
<?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">
<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"/>
<queryString>
<![CDATA[]]>
@ -381,28 +381,28 @@ výdaje]]></text>
</textElement>
<textFieldExpression><![CDATA[$F{endWork}]]></textFieldExpression>
</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"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{distance}]]></textFieldExpression>
</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"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{distanceAmount}]]></textFieldExpression>
</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"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{fuelConsumption}]]></textFieldExpression>
</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"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>

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

@ -1,10 +1,13 @@
<?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>
<tabs>
<tab label="${labels.NewRequirement}"/>
<tab label="${labels.AuthRequirement}"/>
<tab label="${labels.ConfirmRequirement}"/>
<tab label="Scvaleni SC - spolucestujici"/>
</tabs>
<tabpanels>
<tabpanel>
@ -88,6 +91,31 @@
</rows>
</grid>
</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>
</tabbox>
<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)"/>
</template>
</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>
Loading…
Cancel
Save