/// <summary>
        /// Generates the allocation view model.
        /// </summary>
        /// <param name="receiptAllocation">The receipt allocation.</param>
        /// <returns></returns>
        public static ReceiptAllocationViewModel GenerateAllocationViewModel(ReceiptAllocation receiptAllocation)
        {
            ReceiptAllocationViewModel receiptAllocationViewModel = new ReceiptAllocationViewModel();

            receiptAllocationViewModel.ProjectNumber = receiptAllocation.ProjectNumber;
            receiptAllocationViewModel.CommodityID   = receiptAllocation.CommodityID;
            receiptAllocationViewModel.SINumber      = receiptAllocation.SINumber;
            receiptAllocationViewModel.QuantityInMT  = receiptAllocation.QuantityInMT;
            if (receiptAllocation.QuantityInUnit == null)
            {
                receiptAllocationViewModel.QuantityInUnit = 0;
            }
            else
            {
                receiptAllocationViewModel.QuantityInUnit = receiptAllocation.QuantityInUnit.Value;
            }

            receiptAllocationViewModel.HubID   = receiptAllocation.HubID;
            receiptAllocationViewModel.ETA     = receiptAllocation.ETA;
            receiptAllocationViewModel.DonorID = receiptAllocation.DonorID;
            receiptAllocationViewModel.GiftCertificateDetailID = receiptAllocation.GiftCertificateDetailID;
            receiptAllocationViewModel.ReceiptAllocationID     = receiptAllocation.ReceiptAllocationID;
            receiptAllocationViewModel.IsCommited            = receiptAllocation.IsCommited;
            receiptAllocationViewModel.SourceHubID           = receiptAllocation.SourceHubID;
            receiptAllocationViewModel.PurchaseOrder         = receiptAllocation.PurchaseOrder;
            receiptAllocationViewModel.SupplierName          = receiptAllocation.SupplierName;
            receiptAllocationViewModel.OtherDocumentationRef = receiptAllocation.OtherDocumentationRef;
            receiptAllocationViewModel.Remark          = receiptAllocation.Remark;
            receiptAllocationViewModel.Receives        = receiptAllocation.Receives.ToList();
            receiptAllocationViewModel.CommodityTypeID = receiptAllocation.Commodity.CommodityTypeID;

            receiptAllocationViewModel.ProgramID         = receiptAllocation.ProgramID;
            receiptAllocationViewModel.CommoditySourceID = receiptAllocation.CommoditySourceID;
            return(receiptAllocationViewModel);
        }
        /// <summary>
        /// Generates the receipt allocation.
        /// </summary>
        /// <returns></returns>
        public ReceiptAllocation GenerateReceiptAllocation()
        {
            ReceiptAllocation receiptAllocation = new ReceiptAllocation()
            {
                ProjectNumber = this.ProjectNumber,
                SINumber      = this.SINumber,
                QuantityInMT  = this.QuantityInMT,
                CommodityID   = this.CommodityID,
                HubID         = this.HubID,

                ETA     = this.ETA,
                DonorID = this.DonorID == null ? (int?)null : this.DonorID.Value,
                GiftCertificateDetailID = this.GiftCertificateDetailID,
                PartitionId             = this.PartitionId,
                ProgramID             = this.ProgramID,
                CommoditySourceID     = this.CommoditySourceID,
                IsCommited            = this.IsCommited,
                SourceHubID           = this.SourceHubID,
                PurchaseOrder         = this.PurchaseOrder,
                SupplierName          = this.SupplierName,
                OtherDocumentationRef = this.OtherDocumentationRef,
                QuantityInUnit        = this.QuantityInUnit,
                Receives = this.Receives,
                Remark   = this.Remark
            };

            if (this.ReceiptAllocationID.HasValue)
            {
                receiptAllocation.ReceiptAllocationID = this.ReceiptAllocationID.Value;
            }

            return(receiptAllocation);
        }
Exemple #3
0
 public decimal GetReceivedAlreadyInUnit(ReceiptAllocation receiptAllocation)
 {
     decimal sum = 0;
     if (receiptAllocation.Receives != null)
         foreach (Receive r in receiptAllocation.Receives)
         {
             foreach (ReceiveDetail rd in r.ReceiveDetails)
             {
                 sum = sum + rd.QuantityInUnit;
             }
         }
     return sum;
 }
Exemple #4
0
        public decimal GetReceivedAlreadyInUnit(ReceiptAllocation receiptAllocation)
        {
            decimal sum = 0;

            if (receiptAllocation.Receives != null)
            {
                foreach (Receive r in receiptAllocation.Receives)
                {
                    foreach (ReceiveDetail rd in r.ReceiveDetails)
                    {
                        sum = sum + rd.QuantityInUnit;
                    }
                }
            }
            return(sum);
        }
Exemple #5
0
        public static ReceiptAllocationViewModelDto GenerateAllocationViewModelDto(ReceiptAllocation receiptAllocation)
        {
            ReceiptAllocationViewModelDto receiptAllocationViewModelDto = new ReceiptAllocationViewModelDto();

            receiptAllocationViewModelDto.ProjectNumber = receiptAllocation.ProjectNumber;
            receiptAllocationViewModelDto.CommodityID   = receiptAllocation.CommodityID;
            receiptAllocationViewModelDto.SINumber      = receiptAllocation.SINumber;
            receiptAllocationViewModelDto.QuantityInMT  = receiptAllocation.QuantityInMT;

            receiptAllocationViewModelDto.HubID = receiptAllocation.HubID;
            receiptAllocationViewModelDto.ETA   = receiptAllocation.ETA;
            if (receiptAllocation.DonorID != null)
            {
                receiptAllocationViewModelDto.DonorID = receiptAllocation.DonorID.Value;
            }
            if (receiptAllocation.GiftCertificateDetailID != null)
            {
                receiptAllocationViewModelDto.GiftCertificateDetailID = receiptAllocation.GiftCertificateDetailID.Value;
            }
            receiptAllocationViewModelDto.ReceiptAllocationID = receiptAllocation.ReceiptAllocationID;
            receiptAllocationViewModelDto.IsCommited          = receiptAllocation.IsCommited;
            if (receiptAllocation.SourceHubID != null)
            {
                receiptAllocationViewModelDto.SourceHubID = receiptAllocation.SourceHubID.Value;
            }
            receiptAllocationViewModelDto.PurchaseOrder         = receiptAllocation.PurchaseOrder;
            receiptAllocationViewModelDto.SupplierName          = receiptAllocation.SupplierName;
            receiptAllocationViewModelDto.OtherDocumentationRef = receiptAllocation.OtherDocumentationRef;
            receiptAllocationViewModelDto.Remark = receiptAllocation.Remark;

            receiptAllocationViewModelDto.ProgramID         = receiptAllocation.ProgramID;
            receiptAllocationViewModelDto.CommoditySourceID = receiptAllocation.CommoditySourceID;

            receiptAllocationViewModelDto.CommodityName        = receiptAllocation.CommodityName;
            receiptAllocationViewModelDto.ReceivedQuantityInMT = receiptAllocation.ReceivedQuantityInMT;
            receiptAllocationViewModelDto.RemainingBalanceInMt = receiptAllocation.RemainingBalanceInMT;


            return(receiptAllocationViewModelDto);
        }
        /// <summary>
        /// Generates the receipt allocation.
        /// </summary>
        /// <returns></returns>
        public ReceiptAllocation GenerateReceiptAllocation()
        {
            ReceiptAllocation receiptAllocation = new ReceiptAllocation()
            {

                ProjectNumber = this.ProjectNumber,
                SINumber = this.SINumber,
                QuantityInMT = this.QuantityInMT,
                CommodityID = this.CommodityID,
                HubID = this.HubID,

                ETA = this.ETA,
                DonorID = this.DonorID == null ? (int?)null : this.DonorID.Value,
                GiftCertificateDetailID = this.GiftCertificateDetailID,
                PartitionId = this.PartitionId,
                ProgramID = this.ProgramID,
                CommoditySourceID = this.CommoditySourceID,
                IsCommited = this.IsCommited,
                SourceHubID = this.SourceHubID,
                PurchaseOrder = this.PurchaseOrder,
                SupplierName = this.SupplierName,
                OtherDocumentationRef = this.OtherDocumentationRef,
                QuantityInUnit = this.QuantityInUnit,
                Receives = this.Receives,
                Remark = this.Remark
            };
            if (this.ReceiptAllocationID.HasValue)
            {
                receiptAllocation.ReceiptAllocationID = this.ReceiptAllocationID.Value;
            }

            return receiptAllocation;
        }
        /// <summary>
        /// Generates the allocation view model.
        /// </summary>
        /// <param name="receiptAllocation">The receipt allocation.</param>
        /// <returns></returns>
        public static ReceiptAllocationViewModel GenerateAllocationViewModel(ReceiptAllocation receiptAllocation)
        {
            ReceiptAllocationViewModel receiptAllocationViewModel = new ReceiptAllocationViewModel();

            receiptAllocationViewModel.ProjectNumber = receiptAllocation.ProjectNumber;
            receiptAllocationViewModel.CommodityID = receiptAllocation.CommodityID;
            receiptAllocationViewModel.SINumber = receiptAllocation.SINumber;
            receiptAllocationViewModel.QuantityInMT = receiptAllocation.QuantityInMT;
            if (receiptAllocation.QuantityInUnit == null)
                receiptAllocationViewModel.QuantityInUnit = 0;
            else
                receiptAllocationViewModel.QuantityInUnit = receiptAllocation.QuantityInUnit.Value;

            receiptAllocationViewModel.HubID = receiptAllocation.HubID;
            receiptAllocationViewModel.ETA = receiptAllocation.ETA;
            receiptAllocationViewModel.DonorID = receiptAllocation.DonorID;
            receiptAllocationViewModel.GiftCertificateDetailID = receiptAllocation.GiftCertificateDetailID;
            receiptAllocationViewModel.ReceiptAllocationID = receiptAllocation.ReceiptAllocationID;
            receiptAllocationViewModel.IsCommited = receiptAllocation.IsCommited;
            receiptAllocationViewModel.SourceHubID = receiptAllocation.SourceHubID;
            receiptAllocationViewModel.PurchaseOrder = receiptAllocation.PurchaseOrder;
            receiptAllocationViewModel.SupplierName = receiptAllocation.SupplierName;
            receiptAllocationViewModel.OtherDocumentationRef = receiptAllocation.OtherDocumentationRef;
            receiptAllocationViewModel.Remark = receiptAllocation.Remark;
            receiptAllocationViewModel.Receives = receiptAllocation.Receives.ToList();
            receiptAllocationViewModel.CommodityTypeID = receiptAllocation.Commodity.CommodityTypeID;

            receiptAllocationViewModel.ProgramID = receiptAllocation.ProgramID;
            receiptAllocationViewModel.CommoditySourceID = receiptAllocation.CommoditySourceID;
            return receiptAllocationViewModel;
        }
 public bool AddReceiptAllocation(ReceiptAllocation receiptAllocation)
 {
     _unitOfWork.ReceiptAllocationRepository.Add(receiptAllocation);
     _unitOfWork.Save();
     return true;
 }
 public bool DeleteReceiptAllocation(ReceiptAllocation receiptAllocation)
 {
     if (receiptAllocation == null) return false;
     _unitOfWork.ReceiptAllocationRepository.Delete(receiptAllocation);
     _unitOfWork.Save();
     return true;
 }
Exemple #10
0
        public ReceiveNewViewModel ReceiptAllocationToReceive(ReceiptAllocation receiptAllocation)
        {
            var viewModel = new ReceiveNewViewModel
            {
                ReceiptDate = DateTime.Now,
                ReceiptAllocationId = receiptAllocation.ReceiptAllocationID,
                SiNumber = receiptAllocation.SINumber,
                ProjectCode = receiptAllocation.ProjectNumber,
                Program = _unitOfWork.ProgramRepository.FindById(receiptAllocation.ProgramID).Name,
                ProgramId = receiptAllocation.ProgramID,
                CommodityType = _unitOfWork.CommodityTypeRepository.FindById(receiptAllocation.Commodity.CommodityTypeID).Name,
                CommodityTypeId = receiptAllocation.Commodity.CommodityTypeID,
            };

            if (CommoditySource.Constants.LOAN == receiptAllocation.CommoditySourceID
                || CommoditySource.Constants.SWAP == receiptAllocation.CommoditySourceID
                || CommoditySource.Constants.TRANSFER == receiptAllocation.CommoditySourceID
                || CommoditySource.Constants.REPAYMENT == receiptAllocation.CommoditySourceID)
            {
                if (receiptAllocation.SourceHubID.HasValue)
                {
                    viewModel.SourceHub = _unitOfWork.HubRepository.FindById(receiptAllocation.SourceHubID.GetValueOrDefault(0)).Name;
                }
                viewModel.IsFalseGRN = receiptAllocation.IsFalseGRN;
            }

            if (CommoditySource.Constants.LOCALPURCHASE == receiptAllocation.CommoditySourceID)
            {
                viewModel.SupplierName = receiptAllocation.SupplierName;
                viewModel.PurchaseOrder = receiptAllocation.PurchaseOrder;
            }

            viewModel.CommoditySource = receiptAllocation.CommoditySource.Name;
            viewModel.CommoditySourceTypeId = receiptAllocation.CommoditySourceID;
            viewModel.ReceiveDetailNewViewModels = new List<ReceiveDetailNewViewModel> { };
            return viewModel;
        }
 private decimal GetReceivedAlready(ReceiptAllocation receiptAllocation)
 {
     decimal sum = 0;
     if (receiptAllocation.Receives != null)
         foreach (Receive r in receiptAllocation.Receives)
         {
             foreach (ReceiveDetail rd in r.ReceiveDetails)
             {
                 sum = sum + Math.Abs(rd.QuantityInMT);
             }
         }
     return sum;
 }
        public static ReceiptAllocationViewModelDto GenerateAllocationViewModelDto(ReceiptAllocation receiptAllocation)
        {
            ReceiptAllocationViewModelDto receiptAllocationViewModelDto = new ReceiptAllocationViewModelDto();
            receiptAllocationViewModelDto.ProjectNumber = receiptAllocation.ProjectNumber;
            receiptAllocationViewModelDto.CommodityID = receiptAllocation.CommodityID;
            receiptAllocationViewModelDto.SINumber = receiptAllocation.SINumber;
            receiptAllocationViewModelDto.QuantityInMT = receiptAllocation.QuantityInMT;

            receiptAllocationViewModelDto.HubID = receiptAllocation.HubID;
            receiptAllocationViewModelDto.ETA = receiptAllocation.ETA;
            if (receiptAllocation.DonorID != null) receiptAllocationViewModelDto.DonorID = receiptAllocation.DonorID.Value;
            if (receiptAllocation.GiftCertificateDetailID != null)
                receiptAllocationViewModelDto.GiftCertificateDetailID = receiptAllocation.GiftCertificateDetailID.Value;
            receiptAllocationViewModelDto.ReceiptAllocationID = receiptAllocation.ReceiptAllocationID;
            receiptAllocationViewModelDto.IsCommited = receiptAllocation.IsCommited;
            if (receiptAllocation.SourceHubID != null)
                receiptAllocationViewModelDto.SourceHubID = receiptAllocation.SourceHubID.Value;
            receiptAllocationViewModelDto.PurchaseOrder = receiptAllocation.PurchaseOrder;
            receiptAllocationViewModelDto.SupplierName = receiptAllocation.SupplierName;
            receiptAllocationViewModelDto.OtherDocumentationRef = receiptAllocation.OtherDocumentationRef;
            receiptAllocationViewModelDto.Remark = receiptAllocation.Remark;

            receiptAllocationViewModelDto.ProgramID = receiptAllocation.ProgramID;
            receiptAllocationViewModelDto.CommoditySourceID = receiptAllocation.CommoditySourceID;

            receiptAllocationViewModelDto.CommodityName = receiptAllocation.CommodityName;
            receiptAllocationViewModelDto.ReceivedQuantityInMT = receiptAllocation.ReceivedQuantityInMT;
            receiptAllocationViewModelDto.RemainingBalanceInMt = receiptAllocation.RemainingBalanceInMT;

            return receiptAllocationViewModelDto;
        }
        private ReceiptAllocation FromReceiptAllocationViewModel(ReceiptAllocationViewModel viewModel, ReceiptAllocation entityModel)
        {
            // ReceiptAllocationID = receiptAllocation.ReceiptAllocationID,
                    entityModel.PartitionId = viewModel.PartitionId;
                    entityModel.IsCommited = viewModel.IsCommited;
                    entityModel.ETA = viewModel.ETA;
                    entityModel.ProjectNumber = viewModel.ProjectNumber;
                    entityModel.GiftCertificateDetailID = viewModel.GiftCertificateDetailID;
                    entityModel.CommodityID = viewModel.CommodityID;
                   // CommodityName = receiptAllocation.Commodity.Name,
                    entityModel.SINumber = viewModel.SINumber;
                    entityModel.UnitID = viewModel.UnitID;
                    entityModel.QuantityInUnit = viewModel.QuantityInUnit;
                    entityModel.QuantityInMT = viewModel.QuantityInMT;
                    entityModel.RemainingBalanceInMT = viewModel.RemainingBalanceInMT;
                    entityModel.ReceivedQuantityInMT = viewModel.ReceivedQuantityInMT;
                    entityModel.DonorID = viewModel.DonorID;
                    entityModel.ProgramID = viewModel.ProgramID;
                    entityModel.CommoditySourceID = viewModel.CommoditySourceID;
                    entityModel.IsClosed = viewModel.IsClosed;
                    entityModel.PurchaseOrder = viewModel.PurchaseOrder;
                    entityModel.SupplierName = viewModel.SupplierName;
                    entityModel.SourceHubID = viewModel.SourceHubID;
                    entityModel.OtherDocumentationRef = viewModel.OtherDocumentationRef;
                    entityModel.Remark = viewModel.Remark;

            return entityModel;
        }