package info.bukova.isspst.ui.tripbill;

import info.bukova.isspst.data.TripBill;
import info.bukova.isspst.data.Vehicle;
import info.bukova.isspst.services.settings.GlobalSettingsService;
import info.bukova.isspst.services.tripbill.TripBillService;
import info.bukova.isspst.ui.FormViewModel;

import java.util.ArrayList;
import java.util.List;

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;

public class TripBillForm extends FormViewModel<TripBill> {
	
	@WireVariable
	private TripBillService tripBillService;
	private List<Vehicle> vehicles;
	@WireVariable
	private GlobalSettingsService settingsService;

	@Init(superclass = true)
	public void init() {
		vehicles = new ArrayList<Vehicle>();
		vehicles.add(null);
		vehicles.addAll(settingsService.getSettings().getVehicles());
	}

	@Command
	@NotifyChange("dataBean")
	public void calculate() {
		tripBillService.calculate(getDataBean());
	}

	public List<Vehicle> getVehicles() {
		return vehicles;
	}

}
