public ActionResult CustomerDetail(int id) { var customer = _salesService.GetCustomerById(id); var allocations = _salesService.GetCustomerReceiptsForAllocation(id); var model = new Models.ViewModels.Sales.CustomerDetail() { Id = customer.Id, Name = customer.Name, Balance = customer.Balance }; foreach (var receipt in allocations) { model.CustomerAllocations.Add(new Models.ViewModels.Sales.CustomerAllocation() { Id = receipt.Id, AmountAllocated = receipt.SalesReceiptLines.Sum(a => a.AmountPaid), AvailableAmountToAllocate = receipt.AvailableAmountToAllocate }); } foreach (var allocation in customer.CustomerAllocations) { model.ActualAllocations.Add(new Models.ViewModels.Sales.Allocations() { InvoiceNo = allocation.SalesInvoiceHeader.No, ReceiptNo = allocation.SalesReceiptHeader.No, Date = allocation.Date, Amount = allocation.Amount }); } foreach (var invoice in customer.SalesInvoices) { model.CustomerInvoices.Add(new Models.ViewModels.Sales.CustomerSalesInvoice() { Id = invoice.Id, InvoiceNo = invoice.No, Date = invoice.Date, Amount = invoice.ComputeTotalAmount(), Status = invoice.Status.ToString() }); } return(View(model)); }
public ActionResult CustomerDetail(int id) { var customer = _salesService.GetCustomerById(id); var allocations = _salesService.GetCustomerReceiptsForAllocation(id); var model = new Models.ViewModels.Sales.CustomerDetail() { Id = customer.Id, Name = customer.Name, Balance = customer.Balance }; foreach(var receipt in allocations) { model.CustomerAllocations.Add(new Models.ViewModels.Sales.CustomerAllocation() { Id = receipt.Id, AmountAllocated = receipt.SalesReceiptLines.Sum(a => a.AmountPaid), AvailableAmountToAllocate = receipt.AvailableAmountToAllocate }); } foreach (var allocation in customer.CustomerAllocations) { model.ActualAllocations.Add(new Models.ViewModels.Sales.Allocations() { InvoiceNo = allocation.SalesInvoiceHeader.No, ReceiptNo = allocation.SalesReceiptHeader.No, Date = allocation.Date, Amount = allocation.Amount }); } foreach(var invoice in customer.SalesInvoices) { model.CustomerInvoices.Add(new Models.ViewModels.Sales.CustomerSalesInvoice() { Id = invoice.Id, InvoiceNo = invoice.No, Date = invoice.Date, Amount = invoice.ComputeTotalAmount(), Status = invoice.Status.ToString() }); } return View(model); }