public GeneralViewModel(NotificationApplication notification, ShipmentInfo shipmentInfo, FacilityCollection facilityCollection, DateTimeFormatter dateTimeFormatter, QuantityFormatter quantityFormatter, PhysicalCharacteristicsFormatter physicalCharacteristicsFormatter) { Number = notification.NotificationNumber; IsDisposal = notification.NotificationType.Equals(NotificationType.Disposal); IsRecovery = notification.NotificationType.Equals(NotificationType.Recovery); var isPreconsented = facilityCollection.AllFacilitiesPreconsented; if (!isPreconsented.HasValue) { IsPreconsented = false; IsNotPreconsented = false; } else { IsPreconsented = isPreconsented.GetValueOrDefault(); IsNotPreconsented = !isPreconsented.GetValueOrDefault(); } if (shipmentInfo.NumberOfShipments > 1) { IsIndividualShipment = false; IsNotIndividualShipment = true; } else { IsIndividualShipment = true; IsNotIndividualShipment = false; } IntendedNumberOfShipments = shipmentInfo.NumberOfShipments.ToString(); FirstDeparture = dateTimeFormatter.DateTimeToDocumentFormatString(shipmentInfo.ShipmentPeriod.FirstDate); LastDeparture = dateTimeFormatter.DateTimeToDocumentFormatString(shipmentInfo.ShipmentPeriod.LastDate); SetIntendedQuantityFields(shipmentInfo, quantityFormatter); var hasSpecialHandlingRequirements = notification.HasSpecialHandlingRequirements; if (!hasSpecialHandlingRequirements.HasValue) { IsSpecialHandling = false; IsNotSpecialHandling = false; } else { IsSpecialHandling = hasSpecialHandlingRequirements.GetValueOrDefault(); IsNotSpecialHandling = !hasSpecialHandlingRequirements.GetValueOrDefault(); } PackagingTypes = GetPackagingInfo(notification); PhysicalCharacteristics = physicalCharacteristicsFormatter.PhysicalCharacteristicsToCommaDelimitedString( notification.PhysicalCharacteristics); }
public static void ApplyStrikethroughFormattingToUnits(WordprocessingDocument document, ShipmentInfo shipmentInfo) { if (shipmentInfo == null) { return; } ApplyStrikethroughFormattingToUnits(document, shipmentInfo.Units); }
public GeneralBlock(IList<MergeField> mergeFields, NotificationApplication notification, ShipmentInfo shipmentInfo, FacilityCollection facilityCollection) { CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, "General"); data = new GeneralViewModel(notification, shipmentInfo, facilityCollection, new DateTimeFormatter(), new QuantityFormatter(), new PhysicalCharacteristicsFormatter()); }
public void CanCreateShipmentInfo() { var firstDate = new DateTime(2015, 01, 01); var lastDate = new DateTime(2015, 12, 01); var shipmentPeriod = new ShipmentPeriod(firstDate, lastDate, true); var shipmentInfo = new ShipmentInfo(AnyGuid, shipmentPeriod, 10, new ShipmentQuantity(0.0001M, ShipmentQuantityUnits.Tonnes)); Assert.NotNull(shipmentInfo); }
public NotificationChargeCalculatorTests() { notificationId = new Guid("C4C62654-048C-45A2-BF7F-9837EFCF328F"); shipmentInfoRepository = A.Fake<IShipmentInfoRepository>(); shipmentInfo = A.Fake<ShipmentInfo>(); notificationApplicationRepository = A.Fake<INotificationApplicationRepository>(); pricingStructureRepository = A.Fake<IPricingStructureRepository>(); facilityRepository = A.Fake<IFacilityRepository>(); numberOfShipmentsHistotyRepository = A.Fake<INumberOfShipmentsHistotyRepository>(); notificationApplication = new TestableNotificationApplication(); chargeCalculator = new NotificationChargeCalculator(shipmentInfoRepository, notificationApplicationRepository, pricingStructureRepository, facilityRepository, numberOfShipmentsHistotyRepository); }
public MovementBlock(IList<MergeField> mergeFields, Movement movement, MovementDetails movementDetails, NotificationApplication notification, ShipmentInfo shipmentInfo) { CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName); data = new MovementViewModel( movement, movementDetails, notification, shipmentInfo, new DateTimeFormatter(), new QuantityFormatter(), new PhysicalCharacteristicsFormatter(), new PackagingTypesFormatter()); }
public MovementViewModel(Movement movement, MovementDetails movementDetails, NotificationApplication notification, ShipmentInfo shipmentInfo, DateTimeFormatter dateTimeFormatter, QuantityFormatter quantityFormatter, PhysicalCharacteristicsFormatter physicalCharacteristicsFormatter, PackagingTypesFormatter packagingTypesFormatter) { if (notification == null) { return; } NotificationNumber = notification.NotificationNumber ?? string.Empty; IsSpecialHandling = notification.HasSpecialHandlingRequirements.GetValueOrDefault(); IsNotSpecialHandling = !notification.HasSpecialHandlingRequirements.GetValueOrDefault(true); PhysicalCharacteristics = physicalCharacteristicsFormatter.PhysicalCharacteristicsToCommaDelimitedString(notification.PhysicalCharacteristics); IntendedNumberOfShipments = (shipmentInfo == null) ? "0" : shipmentInfo.NumberOfShipments.ToString(); IsRecovery = notification.NotificationType == NotificationType.Recovery; IsDisposal = notification.NotificationType == NotificationType.Disposal; if (movement == null) { return; } Number = movement.Number.ToString(); if (movementDetails == null) { return; } ActualDate = dateTimeFormatter.DateTimeToDocumentFormatString(movement.Date); SetQuantity(movementDetails, quantityFormatter); PackagingTypes = packagingTypesFormatter.PackagingTypesToCommaDelimitedString(movementDetails.PackagingInfos); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //long doID = Request["DOID"] == null ? 0 : Convert.ToInt64(Request["DOID"]); int sequenceNumber = Request["PackageID"] == null ? 1 : Convert.ToInt32(Request["PackageID"]); //var svc = ServiceLocator.Resolve<IModelService>("Internal"); //DeliveryOrder deliveryOrder = svc.SelectOrEmpty(new DeliveryOrderQuery() { ID = doID, Includes = new string[] { "Items" } }).FirstOrDefault(); //List<Package> package = svc.SelectOrEmpty(new PackageQuery() { DeliveryOrderIDs = new long[] { deliveryOrder.ID??0 }, OrderField = "ID" }).ToList(); //OrderItem orderItem = svc.Select(new OrderItemQuery() { IDs = deliveryOrder.Items.Select(o => o.ReferID ?? 0).ToArray(), Includes = new string[] { "Order" } }).FirstOrDefault(); ShipmentInfo shipmentInfo = new ShipmentInfo(); shipmentInfo.DOCode = ""; shipmentInfo.Units = ShipmentInfo.WeightUnits.LB; shipmentInfo.Weight = 50M; shipmentInfo.OriginPersonName = "Sender Name"; shipmentInfo.OriginCompanyName = "Sender Company Name"; shipmentInfo.OriginPhoneNumber = "0805522713"; shipmentInfo.OriginStreetLines = new string[1] { "Address Line 1" }; shipmentInfo.OriginCity = "SHANGHAI"; shipmentInfo.OriginStateProvince = ""; shipmentInfo.OriginPostalCode = "200233"; shipmentInfo.OriginCountryCode = "CN"; shipmentInfo.DestinationPersonName = "Recipient Name"; shipmentInfo.DestinationCompanyName = "Recipient Company Name"; shipmentInfo.DestinationPhoneNumber = "9012637906"; shipmentInfo.DestinationStreetLines = new string[1] { "Address Line 1" }; shipmentInfo.DestinationCity = "Windsor"; shipmentInfo.DestinationStateProvince = "CT"; shipmentInfo.DestinationPostalCode = "06006"; shipmentInfo.DestinationCountryCode = "US"; shipmentInfo.PackageInfos = new List <PackageInfo>(); shipmentInfo.SequenceNumber = sequenceNumber; shipmentInfo.PackageInfos.Add(new PackageInfo() { Weight = 50M, Height = 12, Width = 13, Length = 14, Units = PackageInfo.LinearUnits.IN }); shipmentInfo.PackageInfos.Add(new PackageInfo() { Weight = 50M, Height = 12, Width = 13, Length = 14, Units = PackageInfo.LinearUnits.IN }); try { this.imgExpress.Src = FedexUtil.Get(shipmentInfo); //this.imgExpress.Src = "http://192.168.1.14:8013/Content/794809821138.png"; OnloadFunction = "PrintPage()"; } catch (Exception err) { lblMessage.Visible = true; lblMessage.Text = err.Message; } OnloadFunction = "PrintPage()"; } }
public void CanUpdateShipmentQuantity() { var firstDate = new DateTime(2015, 01, 01); var lastDate = new DateTime(2015, 12, 01); var shipmentPeriod = new ShipmentPeriod(firstDate, lastDate, true); var shipmentInfo = new ShipmentInfo(AnyGuid, shipmentPeriod, 10, new ShipmentQuantity(0.0001M, ShipmentQuantityUnits.Tonnes)); shipmentInfo.UpdateQuantity(new ShipmentQuantity(2.0M, ShipmentQuantityUnits.Kilograms)); Assert.Equal(2.0M, shipmentInfo.Quantity); Assert.Equal(ShipmentQuantityUnits.Kilograms, shipmentInfo.Units); }
public void CanUpdateShipmentPeriod() { var firstDate = new DateTime(2015, 01, 01); var lastDate = new DateTime(2015, 12, 01); var shipmentPeriod = new ShipmentPeriod(firstDate, lastDate, true); var shipmentInfo = new ShipmentInfo(AnyGuid, shipmentPeriod, 10, new ShipmentQuantity(0.0001M, ShipmentQuantityUnits.Tonnes)); var newFirstDate = new DateTime(2015, 06, 01); var newLastDate = new DateTime(2016, 05, 31); var newShipmentPeriod = new ShipmentPeriod(newFirstDate, newLastDate, true); shipmentInfo.UpdateShipmentPeriod(newShipmentPeriod, NotificationStatus.NotSubmitted); Assert.Equal(newFirstDate, shipmentInfo.ShipmentPeriod.FirstDate); Assert.Equal(newLastDate, shipmentInfo.ShipmentPeriod.LastDate); }
public void QuantityKilogramsMoreThan1DecimalPlaceRoundsDown() { var firstDate = new DateTime(2015, 01, 01); var lastDate = new DateTime(2015, 12, 01); var shipmentPeriod = new ShipmentPeriod(firstDate, lastDate, true); var shipmentInfo = new ShipmentInfo(AnyGuid, shipmentPeriod, 10, new ShipmentQuantity(1.23m, ShipmentQuantityUnits.Kilograms)); Assert.Equal(1.2m, shipmentInfo.Quantity); }
public void QuantityTonnesMoreThan4DecimalPlacesRoundsUp() { var firstDate = new DateTime(2015, 01, 01); var lastDate = new DateTime(2015, 12, 01); var shipmentPeriod = new ShipmentPeriod(firstDate, lastDate, true); var shipmentInfo = new ShipmentInfo(AnyGuid, shipmentPeriod, 10, new ShipmentQuantity(1.23446m, ShipmentQuantityUnits.Tonnes)); Assert.Equal(1.2345m, shipmentInfo.Quantity); }
public void PreconsentedNotificationDatesCanBeInside36Months() { var firstDate = new DateTime(2015, 01, 01); var lastDate = new DateTime(2017, 12, 31); var shipmentPeriod = new ShipmentPeriod(firstDate, lastDate, true); var shipmentInfo = new ShipmentInfo(AnyGuid, shipmentPeriod, 10, new ShipmentQuantity(1, ShipmentQuantityUnits.Kilograms)); Assert.NotNull(shipmentInfo); }
// public OrderState? CurrentOrderState() // { // if (!string.IsNullOrEmpty(_httpContextAccessor.HttpContext.Session.GetString(orderStateKey))) // return (OrderState) Enum.Parse(typeof(OrderState), // _httpContextAccessor.HttpContext.Session.GetString(orderStateKey)); // return null; // } // // public void SetCurrentOrderState(OrderState state) // { // _httpContextAccessor.HttpContext.Session.SetString(orderStateKey, state.ToString()); // } public void SaveShipmentInfoInSession(ShipmentInfo shipmentInfo) { _httpContextAccessor.HttpContext.Session.SetString(shipmentInfoKey, JsonConvert.SerializeObject(shipmentInfo)); }
public GeneralViewModel(NotificationApplication notification, ShipmentInfo shipmentInfo, FacilityCollection facilityCollection, DateTimeFormatter dateTimeFormatter, QuantityFormatter quantityFormatter, PhysicalCharacteristicsFormatter physicalCharacteristicsFormatter) { Number = notification.NotificationNumber; IsDisposal = notification.NotificationType.Equals(NotificationType.Disposal); IsRecovery = notification.NotificationType.Equals(NotificationType.Recovery); var isPreconsented = facilityCollection.AllFacilitiesPreconsented; if (!isPreconsented.HasValue) { IsPreconsented = false; IsNotPreconsented = false; } else { IsPreconsented = isPreconsented.GetValueOrDefault(); IsNotPreconsented = !isPreconsented.GetValueOrDefault(); } if (shipmentInfo.NumberOfShipments > 1) { IsIndividualShipment = false; IsNotIndividualShipment = true; } else { IsIndividualShipment = true; IsNotIndividualShipment = false; } IntendedNumberOfShipments = shipmentInfo.NumberOfShipments.ToString(); FirstDeparture = dateTimeFormatter.DateTimeToDocumentFormatString(shipmentInfo.ShipmentPeriod.FirstDate); LastDeparture = dateTimeFormatter.DateTimeToDocumentFormatString(shipmentInfo.ShipmentPeriod.LastDate); SetIntendedQuantityFields(shipmentInfo, quantityFormatter); var hasSpecialHandlingRequirements = notification.HasSpecialHandlingRequirements; if (!hasSpecialHandlingRequirements.HasValue) { IsSpecialHandling = false; IsNotSpecialHandling = false; } else { IsSpecialHandling = hasSpecialHandlingRequirements.GetValueOrDefault(); IsNotSpecialHandling = !hasSpecialHandlingRequirements.GetValueOrDefault(); } PackagingTypes = GetPackagingInfo(notification); PhysicalCharacteristics = physicalCharacteristicsFormatter.PhysicalCharacteristicsToCommaDelimitedString( notification.PhysicalCharacteristics); CA = CompetentAuthorityFormatter.GetCompetentAuthority(notification.CompetentAuthority); }
private void SetIntendedQuantityFields(ShipmentInfo shipmentInfo, QuantityFormatter quantityFormatter) { IntendedQuantityTonnes = string.Empty; IntendedQuantityKg = string.Empty; IntendedQuantityM3 = string.Empty; IntendedQuantityLtrs = string.Empty; var quantity = quantityFormatter.QuantityToStringWithUnits(shipmentInfo.Quantity, shipmentInfo.Units); switch (shipmentInfo.Units) { case ShipmentQuantityUnits.Kilograms: IntendedQuantityKg = quantity; break; case ShipmentQuantityUnits.CubicMetres: IntendedQuantityM3 = quantity; break; case ShipmentQuantityUnits.Litres: IntendedQuantityLtrs = quantity; break; case ShipmentQuantityUnits.Tonnes: IntendedQuantityTonnes = quantity; break; default: break; } }
private void SetUpRepositoryCalls(Movement[] movements, ShipmentInfo shipment) { A.CallTo(() => movementRepository.GetMovementsByStatus(NotificationId, MovementStatus.Received)).Returns(movements.Where(m => m.Status == MovementStatus.Received)); A.CallTo(() => movementRepository.GetMovementsByStatus(NotificationId, MovementStatus.Completed)).Returns(movements.Where(m => m.Status == MovementStatus.Completed)); A.CallTo(() => shipmentRepository.GetByNotificationId(NotificationId)).Returns(shipment); }
public void CanUpdateNumberOfShipments() { var firstDate = new DateTime(2015, 01, 01); var lastDate = new DateTime(2015, 12, 01); var shipmentPeriod = new ShipmentPeriod(firstDate, lastDate, true); var shipmentInfo = new ShipmentInfo(AnyGuid, shipmentPeriod, 10, new ShipmentQuantity(0.0001M, ShipmentQuantityUnits.Tonnes)); shipmentInfo.UpdateNumberOfShipments(50); Assert.Equal(50, shipmentInfo.NumberOfShipments); }