public async Task WasteReceivedDateCanBeInThePast() { movement = new ImportMovement(notificationId, 52, PastDate); A.CallTo(() => movementRepository.Get(movementId)).Returns(movement); var result = await receiveFactory.Receive(movementId, new ShipmentQuantity(10, ShipmentQuantityUnits.Kilograms), PastDate); Assert.Equal(PastDate, result.Date); }
public async Task WasteReceivedDateCanBeInThePast() { movement = new ImportMovement(notificationId, 52, PastDate); A.CallTo(() => movementRepository.Get(movementId)).Returns(movement); var result = await rejectFactory.Reject(movementId, PastDate, rejectionreason); Assert.Equal(PastDate, result.Date); }
public async Task <ImportMovementPartialRejection> PartailReject(Guid movementId, DateTime date, string reason, decimal actualQuantity, ShipmentQuantityUnits actualUnit, decimal rejectedQuantity, ShipmentQuantityUnits rejectedUnit, DateTime?wasteDisposedDate) { var movement = await movementRepository.Get(movementId); if (date < movement.ActualShipmentDate) { throw new InvalidOperationException("The when the waste was received date cannot be before the actual date of shipment."); } if (date > SystemTime.UtcNow.Date) { throw new InvalidOperationException("The when the waste was received date cannot be in the future."); } var partialRejection = movement.PartialReject(movementId, date, reason, actualQuantity, actualUnit, rejectedQuantity, rejectedUnit, wasteDisposedDate); importMovementPartailRejectionRepository.Add(partialRejection); return(partialRejection); }
public CancelImportMovementTests() { completedReceiptRepository = A.Fake<IImportMovementCompletedReceiptRepository>(); movementRepository = A.Fake<IImportMovementRepository>(); receiptRepository = A.Fake<IImportMovementReceiptRepository>(); movement = new ImportMovement(notificationId, 1, new DateTime(2016, 1, 1)); A.CallTo(() => movementRepository.Get(movementId)).Returns(movement); cancelMovement = new CancelImportMovement(movementRepository, receiptRepository, completedReceiptRepository); }
public CancelImportMovementTests() { completedReceiptRepository = A.Fake <IImportMovementCompletedReceiptRepository>(); movementRepository = A.Fake <IImportMovementRepository>(); receiptRepository = A.Fake <IImportMovementReceiptRepository>(); movement = new ImportMovement(notificationId, 1, new DateTime(2016, 1, 1)); A.CallTo(() => movementRepository.Get(movementId)).Returns(movement); cancelMovement = new CancelImportMovement(movementRepository, receiptRepository, completedReceiptRepository); }
public async Task WasteReceivedDateCanBeInThePast() { movement = new ImportMovement(notificationId, 52, PastDate); A.CallTo(() => movementRepository.Get(movementId)).Returns(movement); var result = await partialRejectFactory.PartailReject(movementId, PastDate, rejectionreason, 15, shipmentQuantityUnits, 5, shipmentQuantityUnits, PastDate); Assert.Equal(PastDate, result.WasteReceivedDate); }
public async Task <ImportMovementData> HandleAsync(GetImportMovementDates message) { var movement = await movementRepository.Get(message.MovementId); return(new ImportMovementData { NotificationId = movement.NotificationId, ActualDate = movement.ActualShipmentDate, Number = movement.Number, PreNotificationDate = movement.PrenotificationDate, IsCancelled = movement.IsCancelled }); }
public async Task <RejectedMovementDetails> HandleAsync(GetRejectedImportMovementDetails message) { var movement = await movementRepository.Get(message.MovementId); var details = await rejectionRepository.GetByMovementIdOrDefault(message.MovementId); return(new RejectedMovementDetails { Number = movement.Number, Date = details.Date, Reason = details.Reason }); }
public async Task <bool> HandleAsync(SetImportMovementDates message) { var movement = await movementRepository.Get(message.MovementId); movement.SetActualShipmentDate(message.ActualShipmentDate); if (message.PrenotificationDate.HasValue) { movement.SetPrenotificationDate(message.PrenotificationDate.Value); } await context.SaveChangesAsync(); return(true); }
public async Task <Unit> HandleAsync(SetMovementComments message) { var movement = await repository.Get(message.MovementId); if (!string.IsNullOrWhiteSpace(message.Comments)) { movement.SetComments(message.Comments); } if (!string.IsNullOrWhiteSpace(message.StatsMarking)) { movement.SetStatsMarking(message.StatsMarking); } await context.SaveChangesAsync(); return(Unit.Value); }
public async Task <ImportMovementReceipt> Receive(Guid movementId, ShipmentQuantity quantity, DateTime date) { var movement = await movementRepository.Get(movementId); if (date < movement.ActualShipmentDate) { throw new InvalidOperationException("The when the waste was received date cannot be before the actual date of shipment."); } if (date > SystemTime.UtcNow.Date) { throw new InvalidOperationException("The when the waste was received date cannot be in the future."); } var receipt = movement.Receive(quantity, date); receiptRepository.Add(receipt); return(receipt); }
public async Task <ImportMovementRejection> Reject(Guid importMovementId, DateTime date, string reason, decimal?quantity, ShipmentQuantityUnits?unit) { var movement = await movementRepository.Get(importMovementId); if (date < movement.ActualShipmentDate) { throw new InvalidOperationException("The when the waste was received date cannot be before the actual date of shipment."); } if (date > SystemTime.UtcNow.Date) { throw new InvalidOperationException("The when the waste was received date cannot be in the future."); } var rejection = movement.Reject(date, reason, quantity, unit); rejectionRepository.Add(rejection); return(rejection); }
public async Task Cancel(Guid importMovementId) { var receipt = await receiptRepository.GetByMovementIdOrDefault(importMovementId); var completedReceipt = await completedReceiptRepository.GetByMovementIdOrDefault(importMovementId); if (receipt != null) { throw new InvalidOperationException(string.Format("Can't cancel movement {0} as it has been received", importMovementId)); } if (completedReceipt != null) { throw new InvalidOperationException(string.Format("Can't cancel movement {0} as it has been recovered / disposed of", importMovementId)); } var movement = await movementRepository.Get(importMovementId); movement.Cancel(); }
public async Task <ImportMovementCompletedReceipt> Complete(Guid movementId, DateTime date) { var movement = await movementRepository.Get(movementId); var movementReceipt = await movementReceiptRepository.GetByMovementIdOrDefault(movementId); if (date < movementReceipt.Date) { throw new InvalidOperationException("The when was the waste recovered date cannot be before the when was the waste received. "); } if (date > SystemTime.UtcNow.Date) { throw new InvalidOperationException("The when the waste was recovered date cannot be in the future."); } var completedReceipt = movement.Complete(date); completedReceiptRepository.Add(completedReceipt); return(completedReceipt); }
public async Task <Guid> HandleAsync(GetNotificationIdByMovementId message) { var movement = await importMovementRepository.Get(message.MovementId); return(movement.NotificationId); }
public async Task EnsureAccessAsync(Guid movementId) { var notificationId = (await repository.Get(movementId)).NotificationId; await authorization.EnsureAccessAsync(notificationId); }