예제 #1
0
        public static OrderShipmentModel GetShipment(long warehouseId, long customerId, long customerSiteId, long orderId)
        {
            OrderShipmentModel newShipment = new OrderShipmentModel
            {
                CustomerId     = customerId,
                CustomerSiteId = customerSiteId,
                DeliveryDate   = DateTime.Now,
                Id             = 0,
                OrderId        = orderId,
                OrderShipments = new List <OrderShipmentLine>(),
                WarehouseId    = warehouseId
            };

            List <OrderModel> orders = OrderHelper.GetOrders(orderId, customerId, customerSiteId);

            if (orders.Count() > 0)
            {
                foreach (var order in orders)
                {
                    List <OrderDetailModel> orderDetail = OrderHelper.GetOrderDetail(order.Id.ToString()).ToList();
                    if (orderDetail != null && orderDetail.Count() > 0)
                    {
                        orderDetail = orderDetail.Where(rec => rec.WarehouseId == warehouseId).ToList();
                        if (orderDetail != null && orderDetail.Count() > 0)
                        {
                            foreach (var detailItem in orderDetail)
                            {
                                List <ShipmentModel> shipments = GetShipments(detailItem.Id);
                                if (shipments != null && shipments.Count() > 0)
                                {
                                    if (shipments.Sum(rec => rec.Quantity) < detailItem.Quantity)
                                    {
                                        OrderShipmentLine current = fromOrderDetailtoShipment(detailItem, shipments);
                                        current.CustomerName     = order.CustomerName;
                                        current.CustomerSiteName = order.CustomerSiteName;
                                        current.OrderNo          = order.OrderNo;

                                        if (!SessionHelper.Shipment.OrderShipments.Any(rec => rec.LineId == detailItem.Id))
                                        {
                                            newShipment.OrderShipments.Add(current);
                                        }
                                    }
                                }
                                else
                                {
                                    OrderShipmentLine current = fromOrderDetailtoShipment(detailItem, shipments);
                                    current.CustomerName     = order.CustomerName;
                                    current.CustomerSiteName = order.CustomerSiteName;
                                    current.OrderNo          = order.OrderNo;

                                    newShipment.OrderShipments.Add(current);
                                }
                            }
                        }
                    }
                }
            }

            return(newShipment);
        }
예제 #2
0
 private static void updateOrders(List <long> tobeUpdated)
 {
     tobeUpdated = tobeUpdated.Distinct().ToList();
     foreach (var orderId in tobeUpdated)
     {
         List <OrderDetailModel> orderDetailQty = OrderHelper.GetOrderDetail(orderId.ToString());
         string status = "";
         foreach (var orderDetailItem in orderDetailQty)
         {
             List <ShipmentModel> ShippedQty = GetShipments(orderDetailItem.Id);
             if (ShippedQty != null && ShippedQty.Count() > 0)
             {
                 if (ShippedQty.Sum(x => x.Quantity) < orderDetailItem.Quantity)
                 {
                     status = "Partially Shipped";
                     break;
                 }
                 else
                 {
                     status = "Shipped";
                 }
             }
             else
             {
                 status = "Booked";
                 break;
             }
         }
         OrderModel updatedOrder = OrderHelper.GetOrder(orderId.ToString());
         updatedOrder.Status = status;
         string result = OrderHelper.UpdateOrder(updatedOrder);
     }
 }