public static InvoiceStatus DetermineStatus(this EFInvoice.Invoice value) { if (value.InvoiceType.Trim().Equals("cm", StringComparison.InvariantCultureIgnoreCase)) { return(InvoiceStatus.Open); } switch (value.InvoiceStatus.ToUpper()) { case "O": if (value.DueDate >= DateTime.Now) { return(InvoiceStatus.Open); } else { return(InvoiceStatus.PastDue); } case "P": return(InvoiceStatus.Pending); default: return(InvoiceStatus.Paid); } }
public static InvoiceTransactionModel ToTransationModel(this EFInvoice.Invoice value) { return(new InvoiceTransactionModel() { BranchId = value.Division.Substring(0, 3), InvoiceNumber = value.InvoiceNumber.Trim(), Type = DetermineType(value.InvoiceType.Trim()), TypeDescription = EnumUtils <InvoiceType> .GetDescription(DetermineType(value.InvoiceType.Trim())), CustomerNumber = value.CustomerNumber, Amount = value.AmountDue, DueDate = value.DueDate, InvoiceDate = value.InvoiceDate, OrderDate = value.InvoiceDate }); }
public static InvoiceModel ToInvoiceModel(this EFInvoice.Invoice value, KeithLink.Svc.Core.Models.Profile.Customer customer = null) { InvoiceModel retVal = new InvoiceModel(); retVal.BranchId = value.Division.Substring(0, 3); retVal.InvoiceNumber = value.InvoiceNumber.Trim(); retVal.Type = DetermineType(value.InvoiceType.Trim()); retVal.TypeDescription = EnumUtils <InvoiceType> .GetDescription(DetermineType(value.InvoiceType.Trim())); retVal.Status = value.DetermineStatus(); retVal.StatusDescription = EnumUtils <InvoiceStatus> .GetDescription(value.DetermineStatus()); retVal.CustomerNumber = value.CustomerNumber; retVal.CustomerName = customer == null ? "N/A" : customer.CustomerName; retVal.Amount = value.AmountDue; retVal.DueDate = value.DueDate; retVal.InvoiceDate = value.InvoiceDate; retVal.OrderDate = value.InvoiceDate; retVal.IsPayable = value.InvoiceStatus.Equals("O", StringComparison.InvariantCultureIgnoreCase) && customer != null && customer.KPayCustomer; return(retVal); }