Пример #1
0
        public static void Initialize(MyRestaurantContext context)
        {
            PaymentTypeInitializer.Initialize(context);
            UnitOfMeasureInitializer.Initialize(context);
            StockTypeInitializer.Initialize(context);
            StockItemInitializer.Initialize(context);
            SupplierInitializer.Initialize(context);
            UserInitializer.Initialize(context);
            PurchaseOrderInitializer.Initialize(context);
            PurchaseOrderItemInitializer.Initialize(context);

            if (!context.GoodsReceivedNotes.Any())
            {
                var goodsReceivedNotes = new List <GoodsReceivedNote>
                {
                    new GoodsReceivedNote {
                        PurchaseOrderId = 1,
                        InvoiceNumber   = "INV_20210132_01",
                        PaymentTypeId   = 1,
                        Nbt             = 0.5m,
                        Vat             = 0.5m,
                        Discount        = 0.5m,
                        ReceivedBy      = context.Users.First(d => d.FirstName == "Admin").Id,
                        ReceivedDate    = DateTime.Now.AddDays(-5),
                        ApprovedBy      = Guid.Empty,
                        ApprovalStatus  = Status.Pending,
                        ApprovedDate    = default,
        public static void Initialize(MyRestaurantContext context)
        {
            StockItemInitializer.Initialize(context);
            PurchaseOrderInitializer.Initialize(context);

            if (!context.PurchaseOrderItems.Any())
            {
                var items = new List <PurchaseOrderItem>
                {
                    new PurchaseOrderItem {
                        PurchaseOrderId = 1, ItemId = 1, ItemUnitPrice = 540, Quantity = 5
                    },
                    new PurchaseOrderItem {
                        PurchaseOrderId = 2, ItemId = 2, ItemUnitPrice = 30, Quantity = 10
                    },
                    new PurchaseOrderItem {
                        PurchaseOrderId = 1, ItemId = 3, ItemUnitPrice = 50, Quantity = 5
                    },
                    new PurchaseOrderItem {
                        PurchaseOrderId = 2, ItemId = 4, ItemUnitPrice = 260, Quantity = 6
                    },
                    new PurchaseOrderItem {
                        PurchaseOrderId = 3, ItemId = 15, ItemUnitPrice = 8500, Quantity = 1
                    },
                    new PurchaseOrderItem {
                        PurchaseOrderId = 4, ItemId = 21, ItemUnitPrice = 3240, Quantity = 3
                    },
                    new PurchaseOrderItem {
                        PurchaseOrderId = 5, ItemId = 29, ItemUnitPrice = 450, Quantity = 40
                    },
                    new PurchaseOrderItem {
                        PurchaseOrderId = 6, ItemId = 28, ItemUnitPrice = 320, Quantity = 20
                    }
                };
                context.PurchaseOrderItems.AddRange(items);
                context.SaveChanges();
            }
        }
Пример #3
0
 public PurchaseOrderServiceTest()
 {
     PurchaseOrderInitializer.Initialize(_myRestaurantContext);
 }