Пример #1
0
        public async Task <Lib.Models.UnitReceiptNoteModel.UnitReceiptNote> GetNewHavingStockData(string user)
        {
            DeliveryOrder deliveryOrder = await deliveryOrderDataUtil.GetTestHavingStockData(user);

            List <DeliveryOrderItem>   doItem   = new List <DeliveryOrderItem>(deliveryOrder.Items);
            List <DeliveryOrderDetail> doDetail = new List <DeliveryOrderDetail>(doItem[0].Details);


            doItem[0].Details = doDetail;
            return(new Lib.Models.UnitReceiptNoteModel.UnitReceiptNote
            {
                UnitId = doDetail[0].UnitId,
                UnitCode = doDetail[0].UnitCode,
                UnitName = "UnitName",
                Remark = "Test URN",
                SupplierCode = deliveryOrder.SupplierCode,
                SupplierId = deliveryOrder.SupplierId,
                SupplierName = deliveryOrder.SupplierName,
                ReceiptDate = DateTimeOffset.UtcNow,
                DOId = deliveryOrder.Id,
                DONo = deliveryOrder.DONo,
                Items = new List <Lib.Models.UnitReceiptNoteModel.UnitReceiptNoteItem> {
                    unitReceiptNoteItemDataUtil.GetNewData(doItem)
                }
            });
        }
Пример #2
0
        public async Task <Lib.Models.UnitReceiptNoteModel.UnitReceiptNote> GetNewDatas(string user)
        {
            DeliveryOrder deliveryOrder = await deliveryOrderDataUtil.GetTestData(user);

            List <DeliveryOrderItem>   doItem   = new List <DeliveryOrderItem>(deliveryOrder.Items);
            List <DeliveryOrderDetail> doDetail = new List <DeliveryOrderDetail>(doItem[0].Details);
            var dt = DateTime.Now;

            dt = dt.Date;

            doItem[0].Details = doDetail;
            return(new Lib.Models.UnitReceiptNoteModel.UnitReceiptNote
            {
                UnitId = doDetail[0].UnitId,
                UnitCode = doDetail[0].UnitCode,
                UnitName = "UnitName",
                Remark = "Test URN",
                URNNo = "BPI-001",
                SupplierCode = deliveryOrder.SupplierCode,
                SupplierId = deliveryOrder.SupplierId,
                SupplierName = deliveryOrder.SupplierName,
                ReceiptDate = new DateTimeOffset(new DateTime(dt.Ticks), TimeSpan.Zero),
                DOId = deliveryOrder.Id,
                DONo = deliveryOrder.DONo,
                Items = new List <Lib.Models.UnitReceiptNoteModel.UnitReceiptNoteItem> {
                    unitReceiptNoteItemDataUtil.GetNewData(doItem)
                }
            });
        }
Пример #3
0
        public dynamic Insert(DeliveryOrder model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Create", Core.Constants.Constant.MenuName.DeliveryOrder, Core.Constants.Constant.MenuGroupName.Transaction))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Add record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                model = _deliveryOrderService.CreateObject(model, _salesOrderService, _warehouseService);
            }
            catch (Exception ex)
            {
                LOG.Error("Insert Failed", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Errors
            }));
        }
Пример #4
0
        public dynamic Delete(DeliveryOrder model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Delete", Core.Constants.Constant.MenuName.DeliveryOrder, Core.Constants.Constant.MenuGroupName.Transaction))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Delete Record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                var data = _deliveryOrderService.GetObjectById(model.Id);
                model = _deliveryOrderService.SoftDeleteObject(data, _deliveryOrderDetailService);
            }
            catch (Exception ex)
            {
                LOG.Error("Delete Failed", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Errors
            }));
        }
Пример #5
0
        public override string GenerateFile()
        {
            DeliveryOrder p = new DeliveryOrder();

            p.SetDateSource(this);
            return(this.ExportPdf(p));
        }
Пример #6
0
        private async Task <Job> PostOrderToJob(OrderModel model, string adminUserId = null)
        {
            UserModel userModel      = new UserModel(await accountManager.FindByIdAsync(model.UserId));
            UserModel adminUserModel = null;

            Vendor vendor = default(Vendor);

            if (!string.IsNullOrWhiteSpace(model.VendorId))
            {
                vendor = await vendorService.Get(model.VendorId);
            }

            if (!string.IsNullOrWhiteSpace(adminUserId))
            {
                adminUserModel = new UserModel(await accountManager.FindByIdAsync(adminUserId));
            }

            JobShop    jobShop = new JobShop();
            JobBuilder builder;

            switch (model.Type)
            {
            case OrderTypes.ClassifiedDelivery:
            {
                ClassifiedDeliveryOrder classifiedDeliveryOrderModel = model as ClassifiedDeliveryOrder;
                if (!string.IsNullOrWhiteSpace(classifiedDeliveryOrderModel.BuyerInfo?.UserRef))
                {
                    var user = await accountManager.FindByIdAsync(classifiedDeliveryOrderModel.BuyerInfo.UserRef);

                    classifiedDeliveryOrderModel.BuyerInfo.PhoneNumber = user.PhoneNumber;
                    classifiedDeliveryOrderModel.BuyerInfo.Address     = user.Profile.Address;
                    classifiedDeliveryOrderModel.BuyerInfo.Name        = GetNameFromProfile(user);
                }
                if (!string.IsNullOrWhiteSpace(classifiedDeliveryOrderModel.SellerInfo?.UserRef))
                {
                    var user = await accountManager.FindByIdAsync(classifiedDeliveryOrderModel.SellerInfo.UserRef);

                    classifiedDeliveryOrderModel.SellerInfo.PhoneNumber = user.PhoneNumber;
                    classifiedDeliveryOrderModel.SellerInfo.Address     = user.Profile.Address;
                    classifiedDeliveryOrderModel.SellerInfo.Name        = GetNameFromProfile(user);
                }
                builder = GetDeliveryJobBuilder(userModel, adminUserModel, classifiedDeliveryOrderModel, vendor);
                break;
            }

            case OrderTypes.Delivery:
            {
                DeliveryOrder deliveryOrderModel = model as DeliveryOrder;
                builder = GetDeliveryJobBuilder(userModel, adminUserModel, deliveryOrderModel, vendor);
                break;
            }

            default:
                throw new InvalidOperationException("Invalid/Not supported Order Type Provided");
            }
            var result = await ConstructAndRegister(jobShop, builder);

            this.jobSearchIndexService.OnNext(result);
            return(result);
        }
Пример #7
0
        public ActionResult SetDate(int id, DateTime?value)
        {
            var entity = DeliveryOrder.Find(id);

            if (entity.IsCompleted || entity.IsCancelled)
            {
                Response.StatusCode = 400;
                return(Content(Resources.ItemAlreadyCompletedOrCancelled));
            }

            entity.Updater          = CurrentUser.Employee;
            entity.ModificationTime = DateTime.Now;

            if (value != null)
            {
                entity.Date = value.Value;
            }
            else
            {
                entity.Date = null;
            }
            using (var scope = new TransactionScope()) {
                entity.UpdateAndFlush();
            }


            return(Json(new {
                id = id,
                value = entity.FormattedValueFor(x => x.Date)
            }));
        }
Пример #8
0
        public ActionResult Cancel(int id)
        {
            var entity = DeliveryOrder.TryFind(id);

            if (entity == null || entity.IsCancelled || entity.IsDelivered)
            {
                return(RedirectToAction("Index"));
            }

            entity.IsCancelled      = true;
            entity.ModificationTime = DateTime.Now;
            entity.Updater          = CurrentUser.Employee;

            using (var scope = new TransactionScope()) {
                entity.UpdateAndFlush();
            }

            var Orders = entity.Details.Select(x => x.OrderDetail.SalesOrder).Distinct();

            foreach (var Order in Orders)
            {
                bool NotYetCompleted = Order.Details.Any(x => GetRemainQuantityBySalesOrderDetail(x) > 0.0m);

                if (NotYetCompleted)
                {
                    Order.IsDelivered = false;
                    using (var scope = new TransactionScope()) {
                        Order.UpdateAndFlush();
                    }
                }
            }

            return(RedirectToAction("Index"));
        }
Пример #9
0
        public ActionResult Edit(int id)
        {
            var item = DeliveryOrder.Find(id);

            if (item.IsCompleted || item.IsCancelled)
            {
                return(RedirectToAction("View", new { id = item.Id }));
            }

            if (!CashHelpers.ValidateExchangeRate())
            {
                return(View("InvalidExchangeRate"));
            }

            foreach (var detail in item.Details)
            {
                if (detail.Quantity > GetRemainQuantityBySalesOrderDetail(detail.OrderDetail))
                {
                    detail.Quantity = GetRemainQuantityBySalesOrderDetail(detail.OrderDetail);
                }
            }

            using (var scope = new TransactionScope()) {
                item.UpdateAndFlush();
            }

            return(View(item));
        }
Пример #10
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);
        }
Пример #11
0
 private void CopyFromSO_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e)
 {
     if (View.ObjectTypeInfo.Type == typeof(DeliveryOrder))
     {
         if (((DetailView)View).ViewEditMode == ViewEditMode.View)
         {
             MessageOptions messageOptions = new MessageOptions();
             messageOptions.Duration = 3000;
             messageOptions.Type     = InformationType.Error;
             messageOptions.Message  = "View mode cannot proceed.";
             Application.ShowViewStrategy.ShowMessage(messageOptions);
         }
         else
         {
             DeliveryOrder currentObject = (DeliveryOrder)View.CurrentObject;
             if (currentObject.CustomerID == null)
             {
                 MessageOptions messageOptions = new MessageOptions();
                 messageOptions.Duration = 3000;
                 messageOptions.Type     = InformationType.Error;
                 messageOptions.Message  = "Must select customer";
                 Application.ShowViewStrategy.ShowMessage(messageOptions);
             }
             else
             {
                 GeneralValues.CustomerIid = currentObject.CustomerID.Oid;
             }
         }
         e.View = Application.CreateListView(typeof(SalesOrderDetail), true);
     }
 }
Пример #12
0
        public dynamic UnConfirm(DeliveryOrder model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("UnConfirm", Core.Constants.Constant.MenuName.DeliveryOrder, Core.Constants.Constant.MenuGroupName.Transaction))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to UnConfirm record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                var data = _deliveryOrderService.GetObjectById(model.Id);
                model = _deliveryOrderService.UnconfirmObject(data, _deliveryOrderDetailService, _salesInvoiceService, _salesInvoiceDetailService, _salesOrderService, _salesOrderDetailService, _stockMutationService, _itemService, _barringService, _warehouseItemService);
            }
            catch (Exception ex)
            {
                LOG.Error("Unconfirm Failed", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Errors
            }));
        }
Пример #13
0
        public async void Should_Success_Get_Report_Data()
        {
            ExternalPurchaseOrder externalPurchaseOrder = await EPODataUtil.GetNewData("unit-test");

            await EPOFacade.Create(externalPurchaseOrder, "unit-test", 7);

            DeliveryOrder deliveryOrder = await DODataUtil.GetNewData("unit-test");

            await DOFacade.Create(deliveryOrder, "unit-test");

            UnitReceiptNote urn = await DataUtil.GetNewDatas("unit-test");

            await Facade.Create(urn, "unit-test");

            //UnitPaymentOrder upo = await UPODataUtil.GetTestData();
            //await UPOFacade.Create(upo, "unit-test", false, 7);
            var DateFrom = DateTime.Now;

            DateFrom = DateFrom.Date;
            var DateTo = DateTime.Now;

            DateTo = DateTo.Date;
            var Response = IPRFacade.GetReport(null, null, null, DateFrom, DateTo);

            Assert.NotEqual(Response.Item2, 0);
        }
        private async Task <int> AddFulfillmentAsync(DeliveryOrder model, string username)
        {
            var internalPOFacade = serviceProvider.GetService <InternalPurchaseOrderFacade>();
            int count            = 0;

            foreach (var item in model.Items)
            {
                foreach (var detail in item.Details)
                {
                    var fulfillment = new InternalPurchaseOrderFulFillment()
                    {
                        DeliveryOrderDate = model.ArrivalDate,
                        DeliveryOrderDeliveredQuantity = detail.DOQuantity,
                        DeliveryOrderDetailId          = detail.Id,
                        DeliveryOrderId     = model.Id,
                        DeliveryOrderItemId = item.Id,
                        DeliveryOrderNo     = model.DONo,
                        SupplierDODate      = model.DODate,
                        POItemId            = detail.POItemId
                    };


                    count += await internalPOFacade.CreateFulfillmentAsync(fulfillment, username);
                }
            }
            return(count);
        }
Пример #15
0
        public async Task <IActionResult> Post([FromBody] DeliveryOrderViewModel viewModel)
        {
            identityService.Token    = Request.Headers["Authorization"].First().Replace("Bearer ", "");
            identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;

            ValidateService validateService = (ValidateService)facade.serviceProvider.GetService(typeof(ValidateService));

            try
            {
                validateService.Validate(viewModel);

                DeliveryOrder model = mapper.Map <DeliveryOrder>(viewModel);

                int result = await facade.Create(model, identityService.Username);

                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.CREATED_STATUS_CODE, General.OK_MESSAGE)
                    .Ok();
                return(Created(String.Concat(Request.Path, "/", 0), Result));
            }
            catch (ServiceValidationExeption e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE)
                    .Fail(e);
                return(BadRequest(Result));
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
Пример #16
0
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] DeliveryOrderViewModel vm)
        {
            identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;

            DeliveryOrder m = mapper.Map <DeliveryOrder>(vm);

            ValidateService validateService = (ValidateService)facade.serviceProvider.GetService(typeof(ValidateService));

            try
            {
                validateService.Validate(vm);

                int result = await facade.Update(id, m, identityService.Username);

                return(NoContent());
            }
            catch (ServiceValidationExeption e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE)
                    .Fail(e);
                return(BadRequest(Result));
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
Пример #17
0
        public dynamic GetInfo(int Id)
        {
            DeliveryOrder model = new DeliveryOrder();

            try
            {
                model = _deliveryOrderService.GetObjectById(Id);
            }
            catch (Exception ex)
            {
                LOG.Error("GetInfo", ex);
                model.Errors.Add("Generic", "Error : " + ex);
            }

            return(Json(new
            {
                model.Id,
                model.Code,
                model.SalesOrderId,
                SalesOrder = _salesOrderService.GetObjectById(model.SalesOrderId).Code,
                model.DeliveryDate,
                model.WarehouseId,
                Warehouse = _warehouseService.GetObjectById(model.WarehouseId).Name,
                model.Errors
            }, JsonRequestBehavior.AllowGet));
        }
Пример #18
0
        public async void Should_Success_Get_Report_Data()
        {
            var serviceProvider = new Mock <IServiceProvider>();
            ExternalPurchaseOrder externalPurchaseOrder = await EPODataUtil.GetTestData("Unit test");

            DeliveryOrder deliveryOrder = await DODataUtil.GetTestData("unit-test");

            UnitReceiptNote urn = await DataUtil.GetTestData3("unit-test");

            UnitReceiptNoteFacade facade = new UnitReceiptNoteFacade(serviceProvider.Object, _dbContext(GetCurrentMethod()));

            await _dataUtil(facade, GetCurrentMethod()).GetTestData("unit-test");

            //UnitPaymentOrder upo = await UPODataUtil.GetTestData();
            //await UPOFacade.Create(upo, "unit-test", false, 7);
            var DateFrom = DateTime.Now;

            DateFrom = DateFrom.Date;
            var DateTo = DateTime.Now;

            DateTo = DateTo.Date;
            if (externalPurchaseOrder != null && deliveryOrder != null && urn != null)
            {
                var Response = Facade.GetReport(null, null, null, DateFrom, DateTo);
                Assert.NotEqual(Response.Item2, 0);
            }
        }
Пример #19
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var obj = JObject.Load(reader);
            OrderModel orderModel;

            var type = obj["Type"];
            if (type == null)
            {
                throw new ArgumentNullException("Type", "Order type is null");
            }

            string orderType = type.Value<string>();
            switch (orderType)
            {
                case OrderTypes.Ride:
                    orderModel = new RideOrder();
                    break;
                case OrderTypes.Delivery:
                    orderModel = new DeliveryOrder();
                    break;
                case OrderTypes.ClassifiedDelivery:
                    orderModel = new ClassifiedDeliveryOrder();
                    break;
                default:
                    throw new NotSupportedException(string.Concat("Order Entry type invalid/not supported - ", orderType));
            }

            serializer.Populate(obj.CreateReader(), orderModel);
            return orderModel;

        }
Пример #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DeliveryOrder order     = DeliveryOrder.TryFind(Request.QueryString["Id"]);
            int           pageindex = Request.QueryString["pageindex"] + "" == "" ? 1 : Convert.ToInt32(Request.QueryString["pageindex"]);

            if (order == null)
            {
                return;
            }

            //循环子商品
            string strjosn = order.Child.Substring(1, order.Child.Length - 2);

            string[] objarr = strjosn.Replace("},{", "#").Split('#');

            //计算pagecount
            string db        = ConfigurationManager.AppSettings["ExamineDB"];
            int    pgcount   = DataHelper.QueryValue <int>("select top 1 Count from " + db + "..PrintCount");
            int    pagecount = 0;

            if (pgcount != 0)
            {
                pagecount = (objarr.Length % pgcount) == 0 ? objarr.Length / pgcount : (objarr.Length / pgcount) + 1;
            }
            lblpagecount.InnerText = pagecount == 0 ? 1 + "" : pagecount + "";
        }
Пример #21
0
        public IHttpActionResult PutDeliveryOrder(int id, DeliveryOrder deliveryOrder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != deliveryOrder.ID)
            {
                return(BadRequest());
            }

            db.Entry(deliveryOrder).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DeliveryOrderExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task Should_Error_Update_Invalid_Data()
        {
            DeliveryOrder model = await DataUtil.GetTestData(USERNAME);

            var responseGetById = await this.Client.GetAsync($"{URI}/{model.Id}");

            var json = await responseGetById.Content.ReadAsStringAsync();

            Dictionary <string, object> result = JsonConvert.DeserializeObject <Dictionary <string, object> >(json.ToString());

            Assert.True(result.ContainsKey("apiVersion"));
            Assert.True(result.ContainsKey("message"));
            Assert.True(result.ContainsKey("data"));
            Assert.True(result["data"].GetType().Name.Equals("JObject"));

            DeliveryOrderViewModel viewModel = JsonConvert.DeserializeObject <DeliveryOrderViewModel>(result.GetValueOrDefault("data").ToString());

            viewModel.date     = DateTimeOffset.MinValue;
            viewModel.supplier = null;
            viewModel.items    = new List <DeliveryOrderItemViewModel> {
            };

            var response = await this.Client.PutAsync($"{URI}/{model.Id}", new StringContent(JsonConvert.SerializeObject(viewModel).ToString(), Encoding.UTF8, MediaType));

            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
        }
Пример #23
0
        public async Task <UnitReceiptNoteViewModel> GetNewDataViewModel(string user)
        {
            DeliveryOrder deliveryOrder = await deliveryOrderDataUtil.GetTestData(user);

            List <DeliveryOrderItem> doItem = new List <DeliveryOrderItem>(deliveryOrder.Items);

            return(new UnitReceiptNoteViewModel
            {
                date = DateTimeOffset.Now,
                supplier = new SupplierViewModel
                {
                    _id = deliveryOrder.SupplierId,
                    code = deliveryOrder.SupplierCode,
                    name = deliveryOrder.SupplierName,
                    import = true
                },
                unit = new UnitViewModel
                {
                    _id = "UnitId",
                    code = "UnitCode",
                    name = "UnitName",
                    division = new DivisionViewModel
                    {
                        _id = "DivisionId",
                        code = "DivisionCode",
                        name = "DivisionName",
                    }
                },
                doNo = deliveryOrder.DONo,
                remark = "test",
                items = new List <UnitReceiptNoteItemViewModel> {
                    unitReceiptNoteItemDataUtil.GetNewDataViewModel(doItem)
                }
            });
        }
Пример #24
0
        public DeliveryOrderDetail ConfirmObject(DeliveryOrderDetail deliveryOrderDetail, DateTime ConfirmationDate, IDeliveryOrderService _deliveryOrderService, ISalesOrderDetailService _salesOrderDetailService,
                                                 IStockMutationService _stockMutationService, IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
        {
            deliveryOrderDetail.ConfirmationDate = ConfirmationDate;
            if (_validator.ValidConfirmObject(deliveryOrderDetail, _deliveryOrderService, this, _salesOrderDetailService, _itemService, _warehouseItemService))
            {
                deliveryOrderDetail = _repository.ConfirmObject(deliveryOrderDetail);

                DeliveryOrder         deliveryOrder  = _deliveryOrderService.GetObjectById(deliveryOrderDetail.DeliveryOrderId);
                WarehouseItem         warehouseItem  = _warehouseItemService.FindOrCreateObject(deliveryOrder.WarehouseId, deliveryOrderDetail.ItemId);
                Item                  item           = _itemService.GetObjectById(deliveryOrderDetail.ItemId);
                IList <StockMutation> stockMutations = _stockMutationService.CreateStockMutationForDeliveryOrder(deliveryOrderDetail, warehouseItem);
                foreach (var stockMutation in stockMutations)
                {
                    //item.PendingDelivery -= deliveryOrderDetail.Quantity;
                    //item.Quantity -= deliveryOrderDetail.Quantity;
                    _stockMutationService.StockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
                }

                SalesOrderDetail salesOrderDetail = _salesOrderDetailService.GetObjectById(deliveryOrderDetail.SalesOrderDetailId);
                _salesOrderDetailService.SetDeliveryComplete(salesOrderDetail, deliveryOrderDetail.Quantity);
            }
            return(deliveryOrderDetail);

            ;
        }
Пример #25
0
        public ICollection <DeliveryOrder> RetrieveAllOrders()
        {
            DataSet ds = new DataSet();

            SqlDataAdapter daOrders = new SqlDataAdapter(
                "SELECT ID, size, weight, posting_date, receiving_date, client_ID, driver_ID, state FROM DeliveryOrder",
                "Data Source=.; Initial Catalog=master; Integrated Security=true"
                );

            daOrders.Fill(ds, "DeliveryOrder");

            ICollection <DeliveryOrder> orders = new List <DeliveryOrder>();

            foreach (DataRow r in ds.Tables[0].Rows)
            {
                DeliveryOrder order = new DeliveryOrder();

                order.ID             = (int)r["ID"];
                order.size           = (int)r["size"];
                order.weight         = (int)r["weight"];
                order.posting_date   = (DateTime)r["posting_date"];
                order.receiving_date = (DateTime)r["receiving_date"];
                order.state          = (OrderState)r["state"];

                orders.Add(order);
            }

            return(orders);
        }
Пример #26
0
        public ICollection <DeliveryOrder> RetrieveAllOrders()
        {
            SqlConnection connection = createConnection();
            SqlCommand    cmd        = new SqlCommand("SELECT ID, size, weight, posting_date, receiving_date, client_ID, driver_ID, state FROM DeliveryOrder", connection);

            connection.Open();
            SqlDataReader reader = cmd.ExecuteReader();
            ICollection <DeliveryOrder> orders = new List <DeliveryOrder>();

            while (reader.Read())
            {
                DeliveryOrder order = new DeliveryOrder();

                order.ID             = reader.GetInt32(0);
                order.size           = reader.GetInt32(1);
                order.weight         = reader.GetInt32(2);
                order.posting_date   = reader.GetDateTime(3);
                order.receiving_date = reader.GetDateTime(4);
                order.state          = (OrderState)reader.GetInt32(6);

                orders.Add(order);
            }
            connection.Close();

            return(orders);
        }
Пример #27
0
        public DeliveryOrder RetrieveOrder(int id)
        {
            SqlConnection connection = createConnection();
            SqlCommand    cmd        = new SqlCommand("SELECT ID, size, weight, posting_date, receiving_date, client_ID, driver_ID, state FROM DeliveryOrder where ID = @id", connection);

            connection.Open();
            cmd.Parameters.AddWithValue("@id", id);
            SqlDataReader reader = cmd.ExecuteReader();

            DeliveryOrder order = new DeliveryOrder();

            if (!reader.Read() || reader.IsDBNull(0))
            {
                return(null);
            }

            order.ID             = reader.GetInt32(0);
            order.size           = reader.GetInt32(1);
            order.weight         = reader.GetInt32(2);
            order.posting_date   = reader.GetDateTime(3);
            order.receiving_date = reader.GetDateTime(4);
            order.state          = (OrderState)reader.GetInt32(6);

            connection.Close();

            return(order);
        }
        public void MultipleParcelDiscountManiaShouldApplySmallThenMediumThenMixedDiscounts()
        {
            var deliveryOrder = new DeliveryOrder();

            deliveryOrder = _orderService.AddParcelToOrder(deliveryOrder, 49, 49, 49, 4m);
            deliveryOrder = _orderService.AddParcelToOrder(deliveryOrder, 49, 49, 49, 4m);
            deliveryOrder = _orderService.AddParcelToOrder(deliveryOrder, 49, 49, 49, 3m);
            deliveryOrder = _orderService.AddParcelToOrder(deliveryOrder, 49, 49, 49, 3m);
            deliveryOrder = _orderService.AddParcelToOrder(deliveryOrder, 9, 9, 9, 1m);
            deliveryOrder = _orderService.AddParcelToOrder(deliveryOrder, 9, 9, 9, 1m);
            deliveryOrder = _orderService.AddParcelToOrder(deliveryOrder, 9, 9, 9, 2m);
            deliveryOrder = _orderService.AddParcelToOrder(deliveryOrder, 9, 9, 9, 1m);
            deliveryOrder = _orderService.AddParcelToOrder(deliveryOrder, 99, 99, 99, 1m);
            deliveryOrder = _orderService.AddParcelToOrder(deliveryOrder, 99, 99, 99, 1m);
            deliveryOrder = _orderService.AddParcelToOrder(deliveryOrder, 99, 99, 99, 1m);
            deliveryOrder = _orderService.AddParcelToOrder(deliveryOrder, 100, 100, 100, 1m);
            deliveryOrder = _orderService.AddParcelToOrder(deliveryOrder, 100, 100, 100, 1m);
            deliveryOrder = _orderService.AddParcelToOrder(deliveryOrder, 100, 100, 100, 1m);

            var printedResult = _orderService.PrintOrder(deliveryOrder);

            Assert.Equal("Medium Parcel, Cost = $10; Medium Parcel, Cost = $10; Medium Parcel, Cost = $8; Medium Parcel, Cost = $8; " +
                         "Small Parcel, Cost = $3; Small Parcel, Cost = $3; Small Parcel, Cost = $5; Small Parcel, Cost = $3; " +
                         "Large Parcel, Cost = $15; Large Parcel, Cost = $15; Large Parcel, Cost = $15; " +
                         "Extra Large Parcel, Cost = $25; Extra Large Parcel, Cost = $25; Extra Large Parcel, Cost = $25; " +
                         "Discount = $19; Total Order = $151", printedResult);
        }
Пример #29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            switch (RequestActionString)
            {
            case "batchdelete":
                IList <object> idList = RequestData.GetList <object>("IdList");
                if (idList != null && idList.Count > 0)
                {
                    foreach (object obj in idList)
                    {
                        InWarehouse[] iwEnts = InWarehouse.FindAllByProperties("PublicInterface", obj.ToString());
                        if (iwEnts.Length > 0)
                        {
                            OtherInWarehouseDetail.DeleteAll("InWarehouseId='" + iwEnts[0].Id + "'");
                            InWarehouse.DeleteAll("PublicInterface='" + obj.ToString() + "'");
                        }
                        DeliveryOrder[] doEnts = DeliveryOrder.FindAllByProperties("PId", obj.ToString());
                        if (doEnts.Length > 0)
                        {
                            DelieryOrderPart.DeleteAll("DId='" + doEnts[0].Id + "'");
                            DeliveryOrder.DeleteAll("PId='" + obj.ToString() + "'");
                        }
                        DataHelper.ExecSql("delete SHHG_AimExamine..WarehouseExchange where Id='" + obj.ToString() + "'");
                        DataHelper.ExecSql("delete SHHG_AimExamine..WarehouseExchangeDetail where WarehouseExchangeId='" + obj.ToString() + "'");
                        PageState.Add("Message", "删除成功!");
                    }
                }
                break;

            default:
                DoSelect();
                break;
            }
        }
        public async Task Should_Success_UpdateThenAddMany()
        {
            var dbContext = _dbContext(GetCurrentMethod());
            DeliveryOrderFacade facade = new DeliveryOrderFacade(dbContext, GetServiceProvider(GetCurrentMethod()).Object);
            DeliveryOrder       model  = await _dataUtil(facade, dbContext, GetCurrentMethod()).GetTestData(USERNAME);

            foreach (var item in model.Items)
            {
                foreach (var detail in item.Details)
                {
                    detail.DOQuantity -= 1;
                }
            }
            var Response = await facade.Update((int)model.Id, model, USERNAME);

            Assert.NotEqual(0, Response);

            var newModelForAddItem = await _dataUtil(facade, dbContext, GetCurrentMethod()).GetNewData(USERNAME);

            DeliveryOrderItem newModelItem = newModelForAddItem.Items.FirstOrDefault();

            model.Items.Add(newModelItem);
            model.Items.Add(newModelItem);
            var ResponseAddItem = await facade.Update((int)model.Id, model, USERNAME);

            Assert.NotEqual(0, ResponseAddItem);
        }
Пример #31
0
        private void searchToolStripButton_Click(object sender, EventArgs e)
        {
            IList result = searchToolStripTextBox.Text == string.Empty ? new ArrayList() : r_grn.Search(searchToolStripTextBox.Text);

            if (result.Count == 1)
            {
                m_do          = (DeliveryOrder)result[0];
                m_do          = (DeliveryOrder)r_grn.Get(m_do.ID);
                m_do.EMPLOYEE = (Employee)r_employee.GetById(m_do.EMPLOYEE);
                m_do.CUSTOMER = (Customer)r_sup.GetById(m_do.CUSTOMER);
                setEditMode(EditMode.View);
                loadData();
                setEnableForm(false);
            }
            else
            {
                using (SearchDeliveryOrderForm frm = new SearchDeliveryOrderForm(searchToolStripTextBox.Text, result))
                {
                    frm.ShowDialog();
                    if (frm.DELIVERY_ORDER == null)
                    {
                        return;
                    }
                    else
                    {
                        m_do          = frm.DELIVERY_ORDER;
                        m_do          = (DeliveryOrder)r_grn.Get(m_do.ID);
                        m_do.EMPLOYEE = (Employee)r_employee.GetById(m_do.EMPLOYEE);
                        setEditMode(EditMode.View);
                        loadData();
                        setEnableForm(false);
                    }
                }
            }
        }
Пример #32
0
        public void Test_ProcessOrder_Valid()
        {
            // Arrange
            var orderCalcSvc = new DefaultOrderCalculationService();
            var serviceChargeCalcSvc = new DefaultDeliveryServiceChargeCalculationService();

            var deliveryOrderProcessor = new DeliveryOrderProcessor(
                orderCalcSvc, serviceChargeCalcSvc);

            var deliveryOrder = new DeliveryOrder
            {
                UserId = "this.User",
                From = new DefaultAddress { Address = "My Home" },
                To = new DefaultAddress { Address = "My Office" },
                OrderCart = new OrderDetails
                {
                    PackageList = new List<ItemDetails>()
                    {
                        new ItemDetails
                        {
                            Item = "Coffee",
                            Quantity = 2,
                            Price = 150.0m,
                            VAT = 15.0m
                        }              
                    }                    
                },
                PaymentMethod = "CashOnDelivery"
            };

            // Act
            deliveryOrderProcessor.ProcessOrder(deliveryOrder);
            var coffees = deliveryOrder.OrderCart.PackageList;
            var cart = deliveryOrder.OrderCart;

            var serviceCharge = serviceChargeCalcSvc.CalculateServiceCharge(coffees);
            var subTotal = orderCalcSvc.CalculateSubtotal(coffees);
            var totalToPay = orderCalcSvc.CalculateTotalToPay(coffees, serviceCharge);
            var totalVATAmount = orderCalcSvc.CalculateTotalVATAmount(coffees, serviceCharge);
            var totalWeight = 0;


            // Assert
            Assert.AreEqual(serviceCharge, cart.ServiceCharge);
            Assert.AreEqual(subTotal, cart.SubTotal);
            Assert.AreEqual(totalToPay, cart.TotalToPay);
            Assert.AreEqual(totalVATAmount, cart.TotalVATAmount);
            Assert.AreEqual(totalWeight, cart.TotalWeight);
        }
Пример #33
0
        public void Test_DeliveryOrder_Creation_With_Name()
        {
            DefaultAddress FromLocation = new DefaultAddress("Test From Address", new Point((new double[] { 1, 2 }).ToList()));
            DefaultAddress ToLocation = new DefaultAddress("Test To Address", new Point((new double[] { 2, 1 }).ToList()));
            string orderName = "Test Delivery Order";
            string PackageDescription = "Sample Package Description";

            List<ItemDetails> invoiceItems = new List<ItemDetails>();
            invoiceItems.Add(new ItemDetails()
            {
                Item = "Test Item 1",
                Price = 100,
                Quantity = 1,
                VAT = 10,
                Weight = 5
            });

            invoiceItems.Add(new ItemDetails()
            {
                Item = "Test Item 2",
                Price = 100,
                Quantity = 3,
                VAT = 20,
                Weight = 2
            });

            DeliveryOrder order = new DeliveryOrder(orderName);
            order.From = FromLocation;
            order.To = ToLocation;
            order.Description = PackageDescription;
            order.UserId = "12345678";

            Assert.IsNotNull(order);
            Assert.AreEqual(FromLocation, order.From);
            Assert.AreEqual(ToLocation, order.To);
            Assert.AreEqual(orderName, order.Name);
            Assert.AreEqual("default", order.Variant);
            Assert.AreEqual(JobTaskTypes.DELIVERY, order.Type);
            Assert.Null(order.ETA);
            Assert.Null(order.ETAMinutes);
            Assert.AreEqual("12345678", order.UserId);
        }
Пример #34
0
 private DeliveryOrder GetDummyOrder(string orderType)
 {
     DeliveryOrder order = new DeliveryOrder();
     order.UserId = "abcdef123ijkl12";
     order.From = new DefaultAddress("Test From Address", new Point((new double[] { 1, 2 }).ToList()));
     order.To = new DefaultAddress("Test To Address", new Point((new double[] { 2, 1 }).ToList()));
     order.PaymentMethod = "SamplePaymentMethod";
     order.Type = orderType;
     return order;
 }
Пример #35
0
        public void Test_DeliveryJob_State_Changes_To_InProgress_After_FirstTask_Passed_Or_Reached_InProgress()
        {
            string orderName = "Sample Delivery Order";

            DeliveryOrder order = new DeliveryOrder();
            order.Name = orderName;
            order.From = new DefaultAddress("Test From Address", new Point((new double[] { 1, 2 }).ToList()));
            order.To = new DefaultAddress("Test To Address", new Point((new double[] { 2, 1 }).ToList()));
            UserModel userModel = new UserModel()
            {
                Email = "*****@*****.**",
                EmailConfirmed = false,
                IsUserAuthenticated = false,
                PhoneNumber = "+8801684512833",
                PhoneNumberConfirmed = true,
                Profile = new UserProfile()
                {
                    Address = new DefaultAddress("Somewhere User belong", new Point(2, 1)),
                    Age = 26,
                    FirstName = "Gabul",
                    LastName = "Habul",
                    Gender = Gender.MALE,
                    PicUri = null
                },
                Type = Data.Model.Identity.IdentityTypes.USER,
                UserId = "123456789",
                UserName = "******"
            };



            var builder = new DeliveryJobBuilder(order, userModel, hridService, paymentMethodMock.Object);
            builder.BuildJob();

            //Changing that back to IN PROGRESS
            builder.Job.Tasks.First().State = JobTaskState.IN_PROGRESS;
            Assert.AreEqual(JobState.IN_PROGRESS, builder.Job.State);
        }
Пример #36
0
        public void Test_DeliverJobBuilder_Creation_With_ClassifiedDelivery_TaskInitiation()
        {
            string orderName = "Classified  Delivery Order";

            DeliveryOrder order = new DeliveryOrder();
            order.Name = orderName;
            order.From = new DefaultAddress("Test From Address", new Point((new double[] { 1, 2 }).ToList()));
            order.To = new DefaultAddress("Test To Address", new Point((new double[] { 2, 1 }).ToList()));
            order.Type = OrderTypes.ClassifiedDelivery;

            UserModel userModel = new UserModel()
            {
                Email = "*****@*****.**",
                EmailConfirmed = false,
                IsUserAuthenticated = false,
                PhoneNumber = "+8801684512833",
                PhoneNumberConfirmed = true,
                Profile = new UserProfile()
                {
                    Address = new DefaultAddress("Somewhere User belong", new Point(2, 1)),
                    Age = 26,
                    FirstName = "Gabul",
                    LastName = "Habul",
                    Gender = Gender.MALE,
                    PicUri = null
                },
                Type = Data.Model.Identity.IdentityTypes.USER,
                UserId = "123456789",
                UserName = "******"
            };

            UserModel backendAdminModel = new UserModel()
            {
                Email = "*****@*****.**",
                EmailConfirmed = false,
                IsUserAuthenticated = false,
                PhoneNumber = "+8801684512833",
                PhoneNumberConfirmed = true,
                Profile = new UserProfile()
                {
                    Address = new DefaultAddress("Somewhere User belong", new Point(2, 1)),
                    Age = 26,
                    FirstName = "Gabul",
                    LastName = "Habul",
                    Gender = Gender.MALE,
                    PicUri = null
                },
                Type = Data.Model.Identity.IdentityTypes.USER,
                UserId = "123456789",
                UserName = "******"
            };

            var builder = new DeliveryJobBuilder(order, userModel, backendAdminModel, hridService, paymentMethodMock.Object);
            builder.BuildJob();

            Assert.IsNotNull(builder);
            Assert.IsNotNull(builder.Job);
            Assert.IsNotNull(builder.Job.Name);
            Assert.AreEqual(MockedHrid, builder.Job.HRID);
            Assert.AreEqual(orderName, builder.Job.Name);
            Assert.AreEqual(order, builder.Job.Order);
            Assert.AreEqual(userModel, builder.Job.User);
            Assert.That(builder.Job.Assets != null && builder.Job.Assets.Count == 0);
            Assert.AreEqual(backendAdminModel, builder.Job.JobServedBy);
            Assert.NotNull(builder.Job.CreateTime);
            Assert.NotNull(builder.Job.ModifiedTime);
            Assert.IsNotNull(builder.Job.Tasks);
            Assert.AreEqual(4, builder.Job.Tasks.Count);
            Assert.That(builder.Job.Tasks.First().GetType() == typeof(FetchDeliveryManTask));
            Assert.That(builder.Job.Tasks[1].GetType() == typeof(PackagePickUpTask));
            Assert.That(builder.Job.Tasks.Last().GetType() == typeof(SecureDeliveryTask));
            Assert.True(builder.Job.IsAssetEventsHooked);
            Assert.NotNull(builder.Job.TerminalTask);
            Assert.That(builder.Job.TerminalTask == builder.Job.Tasks.Last());
            Assert.AreEqual(JobState.ENQUEUED, builder.Job.State);
        }
Пример #37
0
        public void Test_DeliverJobBuilder_Creation()
        {
            DeliveryOrder order = new DeliveryOrder();
            order.From = new DefaultAddress("Test From Address", new Point((new double[] { 1, 2 }).ToList()));
            order.To = new DefaultAddress("Test To Address", new Point((new double[] { 2, 1 }).ToList()));
            order.UserId = "SampleUserId";
            order.PaymentMethod = "SamplePaymentMethod";

            UserModel userModel = new UserModel()
            {
                Email = "*****@*****.**",
                EmailConfirmed = false,
                IsUserAuthenticated = false,
                PhoneNumber = "+8801684512833",
                PhoneNumberConfirmed = true,
                Profile = new UserProfile()
                {
                    Address = new DefaultAddress("Somewhere User belong", new Point(2, 1)),
                    Age = 26,
                    FirstName = "Gabul",
                    LastName = "Habul",
                    Gender = Gender.MALE,
                    PicUri = null
                },
                Type = Data.Model.Identity.IdentityTypes.USER,
                UserId = "123456789",
                UserName = "******"
            };

            UserModel backendAdminModel = new UserModel()
            {
                Email = "*****@*****.**",
                EmailConfirmed = false,
                IsUserAuthenticated = false,
                PhoneNumber = "+8801684512833",
                PhoneNumberConfirmed = true,
                Profile = new UserProfile()
                {
                    Address = new DefaultAddress("Somewhere User belong", new Point(2, 1)),
                    Age = 26,
                    FirstName = "Gabul",
                    LastName = "Habul",
                    Gender = Gender.MALE,
                    PicUri = null
                },
                Type = Data.Model.Identity.IdentityTypes.USER,
                UserId = "123456789",
                UserName = "******"
            };

            Validator.ValidateObject(order, new ValidationContext(order), validateAllProperties: true);

            var builder = new DeliveryJobBuilder(order, userModel, backendAdminModel, hridService, paymentMethodMock.Object);

            Assert.IsNotNull(builder);
            Assert.IsNotNull(builder.Job);
            Assert.AreEqual(order, builder.Job.Order);
            Assert.AreEqual(MockedHrid, builder.Job.HRID);
            Assert.AreEqual(userModel, builder.Job.User);
            Assert.That(builder.Job.Assets != null && builder.Job.Assets.Count == 0);
            Assert.AreEqual(backendAdminModel, builder.Job.JobServedBy);
            Assert.NotNull(builder.Job.CreateTime);
            Assert.NotNull(builder.Job.ModifiedTime);
            Assert.AreEqual(JobState.ENQUEUED, builder.Job.State);
            Assert.False(builder.Job.IsAssetEventsHooked);
            Assert.Null(builder.Job.TerminalTask);
        }
Пример #38
0
        public void Test_NextTask_State_Progress_After_Asset_Assignment_In_First_Task_Without_MOVING_TO_IN_PROGRESS()
        {
            string orderName = "Sample Delivery Order";

            DeliveryOrder order = new DeliveryOrder();
            order.Name = orderName;
            order.From = new DefaultAddress("Test From Address", new Point((new double[] { 1, 2 }).ToList()));
            order.To = new DefaultAddress("Test To Address", new Point((new double[] { 2, 1 }).ToList()));
            UserModel userModel = new UserModel()
            {
                Email = "*****@*****.**",
                EmailConfirmed = false,
                IsUserAuthenticated = false,
                PhoneNumber = "+8801684512833",
                PhoneNumberConfirmed = true,
                Profile = new UserProfile()
                {
                    Address = new DefaultAddress("Somewhere User belong", new Point(2, 1)),
                    Age = 26,
                    FirstName = "Gabul",
                    LastName = "Habul",
                    Gender = Gender.MALE,
                    PicUri = null
                },
                Type = Data.Model.Identity.IdentityTypes.USER,
                UserId = "123456789",
                UserName = "******"
            };

            var builder = new DeliveryJobBuilder(order, userModel, hridService, paymentMethodMock.Object);
            builder.BuildJob();

            var SampleAssetModel = new AssetModel()
            {
                AverageRating = 0.0,
                Email = "*****@*****.**",
                EmailConfirmed = false,
                PhoneNumber = "+8801711111111",
                PhoneNumberConfirmed = true,
                Profile = new UserProfile()
                {
                    Address = new DefaultAddress("Somewhere User belong", new Point(2, 1)),
                    Age = 20,
                    FirstName = "John",
                    LastName = "Doe",
                    Gender = Gender.MALE,
                    PicUri = null
                },
                Type = Data.Model.Identity.IdentityTypes.BIKE_MESSENGER,
                UserId = "12345678",
                UserName = "******"
            };

            builder.Job.Tasks.First().Asset = SampleAssetModel;
            builder.Job.Tasks.First().State = JobTaskState.IN_PROGRESS;
            builder.Job.Tasks.First().UpdateTask();

            Assert.That(builder.Job.State == JobState.IN_PROGRESS);
            Assert.That(builder.Job.Tasks.First().State == JobTaskState.COMPLETED);
            Assert.That(builder.Job.Tasks[1].State == JobTaskState.IN_PROGRESS);
        }
Пример #39
0
        private JobBuilder GetDeliveryJobBuilder(UserModel userModel, UserModel adminUserModel, DeliveryOrder deliveryOrderModel, Vendor vendor)
        {
            JobBuilder builder;
            orderProcessor = new DeliveryOrderProcessor(
                      orderCalculationService,
                      serviceChargeCalculationService);
            var paymentMethod = paymentService.GetPaymentMethodByKey(deliveryOrderModel.PaymentMethod);
            orderProcessor.ProcessOrder(deliveryOrderModel);

            // Resolve appropriate profit sharing strategy here

            builder = adminUserModel == null ?
                new DeliveryJobBuilder(deliveryOrderModel, userModel, hridService, paymentMethod, vendor)
                : new DeliveryJobBuilder(deliveryOrderModel, userModel, adminUserModel, hridService, paymentMethod, vendor);
            return builder;
        }
Пример #40
0
        private void SetupJobTaskETAs(DeliveryOrder order)
        {
            var duplicatePref = order.JobTaskETAPreference.GroupBy(x => x.Type).Where(x => x.Count() > 1).FirstOrDefault();
            if (duplicatePref != null && duplicatePref.Count() > 0)
                throw new NotSupportedException("Duplicate preference for one single jobtask type detected");

            if (order.JobTaskETAPreference?.Count > 0)
            {

                foreach (var task in this.job.Tasks)
                {
                    var pref = order.JobTaskETAPreference.FirstOrDefault(x => x.Type == task.Type);
                    if (pref != null)
                    {
                        task.ETA = pref.ETA.HasValue ? pref.ETA : null;
                    }
                }
            }
        }
Пример #41
0
        public ActionResult New(DeliveryOrder item)
        {
            item.Customer = Customer.TryFind (WebConfig.DefaultCustomer);

            if (!ModelState.IsValid) {
                return PartialView ("_Create", item);
            }

            item.Store = WebConfig.Store;

            item.Serial = 0;
            item.Date = DateTime.Now;
            item.CreationTime = DateTime.Now;
            item.Creator = CurrentUser.Employee;
            item.ModificationTime = item.CreationTime;
            item.Updater = item.Creator;

            using (var scope = new TransactionScope ()) {
                item.CreateAndFlush ();
            }

            return RedirectToAction ("Edit", new { id = item.Id });
        }
Пример #42
0
 public DeliveryJobBuilder(DeliveryOrder order, UserModel userModel, UserModel adminUserModel, IHRIDService hridService, IPaymentMethod paymentMethod, Vendor vendor = null) 
     : base(order, userModel, adminUserModel, hridService, vendor)
 {
     this.order = order;
     this.paymentMethod = paymentMethod;
 }