Ejemplo n.º 1
0
        public PurchaseOrder VHasNoPurchaseOrderDetail(PurchaseOrder purchaseOrder, IPurchaseOrderDetailService _purchaseOrderDetailService)
        {
            IList <PurchaseOrderDetail> details = _purchaseOrderDetailService.GetObjectsByPurchaseOrderId(purchaseOrder.Id);

            if (details.Any())
            {
                purchaseOrder.Errors.Add("PurchaseOrder", "Memiliki Purchase Order Details");
            }
            return(purchaseOrder);
        }
Ejemplo n.º 2
0
        public PurchaseOrder VHasPurchaseOrderDetails(PurchaseOrder purchaseOrder, IPurchaseOrderDetailService _purchaseOrderDetailService)
        {
            IList <PurchaseOrderDetail> details = _purchaseOrderDetailService.GetObjectsByPurchaseOrderId(purchaseOrder.Id);

            if (!details.Any())
            {
                purchaseOrder.Errors.Add("Generic", "Tidak memiliki Purchase Order Details");
            }
            return(purchaseOrder);
        }
Ejemplo n.º 3
0
        public PurchaseOrder CheckAndSetReceivalComplete(PurchaseOrder purchaseOrder, IPurchaseOrderDetailService _purchaseOrderDetailService)
        {
            IList <PurchaseOrderDetail> details = _purchaseOrderDetailService.GetObjectsByPurchaseOrderId(purchaseOrder.Id);

            foreach (var detail in details)
            {
                if (!detail.IsAllReceived)
                {
                    return(purchaseOrder);
                }
            }
            return(_repository.SetReceivalComplete(purchaseOrder));
        }
Ejemplo n.º 4
0
        public PurchaseOrderDetail VUniquePurchaseOrderDetail(PurchaseOrderDetail purchaseOrderDetail, IPurchaseOrderDetailService _purchaseOrderDetails, IItemService _itemService)
        {
            IList <PurchaseOrderDetail> details = _purchaseOrderDetails.GetObjectsByPurchaseOrderId(purchaseOrderDetail.PurchaseOrderId);

            foreach (var detail in details)
            {
                if (detail.ItemId == purchaseOrderDetail.ItemId && detail.Id != purchaseOrderDetail.Id)
                {
                    purchaseOrderDetail.Errors.Add("PurchaseOrderDetail", "Tidak boleh memiliki Sku yang sama dalam 1 Purchase Order");
                    return(purchaseOrderDetail);
                }
            }
            return(purchaseOrderDetail);
        }
Ejemplo n.º 5
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 = _purchaseOrderDetailService.GetObjectsByPurchaseOrderId(id).Where(d => d.IsDeleted == false);

            var list = query as IEnumerable <PurchaseOrderDetail>;

            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.º 6
0
 public PurchaseOrder UnconfirmObject(PurchaseOrder purchaseOrder, IPurchaseOrderDetailService _purchaseOrderDetailService, IPurchaseReceivalService _purchaseReceivalService,
                                      IPurchaseReceivalDetailService _purchaseReceivalDetailService, IStockMutationService _stockMutationService,
                                      IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     if (_validator.ValidUnconfirmObject(purchaseOrder, _purchaseReceivalService))
     {
         IList <PurchaseOrderDetail> purchaseOrderDetails = _purchaseOrderDetailService.GetObjectsByPurchaseOrderId(purchaseOrder.Id);
         foreach (var detail in purchaseOrderDetails)
         {
             detail.Errors = new Dictionary <string, string>();
             _purchaseOrderDetailService.UnconfirmObject(detail, _purchaseReceivalDetailService, _stockMutationService, _itemService, _barringService, _warehouseItemService);
         }
         _repository.UnconfirmObject(purchaseOrder);
     }
     return(purchaseOrder);
 }
Ejemplo n.º 7
0
 public PurchaseOrder ConfirmObject(PurchaseOrder purchaseOrder, DateTime ConfirmationDate, IPurchaseOrderDetailService _purchaseOrderDetailService,
                                    IStockMutationService _stockMutationService, IItemService _itemService, IBarringService _barringService,
                                    IWarehouseItemService _warehouseItemService)
 {
     purchaseOrder.ConfirmationDate = ConfirmationDate;
     if (_validator.ValidConfirmObject(purchaseOrder, _purchaseOrderDetailService))
     {
         IList <PurchaseOrderDetail> purchaseOrderDetails = _purchaseOrderDetailService.GetObjectsByPurchaseOrderId(purchaseOrder.Id);
         foreach (var detail in purchaseOrderDetails)
         {
             detail.Errors = new Dictionary <string, string>();
             _purchaseOrderDetailService.ConfirmObject(detail, ConfirmationDate, _stockMutationService, _itemService, _barringService, _warehouseItemService, this);
         }
         _repository.ConfirmObject(purchaseOrder);
     }
     return(purchaseOrder);
 }