private string GenerateNo() { var year = DateTime.Now.ToString("yy"); var prefix = $"{year}/SPDL /"; var lastInvoiceNo = _repository.ReadAll().Where(w => w.LocalCoverLetterNo.StartsWith(prefix)) .OrderByDescending(o => o.LocalCoverLetterNo) .Select(s => int.Parse(s.LocalCoverLetterNo.Replace(prefix, ""))) .FirstOrDefault(); var invoiceNo = $"{prefix}{(lastInvoiceNo + 1).ToString("D5")}"; return(invoiceNo); }
public IQueryable <GarmentLocalSalesOmzetViewModel> GetData(DateTime?dateFrom, DateTime?dateTo, int offset) { var query = repository.ReadAll(); var queryItem = itemrepository.ReadAll(); var querylcl = lclrepository.ReadAll(); DateTime DateFrom = dateFrom == null ? new DateTime(1970, 1, 1) : (DateTime)dateFrom; DateTime DateTo = dateTo == null ? DateTime.Now : (DateTime)dateTo; query = query.Where(w => w.Date.AddHours(offset).Date >= DateFrom.Date && w.Date.AddHours(offset).Date <= DateTo.Date); query = query.OrderBy(w => w.BuyerCode).ThenBy(w => w.Date); var newQ = (from a in query join b in queryItem on a.Id equals b.LocalSalesNoteId join c in querylcl on a.Id equals c.LocalSalesNoteId into dd from CL in dd.DefaultIfEmpty() where a.TransactionTypeCode != "SML" && a.TransactionTypeCode != "LMS" //group new { Amt = Convert.ToDecimal(b.Quantity) * Convert.ToDecimal(b.Price) } by new { a.NoteNo, a.Date, a.BuyerCode, a.BuyerName, a.UseVat } into G select new GarmentLocalSalesOmzetViewModel { LSNo = a.NoteNo, LSDate = a.Date, BuyerCode = a.BuyerCode, BuyerName = a.BuyerName, KaberType = a.KaberType, TransactionName = a.TransactionTypeName, BCNo = CL == null ? "-" : CL.BCNo, DispoNo = a.DispositionNo, Tempo = a.Tempo, ProductCode = b.ProductCode, ProductName = b.ProductName, Quantity = b.Quantity, UomUnit = b.UomUnit, DPP = Convert.ToDecimal(b.Quantity) * Convert.ToDecimal(b.Price), UseVat = a.UseVat == true ? "YA" : "TIDAK", PPN = (a.UseVat == true && a.KaberType == "KABER") || a.UseVat == false ? 0 : (Convert.ToDecimal(0.1) * Convert.ToDecimal(b.Quantity) * Convert.ToDecimal(b.Price)), Total = (a.UseVat == true && a.KaberType == "KABER") || a.UseVat == false ? Convert.ToDecimal(b.Quantity) * Convert.ToDecimal(b.Price) : (Convert.ToDecimal(1.1) * Convert.ToDecimal(b.Quantity) * Convert.ToDecimal(b.Price)), }); return(newQ); }