/// <summary> /// Finds all invoices given an invoice run number. /// </summary> /// <param name="runNumber">Invoice Run Number</param> /// <returns>A summary of all invoices with matching Run Number</returns> /// <remarks> /// Each invoice run has a run number, so finding all invoices with a particular run number /// Finds all invoices calculated in the same batch. /// </remarks> public IList<InvoiceSearchItem> FindInvoicesByRunNumber(int runNumber) { IList<InvoiceSearchItem> items = new List<InvoiceSearchItem>(); var results = _invoiceRepository.FindInvoicesByRunNumber(runNumber); foreach (var item in results) { var searchItem = new InvoiceSearchItem { InvoiceHeaderId = item.Id.Value, InvoiceNumber = item.InvoiceNumber, InvoiceDate = item.ToDate, To = item.To, RunNumber = item.InvoiceRunNumber, CanBeEmailed = !string.IsNullOrEmpty(item.Email) }; items.Add(searchItem); } return items; }
/// <summary> /// Finds invoices given a particular partial invoice number. /// </summary> /// <param name="invoiceNumber">The left most characters of the invoice number.</param> /// <returns>A list of all invoices with matching invoice number fragment.</returns> public IList<InvoiceSearchItem> FindInvoicesByInvoiceNumber(string invoiceNumber) { IList<InvoiceSearchItem> items = new List<InvoiceSearchItem>(); var results = _invoiceRepository.FindInvoicesByInvoiceNumber(invoiceNumber); foreach (var item in results) { var searchItem = new InvoiceSearchItem { InvoiceHeaderId = item.Id.Value, InvoiceNumber = item.InvoiceNumber, InvoiceDate = item.ToDate, To = item.To, RunNumber = item.InvoiceRunNumber, }; items.Add(searchItem); } return items; }