Beispiel #1
0
        private static IWorkspace PrepareMenu(string fileName)
        {
            var pth = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            pth = Path.Combine(pth, "..\\..\\..\\Samba.Presentation");
            LocalSettings.AppPath = pth;
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            WorkspaceFactory.SetDefaultConnectionString(fileName);
            var dataCreationService = new DataCreationService();

            dataCreationService.CreateData();
            var workspace = WorkspaceFactory.Create();

            return(workspace);
        }
Beispiel #2
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);
        }