Exemple #1
0
        public StockAdjustment VDetailsAreVerifiedConfirmable(StockAdjustment stockAdjustment, IStockAdjustmentService _stockAdjustmentService, IStockAdjustmentDetailService _stockAdjustmentDetailService,
                                                              IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
        {
            IList <StockAdjustmentDetail> details = _stockAdjustmentDetailService.GetObjectsByStockAdjustmentId(stockAdjustment.Id);

            foreach (var stockAdjustmentDetail in details)
            {
                int           stockAdjustmentDetailQuantity = stockAdjustmentDetail.Quantity;
                decimal       stockAdjustmentDetailPrice    = stockAdjustmentDetail.Price;
                Item          item          = _itemService.GetObjectById(stockAdjustmentDetail.ItemId);
                WarehouseItem warehouseItem = _warehouseItemService.FindOrCreateObject(stockAdjustment.WarehouseId, item.Id);
                if (item.Quantity + stockAdjustmentDetailQuantity < 0)
                {
                    stockAdjustment.Errors.Add("Generic", "Stock barang tidak boleh menjadi kurang dari 0");
                }
                else if (warehouseItem.Quantity + stockAdjustmentDetailQuantity < 0)
                {
                    stockAdjustmentDetail.Errors.Add("Generic", "Stock di dalam warehouse tidak boleh kurang dari 0");
                }

                else if (_itemService.CalculateAvgPrice(item, stockAdjustmentDetail.Quantity, stockAdjustmentDetailPrice) < 0)
                {
                    stockAdjustment.Errors.Add("Generic", "AvgPrice tidak boleh kurang dari 0");
                }
            }
            return(stockAdjustment);
        }
Exemple #2
0
        public StockAdjustment VHasStockAdjustmentDetails(StockAdjustment stockAdjustment, IStockAdjustmentDetailService _stockAdjustmentDetailService)
        {
            IList <StockAdjustmentDetail> details = _stockAdjustmentDetailService.GetObjectsByStockAdjustmentId(stockAdjustment.Id);

            if (!details.Any())
            {
                stockAdjustment.Errors.Add("Generic", "Details tidak boleh tidak ada");
            }
            return(stockAdjustment);
        }
        public StockAdjustmentDetail VUniqueItem(StockAdjustmentDetail stockAdjustmentDetail, IStockAdjustmentDetailService _stockAdjustmentDetailService, IItemService _itemService)
        {
            IList <StockAdjustmentDetail> details = _stockAdjustmentDetailService.GetObjectsByStockAdjustmentId(stockAdjustmentDetail.StockAdjustmentId);

            foreach (var detail in details)
            {
                if (detail.ItemId == stockAdjustmentDetail.ItemId && detail.Id != stockAdjustmentDetail.Id)
                {
                    stockAdjustmentDetail.Errors.Add("Generic", "Tidak boleh ada duplikasi item dalam 1 Stock Adjustment");
                }
            }
            return(stockAdjustmentDetail);
        }
Exemple #4
0
 public StockAdjustment UnconfirmObject(StockAdjustment stockAdjustment, IStockAdjustmentDetailService _stockAdjustmentDetailService,
                                        IStockMutationService _stockMutationService, IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     if (_validator.ValidUnconfirmObject(stockAdjustment, this, _stockAdjustmentDetailService, _itemService, _barringService, _warehouseItemService))
     {
         IList <StockAdjustmentDetail> stockAdjustmentDetails = _stockAdjustmentDetailService.GetObjectsByStockAdjustmentId(stockAdjustment.Id);
         foreach (var detail in stockAdjustmentDetails)
         {
             detail.Errors = new Dictionary <string, string>();
             _stockAdjustmentDetailService.UnconfirmObject(detail, this, _stockMutationService, _itemService, _barringService, _warehouseItemService);
         }
         _repository.UnconfirmObject(stockAdjustment);
     }
     return(stockAdjustment);
 }
        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 = _stockAdjustmentDetailService.GetObjectsByStockAdjustmentId(id).Where(d => d.IsDeleted == false);

            var list = query as IEnumerable <StockAdjustmentDetail>;

            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
                    }
                }).ToArray()
            }, JsonRequestBehavior.AllowGet));
        }
Exemple #6
0
 public StockAdjustment UnconfirmObject(StockAdjustment stockAdjustment, IStockAdjustmentDetailService _stockAdjustmentDetailService,
                                        IStockMutationService _stockMutationService, IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService,
                                        IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService)
 {
     if (_validator.ValidUnconfirmObject(stockAdjustment, this, _stockAdjustmentDetailService, _itemService, _barringService, _warehouseItemService, _closingService))
     {
         IList <StockAdjustmentDetail> stockAdjustmentDetails = _stockAdjustmentDetailService.GetObjectsByStockAdjustmentId(stockAdjustment.Id);
         foreach (var detail in stockAdjustmentDetails)
         {
             detail.Errors = new Dictionary <string, string>();
             _stockAdjustmentDetailService.UnconfirmObject(detail, this, _stockMutationService, _itemService, _barringService, _warehouseItemService);
         }
         _generalLedgerJournalService.CreateUnconfirmationJournalForStockAdjustment(stockAdjustment, _accountService);
         _repository.UnconfirmObject(stockAdjustment);
     }
     return(stockAdjustment);
 }