Do globálního nastavení byla přidaná sekce pro nastavení cestovních
náhrad. refs #112
This commit is contained in:
@@ -6,6 +6,7 @@ import info.bukova.isspst.data.NumberSeries;
|
||||
import info.bukova.isspst.data.Permission;
|
||||
import info.bukova.isspst.data.RequirementType;
|
||||
import info.bukova.isspst.data.Role;
|
||||
import info.bukova.isspst.data.SettingsData;
|
||||
import info.bukova.isspst.data.User;
|
||||
import info.bukova.isspst.reporting.Report;
|
||||
import info.bukova.isspst.reporting.ReportMapping;
|
||||
@@ -18,6 +19,7 @@ import info.bukova.isspst.services.users.PermissionService;
|
||||
import info.bukova.isspst.services.users.RoleService;
|
||||
import info.bukova.isspst.services.users.UserService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
@@ -273,6 +275,20 @@ public class AppInitListener implements ServletContextListener {
|
||||
gSettingsService.add(gs);
|
||||
}
|
||||
|
||||
SettingsData data = gSettingsService.getSettings();
|
||||
if (data.getRefunds().isEmpty()) {
|
||||
BigDecimal[] refunds0 = {BigDecimal.ZERO,BigDecimal.ZERO,BigDecimal.ZERO,BigDecimal.ZERO};
|
||||
BigDecimal[] refunds5 = {BigDecimal.valueOf(70),BigDecimal.valueOf(21),BigDecimal.ZERO,BigDecimal.ZERO};
|
||||
BigDecimal[] refunds12 = {BigDecimal.valueOf(105),BigDecimal.valueOf(68),BigDecimal.valueOf(32),BigDecimal.ZERO};
|
||||
BigDecimal[] refunds18 = {BigDecimal.valueOf(165),BigDecimal.valueOf(124),BigDecimal.valueOf(83),BigDecimal.valueOf(42)};
|
||||
|
||||
data.getRefunds().put(0, refunds0);
|
||||
data.getRefunds().put(5, refunds5);
|
||||
data.getRefunds().put(12, refunds12);
|
||||
data.getRefunds().put(18, refunds18);
|
||||
|
||||
gSettingsService.updateSettings();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import info.bukova.isspst.mail.MailMessage;
|
||||
|
||||
@@ -17,6 +20,7 @@ public class SettingsData {
|
||||
private String accountNumber;
|
||||
private String bankCode;
|
||||
private List<Vehicle> vehicles;
|
||||
private Map<Integer, BigDecimal[]> refunds;
|
||||
|
||||
public SettingsData() {
|
||||
newReqTemplate = new MailMessage();
|
||||
@@ -25,6 +29,7 @@ public class SettingsData {
|
||||
mainAddress = new Address();
|
||||
shippingAddrs = new ArrayList<Address>();
|
||||
vehicles = new ArrayList<Vehicle>();
|
||||
refunds = new HashMap<Integer, BigDecimal[]>();
|
||||
}
|
||||
|
||||
public boolean isEnableRequirements() {
|
||||
@@ -107,4 +112,12 @@ public class SettingsData {
|
||||
this.vehicles = vehicles;
|
||||
}
|
||||
|
||||
public Map<Integer, BigDecimal[]> getRefunds() {
|
||||
return refunds;
|
||||
}
|
||||
|
||||
public void setRefunds(Map<Integer, BigDecimal[]> refunds) {
|
||||
this.refunds = refunds;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
|
||||
"http://castor.codehaus.org/mapping.dtd">
|
||||
|
||||
<mapping>
|
||||
|
||||
<class name="info.bukova.isspst.data.SettingsData" auto-complete="true" >
|
||||
<map-to xml="settings-data"/>
|
||||
<field name="refunds" collection="map">
|
||||
|
||||
<bind-xml name="refunds">
|
||||
<class name="org.exolab.castor.mapping.MapItem">
|
||||
<field name="key" type="java.lang.Integer">
|
||||
<bind-xml name="key" node="attribute" />
|
||||
</field>
|
||||
<field name="value" collection="array" type="java.math.BigDecimal">
|
||||
<bind-xml name="nested" />
|
||||
</field>
|
||||
</class>
|
||||
</bind-xml>
|
||||
</field>
|
||||
</class>
|
||||
|
||||
</mapping>
|
||||
@@ -1,14 +1,5 @@
|
||||
package info.bukova.isspst.ui.settings;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.zkoss.bind.annotation.BindingParam;
|
||||
import org.zkoss.bind.annotation.Command;
|
||||
import org.zkoss.bind.annotation.Init;
|
||||
import org.zkoss.bind.annotation.NotifyChange;
|
||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||
import org.zkoss.zul.Window;
|
||||
|
||||
import info.bukova.isspst.data.Address;
|
||||
import info.bukova.isspst.data.Requirement;
|
||||
import info.bukova.isspst.data.SettingsData;
|
||||
@@ -18,6 +9,18 @@ import info.bukova.isspst.services.settings.GlobalSettingsService;
|
||||
import info.bukova.isspst.sort.ReflectionTools;
|
||||
import info.bukova.isspst.ui.LocaleConverter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.zkoss.bind.annotation.BindingParam;
|
||||
import org.zkoss.bind.annotation.Command;
|
||||
import org.zkoss.bind.annotation.Init;
|
||||
import org.zkoss.bind.annotation.NotifyChange;
|
||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||
import org.zkoss.zul.Window;
|
||||
|
||||
public class GlobalSettingsVM {
|
||||
|
||||
@WireVariable
|
||||
@@ -25,11 +28,13 @@ public class GlobalSettingsVM {
|
||||
private SettingsData settings;
|
||||
private LocaleConverter locConverter;
|
||||
private Address selAddress;
|
||||
private List<Integer> refundsHours;
|
||||
|
||||
@Init
|
||||
public void init() {
|
||||
settings = settingsService.getSettings();
|
||||
locConverter = new LocaleConverter();
|
||||
setRefundsHours(settings.getRefunds().keySet());
|
||||
}
|
||||
|
||||
public SettingsData getSettings() {
|
||||
@@ -92,4 +97,13 @@ public class GlobalSettingsVM {
|
||||
this.selAddress = selAddress;
|
||||
}
|
||||
|
||||
public List<Integer> getRefundsHours() {
|
||||
return refundsHours;
|
||||
}
|
||||
|
||||
private void setRefundsHours(Set<Integer> refundsHours) {
|
||||
this.refundsHours = new ArrayList<Integer>(settings.getRefunds().keySet());
|
||||
Collections.sort(this.refundsHours);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user