Ejemplo n.º 1
0
        public SalesOrder VHasNoSalesOrderDetail(SalesOrder salesOrder, ISalesOrderDetailService _salesOrderDetailService)
        {
            IList <SalesOrderDetail> details = _salesOrderDetailService.GetObjectsBySalesOrderId(salesOrder.Id);

            if (details.Any())
            {
                salesOrder.Errors.Add("Generic", "Masih memiliki sales order detail");
            }
            return(salesOrder);
        }
Ejemplo n.º 2
0
        public SalesOrder CheckAndSetDeliveryComplete(SalesOrder salesOrder, ISalesOrderDetailService _salesOrderDetailService)
        {
            IList <SalesOrderDetail> details = _salesOrderDetailService.GetObjectsBySalesOrderId(salesOrder.Id);

            foreach (var detail in details)
            {
                if (!detail.IsAllDelivered)
                {
                    return(salesOrder);
                }
            }
            return(_repository.SetDeliveryComplete(salesOrder));
        }
Ejemplo n.º 3
0
        public SalesOrderDetail VUniqueSalesOrderDetail(SalesOrderDetail salesOrderDetail, ISalesOrderDetailService _salesOrderDetailService, IItemService _itemService)
        {
            IList <SalesOrderDetail> details = _salesOrderDetailService.GetObjectsBySalesOrderId(salesOrderDetail.SalesOrderId);

            foreach (var detail in details)
            {
                if (detail.ItemId == salesOrderDetail.ItemId && detail.Id != salesOrderDetail.Id)
                {
                    salesOrderDetail.Errors.Add("Generic", "Tidak boleh memiliki Sku yang sama dalam 1 Sales Order");
                    return(salesOrderDetail);
                }
            }
            return(salesOrderDetail);
        }
Ejemplo n.º 4
0
        public dynamic GetListDetail(string _search, long nd, int rows, int?page, string sidx, string sord, int id, string filters = "")
        {
            // Construct where statement

            string strWhere = GeneralFunction.ConstructWhere(filters);

            // Get Data
            var query = _salesOrderDetailService.GetObjectsBySalesOrderId(id).Where(d => d.IsDeleted == false);

            var list = query as IEnumerable <SalesOrderDetail>;

            var pageIndex    = Convert.ToInt32(page) - 1;
            var pageSize     = rows;
            var totalRecords = query.Count();
            var totalPages   = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            // default last page
            if (totalPages > 0)
            {
                if (!page.HasValue)
                {
                    pageIndex = totalPages - 1;
                    page      = totalPages;
                }
            }

            list = list.Skip(pageIndex * pageSize).Take(pageSize);

            return(Json(new
            {
                total = totalPages,
                page = page,
                records = totalRecords,
                rows = (
                    from model in list
                    select new
                {
                    id = model.Id,
                    cell = new object[] {
                        model.Code,
                        model.ItemId,
                        _itemService.GetObjectById(model.ItemId).Name,
                        model.Quantity,
                        model.Price
                    }
                }).ToArray()
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
 public SalesOrder UnconfirmObject(SalesOrder salesOrder, ISalesOrderDetailService _salesOrderDetailService,
                                   IDeliveryOrderService _deliveryOrderService, IDeliveryOrderDetailService _deliveryOrderDetailService,
                                   IStockMutationService _stockMutationService, IItemService _itemService,
                                   IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     if (_validator.ValidUnconfirmObject(salesOrder, _deliveryOrderService))
     {
         IList <SalesOrderDetail> salesOrderDetails = _salesOrderDetailService.GetObjectsBySalesOrderId(salesOrder.Id);
         foreach (var detail in salesOrderDetails)
         {
             detail.Errors = new Dictionary <string, string>();
             _salesOrderDetailService.UnconfirmObject(detail, this, _deliveryOrderDetailService, _stockMutationService, _itemService, _barringService, _warehouseItemService);
         }
         _repository.UnconfirmObject(salesOrder);
     }
     return(salesOrder);
 }
Ejemplo n.º 6
0
 public SalesOrder ConfirmObject(SalesOrder salesOrder, DateTime ConfirmationDate, ISalesOrderDetailService _salesOrderDetailService,
                                 IStockMutationService _stockMutationService, IItemService _itemService, IBarringService _barringService,
                                 IWarehouseItemService _warehouseItemService)
 {
     salesOrder.ConfirmationDate = ConfirmationDate;
     if (_validator.ValidConfirmObject(salesOrder, _salesOrderDetailService))
     {
         IList <SalesOrderDetail> salesOrderDetails = _salesOrderDetailService.GetObjectsBySalesOrderId(salesOrder.Id);
         foreach (var detail in salesOrderDetails)
         {
             detail.Errors = new Dictionary <string, string>();
             _salesOrderDetailService.ConfirmObject(detail, ConfirmationDate, _stockMutationService, _itemService,
                                                    _barringService, _warehouseItemService);
         }
         _repository.ConfirmObject(salesOrder);
     }
     return(salesOrder);
 }