public void SaveOrUpdateUser(AppUser user) { if (user.Id <= 0) { user.DateCreated = DateTime.Now; user.DateModified = DateTime.Now; using (var wr = WorkspaceFactory.CreateReadOnly()) { if (wr.Single <AppUser>(x => x.UserName == user.UserName) != null) { throw new Exception("User name already exists"); } } } else { foreach (AppUserRole r in user.AppUserRoles) { if (r.Id == 0) { _workspace.Add(r); } } } SaveOrUpdateEntity <AppUser>(user); }
public Task AddToRoleAsync(User user, string roleName) { if (user == null) { throw new ArgumentNullException("user"); } if (string.IsNullOrWhiteSpace(roleName)) { throw new ArgumentException("Value of cannot be null or empty.", "roleName"); } var role = _workspace.Single <Role>(x => x.Name.ToUpper() == roleName.ToUpper()); if (role == null) { throw new InvalidOperationException(string.Format("Role {0} not found.", roleName)); } var userRole = new UserRole { UserId = user.Id, RoleId = role.Id }; _workspace.Add(userRole); _workspace.SaveChanges(); return(Task.FromResult(0)); }
public IEnumerable<MenuItem> BatchCreateMenuItems(string[] values, IWorkspace workspace) { var ds = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; IList<MenuItem> result = new List<MenuItem>(); if (values.Length > 0) { var currentCategory = Resources.Common; foreach (var item in values) { if (item.StartsWith("#")) { currentCategory = item.Trim('#', ' '); } else if (item.Contains(" ")) { IList<string> parts = new List<string>(item.Split(' ')); var price = ConvertToDecimal(parts[parts.Count - 1], ds); parts.RemoveAt(parts.Count - 1); var itemName = string.Join(" ", parts.ToArray()); var mi = MenuItem.Create(); mi.Name = itemName; mi.Portions[0].Price.Amount = price; mi.GroupCode = currentCategory; workspace.Add(mi); workspace.Add(mi.Portions[0]); result.Add(mi); } } } return result; }
public IEnumerable <MenuItem> BatchCreateMenuItems(string[] values, IWorkspace workspace) { var ds = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; IList <MenuItem> result = new List <MenuItem>(); if (values.Length > 0) { var currentCategory = Resources.Common; foreach (var item in values) { if (item.StartsWith("#")) { currentCategory = item.Trim('#', ' '); } else if (item.Contains(" ")) { IList <string> parts = new List <string>(item.Split(' ')); var price = ConvertToDecimal(parts[parts.Count - 1], ds); parts.RemoveAt(parts.Count - 1); var itemName = string.Join(" ", parts.ToArray()); var mi = MenuItem.Create(); mi.Name = itemName; mi.Portions[0].Price.Amount = price; mi.GroupCode = currentCategory; workspace.Add(mi); workspace.Add(mi.Portions[0]); result.Add(mi); } } } return(result); }
public void CommitChanges() { Debug.Assert(_workspace != null); Debug.Assert(Ticket != null); Debug.Assert(Ticket.Id > 0 || Ticket.TicketItems.Count > 0); if (Ticket.Id == 0 && Ticket.TicketNumber != null) { _workspace.Add(Ticket); } Ticket.LastUpdateTime = DateTime.Now; _workspace.CommitChanges(); }
public IEnumerable <Table> BatchCreateTables(string[] values, IWorkspace workspace) { IList <Table> result = new List <Table>(); if (values.Length > 0) { var currentCategory = Resources.Common; foreach (var value in values) { if (value.StartsWith("#")) { currentCategory = value.Trim('#', ' '); } else { var tableName = value; var count = Dao.Count <Table>(y => y.Name == tableName.Trim()); if (count == 0) { var table = new Table { Name = value.Trim(), Category = currentCategory }; if (result.Count(x => x.Name.ToLower() == table.Name.ToLower()) == 0) { result.Add(table); workspace.Add(table); } } } } } return(result); }
public void SaveOrUpdateEntity <T>(T item) where T : class { IEntity entity = (IEntity)item; if (entity.Id == 0) { _workspace.Add <T>(item); } else { _workspace.Update <T>(item); } try { _workspace.CommitChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; } _workspace.Refresh(item); }
public ProgramSetting GetSetting(string valueName) { var setting = _workspace.Single <ProgramSettingValue>(x => x.Name == valueName); if (_settingCache.ContainsKey(valueName)) { if (setting == null) { setting = _settingCache[valueName]; } else { _settingCache.Remove(valueName); } } if (setting == null) { setting = new ProgramSettingValue { Name = valueName }; _settingCache.Add(valueName, setting); _workspace.Add(setting); } return(new ProgramSetting(setting)); }
private void ImportItems <T>(Func <string[], IWorkspace, IEnumerable <T> > func) where T : class { var fileName = string.Format("{0}\\Imports\\" + typeof(T).Name.ToLower() + "{1}.txt", LocalSettings.AppPath, "_" + LocalSettings.CurrentLanguage); if (!File.Exists(fileName)) { fileName = string.Format("{0}\\Imports\\" + typeof(T).Name.ToLower() + ".txt", LocalSettings.AppPath); } if (!File.Exists(fileName)) { return; } var lines = File.ReadAllLines(fileName); var items = func(lines, _workspace); items.ToList().ForEach(x => _workspace.Add(x)); _workspace.CommitChanges(); }
private void OnAddTicketTagExecuted(string obj) { var ti = new TicketTag { Name = Resources.NewTag }; _workspace.Add(ti); Model.TicketTags.Add(ti); TicketTags.Add(new TicketTagViewModel(ti)); }
public Task CreateAsync(Role role) { if (role == null) { throw new ArgumentNullException("role"); } _workspace.Add(role); _workspace.SaveChanges(); return(Task.FromResult(0)); }
private void RestartWorkperiod(IWorkspace workspace) { WorkPeriodService.StopWorkPeriod(""); Thread.Sleep(1); var pc = InventoryService.GetCurrentPeriodicConsumption(); InventoryService.SavePeriodicConsumption(pc); foreach (var warehouseConsumption in pc.WarehouseConsumptions) { warehouseConsumption.PeriodicConsumptionId = pc.Id; workspace.Add(warehouseConsumption); warehouseConsumption.PeriodicConsumptionItems.ToList().ForEach(x => { x.WarehouseConsumptionId = warehouseConsumption.Id; workspace.Add(x); }); } WorkPeriodService.StartWorkPeriod(""); }
public IEnumerable<Reason> BatchCreateReasons(string[] values, int reasonType, IWorkspace workspace) { IList<Reason> result = new List<Reason>(); if (values.Length > 0) { foreach (var reason in values.Select(value => new Reason { Name = value, ReasonType = reasonType })) { workspace.Add(reason); result.Add(reason); } } return result; }
private PrinterTemplate AddDefaultPrintersAndTerminal() { var customerReceiptTemplate = new PrinterTemplate { Name = Resources.CustomerReceiptTemplate, Template = DataCreationService.GetDefaultCustomerReceiptTemplate() }; _workspace.Add(customerReceiptTemplate); var printer1 = new Printer { Name = Resources.TicketPrinter }; _workspace.Add(printer1); _workspace.CommitChanges(); var t = new Terminal { IsDefault = true, Name = Resources.Server, ReportPrinterId = printer1.Id, TransactionPrinterId = printer1.Id, }; var pm1 = new PrinterMap { PrinterId = printer1.Id, PrinterTemplateId = customerReceiptTemplate.Id }; _workspace.Add(pm1); var pj1 = new PrintJob { Name = Resources.PrintBill, WhatToPrint = (int)WhatToPrintTypes.Everything, }; pj1.PrinterMaps.Add(pm1); _workspace.Add(pj1); _workspace.Add(t); return(customerReceiptTemplate); }
public void SaveOrUpdateEntity <T>(T item) where T : class { IEntity entity = (IEntity)item; if (entity.Id == 0) { _workspace.Add <T>(item); } else { _workspace.Update <T>(item); } _workspace.CommitChanges(); }
protected override void OnSave(string value) { foreach (var printerMap in _printerMaps) { if (printerMap.Department == Department.All) { printerMap.Department = null; } if (printerMap.MenuItem == MenuItem.All) { printerMap.MenuItem = null; } if (printerMap.MenuItemGroupCode == "*") { printerMap.MenuItemGroupCode = null; } if (printerMap.TicketTag == "*") { printerMap.TicketTag = null; } } foreach (var newPrinterMap in _newPrinterMaps) { if (newPrinterMap.Printer != null) { if (newPrinterMap.Department == Department.All) { newPrinterMap.Department = null; } if (newPrinterMap.MenuItem == MenuItem.All) { newPrinterMap.MenuItem = null; } if (newPrinterMap.MenuItemGroupCode == "*") { newPrinterMap.MenuItemGroupCode = null; } if (newPrinterMap.TicketTag == "*") { newPrinterMap.TicketTag = null; } _workspace.Add(newPrinterMap); } } base.OnSave(value); _newPrinterMaps.Clear(); }
public IEnumerable <Reason> BatchCreateReasons(string[] values, int reasonType, IWorkspace workspace) { IList <Reason> result = new List <Reason>(); if (values.Length > 0) { foreach (var reason in values.Select(value => new Reason { Name = value, ReasonType = reasonType })) { workspace.Add(reason); result.Add(reason); } } return(result); }
public void StartWorkPeriod(string description, IWorkspace workspace) { var latestWorkPeriod = workspace.Last<WorkPeriod>(); if (latestWorkPeriod != null && latestWorkPeriod.StartDate == latestWorkPeriod.EndDate) { return; } var now = DateTime.Now; var newPeriod = new WorkPeriod { StartDate = now, EndDate = now, StartDescription = description, }; workspace.Add(newPeriod); workspace.CommitChanges(); }
public void StartWorkPeriod(string description, IWorkspace workspace) { var latestWorkPeriod = workspace.Last <WorkPeriod>(); if (latestWorkPeriod != null && latestWorkPeriod.StartDate == latestWorkPeriod.EndDate) { return; } var now = DateTime.Now; var newPeriod = new WorkPeriod { StartDate = now, EndDate = now, StartDescription = description, }; workspace.Add(newPeriod); workspace.CommitChanges(); }
public SettingGetter GetSetting(string valueName) { ProgramSetting setting; try { setting = _workspace.Single <ProgramSetting>(x => x.Name == valueName); } catch (Exception) { _workspace.Delete <ProgramSetting>(x => x.Name == valueName); _workspace.CommitChanges(); setting = null; } if (_settingCache.ContainsKey(valueName)) { if (setting == null) { setting = _settingCache[valueName]; } else { _settingCache.Remove(valueName); } } if (setting == null) { setting = new ProgramSetting { Name = valueName }; _settingCache.Add(valueName, setting); _workspace.Add(setting); _workspace.CommitChanges(); } return(new SettingGetter(setting)); }
/// <summary> /// Adds the specified entity. /// </summary> /// <param name="entity">The entity.</param> /// <remarks></remarks> public virtual T Add(T entity) { return(_workspace.Add(entity)); }
public void GenerateSystemRules(IWorkspace workspace) { var closeTicketAutomation = new AutomationCommand { Name = Resources.CloseTicket, ButtonHeader = Resources.Close, SortOrder = -1, Color = "#FFFF0000", FontSize = 40 }; closeTicketAutomation.AutomationCommandMaps.Add(new AutomationCommandMap { EnabledStates = string.Format("{0},{1},{2},{3},IsClosed", Resources.New, Resources.NewOrders, Resources.Unpaid, Resources.Locked), VisibleStates = "*", DisplayUnderTicket = true }); workspace.Add(closeTicketAutomation); var settleAutomation = new AutomationCommand { Name = Resources.Settle, ButtonHeader = Resources.Settle, SortOrder = -2, FontSize = 40 }; settleAutomation.AutomationCommandMaps.Add(new AutomationCommandMap { EnabledStates = "*", VisibleStates = "*", DisplayUnderTicket = true }); workspace.Add(settleAutomation); var printBillAutomation = new AutomationCommand { Name = Resources.PrintBill, ButtonHeader = Resources.PrintBill, SortOrder = -1 }; printBillAutomation.AutomationCommandMaps.Add(new AutomationCommandMap { EnabledStates = Resources.NewOrders + "," + Resources.Unpaid + ",IsClosed", VisibleStates = "*", DisplayOnTicket = true, DisplayOnPayment = true }); workspace.Add(printBillAutomation); var unlockTicketAutomation = new AutomationCommand { Name = Resources.UnlockTicket, ButtonHeader = Resources.UnlockTicket, SortOrder = -1 }; unlockTicketAutomation.AutomationCommandMaps.Add(new AutomationCommandMap { EnabledStates = Resources.Locked, VisibleStates = Resources.Locked, DisplayOnTicket = true }); workspace.Add(unlockTicketAutomation); var addTicketAutomation = new AutomationCommand { Name = string.Format(Resources.Add_f, Resources.Ticket), ButtonHeader = string.Format(Resources.Add_f, Resources.Ticket), SortOrder = -1 }; addTicketAutomation.AutomationCommandMaps.Add(new AutomationCommandMap { EnabledStates = string.Format("{0},{1}", Resources.Unpaid, Resources.Locked), VisibleStates = "*", DisplayOnTicket = true }); workspace.Add(addTicketAutomation); var giftItemAutomation = new AutomationCommand { Name = Resources.Gift, ButtonHeader = Resources.Gift, SortOrder = -1 }; giftItemAutomation.AutomationCommandMaps.Add(new AutomationCommandMap { EnabledStates = "GStatus=", VisibleStates = "GStatus=", DisplayOnOrders = true }); workspace.Add(giftItemAutomation); var cancelGiftItemAutomation = new AutomationCommand { Name = string.Format(Resources.Cancel_f, Resources.Gift), ButtonHeader = string.Format(Resources.Cancel_f, Resources.Gift), SortOrder = -1 }; cancelGiftItemAutomation.AutomationCommandMaps.Add(new AutomationCommandMap { EnabledStates = Resources.Gift, VisibleStates = Resources.Gift, DisplayOnOrders = true }); workspace.Add(cancelGiftItemAutomation); var voidItemAutomation = new AutomationCommand { Name = Resources.Void, ButtonHeader = Resources.Void, SortOrder = -1 }; voidItemAutomation.AutomationCommandMaps.Add(new AutomationCommandMap { EnabledStates = string.Format("GStatus={0}," + Resources.Submitted, Resources.Gift), VisibleStates = string.Format("GStatus=,GStatus={0}", Resources.Gift), DisplayOnOrders = true }); workspace.Add(voidItemAutomation); var cancelVoidItemAutomation = new AutomationCommand { Name = string.Format(Resources.Cancel_f, Resources.Void), ButtonHeader = string.Format(Resources.Cancel_f, Resources.Void), SortOrder = -1 }; cancelVoidItemAutomation.AutomationCommandMaps.Add(new AutomationCommandMap { EnabledStates = Resources.New, VisibleStates = Resources.Void, DisplayOnOrders = true }); workspace.Add(cancelVoidItemAutomation); var newOrderState = new State { Name = Resources.NewOrders, Color = "Orange", GroupName = "Status" }; workspace.Add(newOrderState); var availableState = new State { Name = Resources.Available, Color = "White", GroupName = "Status" }; workspace.Add(availableState); var billRequestedState = new State { Name = Resources.BillRequested, Color = "Maroon", GroupName = "Status" }; workspace.Add(billRequestedState); var giftStatus = new State { Name = Resources.Gift, GroupName = "GStatus", ShowOnEndOfDayReport = true, ShowOnProductReport = true, ShowOnTicket = true }; workspace.Add(giftStatus); var status = new State { Name = Resources.Status, GroupName = "Status", ShowOnEndOfDayReport = true, ShowOnProductReport = false, ShowOnTicket = true }; workspace.Add(status); var updateOrderAction = new AppAction { ActionType = ActionNames.UpdateOrder, Name = string.Format(Resources.Update_f, Resources.Order), Parameter = Params() .Add("IncreaseInventory", "[:Increase]").Add("DecreaseInventory", "[:Decrease]") .Add("CalculatePrice", "[:Calculate Price]").Add("Locked", "[:Locked]"). ToString(), SortOrder = -1 }; workspace.Add(updateOrderAction); var updateTicketStatusAction = new AppAction { ActionType = ActionNames.UpdateTicketState, Name = Resources.UpdateTicketStatus, Parameter = Params().Add("StateName", Resources.Status).Add("State", "[:Status]").Add("CurrentState", "[:Current Status]").ToString(), SortOrder = -1 }; workspace.Add(updateTicketStatusAction); var updateOrderStatusAction = new AppAction { ActionType = ActionNames.UpdateOrderState, Name = string.Format(Resources.Update_f, Resources.OrderStatus), Parameter = Params().Add("StateName", "Status").Add("State", "[:Status]").Add("CurrentState", "[:Current Status]").ToString(), SortOrder = -1 }; workspace.Add(updateOrderStatusAction); var updateOrderGiftStatusAction = new AppAction { ActionType = ActionNames.UpdateOrderState, Name = Resources.UpdateOrderGiftState, Parameter = Params() .Add("StateName", "GStatus").Add("GroupOrder", "1") .Add("CurrentState", "[:Current Status]").Add("State", "[:Status]") .Add("StateOrder", "1").Add("StateValue", "[:Value]") .ToString(), SortOrder = -1 }; workspace.Add(updateOrderGiftStatusAction); var updateEntityStateAction = new AppAction { ActionType = ActionNames.UpdateEntityState, Name = Resources.UpdateEntityState, Parameter = Params().Add("EntityStateName", "Status").Add("EntityState", "[:Status]").ToString(), SortOrder = -1 }; workspace.Add(updateEntityStateAction); var createTicketAction = new AppAction { ActionType = ActionNames.CreateTicket, Name = string.Format(Resources.Create_f, Resources.Ticket), Parameter = "", SortOrder = -1 }; workspace.Add(createTicketAction); var closeTicketAction = new AppAction { ActionType = ActionNames.CloseActiveTicket, Name = Resources.CloseTicket, Parameter = "", SortOrder = -1 }; workspace.Add(closeTicketAction); var displayPaymentScreenAction = new AppAction { ActionType = ActionNames.DisplayPaymentScreen, Name = Resources.DisplayPaymentScreen, Parameter = "", SortOrder = -1 }; workspace.Add(displayPaymentScreenAction); var printBillAction = new AppAction { ActionType = ActionNames.ExecutePrintJob, Name = Resources.ExecutePrintBillJob, Parameter = Params().Add("PrintJobName", Resources.PrintBill).ToString(), SortOrder = -1 }; workspace.Add(printBillAction); var printKitchenOrdersAction = new AppAction { ActionType = ActionNames.ExecutePrintJob, Name = Resources.ExecuteKitchenOrdersPrintJob, Parameter = Params().Add("PrintJobName", Resources.PrintOrdersToKitchenPrinter).Add("OrderStateName", "Status").Add("OrderState", Resources.New).ToString(), SortOrder = -1 }; workspace.Add(printKitchenOrdersAction); var lockTicketAction = new AppAction { ActionType = ActionNames.LockTicket, Name = Resources.LockTicket, Parameter = "", SortOrder = -1 }; workspace.Add(lockTicketAction); var unlockTicketAction = new AppAction { ActionType = ActionNames.UnlockTicket, Name = Resources.UnlockTicket, Parameter = "", SortOrder = -1 }; workspace.Add(unlockTicketAction); var markTicketAsClosed = new AppAction { ActionType = ActionNames.MarkTicketAsClosed, Name = Resources.MarkTicketAsClosed, Parameter = "", SortOrder = -1 }; workspace.Add(markTicketAsClosed); workspace.CommitChanges(); var newTicketRule = new AppRule { Name = Resources.NewTicketCreatingRule, EventName = RuleEventNames.TicketCreated, SortOrder = -1 }; newTicketRule.Actions.Add(new ActionContainer(updateTicketStatusAction) { ParameterValues = string.Format("Status={0}", Resources.New) }); newTicketRule.AddRuleMap(); workspace.Add(newTicketRule); var newOrderAddingRule = new AppRule { Name = Resources.NewOrderAddingRule, EventName = RuleEventNames.OrderAdded, SortOrder = -1 }; newOrderAddingRule.Actions.Add(new ActionContainer(updateTicketStatusAction) { ParameterValues = string.Format("Status={0}", Resources.NewOrders) }); newOrderAddingRule.Actions.Add(new ActionContainer(updateOrderStatusAction) { ParameterValues = string.Format("Status={0}", Resources.New) }); newOrderAddingRule.AddRuleMap(); workspace.Add(newOrderAddingRule); var ticketPayCheckRule = new AppRule { Name = Resources.TicketPaymentCheck, EventName = RuleEventNames.BeforeTicketClosing, EventConstraints = "RemainingAmount;=;0", SortOrder = -1 }; ticketPayCheckRule.Actions.Add(new ActionContainer(updateTicketStatusAction) { ParameterValues = "Status=" + Resources.Paid }); ticketPayCheckRule.Actions.Add(new ActionContainer(markTicketAsClosed)); ticketPayCheckRule.AddRuleMap(); workspace.Add(ticketPayCheckRule); var ticketMovedRule = new AppRule { Name = Resources.TicketMovedRule, EventName = RuleEventNames.TicketMoved, SortOrder = -1 }; ticketMovedRule.Actions.Add(new ActionContainer(updateTicketStatusAction) { ParameterValues = string.Format("Status={0}", Resources.NewOrders) }); ticketMovedRule.AddRuleMap(); workspace.Add(ticketMovedRule); var ticketClosingRule = new AppRule { Name = string.Format(Resources.Rule_f, Resources.TicketClosing), EventName = RuleEventNames.TicketClosing, SortOrder = -1 }; ticketClosingRule.Actions.Add(new ActionContainer(printKitchenOrdersAction)); ticketClosingRule.Actions.Add(new ActionContainer(updateTicketStatusAction) { ParameterValues = string.Format("Status={0}#Current Status={1}", Resources.Unpaid, Resources.NewOrders) }); ticketClosingRule.Actions.Add(new ActionContainer(updateOrderStatusAction) { ParameterValues = string.Format("Status={0}#Current Status={1}", Resources.Submitted, Resources.New) }); ticketClosingRule.AddRuleMap(); workspace.Add(ticketClosingRule); var giftOrderRule = new AppRule { Name = string.Format(Resources.Rule_f, Resources.Gift), EventName = RuleEventNames.AutomationCommandExecuted, EventConstraints = string.Format("AutomationCommandName;=;{0}", giftItemAutomation.Name), SortOrder = -1 }; giftOrderRule.Actions.Add(new ActionContainer(updateOrderAction) { ParameterValues = "Decrease=True#Calculate Price=False" }); giftOrderRule.Actions.Add(new ActionContainer(updateOrderGiftStatusAction) { ParameterValues = string.Format("Status={0}#Value=[:Value]", Resources.Gift) }); giftOrderRule.AddRuleMap(); workspace.Add(giftOrderRule); var cancelGiftOrderRule = new AppRule { Name = string.Format(Resources.Rule_f, string.Format(Resources.Cancel_f, Resources.Gift)), EventName = RuleEventNames.AutomationCommandExecuted, EventConstraints = string.Format("AutomationCommandName;=;{0}", cancelGiftItemAutomation.Name), SortOrder = -1 }; cancelGiftOrderRule.Actions.Add(new ActionContainer(updateOrderAction) { ParameterValues = "Decrease=True#Calculate Price=True" }); cancelGiftOrderRule.Actions.Add(new ActionContainer(updateOrderGiftStatusAction) { ParameterValues = string.Format("Current Status={0}#Status=#Value=", Resources.Gift) }); cancelGiftOrderRule.AddRuleMap(); workspace.Add(cancelGiftOrderRule); var voidOrderRule = new AppRule { Name = string.Format(Resources.Rule_f, Resources.Void), EventName = RuleEventNames.AutomationCommandExecuted, EventConstraints = string.Format("AutomationCommandName;=;{0}", voidItemAutomation.Name), SortOrder = -1 }; voidOrderRule.Actions.Add(new ActionContainer(updateOrderAction) { ParameterValues = "Decrease=False#Calculate Price=False" }); voidOrderRule.Actions.Add(new ActionContainer(updateOrderGiftStatusAction) { ParameterValues = string.Format("Status={0}#Value=[:Value]", Resources.Void) }); voidOrderRule.Actions.Add(new ActionContainer(updateOrderStatusAction) { ParameterValues = string.Format("Status={0}", Resources.New) }); voidOrderRule.AddRuleMap(); workspace.Add(voidOrderRule); var cancelVoidOrderRule = new AppRule { Name = string.Format(Resources.Rule_f, string.Format(Resources.Cancel_f, Resources.Void)), EventName = RuleEventNames.AutomationCommandExecuted, EventConstraints = string.Format("AutomationCommandName;=;{0}", cancelVoidItemAutomation.Name), SortOrder = -1 }; cancelVoidOrderRule.Actions.Add(new ActionContainer(updateOrderAction) { ParameterValues = "Decrease=True#Calculate Price=True" }); cancelVoidOrderRule.Actions.Add(new ActionContainer(updateOrderGiftStatusAction) { ParameterValues = string.Format("Current Status={0}#Status=#Value=", Resources.Void) }); cancelVoidOrderRule.Actions.Add(new ActionContainer(updateOrderStatusAction) { ParameterValues = string.Format("Status={0}", Resources.Submitted) }); cancelVoidOrderRule.AddRuleMap(); workspace.Add(cancelVoidOrderRule); var newOrderRule = new AppRule { Name = Resources.UpdateNewOrderEntityColor, EventName = RuleEventNames.TicketStateUpdated, EventConstraints = "State;=;" + Resources.Unpaid, SortOrder = -1 }; newOrderRule.Actions.Add(new ActionContainer(updateEntityStateAction) { ParameterValues = "Status=" + Resources.NewOrders }); newOrderRule.AddRuleMap(); workspace.Add(newOrderRule); var availableRule = new AppRule { Name = Resources.UpdateAvailableEntityColor, EventName = RuleEventNames.EntityUpdated, EventConstraints = "OpenTicketCount;=;0", SortOrder = -1 }; var ac2 = new ActionContainer(updateEntityStateAction) { ParameterValues = string.Format("Status={0}", Resources.Available) }; availableRule.Actions.Add(ac2); availableRule.AddRuleMap(); workspace.Add(availableRule); var movingRule = new AppRule { Name = Resources.UpdateMovedEntityColor, EventName = "TicketEntityChanged", EventConstraints = "OrderCount;>;0", SortOrder = -1 }; var ac3 = new ActionContainer(updateEntityStateAction) { ParameterValues = string.Format("Status={0}", Resources.NewOrders) }; movingRule.Actions.Add(ac3); movingRule.AddRuleMap(); workspace.Add(movingRule); var printBillRule = new AppRule { Name = string.Format(Resources.Rule_f, Resources.PrintBill), EventName = RuleEventNames.AutomationCommandExecuted, EventConstraints = "AutomationCommandName;=;" + Resources.PrintBill, SortOrder = -1 }; printBillRule.Actions.Add(new ActionContainer(printBillAction)); printBillRule.Actions.Add(new ActionContainer(lockTicketAction)); printBillRule.Actions.Add(new ActionContainer(updateEntityStateAction) { ParameterValues = string.Format("Status={0}", Resources.BillRequested) }); printBillRule.Actions.Add(new ActionContainer(updateTicketStatusAction) { ParameterValues = string.Format("Status={0}", Resources.Locked) }); printBillRule.Actions.Add(new ActionContainer(closeTicketAction)); printBillRule.AddRuleMap(); workspace.Add(printBillRule); var unlockTicketRule = new AppRule { Name = string.Format(Resources.Rule_f, Resources.UnlockTicket), EventName = RuleEventNames.AutomationCommandExecuted, EventConstraints = "AutomationCommandName;=;" + Resources.UnlockTicket, SortOrder = -1 }; unlockTicketRule.Actions.Add(new ActionContainer(unlockTicketAction)); unlockTicketRule.Actions.Add(new ActionContainer(updateTicketStatusAction) { ParameterValues = string.Format("Status={0}", Resources.Unpaid) }); unlockTicketRule.AddRuleMap(); workspace.Add(unlockTicketRule); var createTicketRule = new AppRule { Name = string.Format(Resources.Rule_f, string.Format(Resources.Create_f, Resources.Ticket)), EventName = RuleEventNames.AutomationCommandExecuted, EventConstraints = "AutomationCommandName;=;" + string.Format(Resources.Add_f, Resources.Ticket), SortOrder = -1 }; createTicketRule.Actions.Add(new ActionContainer(createTicketAction)); createTicketRule.AddRuleMap(); workspace.Add(createTicketRule); var updateMergedTicket = new AppRule { Name = Resources.UpdateMergedTicketsState, EventName = RuleEventNames.TicketsMerged, SortOrder = -1 }; updateMergedTicket.Actions.Add(new ActionContainer(updateEntityStateAction) { ParameterValues = string.Format("Status={0}", Resources.NewOrders) }); updateMergedTicket.Actions.Add(new ActionContainer(updateTicketStatusAction) { ParameterValues = string.Format("Status={0}", Resources.NewOrders) }); updateMergedTicket.AddRuleMap(); workspace.Add(updateMergedTicket); var closeTicketRule = new AppRule { Name = string.Format(Resources.Rule_f, Resources.CloseTicket), EventName = RuleEventNames.AutomationCommandExecuted, EventConstraints = "AutomationCommandName;=;" + Resources.CloseTicket, SortOrder = -1 }; closeTicketRule.Actions.Add(new ActionContainer(closeTicketAction)); closeTicketRule.AddRuleMap(); workspace.Add(closeTicketRule); var settleTicketRule = new AppRule { Name = string.Format(Resources.Rule_f, Resources.Settle), EventName = RuleEventNames.AutomationCommandExecuted, EventConstraints = "AutomationCommandName;=;" + Resources.Settle, SortOrder = -1 }; settleTicketRule.Actions.Add(new ActionContainer(displayPaymentScreenAction)); settleTicketRule.AddRuleMap(); workspace.Add(settleTicketRule); workspace.CommitChanges(); }
public IEnumerable<Table> BatchCreateTables(string[] values, IWorkspace workspace) { IList<Table> result = new List<Table>(); if (values.Length > 0) { var currentCategory = Resources.Common; foreach (var value in values) { if (value.StartsWith("#")) { currentCategory = value.Trim('#', ' '); } else { var tableName = value; var count = Dao.Count<Table>(y => y.Name == tableName.Trim()); if (count == 0) { var table = new Table { Name = value.Trim(), Category = currentCategory }; if (result.Count(x => x.Name.ToLower() == table.Name.ToLower()) == 0) { result.Add(table); workspace.Add(table); } } } } } return result; }
public void CreateData() { CreateDefaultCurrenciesIfNeeded(); if (!ShouldCreateData()) { return; } var saleAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Sales) }; var receivableAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Receiveable) }; var paymentAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Payment) }; var discountAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Discount) }; var customerAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Customer) }; _workspace.Add(receivableAccountType); _workspace.Add(saleAccountType); _workspace.Add(paymentAccountType); _workspace.Add(discountAccountType); _workspace.Add(customerAccountType); _workspace.CommitChanges(); var customerEntityType = new EntityType { Name = Resources.Customers, EntityName = Resources.Customer, AccountTypeId = customerAccountType.Id, PrimaryFieldName = Resources.Name }; customerEntityType.EntityCustomFields.Add(new EntityCustomField { EditingFormat = "(###) ### ####", FieldType = 0, Name = Resources.Phone }); customerEntityType.AccountNameTemplate = "[Name]-[" + Resources.Phone + "]"; var tableEntityType = new EntityType { Name = Resources.Tables, EntityName = Resources.Table, PrimaryFieldName = Resources.Name }; _workspace.Add(customerEntityType); _workspace.Add(tableEntityType); _workspace.CommitChanges(); var accountScreen = new AccountScreen { Name = Resources.General }; accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = saleAccountType.Name, AccountTypeId = saleAccountType.Id, DisplayDetails = true, SortOrder = 10 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = receivableAccountType.Name, AccountTypeId = receivableAccountType.Id, DisplayDetails = true, SortOrder = 20 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = discountAccountType.Name, AccountTypeId = discountAccountType.Id, DisplayDetails = true, SortOrder = 30 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = paymentAccountType.Name, AccountTypeId = paymentAccountType.Id, DisplayDetails = true, SortOrder = 40 }); _workspace.Add(accountScreen); var defaultSaleAccount = new Account { AccountTypeId = saleAccountType.Id, Name = Resources.Sales }; var defaultReceivableAccount = new Account { AccountTypeId = receivableAccountType.Id, Name = Resources.Receivables }; var cashAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.Cash }; var creditCardAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.CreditCard }; var voucherAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.Voucher }; var defaultDiscountAccount = new Account { AccountTypeId = discountAccountType.Id, Name = Resources.Discount }; var defaultRoundingAccount = new Account { AccountTypeId = discountAccountType.Id, Name = Resources.Rounding }; _workspace.Add(defaultSaleAccount); _workspace.Add(defaultReceivableAccount); _workspace.Add(defaultDiscountAccount); _workspace.Add(defaultRoundingAccount); _workspace.Add(cashAccount); _workspace.Add(creditCardAccount); _workspace.Add(voucherAccount); _workspace.CommitChanges(); var discountTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Discount), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = defaultDiscountAccount.Id }; var roundingTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Rounding), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = defaultRoundingAccount.Id }; var saleTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Sale), SourceAccountTypeId = saleAccountType.Id, TargetAccountTypeId = receivableAccountType.Id, DefaultSourceAccountId = defaultSaleAccount.Id, DefaultTargetAccountId = defaultReceivableAccount.Id }; var paymentTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Payment), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = cashAccount.Id }; var customerAccountTransactionType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.AccountTransaction), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = customerAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id }; var customerCashPaymentType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.CashPayment), SourceAccountTypeId = customerAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultTargetAccountId = cashAccount.Id }; var customerCreditCardPaymentType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.CreditCardPayment), SourceAccountTypeId = customerAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultTargetAccountId = creditCardAccount.Id }; _workspace.Add(saleTransactionType); _workspace.Add(paymentTransactionType); _workspace.Add(discountTransactionType); _workspace.Add(roundingTransactionType); _workspace.Add(customerAccountTransactionType); _workspace.Add(customerCashPaymentType); _workspace.Add(customerCreditCardPaymentType); var discountService = new CalculationType { AccountTransactionType = discountTransactionType, CalculationMethod = 0, DecreaseAmount = true, Name = Resources.Discount }; var roundingService = new CalculationType { AccountTransactionType = roundingTransactionType, CalculationMethod = 2, DecreaseAmount = true, IncludeTax = true, Name = Resources.Round }; var discountSelector = new CalculationSelector { Name = Resources.Discount, ButtonHeader = Resources.DiscountPercentSign }; discountSelector.CalculationTypes.Add(discountService); discountSelector.AddCalculationSelectorMap(); var roundingSelector = new CalculationSelector { Name = Resources.Round, ButtonHeader = Resources.Round }; roundingSelector.CalculationTypes.Add(roundingService); roundingSelector.AddCalculationSelectorMap(); _workspace.Add(discountService); _workspace.Add(roundingService); _workspace.Add(discountSelector); _workspace.Add(roundingSelector); var screen = new ScreenMenu(); _workspace.Add(screen); var ticketNumerator = new Numerator { Name = Resources.TicketNumerator }; _workspace.Add(ticketNumerator); var orderNumerator = new Numerator { Name = Resources.OrderNumerator }; _workspace.Add(orderNumerator); _workspace.CommitChanges(); var ticketType = new TicketType { Name = Resources.Ticket, TicketNumerator = ticketNumerator, OrderNumerator = orderNumerator, SaleTransactionType = saleTransactionType, ScreenMenuId = screen.Id, }; ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment { EntityTypeId = tableEntityType.Id, EntityTypeName = tableEntityType.Name, SortOrder = 10 }); ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment { EntityTypeId = customerEntityType.Id, EntityTypeName = customerEntityType.Name, SortOrder = 20 }); var cashPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = cashAccount, Name = cashAccount.Name }; cashPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var creditCardPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = creditCardAccount, Name = creditCardAccount.Name }; creditCardPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var voucherPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = voucherAccount, Name = voucherAccount.Name }; voucherPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var accountPayment = new PaymentType { AccountTransactionType = customerAccountTransactionType, Name = Resources.CustomerAccount }; accountPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); _workspace.Add(cashPayment); _workspace.Add(creditCardPayment); _workspace.Add(voucherPayment); _workspace.Add(accountPayment); _workspace.Add(ticketType); var warehouseType = new WarehouseType { Name = Resources.Warehouses }; _workspace.Add(warehouseType); _workspace.CommitChanges(); var localWarehouse = new Warehouse { Name = Resources.LocalWarehouse, WarehouseTypeId = warehouseType.Id }; _workspace.Add(localWarehouse); _workspace.CommitChanges(); var department = new Department { Name = Resources.Restaurant, TicketTypeId = ticketType.Id, WarehouseId = localWarehouse.Id }; _workspace.Add(department); var transactionType = new InventoryTransactionType { Name = Resources.PurchaseTransactionType, TargetWarehouseTypeId = warehouseType.Id, DefaultTargetWarehouseId = localWarehouse.Id }; _workspace.Add(transactionType); var transactionDocumentType = new InventoryTransactionDocumentType { Name = Resources.PurchaseTransaction, InventoryTransactionType = transactionType }; _workspace.Add(transactionDocumentType); var role = new UserRole("Admin") { IsAdmin = true, DepartmentId = 1 }; _workspace.Add(role); var u = new User("Administrator", "1234") { UserRole = role }; _workspace.Add(u); var ticketPrinterTemplate = new PrinterTemplate { Name = Resources.TicketTemplate, Template = GetDefaultTicketPrintTemplate() }; var kitchenPrinterTemplate = new PrinterTemplate { Name = Resources.KitchenOrderTemplate, Template = GetDefaultKitchenPrintTemplate() }; var customerReceiptTemplate = new PrinterTemplate { Name = Resources.CustomerReceiptTemplate, Template = GetDefaultCustomerReceiptTemplate() }; _workspace.Add(ticketPrinterTemplate); _workspace.Add(kitchenPrinterTemplate); _workspace.Add(customerReceiptTemplate); var printer1 = new Printer { Name = Resources.TicketPrinter }; var printer2 = new Printer { Name = Resources.KitchenPrinter }; var printer3 = new Printer { Name = Resources.InvoicePrinter }; _workspace.Add(printer1); _workspace.Add(printer2); _workspace.Add(printer3); _workspace.CommitChanges(); var t = new Terminal { IsDefault = true, Name = Resources.Server, ReportPrinterId = printer1.Id, TransactionPrinterId = printer1.Id, }; var pm1 = new PrinterMap { PrinterId = printer1.Id, PrinterTemplateId = ticketPrinterTemplate.Id }; _workspace.Add(pm1); var pj1 = new PrintJob { Name = Resources.PrintBill, WhatToPrint = (int)WhatToPrintTypes.Everything, }; pj1.PrinterMaps.Add(pm1); _workspace.Add(pj1); var pm2 = new PrinterMap { PrinterId = printer2.Id, PrinterTemplateId = kitchenPrinterTemplate.Id }; var pj2 = new PrintJob { Name = Resources.PrintOrdersToKitchenPrinter, WhatToPrint = (int)WhatToPrintTypes.Everything, }; pj2.PrinterMaps.Add(pm2); _workspace.Add(pj2); _workspace.Add(t); new RuleGenerator().GenerateSystemRules(_workspace); ImportMenus(screen); ImportTableResources(tableEntityType, ticketType); var customerScreen = new EntityScreen { Name = string.Format(Resources.Customer_f, Resources.Search), DisplayMode = 1, EntityTypeId = customerEntityType.Id, TicketTypeId = ticketType.Id }; customerScreen.EntityScreenMaps.Add(new EntityScreenMap()); _workspace.Add(customerScreen); var customerTicketScreen = new EntityScreen { Name = Resources.CustomerTickets, DisplayMode = 0, EntityTypeId = customerEntityType.Id, StateFilter = Resources.NewOrders, ColumnCount = 6, RowCount = 6, TicketTypeId = ticketType.Id }; customerTicketScreen.EntityScreenMaps.Add(new EntityScreenMap()); _workspace.Add(customerTicketScreen); var customerCashDocument = new AccountTransactionDocumentType { Name = string.Format(Resources.Customer_f, Resources.Cash), ButtonHeader = Resources.Cash, DefaultAmount = string.Format("[{0}]", Resources.Balance), DescriptionTemplate = string.Format(Resources.Payment_f, Resources.Cash), MasterAccountTypeId = customerAccountType.Id, PrinterTemplateId = customerReceiptTemplate.Id }; customerCashDocument.AddAccountTransactionDocumentTypeMap(); customerCashDocument.TransactionTypes.Add(customerCashPaymentType); var customerCreditCardDocument = new AccountTransactionDocumentType { Name = string.Format(Resources.Customer_f, Resources.CreditCard), ButtonHeader = Resources.CreditCard, DefaultAmount = string.Format("[{0}]", Resources.Balance), DescriptionTemplate = string.Format(Resources.Payment_f, Resources.CreditCard), MasterAccountTypeId = customerAccountType.Id, PrinterTemplateId = customerReceiptTemplate.Id }; customerCreditCardDocument.AddAccountTransactionDocumentTypeMap(); customerCreditCardDocument.TransactionTypes.Add(customerCreditCardPaymentType); _workspace.Add(customerCashDocument); _workspace.Add(customerCreditCardDocument); ImportItems(BatchCreateEntities); ImportItems(BatchCreateTransactionTypes); ImportItems(BatchCreateTransactionTypeDocuments); _workspace.CommitChanges(); _workspace.Dispose(); }
public async Task <bool> Execute(IWorkspace workspace, object arg) { var drawingPlane = workspace.DrawingPlane; var distance = await workspace.InputService.GetDistance(defaultDistance : lastOffsetDistance); if (distance.Cancel) { return(false); } double dist; if (distance.HasValue) { dist = distance.Value; } else { dist = lastOffsetDistance; } workspace.OutputService.WriteLine("Using offset distance of {0}", dist); lastOffsetDistance = dist; var selection = await workspace.InputService.GetEntity(new UserDirective("Select entity")); while (!selection.Cancel && selection.HasValue) { var ent = selection.Value.Entity; if (!EditUtilities.CanOffsetEntity(ent)) { workspace.OutputService.WriteLine("Unable to offset {0}", ent.Kind); selection = await workspace.InputService.GetEntity(new UserDirective("Select entity")); continue; } if (!drawingPlane.Contains(ent)) { workspace.OutputService.WriteLine("Entity must be entirely on the drawing plane to offset"); selection = await workspace.InputService.GetEntity(new UserDirective("Select entity")); continue; } workspace.SelectedEntities.Clear(); workspace.SelectedEntities.Add(ent); var point = await workspace.InputService.GetPoint(new UserDirective("Side to offset")); if (point.Cancel || !point.HasValue) { break; } if (!drawingPlane.Contains(point.Value)) { workspace.OutputService.WriteLine("Point must be on the drawing plane to offset"); selection = await workspace.InputService.GetEntity(new UserDirective("Select entity")); continue; } // do the actual offset var updated = EditUtilities.Offset(workspace, ent, point.Value, dist); if (updated != null) { var oldLayer = workspace.Drawing.ContainingLayer(ent); workspace.Add(oldLayer, updated); } workspace.SelectedEntities.Clear(); selection = await workspace.InputService.GetEntity(new UserDirective("Select entity")); } return(true); }
public void CanFormatTicket() { WorkspaceFactory.SetDefaultConnectionString("c:\\testData.txt"); IWorkspace workspace = WorkspaceFactory.Create(); Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture; var user = new User("Emre", "1"); workspace.Add(user); var menuItem1 = MenuItem.Create(); menuItem1.Name = "Kurufasülye"; menuItem1.Portions[0].Price.Amount = 5; var menuItem2 = MenuItem.Create(); menuItem2.Name = "Pilav"; menuItem2.Portions[0].Price.Amount = 3; menuItem2.AddPortion("Az", 1, "TL"); workspace.Add(menuItem1); workspace.Add(menuItem2); var d = new Department(); var ticket = Ticket.Create(d); ticket.AddTicketItem(user.Id, menuItem1, "Normal"); ticket.AddTicketItem(user.Id, menuItem2, "Normal"); ticket.Date = new DateTime(2010, 1, 1); ticket.AddTicketDiscount(DiscountType.Amount, 1, user.Id); var template = new PrinterTemplate(); template.HeaderTemplate = @"SAMBA Adisyon Tarihi:{ADİSYON TARİH} [Müşteri Adı: {MÜŞTERİ ADI}]"; template.LineTemplate = @"{MİKTAR} {ÜRÜN} {FİYAT}"; template.FooterTemplate = @"{VARSA İSKONTO} [<C>İkram: {TOPLAM İKRAM}, teşekkürler] [Toplam: {TOPLAM BAKİYE}]"; var formatResult = TicketFormatter.GetFormattedTicket(ticket, ticket.GetUnlockedLines(), template); var expectedResult = @"SAMBA Adisyon Tarihi:01.01.2010 1 Kurufasülye 5,00 1 Pilav 3,00 Belge TOPLAMI:|8,00 <J>İskonto:|1,00 Toplam: 7,00"; var result = string.Join("\r\n", formatResult); Assert.IsTrue(result == expectedResult); template.MergeLines = true; formatResult = TicketFormatter.GetFormattedTicket(ticket, ticket.GetUnlockedLines(), template); result = string.Join("\r\n", formatResult); Assert.AreEqual(expectedResult, result); var l1 = ticket.AddTicketItem(user.Id, menuItem1, "Normal"); l1.Quantity = 5; var l2 = ticket.AddTicketItem(user.Id, menuItem2, "Az"); formatResult = TicketFormatter.GetFormattedTicket(ticket, ticket.GetUnlockedLines(), template); result = string.Join("\r\n", formatResult); expectedResult = @"SAMBA Adisyon Tarihi:01.01.2010 1 Pilav 3,00 6 Kurufasülye 5,00 1 Pilav.Az 1,00 Belge TOPLAMI:|34,00 <J>İskonto:|1,00 Toplam: 33,00"; Assert.AreEqual(expectedResult, result); var c = new Customer { Name = "Emre EREN" }; workspace.Add(c); ticket.CustomerId = c.Id; ticket.CustomerName = c.Name; ticket.AddTicketDiscount(DiscountType.Amount, 0, user.Id); formatResult = TicketFormatter.GetFormattedTicket(ticket, ticket.GetUnlockedLines(), template); expectedResult = @"SAMBA Adisyon Tarihi:01.01.2010 Müşteri Adı: Emre EREN 1 Pilav 3,00 6 Kurufasülye 5,00 1 Pilav.Az 1,00 Toplam: 34,00"; result = string.Join("\r\n", formatResult); Assert.IsTrue(result == expectedResult); l2.Gifted = true; template.GiftLineTemplate = "{MİKTAR} {ÜRÜN} İKRAM"; expectedResult = @"SAMBA Adisyon Tarihi:01.01.2010 Müşteri Adı: Emre EREN 1 Pilav 3,00 6 Kurufasülye 5,00 1 Pilav.Az İKRAM <C>İkram: 1,00, teşekkürler Toplam: 33,00"; formatResult = TicketFormatter.GetFormattedTicket(ticket, ticket.GetUnlockedLines(), template); result = string.Join("\r\n", formatResult); Assert.IsTrue(result == expectedResult); }
public static void AddLayer(this IWorkspace workspace, string layerName) { workspace.Add(new Layer(layerName)); }
private static void CreateWarehouseTestContext(WarehouseTestContext testContext, IWorkspace workspace) { workspace.Delete<InventoryTransactionType>(x => x.Id > 0); workspace.Delete<Entity>(x => x.Id > 0); testContext.Iskender = workspace.Single<MenuItem>(x => x.Name == "İskender"); testContext.Iskender.Portions[0].MenuItemId = testContext.Iskender.Id; testContext.DonerEti = new InventoryItem { Name = "Döner Eti", BaseUnit = "GR", GroupCode = "", TransactionUnit = "KG", TransactionUnitMultiplier = 1000 }; testContext.Yogurt = new InventoryItem { Name = "Yoğurt", BaseUnit = "GR", GroupCode = "", TransactionUnit = "KG", TransactionUnitMultiplier = 1000 }; testContext.Pide = new InventoryItem { Name = "Pide", BaseUnit = "Yarım", GroupCode = "", TransactionUnit = "Adet", TransactionUnitMultiplier = 2 }; testContext.ZeytinYagi = new InventoryItem { Name = "Zeytin Yağı", BaseUnit = "Ölçü", GroupCode = "", TransactionUnit = "Litre", TransactionUnitMultiplier = 100 }; workspace.Add(testContext.DonerEti); workspace.Add(testContext.Yogurt); workspace.Add(testContext.Pide); workspace.Add(testContext.ZeytinYagi); testContext.IskenderRecipe = new Recipe { Name = "İskender Reçetesi", Portion = testContext.Iskender.Portions[0] }; workspace.Add(testContext.IskenderRecipe); testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.DonerEti, Quantity = 120 }); testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.Yogurt, Quantity = 50 }); testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.Pide, Quantity = 2 }); testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.ZeytinYagi, Quantity = 1 }); testContext.LocalWarehouseAccountType = new AccountType { Name = "Local Warehouse Account Type" }; testContext.SellerWarehouseAccountType = new AccountType { Name = "Seller Warehouse Account Type" }; workspace.Add(testContext.LocalWarehouseAccountType); workspace.Add(testContext.SellerWarehouseAccountType); testContext.WarehouseType = workspace.Single<WarehouseType>(x => x.Name == Resources.Warehouses); testContext.WarehouseEntityType = new EntityType { Name = "Warehouse Resource Type" }; workspace.Add(testContext.WarehouseEntityType); testContext.LocalWarehouseAccount = new Account { AccountTypeId = testContext.LocalWarehouseAccountType.Id }; testContext.Seller1Account = new Account { AccountTypeId = testContext.SellerWarehouseAccountType.Id }; testContext.Seller2Account = new Account { AccountTypeId = testContext.SellerWarehouseAccountType.Id }; workspace.Add(testContext.LocalWarehouseAccount); workspace.Add(testContext.Seller1Account); workspace.Add(testContext.Seller2Account); testContext.LocalWarehouse = new Warehouse { WarehouseTypeId = testContext.WarehouseType.Id }; testContext.BarWarehouse = new Warehouse { WarehouseTypeId = testContext.WarehouseType.Id }; testContext.Seller1Warehouse = new Warehouse { WarehouseTypeId = testContext.WarehouseType.Id }; testContext.Seller2Warehouse = new Warehouse { WarehouseTypeId = testContext.WarehouseType.Id }; workspace.Add(testContext.LocalWarehouse); workspace.Add(testContext.BarWarehouse); workspace.Add(testContext.Seller1Warehouse); workspace.Add(testContext.Seller2Warehouse); testContext.LocalWarehouseEntity = new Entity { WarehouseId = testContext.LocalWarehouse.Id, EntityTypeId = testContext.WarehouseEntityType.Id, AccountId = testContext.LocalWarehouseAccount.Id }; testContext.BarWarehouseEntity = new Entity { WarehouseId = testContext.BarWarehouse.Id, EntityTypeId = testContext.WarehouseEntityType.Id }; testContext.Seller1WarehouseEntity = new Entity { WarehouseId = testContext.Seller1Warehouse.Id, EntityTypeId = testContext.WarehouseEntityType.Id, AccountId = testContext.Seller1Account.Id }; testContext.Seller2WarehouseEntity = new Entity { WarehouseId = testContext.Seller2Warehouse.Id, EntityTypeId = testContext.WarehouseEntityType.Id, AccountId = testContext.Seller2Account.Id }; workspace.Add(testContext.LocalWarehouseEntity); workspace.Add(testContext.BarWarehouseEntity); workspace.Add(testContext.Seller1WarehouseEntity); workspace.Add(testContext.Seller2WarehouseEntity); testContext.PurchaseAccountTransactionType = new AccountTransactionType { SourceAccountTypeId = testContext.SellerWarehouseAccountType.Id, TargetAccountTypeId = testContext.LocalWarehouseAccountType.Id, DefaultTargetAccountId = testContext.LocalWarehouseAccount.Id }; workspace.Add(testContext.PurchaseAccountTransactionType); testContext.PurchaseTransactionType = new InventoryTransactionType { Name = "PurchaseTransaction", SourceWarehouseTypeId = testContext.WarehouseType.Id, TargetWarehouseTypeId = testContext.WarehouseType.Id, DefaultSourceWarehouseId = testContext.Seller1Warehouse.Id, DefaultTargetWarehouseId = testContext.LocalWarehouse.Id, }; testContext.PurchaseTransactionDocumentType = new InventoryTransactionDocumentType { AccountTransactionType = testContext.PurchaseAccountTransactionType, InventoryTransactionType = testContext.PurchaseTransactionType, SourceEntityTypeId = testContext.WarehouseEntityType.Id, TargetEntityTypeId = testContext.WarehouseEntityType.Id, DefaultSourceEntityId = testContext.Seller1WarehouseEntity.Id, DefaultTargetEntityId = testContext.LocalWarehouseEntity.Id }; testContext.BarTransferTransactionType = new InventoryTransactionType { Name = "Bar Transfer", SourceWarehouseTypeId = testContext.WarehouseType.Id, TargetWarehouseTypeId = testContext.WarehouseType.Id, DefaultSourceWarehouseId = testContext.LocalWarehouse.Id, DefaultTargetWarehouseId = testContext.BarWarehouse.Id }; testContext.BarTransferTransactionDocumentType = new InventoryTransactionDocumentType { InventoryTransactionType = testContext.BarTransferTransactionType, SourceEntityTypeId = testContext.WarehouseEntityType.Id, TargetEntityTypeId = testContext.WarehouseEntityType.Id, DefaultSourceEntityId = testContext.LocalWarehouseEntity.Id, DefaultTargetEntityId = testContext.BarWarehouseEntity.Id }; workspace.Add(testContext.PurchaseTransactionType); workspace.Add(testContext.BarTransferTransactionType); testContext.Department = workspace.Single<Department>(x => x.Name == "Restoran"); testContext.Department.WarehouseId = testContext.LocalWarehouse.Id; ApplicationStateSetter.SetCurrentDepartment(testContext.Department.Id); WorkPeriodService.StartWorkPeriod(""); Thread.Sleep(1); }
public void CreateData() { CreateDefaultCurrenciesIfNeeded(); if (!ShouldCreateData()) { return; } var saleAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Sales) }; var receivableAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Receiveable) }; var paymentAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Payment) }; var discountAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Discount) }; var customerAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Customer) }; _workspace.Add(receivableAccountType); _workspace.Add(saleAccountType); _workspace.Add(paymentAccountType); _workspace.Add(discountAccountType); _workspace.Add(customerAccountType); _workspace.CommitChanges(); var customerResourceType = new ResourceType { Name = Resources.Customers, EntityName = Resources.Customer, AccountTypeId = customerAccountType.Id }; customerResourceType.ResoruceCustomFields.Add(new ResourceCustomField { EditingFormat = "(###) ### ####", FieldType = 0, Name = Resources.Phone }); customerResourceType.AccountNameTemplate = "[Name]-[Phone]"; var tableResourceType = new ResourceType { Name = Resources.Tables, EntityName = Resources.Table }; _workspace.Add(customerResourceType); _workspace.Add(tableResourceType); _workspace.CommitChanges(); var accountScreen = new AccountScreen { Name = Resources.General }; accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = saleAccountType.Name, AccountTypeId = saleAccountType.Id, DisplayDetails = true }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = receivableAccountType.Name, AccountTypeId = receivableAccountType.Id, DisplayDetails = true }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = discountAccountType.Name, AccountTypeId = discountAccountType.Id, DisplayDetails = true }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = paymentAccountType.Name, AccountTypeId = paymentAccountType.Id, DisplayDetails = true }); _workspace.Add(accountScreen); var defaultSaleAccount = new Account { AccountTypeId = saleAccountType.Id, Name = Resources.Sales }; var defaultReceivableAccount = new Account { AccountTypeId = receivableAccountType.Id, Name = Resources.Receivables }; var cashAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.Cash }; var creditCardAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.CreditCard }; var voucherAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.Voucher }; var defaultDiscountAccount = new Account { AccountTypeId = discountAccountType.Id, Name = Resources.Discount }; var defaultRoundingAccount = new Account { AccountTypeId = discountAccountType.Id, Name = Resources.Rounding }; _workspace.Add(defaultSaleAccount); _workspace.Add(defaultReceivableAccount); _workspace.Add(defaultDiscountAccount); _workspace.Add(defaultRoundingAccount); _workspace.Add(cashAccount); _workspace.Add(creditCardAccount); _workspace.Add(voucherAccount); _workspace.CommitChanges(); var discountTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Discount), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = defaultDiscountAccount.Id }; var roundingTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Rounding), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = defaultRoundingAccount.Id }; var saleTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Sale), SourceAccountTypeId = saleAccountType.Id, TargetAccountTypeId = receivableAccountType.Id, DefaultSourceAccountId = defaultSaleAccount.Id, DefaultTargetAccountId = defaultReceivableAccount.Id }; var paymentTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Payment), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = cashAccount.Id }; var customerAccountTransactionType = new AccountTransactionType { Name = "Customer Account Transaction", SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = customerAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id }; var customerCashPaymentType = new AccountTransactionType { Name = "Customer Cash Payment", SourceAccountTypeId = customerAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultTargetAccountId = cashAccount.Id }; var customerCreditCardPaymentType = new AccountTransactionType { Name = "Customer Credit Card Payment", SourceAccountTypeId = customerAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultTargetAccountId = creditCardAccount.Id }; _workspace.Add(saleTransactionType); _workspace.Add(paymentTransactionType); _workspace.Add(discountTransactionType); _workspace.Add(roundingTransactionType); _workspace.Add(customerAccountTransactionType); _workspace.Add(customerCashPaymentType); _workspace.Add(customerCreditCardPaymentType); var customerCashDocument = new AccountTransactionDocumentType { Name = "Customer Cash", ButtonHeader = Resources.Cash, DefaultAmount = string.Format("[{0}]", Resources.Balance), DescriptionTemplate = string.Format(Resources.Payment_f, Resources.Cash), MasterAccountTypeId = customerAccountType.Id }; customerCashDocument.AddAccountTransactionDocumentTypeMap(); customerCashDocument.TransactionTypes.Add(customerCashPaymentType); var customerCreditCardDocument = new AccountTransactionDocumentType { Name = "Customer Credit Card", ButtonHeader = Resources.CreditCard, DefaultAmount = string.Format("[{0}]", Resources.Balance), DescriptionTemplate = string.Format(Resources.Payment_f, Resources.CreditCard), MasterAccountTypeId = customerAccountType.Id }; customerCreditCardDocument.AddAccountTransactionDocumentTypeMap(); customerCreditCardDocument.TransactionTypes.Add(customerCreditCardPaymentType); _workspace.Add(customerCashDocument); _workspace.Add(customerCreditCardDocument); var discountService = new CalculationType { AccountTransactionType = discountTransactionType, CalculationMethod = 0, DecreaseAmount = true, Name = Resources.Discount }; var roundingService = new CalculationType { AccountTransactionType = roundingTransactionType, CalculationMethod = 2, DecreaseAmount = true, IncludeTax = true, Name = Resources.Round }; var discountSelector = new CalculationSelector { Name = Resources.Discount, ButtonHeader = Resources.DiscountPercentSign }; discountSelector.CalculationTypes.Add(discountService); discountSelector.AddCalculationSelectorMap(); var roundingSelector = new CalculationSelector { Name = Resources.Round, ButtonHeader = Resources.Round }; roundingSelector.CalculationTypes.Add(roundingService); roundingSelector.AddCalculationSelectorMap(); _workspace.Add(discountService); _workspace.Add(roundingService); _workspace.Add(discountSelector); _workspace.Add(roundingSelector); var screen = new ScreenMenu(); _workspace.Add(screen); var ticketNumerator = new Numerator { Name = Resources.TicketNumerator }; _workspace.Add(ticketNumerator); var orderNumerator = new Numerator { Name = Resources.OrderNumerator }; _workspace.Add(orderNumerator); var printBillAutomation = new AutomationCommand { Name = Resources.PrintBill, ButtonHeader = Resources.PrintBill }; printBillAutomation.AutomationCommandMaps.Add(new AutomationCommandMap { VisualBehaviour = 1 }); _workspace.Add(printBillAutomation); var unlockTicketAutomation = new AutomationCommand { Name = Resources.UnlockTicket, ButtonHeader = Resources.UnlockTicket }; unlockTicketAutomation.AutomationCommandMaps.Add(new AutomationCommandMap { VisualBehaviour = 2 }); _workspace.Add(unlockTicketAutomation); var addTicketAutomation = new AutomationCommand { Name = string.Format(Resources.Add_f, Resources.Ticket), ButtonHeader = string.Format(Resources.Add_f, Resources.Ticket) }; addTicketAutomation.AddAutomationCommandMap(); _workspace.Add(addTicketAutomation); _workspace.CommitChanges(); var ticketTemplate = new TicketTemplate { Name = Resources.TicketTemplate, TicketNumerator = ticketNumerator, OrderNumerator = orderNumerator, SaleTransactionType = saleTransactionType, }; var cashPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = cashAccount, Name = cashAccount.Name }; cashPayment.PaymentTypeMaps.Add(new PaymentTypeMap { DisplayAtPaymentScreen = true }); var creditCardPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = creditCardAccount, Name = creditCardAccount.Name }; creditCardPayment.PaymentTypeMaps.Add(new PaymentTypeMap { DisplayAtPaymentScreen = true }); var voucherPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = voucherAccount, Name = voucherAccount.Name }; voucherPayment.PaymentTypeMaps.Add(new PaymentTypeMap { DisplayAtPaymentScreen = true }); var accountPayment = new PaymentType { AccountTransactionType = customerAccountTransactionType, Name = Resources.CustomerAccount }; accountPayment.PaymentTypeMaps.Add(new PaymentTypeMap { DisplayAtPaymentScreen = true }); _workspace.Add(cashPayment); _workspace.Add(creditCardPayment); _workspace.Add(voucherPayment); _workspace.Add(ticketTemplate); _workspace.Add(accountPayment); var department = new Department { Name = Resources.Restaurant, TicketTemplate = ticketTemplate, ScreenMenuId = screen.Id, }; _workspace.Add(department); var role = new UserRole("Admin") { IsAdmin = true, DepartmentId = 1 }; _workspace.Add(role); var u = new User("Administrator", "1234") { UserRole = role }; _workspace.Add(u); var ticketPrinterTemplate = new PrinterTemplate { Name = Resources.TicketTemplate, Template = Resources.TicketTemplateValue }; var kitchenPrinterTemplate = new PrinterTemplate { Name = Resources.KitchenOrderTemplate, Template = Resources.KitchenTemplateValue }; _workspace.Add(ticketPrinterTemplate); _workspace.Add(kitchenPrinterTemplate); var printer1 = new Printer { Name = Resources.TicketPrinter }; var printer2 = new Printer { Name = Resources.KitchenPrinter }; var printer3 = new Printer { Name = Resources.InvoicePrinter }; _workspace.Add(printer1); _workspace.Add(printer2); _workspace.Add(printer3); _workspace.CommitChanges(); var t = new Terminal { IsDefault = true, Name = Resources.Server, ReportPrinter = printer1, }; var pm1 = new PrinterMap { PrinterId = printer1.Id, PrinterTemplateId = ticketPrinterTemplate.Id }; _workspace.Add(pm1); var pj1 = new PrintJob { Name = Resources.PrintBill, LocksTicket = true, WhatToPrint = (int)WhatToPrintTypes.Everything, }; pj1.PrinterMaps.Add(pm1); _workspace.Add(pj1); var pm2 = new PrinterMap { PrinterId = printer2.Id, PrinterTemplateId = kitchenPrinterTemplate.Id }; var pj2 = new PrintJob { Name = Resources.PrintOrdersToKitchenPrinter, WhatToPrint = (int)WhatToPrintTypes.NewLines, }; pj2.PrinterMaps.Add(pm2); _workspace.Add(pj2); _workspace.Add(t); var orderTag1 = new OrderStateGroup { Name = Resources.Gift, ButtonHeader = Resources.Gift, CalculateOrderPrice = false, DecreaseOrderInventory = true }; orderTag1.OrderStates.Add(new OrderState { Name = Resources.Gift }); orderTag1.AddOrderStateMap(); _workspace.Add(orderTag1); var orderTag2 = new OrderStateGroup { Name = Resources.Void, ButtonHeader = Resources.Void, CalculateOrderPrice = false, DecreaseOrderInventory = false }; orderTag2.OrderStates.Add(new OrderState { Name = Resources.Void }); orderTag2.UnlocksOrder = true; orderTag2.AddOrderStateMap(); _workspace.Add(orderTag2); const string parameterFormat = "[{{\"Key\":\"{0}\",\"Value\":\"{1}\"}}]"; //const string doubleParameterFormat = "[{{\"Key\":\"{0}\",\"Value\":\"{1}\"}},{{\"Key\":\"{2}\",\"Value\":\"{3}\"}}]"; var newOrderState = new ResourceState { Name = "New Orders", Color = "Orange" }; _workspace.Add(newOrderState); var availableState = new ResourceState { Name = "Available", Color = "White" }; _workspace.Add(availableState); var billRequestedState = new ResourceState { Name = "Bill Requested", Color = "Maroon" }; _workspace.Add(billRequestedState); var newOrderAction = new AppAction { ActionType = "UpdateResourceState", Name = "Update New Order State", Parameter = string.Format(parameterFormat, "ResourceState", "New Orders") }; _workspace.Add(newOrderAction); var availableAction = new AppAction { ActionType = "UpdateResourceState", Name = "Update Available State", Parameter = string.Format(parameterFormat, "ResourceState", "Available") }; _workspace.Add(availableAction); var billRequestedAction = new AppAction { ActionType = "UpdateResourceState", Name = "Update Bill Requested State", Parameter = string.Format(parameterFormat, "ResourceState", "Bill Requested") }; _workspace.Add(billRequestedAction); var createTicketAction = new AppAction { ActionType = "CreateTicket", Name = string.Format(Resources.Create_f, Resources.Ticket), Parameter = "" }; _workspace.Add(createTicketAction); var closeTicketAction = new AppAction { ActionType = "CloseActiveTicket", Name = Resources.CloseTicket, Parameter = "" }; _workspace.Add(closeTicketAction); var printBillAction = new AppAction { ActionType = "ExecutePrintJob", Name = "Execute Bill Print Job", Parameter = string.Format(parameterFormat, "PrintJobName", Resources.PrintBill) }; _workspace.Add(printBillAction); var printKitchenOrdersAction = new AppAction { ActionType = "ExecutePrintJob", Name = "Execute Kitchen Orders Print Job", Parameter = string.Format(parameterFormat, "PrintJobName", Resources.PrintOrdersToKitchenPrinter) }; _workspace.Add(printKitchenOrdersAction); var unlockTicketAction = new AppAction { ActionType = "UnlockTicket", Name = Resources.UnlockTicket, Parameter = "" }; _workspace.Add(unlockTicketAction); _workspace.CommitChanges(); var newOrderRule = new AppRule { Name = "Update New Order Resource Color", EventName = "TicketClosing", EventConstraints = "NewOrderCount;>;0" }; newOrderRule.Actions.Add(new ActionContainer(printKitchenOrdersAction)); newOrderRule.Actions.Add(new ActionContainer(newOrderAction)); newOrderRule.AddRuleMap(); _workspace.Add(newOrderRule); var availableRule = new AppRule { Name = "Update Available Resource Color", EventName = "ResourceUpdated", EventConstraints = "OpenTicketCount;=;0" }; var ac2 = new ActionContainer(availableAction); availableRule.Actions.Add(ac2); availableRule.AddRuleMap(); _workspace.Add(availableRule); var movingRule = new AppRule { Name = "Update Moved Resource Color", EventName = "TicketResourceChanged", EventConstraints = "OrderCount;>;0" }; var ac3 = new ActionContainer(newOrderAction); movingRule.Actions.Add(ac3); movingRule.AddRuleMap(); _workspace.Add(movingRule); var printBillRule = new AppRule { Name = "Print Bill Rule", EventName = RuleEventNames.AutomationCommandExecuted, EventConstraints = "AutomationCommandName;=;" + Resources.PrintBill }; printBillRule.Actions.Add(new ActionContainer(printBillAction)); printBillRule.Actions.Add(new ActionContainer(billRequestedAction)); printBillRule.Actions.Add(new ActionContainer(closeTicketAction)); printBillRule.AddRuleMap(); _workspace.Add(printBillRule); var unlockTicketRule = new AppRule { Name = "Unlock Ticket Rule", EventName = RuleEventNames.AutomationCommandExecuted, EventConstraints = "AutomationCommandName;=;Unlock Ticket" }; unlockTicketRule.Actions.Add(new ActionContainer(unlockTicketAction)); unlockTicketRule.AddRuleMap(); _workspace.Add(unlockTicketRule); var createTicketRule = new AppRule { Name = "Create Ticket Rule", EventName = RuleEventNames.AutomationCommandExecuted, EventConstraints = "AutomationCommandName;=;Add Ticket" }; createTicketRule.Actions.Add(new ActionContainer(createTicketAction)); createTicketRule.AddRuleMap(); _workspace.Add(createTicketRule); var updateMergedTicket = new AppRule { Name = "Update Merged Tickets State", EventName = RuleEventNames.TicketsMerged }; updateMergedTicket.Actions.Add(new ActionContainer(newOrderAction)); updateMergedTicket.AddRuleMap(); _workspace.Add(updateMergedTicket); ImportMenus(screen); ImportTableResources(tableResourceType, availableState.Id); var customerScreen = new ResourceScreen { Name = "Customer Search", DisplayMode = 2, ResourceTypeId = customerResourceType.Id }; customerScreen.ResourceScreenMaps.Add(new ResourceScreenMap()); _workspace.Add(customerScreen); var customerTicketScreen = new ResourceScreen { Name = "Customer Tickets", DisplayMode = 0, ResourceTypeId = customerResourceType.Id, StateFilterId = newOrderState.Id, ColumnCount = 6, RowCount = 6 }; customerTicketScreen.ResourceScreenMaps.Add(new ResourceScreenMap()); _workspace.Add(customerTicketScreen); ImportItems(BatchCreateResources); ImportItems(BatchCreateTransactionTypes); ImportItems(BatchCreateTransactionTypeDocuments); _workspace.CommitChanges(); _workspace.Dispose(); }
private static void CreateWarehouseTestContext(WarehouseTestContext testContext, IWorkspace workspace) { workspace.Delete <InventoryTransactionType>(x => x.Id > 0); workspace.Delete <Entity>(x => x.Id > 0); testContext.Iskender = workspace.Single <MenuItem>(x => x.Name == "İskender"); testContext.Iskender.Portions[0].MenuItemId = testContext.Iskender.Id; testContext.Doner = workspace.Single <MenuItem>(x => x.Name == "Ankara Döneri"); testContext.Doner.Portions[0].MenuItemId = testContext.Doner.Id; testContext.DonerEti = new InventoryItem { Name = "Döner Eti", BaseUnit = "GR", GroupCode = "", TransactionUnit = "KG", TransactionUnitMultiplier = 1000 }; testContext.Yogurt = new InventoryItem { Name = "Yoğurt", BaseUnit = "GR", GroupCode = "", TransactionUnit = "KG", TransactionUnitMultiplier = 1000 }; testContext.Pide = new InventoryItem { Name = "Pide", BaseUnit = "Yarım", GroupCode = "", TransactionUnit = "Adet", TransactionUnitMultiplier = 2 }; testContext.ZeytinYagi = new InventoryItem { Name = "Zeytin Yağı", BaseUnit = "Ölçü", GroupCode = "", TransactionUnit = "Litre", TransactionUnitMultiplier = 100 }; testContext.Tuz = new InventoryItem { Name = "Tuz", BaseUnit = "Ölçü", GroupCode = "", TransactionUnit = "Paket", TransactionUnitMultiplier = 100 }; testContext.Kekik = new InventoryItem { Name = "Kekik", BaseUnit = "Ölçü", GroupCode = "", TransactionUnit = "Paket", TransactionUnitMultiplier = 100 }; workspace.Add(testContext.DonerEti); workspace.Add(testContext.Yogurt); workspace.Add(testContext.Pide); workspace.Add(testContext.ZeytinYagi); workspace.Add(testContext.Tuz); workspace.Add(testContext.Kekik); testContext.IskenderRecipe = new Recipe { Name = "İskender Reçetesi", Portion = testContext.Iskender.Portions[0] }; workspace.Add(testContext.IskenderRecipe); testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.DonerEti, Quantity = 120 }); testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.Yogurt, Quantity = 50 }); testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.Pide, Quantity = 2 }); testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.ZeytinYagi, Quantity = 1 }); testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.Tuz, Quantity = 10 }); testContext.DonerRecipe = new Recipe { Name = "Döner Reçetesi", Portion = testContext.Doner.Portions[0] }; workspace.Add(testContext.DonerRecipe); testContext.DonerRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.DonerEti, Quantity = 120 }); testContext.LocalWarehouseAccountType = new AccountType { Name = "Local Warehouse Account Type" }; testContext.SellerWarehouseAccountType = new AccountType { Name = "Seller Warehouse Account Type" }; workspace.Add(testContext.LocalWarehouseAccountType); workspace.Add(testContext.SellerWarehouseAccountType); testContext.WarehouseType = workspace.Single <WarehouseType>(x => x.Name == Resources.Warehouses); testContext.WarehouseEntityType = new EntityType { Name = "Warehouse Resource Type" }; workspace.Add(testContext.WarehouseEntityType); testContext.LocalWarehouseAccount = new Account { AccountTypeId = testContext.LocalWarehouseAccountType.Id }; testContext.Seller1Account = new Account { AccountTypeId = testContext.SellerWarehouseAccountType.Id }; testContext.Seller2Account = new Account { AccountTypeId = testContext.SellerWarehouseAccountType.Id }; workspace.Add(testContext.LocalWarehouseAccount); workspace.Add(testContext.Seller1Account); workspace.Add(testContext.Seller2Account); testContext.LocalWarehouse = new Warehouse { Name = "Local Warehouse", WarehouseTypeId = testContext.WarehouseType.Id }; testContext.BarWarehouse = new Warehouse { Name = "Bar Warehouse", WarehouseTypeId = testContext.WarehouseType.Id }; testContext.Seller1Warehouse = new Warehouse { WarehouseTypeId = testContext.WarehouseType.Id }; testContext.Seller2Warehouse = new Warehouse { WarehouseTypeId = testContext.WarehouseType.Id }; workspace.Add(testContext.LocalWarehouse); workspace.Add(testContext.BarWarehouse); workspace.Add(testContext.Seller1Warehouse); workspace.Add(testContext.Seller2Warehouse); testContext.LocalWarehouseEntity = new Entity { WarehouseId = testContext.LocalWarehouse.Id, EntityTypeId = testContext.WarehouseEntityType.Id, AccountId = testContext.LocalWarehouseAccount.Id }; testContext.BarWarehouseEntity = new Entity { WarehouseId = testContext.BarWarehouse.Id, EntityTypeId = testContext.WarehouseEntityType.Id }; testContext.Seller1WarehouseEntity = new Entity { WarehouseId = testContext.Seller1Warehouse.Id, EntityTypeId = testContext.WarehouseEntityType.Id, AccountId = testContext.Seller1Account.Id }; testContext.Seller2WarehouseEntity = new Entity { WarehouseId = testContext.Seller2Warehouse.Id, EntityTypeId = testContext.WarehouseEntityType.Id, AccountId = testContext.Seller2Account.Id }; workspace.Add(testContext.LocalWarehouseEntity); workspace.Add(testContext.BarWarehouseEntity); workspace.Add(testContext.Seller1WarehouseEntity); workspace.Add(testContext.Seller2WarehouseEntity); testContext.PurchaseAccountTransactionType = new AccountTransactionType { SourceAccountTypeId = testContext.SellerWarehouseAccountType.Id, TargetAccountTypeId = testContext.LocalWarehouseAccountType.Id, DefaultTargetAccountId = testContext.LocalWarehouseAccount.Id }; workspace.Add(testContext.PurchaseAccountTransactionType); testContext.PurchaseTransactionType = new InventoryTransactionType { Name = "PurchaseTransaction", SourceWarehouseTypeId = testContext.WarehouseType.Id, TargetWarehouseTypeId = testContext.WarehouseType.Id, DefaultSourceWarehouseId = testContext.Seller1Warehouse.Id, DefaultTargetWarehouseId = testContext.LocalWarehouse.Id, }; testContext.PurchaseTransactionDocumentType = new InventoryTransactionDocumentType { AccountTransactionType = testContext.PurchaseAccountTransactionType, InventoryTransactionType = testContext.PurchaseTransactionType, SourceEntityTypeId = testContext.WarehouseEntityType.Id, TargetEntityTypeId = testContext.WarehouseEntityType.Id, DefaultSourceEntityId = testContext.Seller1WarehouseEntity.Id, DefaultTargetEntityId = testContext.LocalWarehouseEntity.Id }; testContext.BarTransferTransactionType = new InventoryTransactionType { Name = "Bar Transfer", SourceWarehouseTypeId = testContext.WarehouseType.Id, TargetWarehouseTypeId = testContext.WarehouseType.Id, DefaultSourceWarehouseId = testContext.LocalWarehouse.Id, DefaultTargetWarehouseId = testContext.BarWarehouse.Id }; testContext.BarTransferTransactionDocumentType = new InventoryTransactionDocumentType { InventoryTransactionType = testContext.BarTransferTransactionType, SourceEntityTypeId = testContext.WarehouseEntityType.Id, TargetEntityTypeId = testContext.WarehouseEntityType.Id, DefaultSourceEntityId = testContext.LocalWarehouseEntity.Id, DefaultTargetEntityId = testContext.BarWarehouseEntity.Id }; workspace.Add(testContext.PurchaseTransactionType); workspace.Add(testContext.BarTransferTransactionType); testContext.Department = workspace.Single <Department>(x => x.Name == "Restoran"); testContext.Department.WarehouseId = testContext.LocalWarehouse.Id; ApplicationStateSetter.SetCurrentDepartment(testContext.Department.Id); WorkPeriodService.StartWorkPeriod(""); Thread.Sleep(1); }
public void Add(TModel item) { _workspace.Add(item); }
public IEnumerable <MenuItem> BatchCreateMenuItems(string[] values, IWorkspace workspace) { var ds = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; IList <MenuItem> result = new List <MenuItem>(); if (values.Length > 0) { var currentCategory = Resources.Common; foreach (var item in values) { if (item.StartsWith("#")) { currentCategory = item.Trim('#', ' '); } else if (item.Contains("|")) { //Sundae|Small:1.99|Medium:2.99|Large:3.99 IList <string> parts = new List <string>(item.Split('|')); var mi = MenuItem.Create(); mi.Name = parts[0]; for (int i = 1; i < parts.Count; i++) { var tokens = parts[i].Split(':'); if (tokens.Count() != 2) { var price = ConvertToDecimal(tokens[0], ds); mi.Portions[i - 1].Price.Amount = price; } else { var price = ConvertToDecimal(tokens[1], ds); if (mi.Portions.Count < i - 1) { var mp = new MenuItemPortion(); mp.Price = new Price(price, ""); mp.Name = tokens[0]; mi.Portions.Add(mp); } } } mi.GroupCode = currentCategory; workspace.Add(mi); foreach (var p in mi.Portions) { workspace.Add(p); } result.Add(mi); } else if (item.Contains(" ")) { //Sundae 2.99 IList <string> parts = new List <string>(item.Split(' ')); var price = ConvertToDecimal(parts[parts.Count - 1], ds); parts.RemoveAt(parts.Count - 1); var itemName = string.Join(" ", parts.ToArray()); var mi = MenuItem.Create(); mi.Name = itemName; mi.Portions[0].Price.Amount = price; mi.GroupCode = currentCategory; workspace.Add(mi); workspace.Add(mi.Portions[0]); result.Add(mi); } } } return(result); }
public void CreateData() { CreateDefaultCurrenciesIfNeeded(); if (!ShouldCreateData()) { return; } var screen = new ScreenMenu(); _workspace.Add(screen); var ticketNumerator = new Numerator { Name = Resources.TicketNumerator }; _workspace.Add(ticketNumerator); var orderNumerator = new Numerator { Name = Resources.OrderNumerator }; _workspace.Add(orderNumerator); _workspace.CommitChanges(); var department = new Department { Name = Resources.Restaurant, ScreenMenuId = screen.Id, TicketNumerator = ticketNumerator, OrderNumerator = orderNumerator, IsAlaCarte = true }; _workspace.Add(department); var role = new UserRole("Admin") { IsAdmin = true, DepartmentId = 1 }; _workspace.Add(role); var u = new User("Administrator", "1234") { UserRole = role }; _workspace.Add(u); var ticketTemplate = new PrinterTemplate(); ticketTemplate.Name = Resources.TicketTemplate; ticketTemplate.HeaderTemplate = Resources.TicketTemplateHeaderValue; ticketTemplate.LineTemplate = Resources.TicketTempleteLineTemplateValue; ticketTemplate.GiftLineTemplate = Resources.TicketTemplateGiftedLineTemplateValue; ticketTemplate.FooterTemplate = Resources.TicketTemplateFooterValue; var kitchenTemplate = new PrinterTemplate(); kitchenTemplate.Name = Resources.KitchenOrderTemplate; kitchenTemplate.HeaderTemplate = Resources.KitchenTemplateHeaderValue; kitchenTemplate.LineTemplate = Resources.KitchenTemplateLineTemplateValue; kitchenTemplate.GiftLineTemplate = Resources.KitchenTemplateLineTemplateValue; kitchenTemplate.VoidedLineTemplate = Resources.KitchenTemplateVoidedLineTemplateValue; kitchenTemplate.FooterTemplate = "<F>-"; var invoiceTemplate = new PrinterTemplate(); invoiceTemplate.Name = Resources.InvoicePrinterTemplate; invoiceTemplate.HeaderTemplate = Resources.InvoiceTemplateHeaderValue; invoiceTemplate.LineTemplate = Resources.InvoiceTemplateLineTemplateValue; invoiceTemplate.VoidedLineTemplate = ""; invoiceTemplate.FooterTemplate = "<F>-"; _workspace.Add(ticketTemplate); _workspace.Add(kitchenTemplate); _workspace.Add(invoiceTemplate); var printer1 = new Printer { Name = Resources.TicketPrinter }; var printer2 = new Printer { Name = Resources.KitchenPrinter }; var printer3 = new Printer { Name = Resources.InvoicePrinter }; _workspace.Add(printer1); _workspace.Add(printer2); _workspace.Add(printer3); var t = new Terminal { IsDefault = true, Name = Resources.Server, SlipReportPrinter = printer1, }; var pm1 = new PrinterMap { Printer = printer1, PrinterTemplate = ticketTemplate }; _workspace.Add(pm1); var pj1 = new PrintJob { Name = Resources.PrintBill, ButtonText = Resources.PrintBill, LocksTicket = true, Order = 0, UseFromPaymentScreen = true, UseFromTerminal = true, UseFromPos = true, WhatToPrint = (int)WhatToPrintTypes.Everything, WhenToPrint = (int)WhenToPrintTypes.Manual }; pj1.PrinterMaps.Add(pm1); _workspace.Add(pj1); var pm2 = new PrinterMap { Printer = printer2, PrinterTemplate = kitchenTemplate }; var pj2 = new PrintJob { Name = Resources.PrintOrdersToKitchenPrinter, ButtonText = "", Order = 1, WhatToPrint = (int)WhatToPrintTypes.NewLines, WhenToPrint = (int)WhenToPrintTypes.NewLinesAdded }; pj2.PrinterMaps.Add(pm2); _workspace.Add(pj2); t.PrintJobs.Add(pj1); t.PrintJobs.Add(pj2); _workspace.Add(t); ImportMenus(screen); ImportTables(department); _workspace.CommitChanges(); _workspace.Dispose(); }
public void Create(DataCreationService dataCreationService, IWorkspace workspace) { this._workspace = workspace; var saleAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Sales) }; var receivableAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Receiveable) }; var paymentAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Payment) }; var discountAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Discount) }; var customerAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Customer) }; _workspace.Add(receivableAccountType); _workspace.Add(saleAccountType); _workspace.Add(paymentAccountType); _workspace.Add(discountAccountType); _workspace.Add(customerAccountType); _workspace.CommitChanges(); var customerEntityType = new EntityType { Name = Resources.Customers, EntityName = Resources.Customer, AccountTypeId = customerAccountType.Id, PrimaryFieldName = Resources.Name }; customerEntityType.EntityCustomFields.Add(new EntityCustomField { EditingFormat = "(###) ### ####", FieldType = 0, Name = Resources.Phone }); customerEntityType.AccountNameTemplate = "[Name]-[" + Resources.Phone + "]"; //var tableEntityType = new EntityType { Name = Resources.Tables, EntityName = Resources.Table, PrimaryFieldName = Resources.Name }; _workspace.Add(customerEntityType); //_workspace.Add(tableEntityType); _workspace.CommitChanges(); var accountScreen = new AccountScreen { Name = Resources.General }; accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = saleAccountType.Name, AccountTypeId = saleAccountType.Id, DisplayDetails = true, SortOrder = 10 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = receivableAccountType.Name, AccountTypeId = receivableAccountType.Id, DisplayDetails = true, SortOrder = 20 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = discountAccountType.Name, AccountTypeId = discountAccountType.Id, DisplayDetails = true, SortOrder = 30 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = paymentAccountType.Name, AccountTypeId = paymentAccountType.Id, DisplayDetails = true, SortOrder = 40 }); _workspace.Add(accountScreen); var defaultSaleAccount = new Account { AccountTypeId = saleAccountType.Id, Name = Resources.Sales }; var defaultReceivableAccount = new Account { AccountTypeId = receivableAccountType.Id, Name = Resources.Receivables }; var cashAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.Cash }; var creditCardAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.CreditCard }; var voucherAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.Voucher }; var defaultDiscountAccount = new Account { AccountTypeId = discountAccountType.Id, Name = Resources.Discount }; var defaultRoundingAccount = new Account { AccountTypeId = discountAccountType.Id, Name = Resources.Rounding }; _workspace.Add(defaultSaleAccount); _workspace.Add(defaultReceivableAccount); _workspace.Add(defaultDiscountAccount); _workspace.Add(defaultRoundingAccount); _workspace.Add(cashAccount); _workspace.Add(creditCardAccount); _workspace.Add(voucherAccount); _workspace.CommitChanges(); var discountTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Discount), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = defaultDiscountAccount.Id }; var roundingTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Rounding), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = defaultRoundingAccount.Id }; var saleTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Sale), SourceAccountTypeId = saleAccountType.Id, TargetAccountTypeId = receivableAccountType.Id, DefaultSourceAccountId = defaultSaleAccount.Id, DefaultTargetAccountId = defaultReceivableAccount.Id }; var paymentTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Payment), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = cashAccount.Id }; var customerAccountTransactionType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.AccountTransaction), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = customerAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id }; var customerCashPaymentType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.CashPayment), SourceAccountTypeId = customerAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultTargetAccountId = cashAccount.Id }; var customerCreditCardPaymentType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.CreditCardPayment), SourceAccountTypeId = customerAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultTargetAccountId = creditCardAccount.Id }; _workspace.Add(saleTransactionType); _workspace.Add(paymentTransactionType); _workspace.Add(discountTransactionType); _workspace.Add(roundingTransactionType); _workspace.Add(customerAccountTransactionType); _workspace.Add(customerCashPaymentType); _workspace.Add(customerCreditCardPaymentType); var discountService = new CalculationType { AccountTransactionType = discountTransactionType, CalculationMethod = 0, DecreaseAmount = true, Name = Resources.Discount }; var roundingService = new CalculationType { AccountTransactionType = roundingTransactionType, CalculationMethod = 2, DecreaseAmount = true, IncludeTax = true, Name = Resources.Round }; var discountSelector = new CalculationSelector { Name = Resources.Discount, ButtonHeader = Resources.DiscountPercentSign }; discountSelector.CalculationTypes.Add(discountService); discountSelector.AddCalculationSelectorMap(); var roundingSelector = new CalculationSelector { Name = Resources.Round, ButtonHeader = Resources.Round }; roundingSelector.CalculationTypes.Add(roundingService); roundingSelector.AddCalculationSelectorMap(); _workspace.Add(discountService); _workspace.Add(roundingService); _workspace.Add(discountSelector); _workspace.Add(roundingSelector); var screen = new ScreenMenu(); _workspace.Add(screen); var ticketNumerator = new Numerator { Name = Resources.TicketNumerator }; _workspace.Add(ticketNumerator); var orderNumerator = new Numerator { Name = Resources.OrderNumerator }; _workspace.Add(orderNumerator); _workspace.CommitChanges(); var ticketType = new TicketType { Name = Resources.Ticket, TicketNumerator = ticketNumerator, OrderNumerator = orderNumerator, SaleTransactionType = saleTransactionType, ScreenMenuId = screen.Id, }; ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment { EntityTypeId = customerEntityType.Id, EntityTypeName = customerEntityType.Name, SortOrder = 20 }); var cashPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = cashAccount, Name = cashAccount.Name }; cashPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var creditCardPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = creditCardAccount, Name = creditCardAccount.Name }; creditCardPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var voucherPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = voucherAccount, Name = voucherAccount.Name }; voucherPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var accountPayment = new PaymentType { AccountTransactionType = customerAccountTransactionType, Name = Resources.CustomerAccount }; accountPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); _workspace.Add(cashPayment); _workspace.Add(creditCardPayment); _workspace.Add(voucherPayment); _workspace.Add(accountPayment); _workspace.Add(ticketType); var warehouseType = new WarehouseType { Name = Resources.Warehouses }; _workspace.Add(warehouseType); _workspace.CommitChanges(); var localWarehouse = new Warehouse { Name = Resources.LocalWarehouse, WarehouseTypeId = warehouseType.Id }; _workspace.Add(localWarehouse); _workspace.CommitChanges(); var department = new Department { Name = Resources.Retail, TicketTypeId = ticketType.Id, WarehouseId = localWarehouse.Id }; _workspace.Add(department); var transactionType = new InventoryTransactionType { Name = Resources.PurchaseTransactionType, TargetWarehouseTypeId = warehouseType.Id, DefaultTargetWarehouseId = localWarehouse.Id }; _workspace.Add(transactionType); var transactionDocumentType = new InventoryTransactionDocumentType { Name = Resources.PurchaseTransaction, InventoryTransactionType = transactionType }; _workspace.Add(transactionDocumentType); AddDefaultUsers(); PrinterTemplate customerReceiptTemplate = AddDefaultPrintersAndTerminal(); new RuleGenerator().GenerateSystemRules(_workspace); dataCreationService.ImportMenus(screen); //dataCreationService.ImportTableResources(tableEntityType, ticketType); //RL - import data and associate with an entity. //C:\Users\Roy Lawson\source\repos\sdselite\SambaPOS-3\Samba.Presentation\bin\Debug\Imports var customerScreen = new EntityScreen { Name = string.Format(Resources.Customer_f, Resources.Search), DisplayMode = 1, EntityTypeId = customerEntityType.Id, TicketTypeId = ticketType.Id }; customerScreen.EntityScreenMaps.Add(new EntityScreenMap()); _workspace.Add(customerScreen); var customerTicketScreen = new EntityScreen { Name = Resources.CustomerTickets, DisplayMode = 0, EntityTypeId = customerEntityType.Id, StateFilter = Resources.NewOrders, ColumnCount = 6, RowCount = 6, TicketTypeId = ticketType.Id }; customerTicketScreen.EntityScreenMaps.Add(new EntityScreenMap()); _workspace.Add(customerTicketScreen); var customerCashDocument = new AccountTransactionDocumentType { Name = string.Format(Resources.Customer_f, Resources.Cash), ButtonHeader = Resources.Cash, DefaultAmount = string.Format("[{0}]", Resources.Balance), DescriptionTemplate = string.Format(Resources.Payment_f, Resources.Cash), MasterAccountTypeId = customerAccountType.Id, PrinterTemplateId = customerReceiptTemplate.Id }; customerCashDocument.AddAccountTransactionDocumentTypeMap(); customerCashDocument.TransactionTypes.Add(customerCashPaymentType); var customerCreditCardDocument = new AccountTransactionDocumentType { Name = string.Format(Resources.Customer_f, Resources.CreditCard), ButtonHeader = Resources.CreditCard, DefaultAmount = string.Format("[{0}]", Resources.Balance), DescriptionTemplate = string.Format(Resources.Payment_f, Resources.CreditCard), MasterAccountTypeId = customerAccountType.Id, PrinterTemplateId = customerReceiptTemplate.Id }; customerCreditCardDocument.AddAccountTransactionDocumentTypeMap(); customerCreditCardDocument.TransactionTypes.Add(customerCreditCardPaymentType); _workspace.Add(customerCashDocument); _workspace.Add(customerCreditCardDocument); }
public void Add() { _workspace.Add(Action); Action = _actionFactory(); }
public IEnumerable<MenuItem> BatchCreateMenuItems(string[] values, IWorkspace workspace) { var ds = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; IList<MenuItem> result = new List<MenuItem>(); if (values.Length > 0) { var currentCategory = Resources.Common; foreach (var item in values) { if (item.StartsWith("#")) { currentCategory = item.Trim('#', ' '); } else if (item.Contains("|")) { //Sundae|Small:1.99|Medium:2.99|Large:3.99 IList<string> parts = new List<string>(item.Split('|')); var mi = MenuItem.Create(); mi.Name = parts[0]; for (int i = 1; i < parts.Count; i++) { var tokens = parts[i].Split(':'); if (tokens.Count() != 2) { var price = ConvertToDecimal(tokens[0], ds); mi.Portions[i - 1].Price.Amount = price; } else { var price = ConvertToDecimal(tokens[1], ds); if (mi.Portions.Count < i - 1) { var mp = new MenuItemPortion(); mp.Price = new Price(price,""); mp.Name = tokens[0]; mi.Portions.Add(mp); } } } mi.GroupCode = currentCategory; workspace.Add(mi); foreach (var p in mi.Portions) { workspace.Add(p); } result.Add(mi); } else if (item.Contains(" ")) { //Sundae 2.99 IList<string> parts = new List<string>(item.Split(' ')); var price = ConvertToDecimal(parts[parts.Count - 1], ds); parts.RemoveAt(parts.Count - 1); var itemName = string.Join(" ", parts.ToArray()); var mi = MenuItem.Create(); mi.Name = itemName; mi.Portions[0].Price.Amount = price; mi.GroupCode = currentCategory; workspace.Add(mi); workspace.Add(mi.Portions[0]); result.Add(mi); } } } return result; }
private void RestartWorkperiod(IWorkspace workspace) { WorkPeriodService.StopWorkPeriod(""); Thread.Sleep(1); InventoryService.DoWorkPeriodEnd(); var pc = InventoryService.GetCurrentPeriodicConsumption(); InventoryService.SavePeriodicConsumption(pc); foreach (var warehouseConsumption in pc.WarehouseConsumptions) { warehouseConsumption.PeriodicConsumptionId = pc.Id; workspace.Add(warehouseConsumption); warehouseConsumption.PeriodicConsumptionItems.ToList().ForEach(x => { x.WarehouseConsumptionId = warehouseConsumption.Id; workspace.Add(x); }); } WorkPeriodService.StartWorkPeriod(""); Thread.Sleep(1); InventoryService.DoWorkPeriodStart(); }