Reports для роли Поставщик. Фикс GetFilteredList() в CurrencyPurchaseStorage. Добавление DateFrom и DateTo в соответствующую SearchModel.
This commit is contained in:
parent
b89974dd9f
commit
56ebf0902a
@ -106,7 +106,62 @@ namespace BankBusinessLogic.BusinessLogics
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SavePaymentPurchaseToExcel(List<PaymentBindingModel> payments)
|
public List<ReportCurrencyTransferViewModel> GetCurrencyTransfers(List<CurrencyBindingModel> currencies)
|
||||||
|
{
|
||||||
|
var list = new List<ReportCurrencyTransferViewModel>();
|
||||||
|
var payments = _paymentStorage.GetFullList();
|
||||||
|
var transfers = _transferStorage.GetFullList();
|
||||||
|
foreach(var currency in currencies)
|
||||||
|
{
|
||||||
|
var record = new ReportCurrencyTransferViewModel
|
||||||
|
{
|
||||||
|
CurrencyId = currency.Id,
|
||||||
|
CurrencyName = currency.Name,
|
||||||
|
Transfers = new List<(int TransferId, float Amount)>(),
|
||||||
|
};
|
||||||
|
var paymentsId = new List<int>();
|
||||||
|
foreach(var payment in payments)
|
||||||
|
{
|
||||||
|
if (payment.CurrencyPayments.ContainsKey(currency.Id)) paymentsId.Add(payment.Id);
|
||||||
|
}
|
||||||
|
foreach(var transfer in transfers)
|
||||||
|
{
|
||||||
|
foreach(int paymentId in paymentsId)
|
||||||
|
{
|
||||||
|
if (paymentId == transfer.PaymentId)
|
||||||
|
{
|
||||||
|
record.Transfers.Add(new(transfer.Id, transfer.Amount));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list.Add(record);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
public List<ReportCurrencyPurchasePaymentViewModel> GetPurchasePayment(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
var purchases = _currencyPurchaseStorage.GetFilteredList(new CurrencyPurchaseSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo });
|
||||||
|
var list = new List<ReportCurrencyPurchasePaymentViewModel>();
|
||||||
|
var payments = _paymentStorage.GetFullList();
|
||||||
|
foreach (var purchase in purchases)
|
||||||
|
{
|
||||||
|
var record = new ReportCurrencyPurchasePaymentViewModel
|
||||||
|
{
|
||||||
|
CurrencyPurchaseId = purchase.Id,
|
||||||
|
PurchaseDate = purchase.PurchaseDate,
|
||||||
|
Payments = new List<(int PaymentId, string PaymentDate)>(),
|
||||||
|
};
|
||||||
|
var paymentsId = new List<int>();
|
||||||
|
foreach (var payment in payments)
|
||||||
|
{
|
||||||
|
if (payment.CurrencyPayments.ContainsKey(purchase.CurrencyId)) record.Payments.Add(new(payment.Id, payment.PaymentDate.ToString()));
|
||||||
|
}
|
||||||
|
list.Add(record);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SavePaymentPurchaseToExcel(List<PaymentBindingModel> payments)
|
||||||
{
|
{
|
||||||
var result = GetPaymentPurchase(payments);
|
var result = GetPaymentPurchase(payments);
|
||||||
//создание файла будет реализовано в будующих версиях
|
//создание файла будет реализовано в будующих версиях
|
||||||
@ -126,5 +181,22 @@ namespace BankBusinessLogic.BusinessLogics
|
|||||||
//создание файла будет реализовано в будующих версиях
|
//создание файла будет реализовано в будующих версиях
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void SaveCurrencyTransfersToExcel(List<CurrencyBindingModel> currencies)
|
||||||
|
{
|
||||||
|
var report = GetCurrencyTransfers(currencies);
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveCurrencyTransfersToWord(List<CurrencyBindingModel> currencies)
|
||||||
|
{
|
||||||
|
var report = GetCurrencyTransfers(currencies);
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
public void SavePurchasePaymentToPDF(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
var report = GetPurchasePayment(model);
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,5 +15,11 @@ namespace BankContracts.BusinessLogicsContracts
|
|||||||
void SavePaymentPurchaseToWord(List<PaymentBindingModel> payments);
|
void SavePaymentPurchaseToWord(List<PaymentBindingModel> payments);
|
||||||
void SavePaymentPurchaseToExcel(List<PaymentBindingModel> payments);
|
void SavePaymentPurchaseToExcel(List<PaymentBindingModel> payments);
|
||||||
void SaveTransferPurchaseToPDF(ReportBindingModel model);
|
void SaveTransferPurchaseToPDF(ReportBindingModel model);
|
||||||
|
|
||||||
|
List<ReportCurrencyTransferViewModel> GetCurrencyTransfers(List<CurrencyBindingModel> currencies);
|
||||||
|
List<ReportCurrencyPurchasePaymentViewModel> GetPurchasePayment(ReportBindingModel model);
|
||||||
|
void SaveCurrencyTransfersToWord(List<CurrencyBindingModel> currencies);
|
||||||
|
void SaveCurrencyTransfersToExcel(List<CurrencyBindingModel> currencies);
|
||||||
|
void SavePurchasePaymentToPDF(ReportBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,7 @@ namespace BankContracts.SearchModels
|
|||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public int? BankOperatorId { get; set; }
|
public int? BankOperatorId { get; set; }
|
||||||
|
public DateTime? DateFrom { get; set; }
|
||||||
|
public DateTime? DateTo { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BankContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportCurrencyPurchasePaymentViewModel
|
||||||
|
{
|
||||||
|
public int CurrencyPurchaseId { get; set; }
|
||||||
|
public DateTime PurchaseDate { get; set; }
|
||||||
|
public List<(int PaymentId, string PaymentDate)> Payments { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BankContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportCurrencyTransferViewModel
|
||||||
|
{
|
||||||
|
public int CurrencyId { get; set; }
|
||||||
|
public string CurrencyName { get; set; } = string.Empty;
|
||||||
|
public List<(int TransferId, float Amount)> Transfers { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -41,15 +41,26 @@ namespace BankDatabaseImplement.Implements
|
|||||||
|
|
||||||
public List<CurrencyPurchaseViewModel> GetFilteredList(CurrencyPurchaseSearchModel model)
|
public List<CurrencyPurchaseViewModel> GetFilteredList(CurrencyPurchaseSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||||
|
{
|
||||||
using var context = new BankDatabase();
|
using var context = new BankDatabase();
|
||||||
return context.CurrencyPurchases.Include(x => x.BankOperator).Include(x=>x.Currency)
|
return context.CurrencyPurchases.Include(x => x.BankOperator).Include(x => x.Currency)
|
||||||
|
.Where(x => x.PurchaseDate >= model.DateFrom && x.PurchaseDate <= model.DateTo)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
using var context = new BankDatabase();
|
||||||
|
return context.CurrencyPurchases.Include(x => x.BankOperator).Include(x => x.Currency)
|
||||||
.Where(x => x.Id == model.Id)
|
.Where(x => x.Id == model.Id)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CurrencyPurchaseViewModel> GetFullList()
|
public List<CurrencyPurchaseViewModel> GetFullList()
|
||||||
|
Loading…
Reference in New Issue
Block a user