Пример #1
0
        /// <summary>
        /// Flattens the given invoice into a "Basic Invoice" Reposne using the ginven account number and expense for the account
        /// </summary>
        public static InvoiceListing MapFromObject(Invoice invoice)
        {
            if (invoice == null)
            {
                return(null);
            }

            //Calculate Expense of invoice

            decimal expense = 0;

            foreach (var cost in invoice.AccountTotals)
            {
                expense += cost.Expense;
            }

            var listing = new InvoiceListing()
            {
                InvoiceId     = invoice.InvoiceId,
                InvoiceNumber = invoice.InvoiceNumber,
                InvoiceDate   = invoice.InvoiceDate,
                DatePaid      = invoice.DatePaid,
                InvoiceType   = InvoiceTypeListing.MapFromObject(invoice.InvoiceType),
                Expense       = expense,
                Description   = invoice.Description,
                Vendor        = VendorListing.MapFromObject(invoice.Vendor)
            };

            return(listing);
        }
Пример #2
0
 public static TicketBasic MapFromObject(Ticket obj)
 {
     return(new TicketBasic()
     {
         TicketId = obj.TicketId,
         Vendor = VendorListing.MapFromObject(obj.Vendor),
         Account = AccountListing.MapFromObject(obj.Account),
         Material = MaterialVendorListing.MapFromObject(obj.MaterialVendor),
         TicketNumber = obj.TicketNumber,
         Quantity = obj.Quantity,
         Date = obj.Date,
         Cost = obj.Cost,
         Invoice = InvoiceListing.MapFromObject(obj.Invoice)
     });
 }