public IActionResult SalesInvoice(int id) { try { var salesInvoice = _salesService.GetSalesInvoiceById(id); var salesOrderDto = new Dto.Sales.SalesInvoice() { Id = salesInvoice.Id, CustomerId = salesInvoice.CustomerId, CustomerName = salesInvoice.Customer.Party.Name, InvoiceDate = salesInvoice.Date, SalesInvoiceLines = new List <Dto.Sales.SalesInvoiceLine>(), PaymentTermId = salesInvoice.PaymentTermId, ReferenceNo = salesInvoice.ReferenceNo, Posted = salesInvoice.GeneralLedgerHeaderId != null }; foreach (var line in salesInvoice.SalesInvoiceLines) { var lineDto = new Dto.Sales.SalesInvoiceLine(); lineDto.Id = line.Id; lineDto.Amount = line.Amount; lineDto.Discount = line.Discount; lineDto.Quantity = line.Quantity; lineDto.ItemId = line.ItemId; lineDto.MeasurementId = line.MeasurementId; salesOrderDto.SalesInvoiceLines.Add(lineDto); } // is this journal entry ready for posting? if (!salesOrderDto.Posted && salesOrderDto.SalesInvoiceLines.Count >= 1) { salesOrderDto.ReadyForPosting = true; } return(new ObjectResult(salesOrderDto)); } catch (Exception ex) { return(new ObjectResult(ex)); } }
public IActionResult SalesInvoices() { var salesInvoices = _salesService.GetSalesInvoices(); IList <Dto.Sales.SalesInvoice> salesInvoicesDto = new List <Dto.Sales.SalesInvoice>(); foreach (var salesInvoice in salesInvoices) { var salesInvoiceDto = new Dto.Sales.SalesInvoice() { Id = salesInvoice.Id, No = salesInvoice.No, CustomerId = salesInvoice.CustomerId, CustomerName = salesInvoice.Customer.Party.Name, InvoiceDate = salesInvoice.Date, ReferenceNo = salesInvoice.ReferenceNo, Posted = salesInvoice.GeneralLedgerHeaderId != null }; foreach (var line in salesInvoice.SalesInvoiceLines) { var lineDto = new Dto.Sales.SalesInvoiceLine() { ItemId = line.ItemId, MeasurementId = line.MeasurementId, Quantity = line.Quantity, Amount = line.Amount, Discount = line.Discount }; salesInvoiceDto.SalesInvoiceLines.Add(lineDto); } salesInvoicesDto.Add(salesInvoiceDto); } return(new ObjectResult(salesInvoicesDto)); }