コード例 #1
0
 public PurchaseReceivalDetail UpdateObject(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseReceivalService _purchaseReceivalService,
                                            IPurchaseOrderDetailService _purchaseOrderDetailService, IPurchaseOrderService _purchaseOrderService,
                                            IItemService _itemService)
 {
     return(_validator.ValidUpdateObject(purchaseReceivalDetail, this, _purchaseReceivalService, _purchaseOrderDetailService, _itemService) ?
            _repository.UpdateObject(purchaseReceivalDetail) : purchaseReceivalDetail);
 }
コード例 #2
0
 public PurchaseReceivalDetail UnconfirmObject(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseReceivalService _purchaseReceivalService,
                                               IPurchaseOrderService _purchaseOrderService, IPurchaseOrderDetailService _purchaseOrderDetailService,
                                               IPurchaseInvoiceDetailService _purchaseInvoiceDetailService, IStockMutationService _stockMutationService,
                                               IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     if (_validator.ValidUnconfirmObject(purchaseReceivalDetail, _purchaseInvoiceDetailService, _itemService))
     {
         purchaseReceivalDetail = _repository.UnconfirmObject(purchaseReceivalDetail);
         PurchaseReceival      purchaseReceival = _purchaseReceivalService.GetObjectById(purchaseReceivalDetail.PurchaseReceivalId);
         WarehouseItem         warehouseItem    = _warehouseItemService.FindOrCreateObject(purchaseReceival.WarehouseId, purchaseReceivalDetail.ItemId);
         Item                  item             = _itemService.GetObjectById(purchaseReceivalDetail.ItemId);
         IList <StockMutation> stockMutations   = _stockMutationService.SoftDeleteStockMutationForPurchaseReceival(purchaseReceivalDetail, warehouseItem);
         foreach (var stockMutation in stockMutations)
         {
             //decimal itemPrice = _purchaseOrderDetailService.GetObjectById(purchaseReceivalDetail.PurchaseOrderDetailId).Price;
             //item.AvgCost = _itemService.CalculateAvgCost(item, purchaseReceivalDetail.Quantity * (-1), itemPrice);
             //item.PendingReceival += purchaseReceivalDetail.Quantity;
             //item.Quantity -= purchaseReceivalDetail.Quantity;
             _stockMutationService.ReverseStockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
         }
         PurchaseOrderDetail purchaseOrderDetail = _purchaseOrderDetailService.GetObjectById(purchaseReceivalDetail.PurchaseOrderDetailId);
         _purchaseOrderDetailService.UnsetReceivalComplete(purchaseOrderDetail, purchaseReceivalDetail.Quantity, _purchaseOrderService);
     }
     return(purchaseReceivalDetail);
 }
コード例 #3
0
 public PurchaseReceivalDetail ConfirmObject(PurchaseReceivalDetail purchaseReceivalDetail, DateTime ConfirmationDate, IPurchaseReceivalService _purchaseReceivalService,
                                             IPurchaseOrderDetailService _purchaseOrderDetailService, IStockMutationService _stockMutationService,
                                             IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     purchaseReceivalDetail.ConfirmationDate = ConfirmationDate;
     if (_validator.ValidConfirmObject(purchaseReceivalDetail, this, _purchaseOrderDetailService))
     {
         purchaseReceivalDetail = _repository.ConfirmObject(purchaseReceivalDetail);
         PurchaseReceival      purchaseReceival = _purchaseReceivalService.GetObjectById(purchaseReceivalDetail.PurchaseReceivalId);
         WarehouseItem         warehouseItem    = _warehouseItemService.FindOrCreateObject(purchaseReceival.WarehouseId, purchaseReceivalDetail.ItemId);
         Item                  item             = _itemService.GetObjectById(purchaseReceivalDetail.ItemId);
         IList <StockMutation> stockMutations   = _stockMutationService.CreateStockMutationForPurchaseReceival(purchaseReceivalDetail, warehouseItem);
         foreach (var stockMutation in stockMutations)
         {
             // decimal itemPrice = _purchaseOrderDetailService.GetObjectById(purchaseReceivalDetail.PurchaseOrderDetailId).Price;
             // item.AvgCost = _itemService.CalculateAvgCost(item, purchaseReceivalDetail.Quantity, itemPrice);
             //item.PendingReceival -= purchaseReceivalDetail.Quantity;
             //item.Quantity += purchaseReceivalDetail.Quantity;
             _stockMutationService.StockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
         }
         PurchaseOrderDetail purchaseOrderDetail = _purchaseOrderDetailService.GetObjectById(purchaseReceivalDetail.PurchaseOrderDetailId);
         _purchaseOrderDetailService.SetReceivalComplete(purchaseOrderDetail, purchaseReceivalDetail.Quantity);
     }
     return(purchaseReceivalDetail);
 }
コード例 #4
0
 public bool ValidUpdateObject(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseReceivalDetailService _purchaseReceivalDetailService,
                               IPurchaseReceivalService _purchaseReceivalService, IPurchaseOrderDetailService _purchaseOrderDetailService, IItemService _itemService)
 {
     purchaseReceivalDetail.Errors.Clear();
     VUpdateObject(purchaseReceivalDetail, _purchaseReceivalDetailService, _purchaseReceivalService, _purchaseOrderDetailService, _itemService);
     return(isValid(purchaseReceivalDetail));
 }
コード例 #5
0
        public dynamic DeleteDetail(PurchaseReceivalDetail model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.PurchaseReceival, Core.Constants.Constant.MenuGroupName.Transaction))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Edit record");

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

                var data = _purchaseReceivalDetailService.GetObjectById(model.Id);
                model = _purchaseReceivalDetailService.SoftDeleteObject(data);
            }
            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
            }));
        }
コード例 #6
0
 public bool ValidConfirmObject(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseReceivalDetailService _purchaseReceivalDetailService,
                                IPurchaseOrderDetailService _purchaseOrderDetailService)
 {
     purchaseReceivalDetail.Errors.Clear();
     VConfirmObject(purchaseReceivalDetail, _purchaseReceivalDetailService, _purchaseOrderDetailService);
     return(isValid(purchaseReceivalDetail));
 }
コード例 #7
0
        public dynamic GetInfoDetail(int Id)
        {
            PurchaseReceivalDetail model = new PurchaseReceivalDetail();

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

            return(Json(new
            {
                model.Id,
                model.Code,
                model.PurchaseOrderDetailId,
                PurchaseOrderDetail = _purchaseOrderDetailService.GetObjectById(model.PurchaseOrderDetailId).Code,
                model.ItemId,
                Item = _itemService.GetObjectById(model.ItemId).Name,
                model.Errors
            }, JsonRequestBehavior.AllowGet));
        }
コード例 #8
0
        public dynamic InsertDetail(PurchaseReceivalDetail model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.PurchaseReceival, Core.Constants.Constant.MenuGroupName.Transaction))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Edit record");

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

                model = _purchaseReceivalDetailService.CreateObject(model, _purchaseReceivalService, _purchaseOrderDetailService, _purchaseOrderService, _itemService);
            }
            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
            }));
        }
コード例 #9
0
 public PurchaseReceivalDetail VNonNegativeQuantity(PurchaseReceivalDetail purchaseReceivalDetail)
 {
     if (purchaseReceivalDetail.Quantity < 0)
     {
         purchaseReceivalDetail.Errors.Add("Quantity", "Tidak boleh negatif");
     }
     return(purchaseReceivalDetail);
 }
コード例 #10
0
 public PurchaseReceivalDetail CreateObject(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseReceivalService _purchaseReceivalService,
                                            IPurchaseOrderDetailService _purchaseOrderDetailService, IPurchaseOrderService _purchaseOrderService,
                                            IItemService _itemService)
 {
     purchaseReceivalDetail.Errors = new Dictionary <String, String>();
     return(_validator.ValidCreateObject(purchaseReceivalDetail, this, _purchaseReceivalService, _purchaseOrderDetailService, _itemService) ?
            _repository.CreateObject(purchaseReceivalDetail) : purchaseReceivalDetail);
 }
コード例 #11
0
 public PurchaseReceivalDetail VHasConfirmationDate(PurchaseReceivalDetail purchaseReceivalDetail)
 {
     if (purchaseReceivalDetail.ConfirmationDate == null)
     {
         purchaseReceivalDetail.Errors.Add("ConfirmationDate", "Tidak boleh kosong");
     }
     return(purchaseReceivalDetail);
 }
コード例 #12
0
 public PurchaseReceivalDetail VHasBeenConfirmed(PurchaseReceivalDetail purchaseReceivalDetail)
 {
     if (!purchaseReceivalDetail.IsConfirmed)
     {
         purchaseReceivalDetail.Errors.Add("Generic", "Belum selesai");
     }
     return(purchaseReceivalDetail);
 }
コード例 #13
0
 public PurchaseReceivalDetail VHasNotBeenConfirmed(PurchaseReceivalDetail purchaseReceivalDetail)
 {
     if (purchaseReceivalDetail.IsConfirmed)
     {
         purchaseReceivalDetail.Errors.Add("Generic", "Tidak boleh sudah selesai");
     }
     return(purchaseReceivalDetail);
 }
コード例 #14
0
        public IList <StockMutation> SoftDeleteStockMutationForPurchaseReceival(PurchaseReceivalDetail purchaseReceivalDetail, WarehouseItem warehouseItem)
        {
            IList <StockMutation> stockMutations = _repository.GetObjectsBySourceDocumentDetailForWarehouseItem(warehouseItem.Id, Constant.SourceDocumentDetailType.PurchaseReceivalDetail, purchaseReceivalDetail.Id);

            foreach (var stockMutation in stockMutations)
            {
                _repository.Delete(stockMutation);
            }
            return(stockMutations);
        }
コード例 #15
0
        public PurchaseReceivalDetail VHasPurchaseOrderDetail(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseOrderDetailService _purchaseOrderDetailService)
        {
            PurchaseOrderDetail purchaseOrderDetail = _purchaseOrderDetailService.GetObjectById(purchaseReceivalDetail.PurchaseOrderDetailId);

            if (purchaseOrderDetail == null)
            {
                purchaseReceivalDetail.Errors.Add("PurchaseOrderDetailId", "Tidak terasosiasi dengan purchase order detail");
            }
            return(purchaseReceivalDetail);
        }
コード例 #16
0
        public PurchaseReceivalDetail VHasItem(PurchaseReceivalDetail purchaseReceivalDetail, IItemService _itemService)
        {
            Item item = _itemService.GetObjectById(purchaseReceivalDetail.ItemId);

            if (item == null)
            {
                purchaseReceivalDetail.Errors.Add("ItemId", "Tidak terasosiasi dengan item");
            }
            return(purchaseReceivalDetail);
        }
コード例 #17
0
        public PurchaseReceivalDetail VHasNoPurchaseInvoiceDetail(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseInvoiceDetailService _purchaseInvoiceDetailService)
        {
            IList <PurchaseInvoiceDetail> purchaseInvoiceDetails = _purchaseInvoiceDetailService.GetObjectsByPurchaseReceivalDetailId(purchaseReceivalDetail.Id);

            if (purchaseInvoiceDetails.Any())
            {
                purchaseReceivalDetail.Errors.Add("Generic", "Sudah memiliki purchase invoice detail");
            }
            return(purchaseReceivalDetail);
        }
コード例 #18
0
        public PurchaseInvoiceDetail VQuantityIsLessThanOrEqualPendingInvoiceQuantity(PurchaseInvoiceDetail purchaseInvoiceDetail, IPurchaseReceivalDetailService _purchaseReceivalDetailService)
        {
            PurchaseReceivalDetail purchaseReceivalDetail = _purchaseReceivalDetailService.GetObjectById(purchaseInvoiceDetail.PurchaseReceivalDetailId);

            if (purchaseInvoiceDetail.Quantity > purchaseReceivalDetail.PendingInvoicedQuantity)
            {
                purchaseInvoiceDetail.Errors.Add("Generic", "Quantity harus kurang dari atau sama dengan pending invoice quantity");
            }
            return(purchaseInvoiceDetail);
        }
コード例 #19
0
        public PurchaseReceivalDetail VPurchaseOrderDetailHasBeenConfirmed(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseOrderDetailService _purchaseOrderDetailService)
        {
            PurchaseOrderDetail purchaseOrderDetail = _purchaseOrderDetailService.GetObjectById(purchaseReceivalDetail.PurchaseOrderDetailId);

            if (!purchaseOrderDetail.IsConfirmed)
            {
                purchaseReceivalDetail.Errors.Add("Generic", "Purchase Order Detail belum dikonfirmasi");
            }
            return(purchaseReceivalDetail);
        }
コード例 #20
0
        public PurchaseInvoiceDetail VHasPurchaseReceivalDetail(PurchaseInvoiceDetail purchaseInvoiceDetail, IPurchaseReceivalDetailService _purchaseReceivalDetailService)
        {
            PurchaseReceivalDetail prd = _purchaseReceivalDetailService.GetObjectById(purchaseInvoiceDetail.PurchaseReceivalDetailId);

            if (prd == null)
            {
                purchaseInvoiceDetail.Errors.Add("PurchaseReceivalDetail", "Tidak boleh tidak ada");
            }
            return(purchaseInvoiceDetail);
        }
コード例 #21
0
 public PurchaseReceivalDetail InvoiceObject(PurchaseReceivalDetail purchaseReceivalDetail, int Quantity)
 {
     purchaseReceivalDetail.PendingInvoicedQuantity -= Quantity;
     if (purchaseReceivalDetail.PendingInvoicedQuantity == 0)
     {
         purchaseReceivalDetail.IsAllInvoiced = true;
     }
     _repository.UpdateObject(purchaseReceivalDetail);
     return(purchaseReceivalDetail);
 }
コード例 #22
0
 public PurchaseReceivalDetail VUpdateObject(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseReceivalDetailService _purchaseReceivalDetailService,
                                             IPurchaseReceivalService _purchaseReceivalService, IPurchaseOrderDetailService _purchaseOrderDetailService, IItemService _itemService)
 {
     VCreateObject(purchaseReceivalDetail, _purchaseReceivalDetailService, _purchaseReceivalService, _purchaseOrderDetailService, _itemService);
     if (!isValid(purchaseReceivalDetail))
     {
         return(purchaseReceivalDetail);
     }
     VHasNotBeenConfirmed(purchaseReceivalDetail);
     return(purchaseReceivalDetail);
 }
コード例 #23
0
 public PurchaseReceivalDetail VUnconfirmObject(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseInvoiceDetailService _purchaseInvoiceDetailService,
                                                IItemService _itemService)
 {
     VHasItemQuantity(purchaseReceivalDetail, _itemService);
     if (!isValid(purchaseReceivalDetail))
     {
         return(purchaseReceivalDetail);
     }
     VHasNoPurchaseInvoiceDetail(purchaseReceivalDetail, _purchaseInvoiceDetailService);
     return(purchaseReceivalDetail);
 }
コード例 #24
0
        public PurchaseReceivalDetail UndoInvoiceObject(PurchaseReceivalDetail purchaseReceivalDetail, int Quantity, IPurchaseReceivalService _purchaseReceivalService)
        {
            PurchaseReceival purchaseReceival = _purchaseReceivalService.GetObjectById(purchaseReceivalDetail.PurchaseReceivalId);

            _purchaseReceivalService.UnsetInvoiceComplete(purchaseReceival);

            purchaseReceivalDetail.IsAllInvoiced            = false;
            purchaseReceivalDetail.PendingInvoicedQuantity += Quantity;
            _repository.UpdateObject(purchaseReceivalDetail);
            return(purchaseReceivalDetail);
        }
コード例 #25
0
        public PurchaseInvoiceDetail VPurchaseReceivalDetailAndPurchaseInvoiceMustHaveTheSamePurchaseReceival(PurchaseInvoiceDetail purchaseInvoiceDetail,
                                                                                                              IPurchaseReceivalDetailService _purchaseReceivalDetailService, IPurchaseInvoiceService _purchaseInvoiceService)
        {
            PurchaseReceivalDetail purchaseReceivalDetail = _purchaseReceivalDetailService.GetObjectById(purchaseInvoiceDetail.PurchaseReceivalDetailId);
            PurchaseInvoice        purchaseInvoice        = _purchaseInvoiceService.GetObjectById(purchaseInvoiceDetail.PurchaseInvoiceId);

            if (purchaseReceivalDetail.PurchaseReceivalId != purchaseInvoice.PurchaseReceivalId)
            {
                purchaseReceivalDetail.Errors.Add("Generic", "Purchase receival detail dan purchase invoice memiliki purchase receival berbeda");
            }
            return(purchaseInvoiceDetail);
        }
コード例 #26
0
 public PurchaseInvoiceDetail UnconfirmObject(PurchaseInvoiceDetail purchaseInvoiceDetail, IPurchaseReceivalService _purchaseReceivalService,
                                              IPurchaseReceivalDetailService _purchaseReceivalDetailService)
 {
     if (_validator.ValidUnconfirmObject(purchaseInvoiceDetail))
     {
         purchaseInvoiceDetail = _repository.UnconfirmObject(purchaseInvoiceDetail);
         // reverse purchase receival detail PendingInvoiceQuantity
         PurchaseReceivalDetail purchaseReceivalDetail = _purchaseReceivalDetailService.GetObjectById(purchaseInvoiceDetail.PurchaseReceivalDetailId);
         _purchaseReceivalDetailService.UndoInvoiceObject(purchaseReceivalDetail, purchaseInvoiceDetail.Quantity, _purchaseReceivalService);
     }
     return(purchaseInvoiceDetail);
 }
コード例 #27
0
        public string PrintError(PurchaseReceivalDetail obj)
        {
            string erroroutput = "";
            KeyValuePair <string, string> first = obj.Errors.ElementAt(0);

            erroroutput += first.Key + "," + first.Value;
            foreach (KeyValuePair <string, string> pair in obj.Errors.Skip(1))
            {
                erroroutput += Environment.NewLine;
                erroroutput += pair.Key + "," + pair.Value;
            }
            return(erroroutput);
        }
コード例 #28
0
 public PurchaseInvoiceDetail ConfirmObject(PurchaseInvoiceDetail purchaseInvoiceDetail, DateTime ConfirmationDate,
                                            IPurchaseReceivalDetailService _purchaseReceivalDetailService)
 {
     purchaseInvoiceDetail.ConfirmationDate = ConfirmationDate;
     if (_validator.ValidConfirmObject(purchaseInvoiceDetail, this, _purchaseReceivalDetailService))
     {
         purchaseInvoiceDetail = _repository.ConfirmObject(purchaseInvoiceDetail);
         // update purchase receival detail PendingInvoiceQuantity
         PurchaseReceivalDetail purchaseReceivalDetail = _purchaseReceivalDetailService.GetObjectById(purchaseInvoiceDetail.PurchaseReceivalDetailId);
         _purchaseReceivalDetailService.InvoiceObject(purchaseReceivalDetail, purchaseInvoiceDetail.Quantity);
     }
     return(purchaseInvoiceDetail);
 }
コード例 #29
0
        public PurchaseReceivalDetail VUniquePurchaseOrderDetail(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseReceivalDetailService _purchaseReceivalDetailService, IItemService _itemService)
        {
            IList <PurchaseReceivalDetail> details = _purchaseReceivalDetailService.GetObjectsByPurchaseReceivalId(purchaseReceivalDetail.PurchaseReceivalId);

            foreach (var detail in details)
            {
                if (detail.PurchaseOrderDetailId == purchaseReceivalDetail.PurchaseOrderDetailId && detail.Id != purchaseReceivalDetail.Id)
                {
                    purchaseReceivalDetail.Errors.Add("Generic", "Tidak boleh memiliki lebih dari 2 Purchase Receival Detail dalam satu purchase receival");
                }
            }
            return(purchaseReceivalDetail);
        }
コード例 #30
0
        public PurchaseReceivalDetail CreateObject(int purchaseReceivalId, int itemId, int quantity, int purchaseOrderDetailId,
                                                   IPurchaseReceivalService _purchaseReceivalService, IPurchaseOrderDetailService _purchaseOrderDetailService,
                                                   IPurchaseOrderService _purchaseOrderService, IItemService _itemService)
        {
            PurchaseReceivalDetail purchaseReceivalDetail = new PurchaseReceivalDetail
            {
                PurchaseReceivalId    = purchaseReceivalId,
                ItemId                = itemId,
                Quantity              = quantity,
                PurchaseOrderDetailId = purchaseOrderDetailId
            };

            return(this.CreateObject(purchaseReceivalDetail, _purchaseReceivalService, _purchaseOrderDetailService, _purchaseOrderService, _itemService));
        }