Ejemplo n.º 1
0
        /// <summary>
        /// Generates the dispatch model.
        /// </summary>
        /// <param name="dispatch">The dispatch.</param>
        /// <param name="Repository">The repository.</param>
        /// <returns></returns>
        public static Models.DispatchModel GenerateDispatchModel(BLL.Dispatch dispatch,Transaction transactionObj)
        {
            DispatchModel model = new DispatchModel();
            model.BidNumber = dispatch.BidNumber;
            model.DispatchDate = dispatch.DispatchDate;
            model.DispatchID = dispatch.DispatchID;
            model.DriverName = dispatch.DriverName;
            model.DispatchedByStoreMan = dispatch.DispatchedByStoreMan;
            model.FDPID = dispatch.FDPID;
            model.GIN = dispatch.GIN;
            model.Month = dispatch.PeriodMonth;
            model.Year = dispatch.PeriodYear;
            model.PlateNo_Prime = dispatch.PlateNo_Prime;
            model.PlateNo_Trailer = dispatch.PlateNo_Trailer;
            model.RequisitionNo = dispatch.RequisitionNo;
            model.Type = dispatch.Type;
            //model.StackNumber = dispatch.StackNumber;
            //model.StoreID = dispatch.StoreID;
            model.TransporterID = dispatch.TransporterID;
            model.WarehouseID = dispatch.HubID;
            //model.ProgramID = dispatch.ProgramID;
            model.WeighBridgeTicketNumber = dispatch.WeighBridgeTicketNumber;
            model.Remark = dispatch.Remark;

            model.OtherDispatchAllocationID = dispatch.OtherDispatchAllocationID;
            model.DispatchAllocationID = dispatch.DispatchAllocationID;

            // model.ProjectNumber = dispatch.ProjectNumber;
            //model.SINumber = dispatch.SINumber;
            //TODO:Check modification have any impact
            BLL.Transaction transaction = transactionObj;// Repository.Dispatch.GetDispatchTransaction(dispatch.DispatchID);
            if (transaction != null)
            {
                if (transaction.Stack != null) model.StackNumber = transaction.Stack.Value;
                model.StoreID = transaction.StoreID;
                model.ProgramID = transaction.ProgramID;
                model.ProjectNumber = transaction.ProjectCode.Value;
                model.SINumber = transaction.ShippingInstruction.Value;
                model.CommodityTypeID = transaction.Commodity.CommodityTypeID;
            }
            model.DispatchDetails = DispatchDetailModel.GenerateDispatchDetailModels(dispatch.DispatchDetails);
            return model;
        }
        public void Should_Add_InternalMovement()
        {
            InternalMovementViewModel actualViewModel = new InternalMovementViewModel();
            actualViewModel.FromStoreId = 3;
            actualViewModel.SelectedDate = DateTime.Now;
            actualViewModel.FromStackId = 4;
            actualViewModel.ReferenceNumber = "Test/001/";
            actualViewModel.CommodityId = 1;
            actualViewModel.ProgramId = 2;
            actualViewModel.ProjectCodeId = 33;
            actualViewModel.ShippingInstructionId = 46;
            actualViewModel.UnitId = 5;
            actualViewModel.QuantityInUnit = 100;
            actualViewModel.QuantityInMt = 200;
            actualViewModel.ToStoreId = 4;
            actualViewModel.ToStackId = 2;
            actualViewModel.ReasonId = 17;
            actualViewModel.Note = "Test transfer";
            actualViewModel.ApprovedBy = "Mr Test";

            ///expected values
            InternalMovement expectdInternalMovementModel = new InternalMovement();
            expectdInternalMovementModel.PartitionID = 0;
            //expectdInternalMovementModel.TransactionGroupID
            expectdInternalMovementModel.TransferDate = actualViewModel.SelectedDate;
            expectdInternalMovementModel.ReferenceNumber = actualViewModel.ReferenceNumber;
            expectdInternalMovementModel.DReason = actualViewModel.ReasonId;
            expectdInternalMovementModel.Notes = actualViewModel.Note;
            expectdInternalMovementModel.ApprovedBy = actualViewModel.ApprovedBy;

            BLL.UserProfile actualUser = repository.UserProfile.GetUser("admin");

            Transaction expectedFromStoreTrasactionModel = new Transaction();
            expectedFromStoreTrasactionModel.PartitionID = 0;
            //expectedTrasactionModel.TransactionGroupID
            expectedFromStoreTrasactionModel.LedgerID = 2;
            expectedFromStoreTrasactionModel.HubOwnerID = actualUser.DefaultHub.HubOwner.HubOwnerID;
            //expectedTrasactionModel.AccountID =
            expectedFromStoreTrasactionModel.HubID = actualUser.DefaultHub.HubID;
            expectedFromStoreTrasactionModel.StoreID = actualViewModel.FromStoreId;
            expectedFromStoreTrasactionModel.Stack = actualViewModel.FromStackId;
            expectedFromStoreTrasactionModel.ProjectCodeID = actualViewModel.ProjectCodeId;
            expectedFromStoreTrasactionModel.ShippingInstructionID = actualViewModel.ShippingInstructionId;
            expectedFromStoreTrasactionModel.ProgramID = actualViewModel.ProgramId;
            //expectedFromStoreTrasactionModel.ParentCommodityID
            //expectedFromStoreTrasactionModel.CommodityID
            expectedFromStoreTrasactionModel.QuantityInMT = actualViewModel.QuantityInMt;
            expectedFromStoreTrasactionModel.QuantityInUnit  = actualViewModel.QuantityInUnit;
            expectedFromStoreTrasactionModel.UnitID = actualViewModel.UnitId;

            Transaction expectedToStoreTrasactionModel = new Transaction();
            expectedToStoreTrasactionModel.PartitionID = 0;
            //expectedTrasactionModel.TransactionGroupID
            expectedToStoreTrasactionModel.LedgerID = 2;
            expectedToStoreTrasactionModel.HubOwnerID = actualUser.DefaultHub.HubOwner.HubOwnerID;
            //expectedTrasactionModel.AccountID =
            expectedToStoreTrasactionModel.HubID = actualUser.DefaultHub.HubID;
            expectedToStoreTrasactionModel.StoreID = actualViewModel.FromStoreId;
            expectedToStoreTrasactionModel.Stack = actualViewModel.FromStackId;
            expectedToStoreTrasactionModel.ProjectCodeID = actualViewModel.ProjectCodeId;
            expectedToStoreTrasactionModel.ShippingInstructionID = actualViewModel.ShippingInstructionId;
            expectedToStoreTrasactionModel.ProgramID = actualViewModel.ProgramId;
            //expectedFromStoreTrasactionModel.ParentCommodityID
            //expectedFromStoreTrasactionModel.CommodityID
            expectedToStoreTrasactionModel.QuantityInMT = actualViewModel.QuantityInMt;
            expectedToStoreTrasactionModel.QuantityInUnit  = actualViewModel.QuantityInUnit;
            expectedToStoreTrasactionModel.UnitID = actualViewModel.UnitId;

            //var redirectToRouteResult = (RedirectToRouteResult)  new InternalMovementController().Create(actualViewModel);

            //repository.InternalMovement.AddNewInternalMovement(actualViewModel, actualUser);
            repository.Transaction.SaveInternalMovementTrasnsaction(actualViewModel, actualUser);

            //CollectionAssert.Contains(repository.Transaction.GetAll(), expectedFromStoreTrasactionModel);
            //CollectionAssert.Contains(repository.InternalMovement.GetAll(), expectdInternalMovementModel);
        }