示例#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);
        }
 public static MaterialVendorDetails MapFromObject(MaterialVendor obj)
 {
     return(new MaterialVendorDetails()
     {
         MaterialVendorId = obj.MaterialVendorId,
         Cost = obj.Cost,
         Vendor = VendorListing.MapFromObject(obj.Vendor)
     });
 }
示例#3
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)
     });
 }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="invoice"></param>
        /// <returns></returns>
        public static InvoiceDetails MapFromObject(Invoice invoice)
        {
            var details = new InvoiceDetails()
            {
                InvoiceId     = invoice.InvoiceId,
                InvoiceDate   = invoice.InvoiceDate,
                DatePaid      = invoice.DatePaid,
                InvoiceNumber = invoice.InvoiceNumber,
                InvoiceType   = InvoiceTypeListing.MapFromObject(invoice.InvoiceType),
                Description   = invoice.Description,
                Vendor        = VendorListing.MapFromObject(invoice.Vendor)
            };

            details.Tickets = new List <TicketBasic>();
            foreach (var ticket in invoice.Tickets)
            {
                details.Tickets.Add(TicketBasic.MapFromObject(ticket));
            }


            decimal totalExpense = 0;

            details.Expenses = new List <InvoiceExpense>();
            foreach (var accountTotal in invoice.AccountTotals)
            {
                totalExpense += accountTotal.Expense;

                var cityExpenses = new List <CityExpenseBasic>();
                foreach (var expense in accountTotal.CityExpenses)
                {
                    cityExpenses.Add(CityExpenseBasic.MapFromObject(expense));
                }

                details.Expenses.Add(new InvoiceExpense()
                {
                    InvoiceAccountId = accountTotal.InvoiceAccountId,
                    Expense          = accountTotal.Expense,
                    Account          = AccountListing.MapFromObject(accountTotal.Account),
                    CityExpense      = cityExpenses
                });
            }

            details.TotalExpense = totalExpense;
            return(details);
        }