public async Task <IActionResult> GetPaymentRemindList() { var dbRes = await this._invoiceService.QueryableInvoiceBuy() .Where(w => w.PaymentIsDone == false) .Select(s => s) .ToListAsync(); var unpaid = new List <InvoicePaymentRemindDTO>(); var notConfirmed = new List <InvoicePaymentRemindDTO>(); foreach (var inv in dbRes) { var dto = new InvoicePaymentRemindDTO(); this.EtoDTOBasicInvoicePaymentRemind(inv, dto); // paymentDate based on paymentterms.. if (inv.PaymentTerms.PaymentDays.HasValue) { dto.PaymentDate = inv.SellingDate.AddDays(inv.PaymentTerms.PaymentDays.Value); } else { dto.PaymentDate = inv.SellingDate; } //check if invoice is recived (or it its only generated by created laod-buy..) if (inv.InvoiceReceived) { //dto.PaymentDate = unpaid.Add(dto); } else { notConfirmed.Add(dto); } } var res = new { Unpaid = unpaid.OrderBy(o => o.PaymentDate).ToList(), NotConfirmed = notConfirmed.OrderBy(o => o.PaymentDate).ToList() }; return(Ok(res)); }
private InvoicePaymentRemindDTO EtoDTOBasicInvoicePaymentRemind(InvoiceBuy db, InvoicePaymentRemindDTO dto) { var res = dto ?? new InvoicePaymentRemindDTO(); res.Company = this._companyService.CompanyCardMapper(db.CompanySeller); res.Currency = this._invoiceService.EtoDTOCurrency(db.Currency); res.InvoiceId = db.InvoiceBuyId; res.InvoiceNo = db.InvoiceNo; //res.InvoiceTotal = this._invoiceService.EtDTOInvoiceTotal(db.InvoiceTotal); return(res); }