Exemplo n.º 1
0
        public void TestInitialize()
        {
            context = new ApplicationDbContext();
            deliveryOrderService          = new DeliveryOrderService(context);
            deliveryOrderRepository       = new DeliveryOrderRepository(context);
            purchaseOrderRepository       = new PurchaseOrderRepository(context);
            inventoryRepository           = new InventoryRepository(context);
            itemRepository                = new ItemRepository(context);
            deliveryOrderDetailRepository = new DeliveryOrderDetailRepository(context);
            stockMovementRepository       = new StockMovementRepository(context);
            statusRepository              = new StatusRepository(context);

            //create test PO object and save to db

            PurchaseOrder PO = new PurchaseOrder()
            {
                PurchaseOrderNo = "VALLI",
                CreatedDateTime = DateTime.Now,
                Supplier        = context.Supplier.Where(x => x.SupplierCode == "CHEP").First()
            };

            purchaseOrderRepository.Save(PO);

            // create test DO object and save to db
            DeliveryOrder DO = new DeliveryOrder()
            {
                DeliveryOrderNo = "DOTEST",
                PurchaseOrder   = PO,
                CreatedDateTime = DateTime.Now,
                Supplier        = context.Supplier.Where(x => x.SupplierCode == "CHEP").First()
            };

            deliveryOrderRepository.Save(DO);
        }
Exemplo n.º 2
0
 public void TestInitialize()
 {
     // Arrange
     context = new ApplicationDbContext();
     deliveryOrderRepository       = new DeliveryOrderRepository(context);
     deliveryOrderDetailRepository = new DeliveryOrderDetailRepository(context);
 }
Exemplo n.º 3
0
        DeliveryService(EventLog eventLog, DeliveryOrderRepository deliveryOrderRepository, OrderingService orderingService, KitchenService kitchenService)
        {
            this.eventLog = eventLog;
            this.deliveryOrderRepository = deliveryOrderRepository;
            this.orderingService         = orderingService;
            this.kitchenService          = kitchenService;

            this.eventLog.subscribe(new Topic("kitchen_orders"), e->{
                KitchenOrderAssemblyFinishedEvent kitchenOrderAssemblyFinishedEvent = (KitchenOrderAssemblyFinishedEvent)e;
                addDeliveryOrderToRepository(kitchenOrderAssemblyFinishedEvent);
            });
Exemplo n.º 4
0
        public List <Delivery> GetDeliveries(int instanceNumber, DateTime begin, DateTime end,
                                             DeliveryOrder newDeliveryOrder)
        {
            List <Delivery> oldDeliveries =
                DeliveryOrderRepository.GetDeliveriesOrdersWithDeliveryOrderTrips(instanceNumber, begin, end);
            List <Delivery> newDeliveries = newDeliveryOrder.GetDeliveries();
            List <Delivery> deliveries    = new List <Delivery>();

            deliveries.AddRange(newDeliveries);
            deliveries.AddRange(oldDeliveries);
            return(deliveries.OrderBy(d => d.ServiceTimeBegin).ToList());
        }
 public DeliveryOrderService(ApplicationDbContext context)
 {
     this.context = context;
     this.deliveryOrderRepository        = new DeliveryOrderRepository(context);
     this.statusRepository               = new StatusRepository(context);
     this.inventoryRepository            = new InventoryRepository(context);
     this.purchaseOrderRepository        = new PurchaseOrderRepository(context);
     this.stockMovementRepository        = new StockMovementRepository(context);
     this.purchaseOrderDetailsRepository = new PurchaseOrderDetailRepository(context);
     this.itemRepository = new ItemRepository(context);
     this.deliveryOrderDetailRepository = new DeliveryOrderDetailRepository(context);
     this.purchaseOrderService          = new PurchaseOrderService(context);
 }
 public void TestInitialize()
 {
     context = new ApplicationDbContext();
     purchaseOrderService          = new PurchaseOrderService(context);
     purchaseOrderRepository       = new PurchaseOrderRepository(context);
     purchaseOrderDetailRepository = new PurchaseOrderDetailRepository(context);
     statusRepository              = new StatusRepository(context);
     itemRepository                = new ItemRepository(context);
     itemPriceRepository           = new ItemPriceRepository(context);
     supplierRepository            = new SupplierRepository(context);
     deliveryOrderRepository       = new DeliveryOrderRepository(context);
     deliveryOrderDetailRepository = new DeliveryOrderDetailRepository(context);
 }
Exemplo n.º 7
0
        public void TestCleanup()
        {
            // Delete DeliveryOrders
            var deliveryOrderRepository = new DeliveryOrderRepository(context);

            if (deliveryOrderRepository.FindAll().Where(x => x.InvoiceFileName == "IDSERVICETEST").Count() > 0)
            {
                deliveryOrderRepository.FindAll().Where(x => x.InvoiceFileName == "IDSERVICETEST").ToList().ForEach(x => deliveryOrderRepository.Delete(x));
            }

            // Delete Disbursements
            var disbursementRepository = new DisbursementRepository(context);

            if (disbursementRepository.FindAll().Where(x => x.Remarks == "IDSERVICETEST").Count() > 0)
            {
                disbursementRepository.FindAll().Where(x => x.Remarks == "IDSERVICETEST").ToList().ForEach(x => disbursementRepository.Delete(x));
            }

            // Delete Purchase Orders
            var purchaseOrderRepository = new PurchaseOrderRepository(context);

            if (purchaseOrderRepository.FindAll().Where(x => x.Status.StatusId == 16).Count() > 0)
            {
                purchaseOrderRepository.FindAll().Where(x => x.Status.StatusId == 16).ToList().ForEach(x => purchaseOrderRepository.Delete(x));
            }

            // Delete Requisitions
            var requisitionRepository = new RequisitionRepository(context);

            if (requisitionRepository.FindAll().Where(x => x.EmployeeRemarks == "IDSERVICETEST").Count() > 0)
            {
                requisitionRepository.FindAll().Where(x => x.EmployeeRemarks == "IDSERVICETEST").ToList().ForEach(x => requisitionRepository.Delete(x));
            }

            // Delete Retrievals
            var retrievalRepository = new RetrievalRepository(context);

            if (retrievalRepository.FindAll().Where(x => x.Status.StatusId == 16).Count() > 0)
            {
                retrievalRepository.FindAll().Where(x => x.Status.StatusId == 16).ToList().ForEach(x => retrievalRepository.Delete(x));
            }

            // Delete StockAdjustments
            var stockAdjustmentRepository = new StockAdjustmentRepository(context);

            if (stockAdjustmentRepository.FindAll().Where(x => x.Remarks == "IDSERVICETEST").Count() > 0)
            {
                stockAdjustmentRepository.FindAll().Where(x => x.Remarks == "IDSERVICETEST").ToList().ForEach(x => stockAdjustmentRepository.Delete(x));
            }
        }
Exemplo n.º 8
0
        public static string GetNewDeliveryOrderNo(ApplicationDbContext context)
        {
            string prefix   = "DO";
            int    serialNo = new DeliveryOrderRepository(context)
                              .FindByCreatedDateTime(DateTime.Now.Date.AddDays(1 - DateTime.Now.Date.Day), DateTime.Now.Date.AddDays(1))
                              .Where(x => x.DeliveryOrderNo.Length == 13)
                              .Count() > 0 ?
                              new DeliveryOrderRepository(context)
                              .FindByCreatedDateTime(DateTime.Now.Date.AddDays(1 - DateTime.Now.Date.Day), DateTime.Now.Date.AddDays(1))
                              .Where(x => x.DeliveryOrderNo.Length == 13)
                              .AsEnumerable()
                              .Select(x => Int32.Parse(x.DeliveryOrderNo.Substring(x.DeliveryOrderNo.Length - 3)))
                              .OrderByDescending(x => x)
                              .FirstOrDefault() + 1 : 1;

            return($"{prefix}-{DateTime.Now.Year}{DateTime.Now.Month:00}-{serialNo:000}");
        }
        public void TestInitialize()
        {
            context = new ApplicationDbContext();

            stockmovementService = new StockMovementService(context);
            itemService          = new ItemService(context);

            stockmovementRepository = new StockMovementRepository(context);

            ddRepository           = new DisbursementDetailRepository(context);
            sadRepository          = new StockAdjustmentDetailRepository(context);
            dodRepository          = new DeliveryOrderDetailRepository(context);
            disbursementRepository = new DisbursementRepository(context);
            doRepository           = new DeliveryOrderRepository(context);
            saRepository           = new StockAdjustmentRepository(context);

            //create new test object and save into db
            StockMovement sm = new StockMovement()
            {
                StockMovementId   = IdService.GetNewStockMovementId(context),
                DisbursementId    = "TEST",
                StockAdjustmentId = "TEST",
                DeliveryOrderNo   = "TEST",
                Item             = context.Item.Where(x => x.ItemCode == "C003").First(),
                CreatedDateTime  = DateTime.Now,
                OriginalQuantity = 1,
                AfterQuantity    = 2
            };

            stockmovementRepository.Save(sm);

            //create new disbursement object and save into db
            Disbursement disbursement = new Disbursement();

            if (disbursementRepository.FindById("TEST") == null)
            {
                disbursement.DisbursementId  = "TEST";
                disbursement.CreatedDateTime = DateTime.Now;
            }
            else
            {
                disbursement = disbursementRepository.FindById("TEST");
            }
            disbursementRepository.Save(disbursement);

            //create new DisbursementDetail object and save into db
            DisbursementDetail detail = new DisbursementDetail()
            {
                DisbursementId = "TEST",
                Item           = context.Item.First(),
                PlanQuantity   = 3,
                ActualQuantity = 3
            };

            ddRepository.Save(detail);

            //create new DO object and save into db
            DeliveryOrder d = new DeliveryOrder();

            if (doRepository.FindById("TEST") == null)
            {
                d.DeliveryOrderNo = "TEST";
                d.CreatedDateTime = DateTime.Now;
            }
            else
            {
                d = doRepository.FindById("TEST");
            }
            doRepository.Save(d);

            //create new DO detail object and save into db
            DeliveryOrderDetail dod = new DeliveryOrderDetail()
            {
                DeliveryOrder  = d,
                Item           = context.Item.First(),
                PlanQuantity   = 4,
                ActualQuantity = 4
            };

            dodRepository.Save(dod);

            //create new SA object and save into db
            StockAdjustment SA = new StockAdjustment();

            if (saRepository.FindById("TEST") == null)
            {
                SA.StockAdjustmentId = "TEST";
                SA.CreatedDateTime   = DateTime.Now;
            }
            else
            {
                SA = saRepository.FindById("TEST");
            }
            saRepository.Save(SA);

            //create new SA detail object and save into db
            StockAdjustmentDetail SADetail = new StockAdjustmentDetail()
            {
                StockAdjustment  = SA,
                Item             = context.Item.First(),
                OriginalQuantity = 2,
                AfterQuantity    = 4
            };

            sadRepository.Save(SADetail);
        }
Exemplo n.º 10
0
        public RepositoryFactory()
        {
            Repository                           bankRepository         = new Repository(new Bank());
            CurrencyRepository                   ccyRepository          = new CurrencyRepository();
            Repository                           divRepository          = new Repository(new Division());
            Repository                           empRepository          = new EmployeeRepository(new Employee());
            Repository                           topRepository          = new Repository(new TermOfPayment());
            Repository                           unitRepository         = new Repository(new Unit());
            Repository                           cuscatRepository       = new Repository(new CustomerCategory());
            Repository                           supcatRepository       = new Repository(new SupplierCategory());
            Repository                           pricecatRepository     = new Repository(new PriceCategory());
            Repository                           taxRepository          = new Repository(new Tax());
            Repository                           prtGroupRepository     = new Repository(new PartGroup());
            Repository                           warehouseRepository    = new Repository(new Warehouse());
            Repository                           prtCategoryRepository  = new Repository(new PartCategory());
            Repository                           docTypeRepository      = new Repository(new DocumentType());
            Repository                           excRateRepository      = new Repository(new ExchangeRate());
            CustomerRepository                   customerRepository     = new CustomerRepository();
            SupplierRepository                   supplierRepository     = new SupplierRepository();
            Repository                           yearRepository         = new YearRepository();
            Repository                           partRepository         = new PartRepository(new Part());
            StockTakingRepository                stocktakingRepository  = new StockTakingRepository();
            UserRepository                       userRepository         = new UserRepository(new User());
            GeneralSetupRepository               generalsetupRepository = new GeneralSetupRepository();
            PurchaseOrderRepository              poRepository           = new PurchaseOrderRepository();
            PeriodRepository                     periodRepository       = new PeriodRepository();
            UserSettingsRepository               usRepository           = new UserSettingsRepository();
            GoodReceiveNoteRepository            grnRepository          = new GoodReceiveNoteRepository();
            PurchaseReturnRepository             prRepository           = new PurchaseReturnRepository();
            SupplierInvoiceRepository            siRepository           = new SupplierInvoiceRepository();
            SupplierOutStandingInvoiceRepository soiRepository          = new SupplierOutStandingInvoiceRepository();
            SupplierInvoiceJournalRepository     sijRepository          = new SupplierInvoiceJournalRepository();
            PaymentRepository                    payRepository          = new PaymentRepository();
            APDebitNoteRepository                apdnRepository         = new APDebitNoteRepository();
            ProcessTransactionRepository         prtrRepository         = new ProcessTransactionRepository();
            SalesOrderRepository                 slsorderRepository     = new SalesOrderRepository();
            DeliveryOrderRepository              doRepository           = new DeliveryOrderRepository();
            SalesReturnRepository                srRepository           = new SalesReturnRepository();
            CustomerOutStandingInvoiceRepository coirRepository         = new CustomerOutStandingInvoiceRepository();
            CustomerInvoiceRepository            cirRepository          = new CustomerInvoiceRepository();
            ReceiptRepository                    rcptRepository         = new ReceiptRepository();
            ARCreditNoteRepository               arcrRepository         = new ARCreditNoteRepository();
            CustomerInvoiceJournalRepository     cijRepository          = new CustomerInvoiceJournalRepository();
            OpeningStockRepository               opstRepository         = new OpeningStockRepository();
            POSRepository                        posRepository          = new POSRepository();

            m_listService.Add(BANK_REPOSITORY, bankRepository);
            m_listService.Add(CURRENCY_REPOSITORY, ccyRepository);
            m_listService.Add(DIVISION_REPOSITORY, divRepository);
            m_listService.Add(EMPLOYEE_REPOSITORY, empRepository);
            m_listService.Add(TOP_REPOSITORY, topRepository);
            m_listService.Add(UNIT_REPOSITORY, unitRepository);
            m_listService.Add(CUSTOMER_CATEGORY_REPOSITORY, cuscatRepository);
            m_listService.Add(SUPPLIER_CATEGORY_REPOSITORY, supcatRepository);
            m_listService.Add(PRICE_CATEGORY_REPOSITORY, pricecatRepository);
            m_listService.Add(TAX_REPOSITORY, taxRepository);
            m_listService.Add(PART_GROUP_REPOSITORY, prtGroupRepository);
            m_listService.Add(WAREHOUSE_REPOSITORY, warehouseRepository);
            m_listService.Add(PART_CATEGORY_REPOSITORY, prtCategoryRepository);
            m_listService.Add(DOC_TYPE_REPOSITORY, docTypeRepository);
            m_listService.Add(EXCHANGE_RATE_REPOSITORY, excRateRepository);
            m_listService.Add(CUSTOMER_REPOSITORY, customerRepository);
            m_listService.Add(SUPPLIER_REPOSITORY, supplierRepository);
            m_listService.Add(YEAR_REPOSITORY, yearRepository);
            m_listService.Add(PART_REPOSITORY, partRepository);
            m_listService.Add(STOCKTAKING_REPOSITORY, stocktakingRepository);
            m_listService.Add(USER_REPOSITORY, userRepository);
            m_listService.Add(GENERAL_SETUP_REPOSITORY, generalsetupRepository);
            m_listService.Add(PURCHASEORDER_REPOSITORY, poRepository);
            m_listService.Add(PERIOD_REPOSITORY, periodRepository);
            m_listService.Add(USER_SETTING_REPOSITORY, usRepository);
            m_listService.Add(GOODRECEIVENOTE_REPOSITORY, grnRepository);
            m_listService.Add(PURCHASE_RETURN_REPOSITORY, prRepository);
            m_listService.Add(SUPPLIERINVOICE_REPOSITORY, siRepository);
            m_listService.Add(SUPPLIERINVOICE_JOURNAL_REPOSITORY, sijRepository);
            m_listService.Add(SUPPLIER_OUTSTANDING_INVOICE_REPOSITORY, soiRepository);
            m_listService.Add(PAYMENT_REPOSITORY, payRepository);
            m_listService.Add(APDEBITNOTE_REPOSITORY, apdnRepository);
            m_listService.Add(PROCESS_TRANSACTION_REPOSITORY, prtrRepository);
            m_listService.Add(SALES_ORDER_REPOSITORY, slsorderRepository);
            m_listService.Add(DELIVERY_ORDER_REPOSITORY, doRepository);
            m_listService.Add(SALES_RETURN_REPOSITORY, srRepository);
            m_listService.Add(CUSTOMER_OUTSTANDING_INVOICE_REPOSITORY, coirRepository);
            m_listService.Add(CUSTOMERINVOICE_REPOSITORY, cirRepository);
            m_listService.Add(RECEIPT_REPOSITORY, rcptRepository);
            m_listService.Add(ARCREDITNOTE_REPOSITORY, arcrRepository);
            m_listService.Add(CUSTOMERINVOICE_JOURNAL_REPOSITORY, cijRepository);
            m_listService.Add(OPENING_STOCK_REPOSITORY, opstRepository);
            m_listService.Add(POS_REPOSITORY, posRepository);
        }