Beispiel #1
0
 public Transaction(Guid id, TransactionType type, Username username, Amount amount, TransactionDateTime dateTime, Guid categoryId, TransactionDescription?description = null)
 {
     Id = id;
     TransactionType = type;
     Username        = username;
     Amount          = amount;
     DateTime        = dateTime;
     CategoryId      = categoryId;
     Description     = description;
 }
            public CloseReopenTransactionBuilder()
            {
                var now = TimeProvider.Now;

                _description         = new CustomerFriendlyDescription($"{nameof(CloseReopenTransactionBuilder).Replace("Builder", "")}");
                _transactionDateTime = new TransactionDateTime(now);
                _businessDate        = new BusinessDate(now);
                _cardPresent         = new CardPresent(false);
                _currency            = new Currency(Currency.Kind.DKK);
                _traceId             = new TraceId(Guid.NewGuid());
            }
 public CloseReopenTransactionBuilder WithTransactionDateTime(DateTime timestamp)
 {
     _transactionDateTime = new TransactionDateTime(timestamp);
     return(this);
 }
Beispiel #4
0
        void rcpt_PrintPage(object sender, PrintPageEventArgs e)
        {
            // Initialize printing stuff
            Graphics g = e.Graphics;

            Font  font  = new Font("Arial", 12);
            Brush brush = Brushes.Black;

            StringFormat leftAlign = new StringFormat()
            {
                Alignment = StringAlignment.Near
            };
            StringFormat rightAlign = new StringFormat()
            {
                Alignment = StringAlignment.Far
            };
            StringFormat centerAlign = new StringFormat()
            {
                Alignment = StringAlignment.Center
            };

            RectangleF cursor = new RectangleF(e.PageBounds.X, e.PageBounds.Y, e.PageBounds.Width, font.Height);

            // Print Logo
            g.DrawImage(logo, cursor.Width / 2 - logo.Width / 2, cursor.Top);
            cursor.Y += logo.Height;

            // Print InvoiceID Barcode
            g.DrawString(InvoiceID.ToString(), font, brush, cursor, leftAlign);
            cursor.Y += font.Height;

            // Print Header
            g.DrawString(header, font, brush, cursor, centerAlign);
            cursor.Y += font.Height; //TODO: Will nee to handle multiline headers well

            // Print InvoiceID
            g.DrawString("Invoice #: " + InvoiceID.ToString(), font, brush, cursor, leftAlign);


            // Print Location
            g.DrawString("Location" + Location, font, brush, cursor, rightAlign);
            cursor.Y += font.Height;

            // Date and time
            g.DrawString("Date and time: " + TransactionDateTime.ToString(), font, brush, cursor, leftAlign);
            cursor.Y += font.Height;

            // Print Items
            g.DrawString("---------------------------------", font, brush, cursor, leftAlign);
            cursor.Y += font.Height;

            foreach (Item item in Items)
            {
                g.DrawString(item.NumSold + " " + item.Name, font, brush, cursor, leftAlign);
                g.DrawString("$ " + item.Price.ToString(), font, brush, cursor, rightAlign);
                cursor.Y += font.Height;
            }

            g.DrawString("---------------------------------", font, brush, cursor, leftAlign);
            cursor.Y += font.Height;

            // Print subtotal
            g.DrawString("SubTotal:", font, brush, cursor, leftAlign);
            g.DrawString("$ " + Subtotal.ToString(), font, brush, cursor, rightAlign);
            cursor.Y += font.Height;

            // Print tax
            g.DrawString("Tax:", font, brush, cursor, leftAlign);
            g.DrawString("$ " + Tax.ToString(), font, brush, cursor, rightAlign);
            cursor.Y += font.Height;

            // Print total
            g.DrawString("TOTAL:", font, brush, cursor, leftAlign);
            g.DrawString("$ " + Total.ToString(), font, brush, cursor, rightAlign);
            cursor.Y += font.Height;

            g.DrawString("---------------------------------", font, brush, cursor, leftAlign);
            cursor.Y += font.Height;

            // Print # of items
            g.DrawString("# of Items: " + Items.Count.ToString(), font, brush, cursor, leftAlign);
            cursor.Y += font.Height;

            // Print Payment Method
            // Print # of items
            g.DrawString("Payment Method: " + PayMethod + ": " + PayNum, font, brush, cursor, leftAlign);
            cursor.Y += font.Height;

            //Print footer
            // Print # of items
            g.DrawString(footer, font, brush, cursor, centerAlign);
            cursor.Y += font.Height; //TODO: Will nee to handle multiline footers well
        }
Beispiel #5
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity <Transaction>(e =>
            {
                e.ToTable("Transaction");

                e.HasKey(t => t.Id);

                e.Property(t => t.Amount)
                .HasConversion(a => a.Value, d => Amount.From(d))
                .IsRequired()
                ;

                e.Property(t => t.CreatedOnUtc).HasDefaultValue(DateTime.UtcNow)
                .HasColumnType("timestamp with time zone");

                e.Property(t => t.Description)
                .HasMaxLength(1024)
                .HasConversion(d => d.Value, s => TransactionDescription.From(s));

                e.Property(t => t.Username)
                .HasConversion(u => u.Value, s => Username.From(s))
                .IsRequired();

                // e.HasOne(typeof(Transaction), "_user").WithMany("_transaction").HasForeignKey("Username");
                e.HasOne(t => t.User).WithMany(u => u.Transactions).HasForeignKey(t => t.Username);

                e.HasOne(t => t.Category).WithMany(c => c.Transactions).HasForeignKey(t => t.CategoryId);

                e.Property(t => t.CategoryId).IsRequired();

                e.Property(t => t.DateTime)
                .HasConversion(d => d.Value, time => TransactionDateTime.From(time))
                .HasColumnType("timestamp with time zone")
                .IsRequired();

                e.Property(t => t.TransactionType).IsRequired();
            });

            modelBuilder.Entity <Category>(e =>
            {
                e.ToTable("Category");
                // e.HasKey(c => new {c.Name, c.TransactionType});
                e.Property(u => u.Name).IsRequired().HasMaxLength(20);
                e.Property(c => c.Id).IsRequired();

                e.HasIndex(c => new { c.Name, c.TransactionType }).IsUnique();

                e.HasData(
                    new Category(Guid.NewGuid(), "Food & Drinks", TransactionType.Expense),
                    new Category(Guid.NewGuid(), "Travel", TransactionType.Expense),
                    new Category(Guid.NewGuid(), "Transfer", TransactionType.Expense),
                    new Category(Guid.NewGuid(), "Bills", TransactionType.Expense),
                    new Category(Guid.NewGuid(), "Salary", TransactionType.Income),
                    new Category(Guid.NewGuid(), "Transfer", TransactionType.Income)
                    );
            });

            modelBuilder.Entity <User>(e =>
            {
                e.ToTable("User");
                e.HasIndex(u => u.Email).IsUnique();

                e.Property(u => u.CreatedOnUtc).HasDefaultValue(DateTime.UtcNow)
                .HasColumnType("timestamp with time zone");
                e.Property(u => u.LastModifiedUtc).HasColumnType("timestamp with time zone");

                e.Property(u => u.FirstName).IsRequired().HasMaxLength(32);
                e.Property(u => u.LastName).IsRequired().HasMaxLength(32);

                e.Property(u => u.Password).HasColumnName("Password").HasMaxLength(128).HasConversion(p => p.Value, s => Password.From(s));

                // e.OwnsOne(u => u.Password).Property(p => p.Value).HasColumnName("Password").HasMaxLength(32);

                e.HasKey(u => u.Username);

                e.Property(u => u.Username)
                .IsRequired()
                .HasMaxLength(16)
                .HasConversion(u => u.Value, s => Username.From(s));

                e.Property(u => u.Email)
                .IsRequired()
                .HasMaxLength(32)
                .HasConversion(em => em.Value, s => Email.From(s));


                var passwordHelper    = new PasswordHelper();
                const string username = "******";
                var hashedPassword    = passwordHelper.GeneratePasswordHash("Sanjay_11!", username);

                e.HasData(
                    new User(username, "*****@*****.**", hashedPassword, "Sanjay", "Idpuganti")
                    );
            });
        }
        // Event handler for printing receipt
        void rcpt_PrintPage(object sender, PrintPageEventArgs e)
        {
            // Initialize printing stuff
            Graphics g = e.Graphics;

            Font font        = new Font("Arial", 10);
            Font barcodeFont = new Font("Free 3 of 9", 36); //Will default to Sans Serif if not installed

            float lSpacing = 5F;
            Brush brush    = Brushes.Black;
            Pen   pen      = new Pen(brush);

            StringFormat leftAlign = new StringFormat()
            {
                Alignment = StringAlignment.Near
            };
            StringFormat centerAlign = new StringFormat()
            {
                Alignment = StringAlignment.Center
            };
            StringFormat rightAlign = new StringFormat()
            {
                Alignment = StringAlignment.Far
            };

            RectangleF cursor = new RectangleF(e.PageBounds.X, e.PageBounds.Y, e.PageBounds.Width, font.Height);

            // Print Logo
            g.DrawImage(logo, cursor.Width / 2 - logo.Width / 2, cursor.Top);
            cursor.Y += logo.Height + lSpacing;

            // Print InvoiceID Barcode
            cursor = printText("*" + InvoiceID.ToString() + "*", true, g, barcodeFont, brush, cursor, centerAlign, lSpacing);

            // Print Header
            cursor = printHeaderFooter(header, g, font, brush, cursor, centerAlign, lSpacing);

            // Print InvoiceID
            cursor = printText("Invoice #: " + InvoiceID.ToString(), true, g, font, brush, cursor, leftAlign, lSpacing);

            // Print RegisterID
            cursor = printText("Register ID: " + RegisterID.ToString(), false, g, font, brush, cursor, leftAlign, lSpacing);

            // Print Location
            cursor = printText("Location: " + Location, true, g, font, brush, cursor, rightAlign, lSpacing);

            // Date and time
            cursor = printText("Date and time: " + TransactionDateTime.ToString(), true, g, font, brush, cursor, leftAlign, lSpacing);

            // Print Separator
            cursor = printHorizontalLine(g, font, pen, cursor, lSpacing);

            // Print Items
            foreach (Item item in Items)
            {
                cursor = printText(item.NumSold + " " + item.Name, false, g, font, brush, cursor, leftAlign, lSpacing);
                cursor = printText("$ " + item.Price.ToString(), true, g, font, brush, cursor, rightAlign, lSpacing);
            }

            // Print Separator
            cursor = printHorizontalLine(g, font, pen, cursor, lSpacing);

            // Print subtotal
            cursor = printText("SubTotal:", false, g, font, brush, cursor, leftAlign, lSpacing);
            cursor = printText("$ " + Subtotal.ToString(), true, g, font, brush, cursor, rightAlign, lSpacing);

            // Print tax
            cursor = printText("Tax:", false, g, font, brush, cursor, leftAlign, lSpacing);
            cursor = printText("$ " + Tax.ToString(), true, g, font, brush, cursor, rightAlign, lSpacing);

            // Print total
            cursor = printText("TOTAL:", false, g, font, brush, cursor, leftAlign, lSpacing);
            cursor = printText("$ " + Total.ToString(), true, g, font, brush, cursor, rightAlign, lSpacing);

            // Print Separator
            cursor = printHorizontalLine(g, font, pen, cursor, lSpacing);

            // Print # of items
            cursor = printText("# of Items: " + Items.Count.ToString(), true, g, font, brush, cursor, leftAlign, lSpacing);

            // Print Payment Method
            cursor = printText("Payment Method: " + PayMethod + ": " + PayNum, true, g, font, brush, cursor, leftAlign, lSpacing);

            //Print footer
            cursor = printHeaderFooter(footer, g, font, brush, cursor, centerAlign, lSpacing);
        }