Ejemplo n.º 1
0
        public async Task <byte[]> Generate(Guid movementId)
        {
            using (var memoryStream = DocumentHelper.ReadDocumentStreamShared("MovementMergeTemplate.docx"))
            {
                using (var document = WordprocessingDocument.Open(memoryStream, true))
                {
                    var movementDetails = await movementDetailsRepository.GetByMovementId(movementId);

                    var carrierCollection = await carrierRepository.GetByMovementId(movementId);

                    bool hasCarrierAnnex = carrierCollection.Carriers.Count() > 1;

                    var fields = MergeFieldLocator.GetMergeRuns(document);
                    var blocks = await blocksFactory.GetBlocks(movementId, fields);

                    var movementDocument = new MovementDocument(blocks);

                    ShipmentQuantityUnitFormatter.ApplyStrikethroughFormattingToUnits(document, movementDetails.ActualQuantity.Units);

                    movementDocument.Merge(hasCarrierAnnex);

                    MergeFieldLocator.RemoveDataSourceSettingFromMergedDocument(document);
                }

                return(memoryStream.ToArray());
            }
        }
        public async Task <bool> HandleAsync(DoesMovementDetailsExist message)
        {
            var movementDetails = await movementDetailsRepository.GetByMovementId(message.MovementId);

            if (movementDetails == null)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        public async Task <IDocumentBlock> Create(Guid movementId, IList <MergeField> mergeFields)
        {
            var movement = await movementRepository.GetById(movementId);

            var movementDetails = await movementDetailsRepository.GetByMovementId(movementId);

            var notification = await notificationApplicationRepository.GetById(movement.NotificationId);

            var shipment = await shipmentInfoRepository.GetByNotificationId(movement.NotificationId);

            return(new MovementBlock(mergeFields, movement, movementDetails, notification, shipment));
        }
        public async Task <QuantityReceivedTolerance> HandleAsync(DoesQuantityReceivedExceedTolerance message)
        {
            var movementDetails = await movementDetailsRepository.GetByMovementId(message.MovementId);

            var shipmentQuantity = new ShipmentQuantity(message.Quantity, message.Units);

            var intendedQuantity = movementDetails.ActualQuantity.Quantity;
            var units            = movementDetails.ActualQuantity.Units;

            if (shipmentQuantity < new ShipmentQuantity(intendedQuantity * 0.5m, units))
            {
                return(QuantityReceivedTolerance.BelowTolerance);
            }

            if (shipmentQuantity > new ShipmentQuantity(intendedQuantity * 1.5m, units))
            {
                return(QuantityReceivedTolerance.AboveTolerance);
            }

            return(QuantityReceivedTolerance.WithinTolerance);
        }
Ejemplo n.º 5
0
        public async Task <MovementInfo[]> HandleAsync(GetMovementsByIds message)
        {
            var result = new List <MovementInfo>();

            var movements = await movementRepository.GetMovementsByIds(message.NotificationId, message.MovementIds);

            foreach (var movement in movements)
            {
                var details = await movementDetailsRepository.GetByMovementId(movement.Id);

                result.Add(new MovementInfo
                {
                    Id             = movement.Id,
                    ActualQuantity = details.ActualQuantity.Quantity,
                    Unit           = details.ActualQuantity.Units,
                    PackagingTypes = details.PackagingInfos.Select(p => p.PackagingType),
                    ShipmentNumber = movement.Number
                });
            }

            return(result.ToArray());
        }
Ejemplo n.º 6
0
        public async Task <ShipmentQuantityUnits> HandleAsync(GetMovementUnitsByMovementId message)
        {
            var movementDetails = await repository.GetByMovementId(message.Id);

            return(movementDetails.ActualQuantity.Units);
        }