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); }
public JobItem AddWorkItem(Guid jobItemId, int workTime, int overTime, string report, Guid workStatusId, Guid workTypeId) { var jobItem = GetById(jobItemId); if (jobItem == null) { throw new ArgumentException("A valid job item ID must be supplied."); } if (jobItem.Job.IsPending) { throw new DomainValidationException(Messages.JobNotApproved, "Job"); } var status = ValidateWorkStatus(workStatusId); var workType = ValidateWorkType(workTypeId); Console.WriteLine("after work type"); workTime = ValidateWorkTime(workTime); overTime = ValidateOverTime(overTime); report = ValidateReport(report); jobItem.Status = status; _jobItemRepository.EmitItemHistory(CurrentUser, jobItemId, workTime, overTime, report, status.Type, workType.Type); _jobItemRepository.Update(jobItem); return(jobItem); }
public InvoiceItem CreateFromPending( Guid id, Guid invoiceId, string description, decimal calibrationPrice, decimal repairPrice, decimal partsPrice, decimal carriagePrice, decimal investigationPrice, JobItem jobItem) { var invoice = GetInvoice(invoiceId); var invoiceItem = new InvoiceItem(); invoiceItem.Id = id; invoiceItem.ItemNo = _invoiceRepository.GetInvoiceItemCount(invoiceId) + 1; invoiceItem.Invoice = invoice; invoiceItem.Description = description; invoiceItem.CalibrationPrice = calibrationPrice; invoiceItem.RepairPrice = repairPrice; invoiceItem.PartsPrice = partsPrice; invoiceItem.CarriagePrice = carriagePrice; invoiceItem.InvestigationPrice = investigationPrice; invoiceItem.JobItem = jobItem; jobItem.Status = _listItemRepository.GetByType(ListItemType.StatusInvoiced); jobItem.IsInvoiced = true; _jobItemRepository.EmitItemHistory( CurrentUser, jobItem.Id, 0, 0, String.Format("Item invoiced on {0}", invoice.InvoiceNumber), ListItemType.StatusInvoiced, ListItemType.WorkTypeAdministration); _jobItemRepository.Update(jobItem); _invoiceItemRepository.Create(invoiceItem); return(invoiceItem); }