public PendingInvoiceItem CreatePending(Guid id, Guid jobItemId) { if (_invoiceItemRepository.JobItemHasPendingInvoiceItem(jobItemId)) { throw new DomainValidationException(Messages.JobItemHasPendingItem, "JobItemId"); } if (id == Guid.Empty) { throw new ArgumentException("A value must be supplied for the ID"); } if (!CurrentUser.HasRole(UserRole.Manager)) { throw new DomainValidationException(Messages.InsufficientSecurityClearance); } var jobItem = GetJobItem(jobItemId); var quoteItem = GetQuoteItem(jobItemId); var pendingItem = new PendingInvoiceItem(); pendingItem.Id = id; pendingItem.Description = jobItem.Instrument.ToString(); pendingItem.JobItem = jobItem; pendingItem.OrderNo = GetOrderNo(quoteItem); AssignPrices(pendingItem, quoteItem); _invoiceItemRepository.CreatePendingItem(pendingItem); jobItem.IsMarkedForInvoicing = true; _jobItemRepository.Update(jobItem); return(pendingItem); }
public JobItem EditInstrument(Guid jobItemId, Guid instrumentId) { var jobItem = GetById(jobItemId); jobItem.Instrument = _instrumentService.GetById(instrumentId); _jobItemRepository.Update(jobItem); return(jobItem); }
public OrderItem MarkReceived(Guid orderItemId) { var orderItem = GetById(orderItemId); orderItem.DateReceived = AppDateTime.GetUtcNow(); var jobItem = orderItem.JobItem; jobItem.Status = _listItemRepository.GetByType(ListItemType.StatusPartsReceived); _orderItemRepository.Update(orderItem); _jobItemRepository.EmitItemHistory( CurrentUser, jobItem.Id, 0, 0, string.Format("Parts received from order {0}", orderItem.Order.OrderNo), ListItemType.StatusPartsReceived, ListItemType.WorkTypeAdministration); _jobItemRepository.Update(jobItem); return(orderItem); }
public DeliveryItem Create(Guid id, Guid deliveryId, Guid jobItemId, string notes) { if (!CurrentUser.HasRole(UserRole.Member)) { throw new DomainValidationException(DeliveryItemMessages.InsufficientSecurityClearance, "CurrentUser"); } if (id == Guid.Empty) { throw new ArgumentException("An ID must be supplied for the pending item."); } var deliveryItem = new DeliveryItem(); deliveryItem.Id = id; deliveryItem.ItemNo = _deliveryRepository.GetDeliveryItemCount(deliveryId) + 1; deliveryItem.Delivery = GetDelivery(deliveryId); var jobItem = GetJobItem(jobItemId); deliveryItem.JobItem = jobItem; deliveryItem.Notes = notes; deliveryItem.QuoteItem = GetQuoteItem(jobItemId); ValidateAnnotatedObjectThrowOnFailure(deliveryItem); jobItem.Status = _listItemRepository.GetByType(ListItemType.StatusDeliveryNoteProduced); _jobItemRepository.EmitItemHistory( CurrentUser, jobItem.Id, 0, 0, "Item added to delivery note DR2000", ListItemType.StatusDeliveryNoteProduced, ListItemType.WorkTypeAdministration); _jobItemRepository.Update(jobItem); _deliveryItemRepository.Create(deliveryItem); return(deliveryItem); }
public QuoteItem Create(Guid id, Guid quoteId, Guid jobItemId, decimal labour, decimal calibration, decimal parts, decimal carriage, decimal investigation, string report, int days, bool beyondEconomicRepair) { if (!CurrentUser.HasRole(UserRole.Member)) { throw new DomainValidationException(Messages.InsufficientSecurity, "CurrentUser"); } if (id == Guid.Empty) { throw new ArgumentException("An ID must be supplied for the quote item"); } var quote = GetQuote(quoteId); var quoteItem = new QuoteItem(); quoteItem.Id = id; quoteItem.ItemNo = quote.QuoteItems.Count + 1; quoteItem.Quote = quote; quoteItem.Labour = GetLabour(labour); quoteItem.Calibration = GetCalibration(calibration); quoteItem.Parts = GetParts(parts); quoteItem.Carriage = GetCarriage(carriage); quoteItem.Investigation = GetInvestigation(investigation); quoteItem.Report = report; quoteItem.Days = GetDays(days); quoteItem.BeyondEconomicRepair = beyondEconomicRepair; quoteItem.Status = _listItemRepository.GetByType(ListItemType.StatusQuotedPrepared); ValidateAnnotatedObjectThrowOnFailure(quoteItem); var jobItem = GetJobItem(jobItemId); jobItem.Status = _listItemRepository.GetByType(ListItemType.StatusQuotedPrepared); _jobItemRepository.EmitItemHistory( CurrentUser, jobItemId, 0, 0, String.Format("Item quoted on {0}", quote.QuoteNumber), ListItemType.StatusQuotedPrepared, ListItemType.WorkTypeAdministration); quoteItem.JobItem = jobItem; _quoteItemRepository.Create(quoteItem); _jobItemRepository.Update(jobItem); return(quoteItem); }
public ConsignmentItem Create(Guid id, Guid jobItemId, Guid consignmentId, string instructions) { if (!CurrentUser.HasRole(UserRole.Member)) { throw new DomainValidationException(Messages.InsufficientSecurityClearance); } if (id == Guid.Empty) { throw new ArgumentException("An ID must be supplied for the consignment item."); } var jobItem = _jobItemRepository.GetById(jobItemId); if (jobItem == null) { throw new ArgumentException("A valid ID must be supplied for the job item."); } if (jobItem.Job.IsPending) { throw new DomainValidationException(Messages.PendingJob); } var consignment = _consignmentRepository.GetById(consignmentId); if (consignment == null) { throw new ArgumentException("A valid ID must be supplied for the parent consignment."); } var consignmentItem = new ConsignmentItem { Id = id, Consignment = consignment, ItemNo = _consignmentRepository.GetConsignmentItemCount(consignmentId) + 1, JobItem = jobItem, Instructions = instructions }; jobItem.Status = _listItemRepository.GetByType(ListItemType.StatusConsigned); ValidateAnnotatedObjectThrowOnFailure(consignmentItem); _jobItemRepository.EmitItemHistory(CurrentUser, jobItemId, 0, 0, String.Format("Item consigned on {0}", consignment.ConsignmentNo), ListItemType.StatusConsigned, ListItemType.WorkTypeAdministration); _consignmentItemRepository.Create(consignmentItem); _jobItemRepository.Update(jobItem); return(consignmentItem); }