예제 #1
0
            public void CreateTicket(Department department)
            {
                Debug.Assert(_workspace == null);
                Debug.Assert(Ticket == null);
                Debug.Assert(department != null);

                _workspace = WorkspaceFactory.Create();
                Ticket = Ticket.Create(department);
            }
예제 #2
0
        public void UpdateOpenTickets(Department department)
        {
            StopTimer();

            Expression<Func<Ticket, bool>> prediction = x => !x.IsPaid && x.DepartmentId == department.Id;

            var openTickets = _ticketService.GetOpenTickets(prediction);
            var shouldWrap = !department.IsTakeAway;

            OpenTickets = openTickets.Select(x => new OpenTicketButtonViewModel(x, shouldWrap)).OrderBy(x => x.LastOrderDate);

            RaisePropertyChanged(() => OpenTickets);

            StartTimer();
        }
예제 #3
0
        public void UpdateOpenTickets(Department department, string selectedTag)
        {
            Expression<Func<Ticket, bool>> prediction;

            if (department != null)
                prediction = x => !x.IsPaid && x.DepartmentId == department.Id;
            else
                prediction = x => !x.IsPaid;

            OpenTickets = Dao.Select(x => new TerminalOpenTicketView
            {
                Id = x.Id,
                TicketNumber = x.TicketNumber,
                LocationName = x.LocationName,
                CustomerName = x.CustomerName,
                IsLocked = x.Locked,
                TicketTag = x.Tag
            }, prediction).OrderBy(x => x.Title);

            if (!string.IsNullOrEmpty(selectedTag))
            {
                var tag = selectedTag.ToLower() + ":";
                var cnt = OpenTickets.Count(x => string.IsNullOrEmpty(x.TicketTag) || !x.TicketTag.ToLower().Contains(tag));

                OpenTickets = OpenTickets.Where(x => !string.IsNullOrEmpty(x.TicketTag) && x.TicketTag.ToLower().Contains(tag));

                var opt = OpenTickets.SelectMany(x => x.TicketTag.Split('\r'))
                    .Where(x => x.ToLower().Contains(tag))
                    .Distinct()
                    .Select(x => x.Split(':')).Select(x => new TicketTagFilterViewModel { TagGroup = x[0], TagValue = x[1] }).OrderBy(x => x.TagValue).ToList();

                opt.Insert(0, new TicketTagFilterViewModel { TagGroup = selectedTag, TagValue = "*", ButtonColor = "Blue" });

                if (cnt > 0)
                    opt.Insert(0, new TicketTagFilterViewModel { Count = cnt, TagGroup = selectedTag, ButtonColor = "Red" });

                OpenTicketTags = opt.Count() > 1 ? opt : null;

                OpenTickets.ForEach(x => x.Info = x.TicketTag.Split('\r').Where(y => y.ToLower().StartsWith(tag)).Single().Split(':')[1]);
            }
            else
            {
                OpenTicketTags = null;
            }
        }
예제 #4
0
        public OpenTicketsViewModel(IApplicationState applicationState, ITicketService ticketService)
        {
            _timer = new Timer(OnTimer, null, Timeout.Infinite, 1000);
            _applicationState = applicationState;
            _ticketService = ticketService;

            OpenTicketCommand = new DelegateCommand<int?>(OnOpenTicketExecute);

            EventServiceFactory.EventService.GetEvent<GenericEvent<Department>>().Subscribe(
                x =>
                {
                    if (x.Topic == EventTopicNames.ActivateOpenTickets)
                    {
                        _department = x.Value;
                        RaisePropertyChanged(() => OpenTicketListViewColumnCount);
                        UpdateOpenTickets(_department);
                    }
                });
        }
예제 #5
0
 public void SetCurrentDepartment(Department department)
 {
     if (CurrentDepartment == null || department != CurrentDepartment.Model)
     {
         CurrentDepartment = new CurrentDepartmentData { Model = department };
         CurrentDepartment.Model.PublishEvent(EventTopicNames.SelectedDepartmentChanged);
         SetCurrentTicketType(_cacheService.GetTicketTypeById(CurrentDepartment.TicketTypeId));
     }
     SetLocalSetting("DEPARTMENT", department.Name);
 }
예제 #6
0
        public void UpdateOpenTickets(Department department, string selectedTag, string tagFilter)
        {
            StopTimer();

            Expression<Func<Ticket, bool>> prediction;

            if (department != null && string.IsNullOrEmpty(selectedTag))
                prediction = x => !x.IsPaid && x.DepartmentId == department.Id;
            else
                prediction = x => !x.IsPaid;

            var shouldWrap = department != null && !department.IsTakeAway;

            OpenTickets = Dao.Select(x => new OpenTicketViewModel
            {
                Id = x.Id,
                LastOrderDate = x.LastOrderDate,
                TicketNumber = x.TicketNumber,
                LocationName = x.LocationName,
                CustomerName = x.CustomerName,
                RemainingAmount = x.RemainingAmount,
                Date = x.Date,
                WrapText = shouldWrap,
                TicketTag = x.Tag
            }, prediction).OrderBy(x => x.LastOrderDate);

            if (!string.IsNullOrEmpty(selectedTag))
            {
                var tagGroup = AppServices.MainDataContext.SelectedDepartment.TicketTagGroups.SingleOrDefault(
                        x => x.Name == selectedTag);

                if (tagGroup != null)
                {
                    var openTickets = GetOpenTickets(OpenTickets, tagGroup, tagFilter);

                    if (!string.IsNullOrEmpty(tagFilter.Trim()) && tagFilter != "*")
                    {
                        if (openTickets.Count() == 1)
                        {
                            OpenTicketCommand.Execute(openTickets.ElementAt(0).Id);
                        }
                        if (openTickets.Count() == 0)
                        {
                            TicketViewModel.CreateNewTicket();
                            AppServices.MainDataContext.SelectedTicket.SetTagValue(selectedTag, tagFilter);
                            RefreshSelectedTicket();
                            RefreshVisuals();
                        }
                    }

                    if (SelectedTicket == null)
                    {
                        OpenTicketTags = GetOpenTicketTags(OpenTickets, tagGroup, tagFilter);
                        OpenTickets = string.IsNullOrEmpty(tagFilter) && OpenTicketTags.Count() > 0 ? null : openTickets;
                    }
                }
            }
            else
            {
                OpenTicketTags = null;
            }

            SelectedTag = selectedTag;
            StartTimer();
        }
예제 #7
0
        public Order AddOrder(AccountTransactionType template, Department department, string userName, MenuItem menuItem, IList<TaxTemplate> taxTemplates, MenuItemPortion portion, string priceTag, ProductTimer timer)
        {
            UnLock();
            var order = OrderBuilder.Create()
                                    .WithDepartment(department)
                                    .ForMenuItem(menuItem)
                                    .WithUserName(userName)
                                    .WithTaxTemplates(taxTemplates)
                                    .WithPortion(portion)
                                    .WithPriceTag(priceTag)
                                    .WithAccountTransactionType(template)
                                    .WithProductTimer(timer)
                                    .Build();

            AddOrder(order, taxTemplates, template, userName);
            return order;
        }
예제 #8
0
        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();
        }
예제 #9
0
        private void ImportTables(Department department)
        {
            var fileName = string.Format("{0}/Imports/table{1}.txt", LocalSettings.AppPath, "_" + LocalSettings.CurrentLanguage);

            if (!File.Exists(fileName))
                fileName = string.Format("{0}/Imports/table.txt", LocalSettings.AppPath);

            if (!File.Exists(fileName)) return;

            var lines = File.ReadAllLines(fileName);
            var items = BatchCreateTables(lines, _workspace);
            _workspace.CommitChanges();

            var screen = new TableScreen { Name = Resources.AllTables, ColumnCount = 8 };
            _workspace.Add(screen);

            foreach (var table in items)
                screen.AddScreenItem(table);

            _workspace.CommitChanges();

            department.TableScreenId = screen.Id;
        }
예제 #10
0
        public static Ticket Create(Department department, Account account, IEnumerable<CalculationTemplate> calculationTemplates)
        {
            var ticket = new Ticket { DepartmentId = department.Id };

            ticket.AccountTemplateId = department.TicketTemplate.SaleTransactionTemplate.TargetAccountTemplateId;
            ticket.AccountTransactions = new AccountTransactionDocument();
            ticket.UpdateAccount(account);
            foreach (var calculationTemplate in calculationTemplates.OrderBy(x => x.Order))
            {
                ticket.AddCalculation(calculationTemplate, calculationTemplate.Amount);
            }
            return ticket;
        }
예제 #11
0
        public static Ticket Create(Department department, Account account)
        {
            var ticket = new Ticket { DepartmentId = department.Id };

            foreach (var calulationTemplate in department.TicketTemplate.CalulationTemplates.OrderBy(x => x.Order)
                .Where(x => string.IsNullOrEmpty(x.ButtonHeader)))
            {
                ticket.AddCalculation(calulationTemplate, calulationTemplate.Amount);
            }

            ticket.AccountTemplateId = department.TicketTemplate.SaleTransactionTemplate.TargetAccountTemplateId;
            ticket.AccountTransactions = new AccountTransactionDocument();
            ticket.UpdateAccount(account);
            return ticket;
        }
예제 #12
0
        public Order AddOrder(AccountTransactionType template, Department department, string userName, MenuItem menuItem, IList<TaxTemplate> taxTemplates, MenuItemPortion portion, string priceTag, ProductTimer timer)
        {
            UnLock();
            var order = new Order();
            order.UpdateMenuItem(userName, menuItem, taxTemplates, portion, priceTag, 1);
            order.AccountTransactionTypeId = template.Id;
            order.WarehouseId = department.WarehouseId;
            order.DepartmentId = department.Id;
            TransactionDocument.AddSingletonTransaction(template.Id, template, GetTicketAccounts());

            if (taxTemplates != null)
            {
                foreach (var taxTemplate in taxTemplates)
                {
                    TransactionDocument.AddSingletonTransaction(taxTemplate.AccountTransactionType.Id,
                                               taxTemplate.AccountTransactionType,
                                               GetTicketAccounts());
                }
            }

            order.UpdateProductTimer(timer);
            Orders.Add(order);
            return order;
        }
예제 #13
0
        public static Ticket Create(Department department, TicketType ticketType, decimal exchangeRate, IEnumerable<CalculationType> calculationTypes)
        {
            var ticket = new Ticket
                {
                    TicketTypeId = ticketType.Id,
                    DepartmentId = department.Id,
                    TaxIncluded = ticketType.TaxIncluded,
                    TransactionDocument = new AccountTransactionDocument(),
                    ExchangeRate = exchangeRate
                };

            if (calculationTypes != null)
            {
                foreach (var calculationType in calculationTypes.OrderBy(x => x.SortOrder))
                {
                    ticket.AddCalculation(calculationType, calculationType.Amount);
                }
            }
            return ticket;
        }
예제 #14
0
 private void OnDepartmentSelected(Department obj)
 {
     SelectedDepartment = obj;
     InvokeDepartmentSelected(EventArgs.Empty);
 }
예제 #15
0
        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);
        }
예제 #16
0
파일: Ticket.cs 프로젝트: basio/veropos
 public static Ticket Create(Department department)
 {
     var ticket = new Ticket { DepartmentId = department.Id };
     foreach (var taxServiceTemplate in department.TaxServiceTemplates)
     {
         ticket.AddTaxService(taxServiceTemplate.Id, taxServiceTemplate.CalculationMethod, taxServiceTemplate.Amount);
     }
     return ticket;
 }
예제 #17
0
        public static Ticket Create(Department department, Account account, decimal exchangeRate, IEnumerable<CalculationType> calculationTypes)
        {
            var ticket = new Ticket
                             {
                                 DepartmentId = department.Id,
                                 AccountTypeId = department.TicketTemplate.SaleTransactionType.TargetAccountTypeId,
                                 TransactionDocument = new AccountTransactionDocument()
                             };

            ticket.UpdateAccount(account, exchangeRate);

            foreach (var calculationType in calculationTypes.OrderBy(x => x.Order))
            {
                ticket.AddCalculation(calculationType, calculationType.Amount);
            }
            return ticket;
        }
예제 #18
0
 public void SetCurrentDepartment(Department department)
 {
     if (CurrentDepartment == null || department != CurrentDepartment.Model)
     {
         CurrentDepartment = new CurrentDepartmentData { Model = department };
         CurrentDepartment.Model.PublishEvent(EventTopicNames.SelectedDepartmentChanged);
     }
 }