public static void CheckOut(string licencePlate) { Vehicle vehicle = VehicleController.CheckOut(licencePlate); if (vehicle == null) { throw new Exception("Ne postoji vozilo s oznakom " + licencePlate + " u bazi."); } Ticket ticket = Database.Tickets.GetTicket(vehicle.LicencePlates, vehicle.VehicleType, vehicle.CheckedInDate, false); if (ticket == null) { throw new Exception("Vozilo s oznakom " + licencePlate + " nije prijavljeno prilikom ulaska na parking."); } ticket.CheckedOut = DateTime.Now; ticket.Username = LoginController.LoggedInUser.FirstName + " " + LoginController.LoggedInUser.LastName; ticket.ChargedBase = 0; ticket.ChargedTax = 0; ticket.JIR = ""; ticket.ZIK = ""; ticket.ChargeTicket = true; SubscriberCheckOutTicket checkOutTicket = new SubscriberCheckOutTicket(ticket); Database.Tickets.UpdateTicket(ticket); Shared.Worker.Print(checkOutTicket); }
public static void CheckOut(String licencePlate, Company company) { if (!Controller.ChargeRegularUserController.HasInternet()) { throw new Exception("Uređaj nije spojen na Internet. Računi se ne mogu fiskalizirati."); } Vehicle vehicle = VehicleController.CheckOut(licencePlate); if (vehicle == null) { throw new Exception("Vozilo s oznakom " + licencePlate + " nije prijavljeno prilikom ulaska na parkiralište."); } decimal chargeBase = 0; decimal chargeTax = 0; Ticket ticket = Database.Tickets.GetTicket(vehicle.LicencePlates, vehicle.VehicleType, vehicle.CheckedInDate, false); if (ticket == null || ticket.ChargeTicket) { throw new Exception("Vozilo s oznakom " + licencePlate + " nije prijavljeno prilikom ulaska na parking."); } if (ticket.TicketType != "Pojedinačni prijevoz") { throw new Exception("Izlazna karta se naplačuje samo vozilima s pojedinačnom kartom"); } ticket.CheckedOut = DateTime.Now; ticket.Username = LoginController.LoggedInUser.FirstName + " " + LoginController.LoggedInUser.LastName; String JIR; String ZIK; ticket.Charged = ChargesController.GetCharge(ticket.TicketType, vehicle.VehicleType, vehicle.CheckedInDate, out chargeBase, out chargeTax); decimal dailyTicketCharge = ChargesController.GetCharge("Dnevna karta", vehicle.VehicleType); if (ticket.TicketType == "Pojedinačni prijevoz" && ticket.Charged > dailyTicketCharge) { ticket.TicketType = "Dnevna karta"; ticket.Charged = ChargesController.GetCharge(ticket.TicketType, vehicle.VehicleType, out chargeBase, out chargeTax); } //porezna if (!Shared.TestMode) { ChargesController.Fiskaliziraj(vehicle.LicencePlates, vehicle.CheckedInDate, "12345678901", ticket.Charged, chargeBase, chargeTax, out ZIK, out JIR); } else { JIR = "550e8400-e29b-41d4-a716-446655440000"; ZIK = "e4d909c290d0fb1ca068ffaddf22cbd0"; } ticket.ChargedBase = chargeBase; ticket.ChargedTax = chargeTax; ticket.JIR = JIR; ticket.ZIK = ZIK; ticket.ChargeTicket = true; Database.Tickets.UpdateTicket(ticket); ticket.TicketCount = CounterController.GetTicketCount(); CheckOutTicket checkOutTicket = new CheckOutTicket(ticket, company); Shared.Worker.Print(checkOutTicket); Shared.Worker.Print(checkOutTicket); Tickets.AddLogOutTicket(LoginController.LoggedInUser.Username, checkOutTicket.Ticket.TicketType, checkOutTicket.Ticket.VehicleType, checkOutTicket.Ticket.LicencePlates, checkOutTicket.Ticket.Charged); CounterController.IncrementCounter(); }