diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs index 6dbf8c7..9b66f74 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs @@ -5,6 +5,7 @@ using BankYouBankruptContracts.BusinessLogicsContracts; using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.StoragesContracts; using BankYouBankruptContracts.ViewModels; +using BankYouBankruptContracts.ViewModels.Client.Default; using BankYouBankruptDataModels.Enums; using System; using System.Collections.Generic; @@ -22,6 +23,10 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics private readonly IClientStorage _clientStorage; + private readonly IDebitingStorage _debitingStorage; + + private readonly ICardStorage _cardStorage; + private readonly AbstractSaveToExcel _saveToExcel; private readonly AbstractSaveToWordCashier _saveToWord; @@ -31,7 +36,8 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics //инициализируем поля класса через контейнер public ReportCashierLogic(IMoneyTransferStorage moneyTransferStorage, ICashWithdrawalStorage cashWithdrawalStorage, IClientStorage clientStorage, AbstractSaveToExcel saveToExcel, - AbstractSaveToWordCashier saveToWord, AbstractSaveToPdf saveToPdf) + AbstractSaveToWordCashier saveToWord, AbstractSaveToPdf saveToPdf, + IDebitingStorage debitingStorage, ICardStorage cardStorage) { _moneyTransferStorage = moneyTransferStorage; _cashWithdrawalStorage = cashWithdrawalStorage; @@ -40,6 +46,8 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics _saveToWord = saveToWord; _saveToPdf = saveToPdf; _clientStorage = clientStorage; + _debitingStorage = debitingStorage; + _cardStorage = cardStorage; } //формирование списка переводов между счетами за период @@ -73,18 +81,33 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics } //формирование списка выдаци наличных со счёта за период - public List? GetDebitings(ReportBindingModel model) + public List? GetDebitings(ReportBindingModel model) { - return _moneyTransferStorage.GetFilteredList(new MoneyTransferSearchModel { ClientId = model.ClientId, DateFrom = model.DateFrom, DateTo = model.DateTo }) - .Select(x => new ReportCashierViewModel + List CardIdList = new(); + + var list = _cardStorage.GetFilteredList(new CardSearchModel + { + AccountId = model.AccountId + }); + + foreach(var index in list) + { + CardIdList.Add(index.Id); + } + + List totalList = new(); + + foreach(var index in CardIdList) + { + var result = _debitingStorage.GetFilteredList(new DebitingSearchModel { - OperationId = x.Id, - DateComplite = x.DateOperation, - AccountPayeeNumber = x.AccountPayeeNumber, - AccountSenderNumber = x.AccountSenderNumber, - SumOperation = x.Sum - }) - .ToList(); + CardId = index + }); + + totalList.AddRange(result); + } + + return totalList; } //формирование полного имени клиента для отчёта @@ -113,7 +136,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics Title = "Заявки на счёт", - Debiting = null + Debiting = GetDebitings(model) }, ExcelOperationEnum.Для_кассира); } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 77e765a..30c4179 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -397,27 +397,27 @@ namespace BankYouBankruptBusinessLogic.OfficePackage { ColumnName = "A", RowIndex = rowIndex, - Text = "Снятие №" + cr.Id, + Text = "Заявка №" + cr.Id, StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - //строчка с номером счёта отправителя + //строчка с номером счёта получателя InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "B", RowIndex = rowIndex, - Text = "Номер карты: ", + Text = "Сумма заявки: ", StyleInfo = ExcelStyleInfoType.TextWithBorder }); - //вставка номера отправителя + //вставка суммы заявки InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "C", RowIndex = rowIndex, - Text = cr.CardNumber, + Text = cr.Sum.ToString(), StyleInfo = ExcelStyleInfoType.TextWithBorder }); @@ -428,7 +428,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage { ColumnName = "B", RowIndex = rowIndex, - Text = "Сумма снятия: ", + Text = "Статус: ", StyleInfo = ExcelStyleInfoType.TextWithBorder }); @@ -437,7 +437,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage { ColumnName = "C", RowIndex = rowIndex, - Text = cr.Sum.ToString(), + Text = cr.Status.ToString(), StyleInfo = ExcelStyleInfoType.TextWithBorder }); @@ -450,21 +450,45 @@ namespace BankYouBankruptBusinessLogic.OfficePackage { ColumnName = "A", RowIndex = rowIndex, - Text = "Суммарный объём снятий: ", + Text = "Суммарный объём открытых заявок на снятие: ", StyleInfo = ExcelStyleInfoType.Text }); MergeCells(new ExcelMergeParameters { CellFromName = "A" + rowIndex.ToString(), - CellToName = "B" + rowIndex.ToString() + CellToName = "C" + rowIndex.ToString() }); InsertCellInWorksheet(new ExcelCellParameters { - ColumnName = "C", + ColumnName = "D", RowIndex = rowIndex, - Text = info.Crediting.Sum(x => x.Sum).ToString(), + Text = info.Debiting.Where(x => x.Status == StatusEnum.Открыта).Sum(x => x.Sum).ToString(), + StyleInfo = ExcelStyleInfoType.Text + }); + + rowIndex += 2; + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = "Суммарный объём закртытых заявок на снятие: ", + StyleInfo = ExcelStyleInfoType.Text + }); + + MergeCells(new ExcelMergeParameters + { + CellFromName = "A" + rowIndex.ToString(), + CellToName = "C" + rowIndex.ToString() + }); + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "D", + RowIndex = rowIndex, + Text = info.Debiting.Where(x => x.Status == StatusEnum.Закрыта).Sum(x => x.Sum).ToString(), StyleInfo = ExcelStyleInfoType.Text }); diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/MoneyTransfers.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/MoneyTransfers.cshtml index 38ad7a1..5e1e289 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/MoneyTransfers.cshtml +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/MoneyTransfers.cshtml @@ -3,7 +3,7 @@ }
-

Перевод меджу счетами

+

Перевод между счетами

diff --git a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportSupportBindingModel.cs b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportSupportBindingModel.cs index 744c0f1..693079c 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportSupportBindingModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportSupportBindingModel.cs @@ -10,13 +10,13 @@ namespace BankYouBankruptContracts.BindingModels //вспомогательная модель для передачи DateTime при формировании отчёта public class ReportSupportBindingModel { - public int ClientId { get; set; } + public int? ClientId { get; set; } - public int AccountId { get; set; } + public int? AccountId { get; set; } - public DateTime DateFrom { get; set; } + public DateTime? DateFrom { get; set; } - public DateTime DateTo { get; set; } + public DateTime? DateTo { get; set; } //для Excel отчёта клиента public List? CardList { get; set; } diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CardStorage.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CardStorage.cs index 2333ddd..4bea9a8 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CardStorage.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CardStorage.cs @@ -65,6 +65,15 @@ namespace BankYouBankruptDatabaseImplement.Implements .ToList(); } + if (model.AccountId.HasValue) + { + return context.Cards + .Include(x => x.Client) + .Where(x => x.AccountId == model.AccountId) + .Select(x => x.GetViewModel) + .ToList(); + } + return context.Cards .Include(x => x.Client) .Select(x => x.GetViewModel) diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/DebitingStorage.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/DebitingStorage.cs index 13e5b94..e46230c 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/DebitingStorage.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/DebitingStorage.cs @@ -32,7 +32,6 @@ namespace BankYouBankruptDatabaseImplement.Implements var result = context.Debitings.Include(x => x.Card).ToList(); - //для получения всех заявок на стнятие со статусом "Открыта" if (model.Status.HasValue) result = result.Where(x => x.Status == model.Status).ToList(); diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs index e1f641d..83b592b 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs @@ -160,7 +160,7 @@ namespace BankYouBankruptRestAPI.Controllers { _reportCashierLogic.SaveAccountsToExcelFile(new ReportBindingModel { - FileName = "Отчёт по переводам.xls", + FileName = "Отчёт по зявкам на снятие.xls", AccountId = model.AccountId }); } diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по переводам.xls b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по переводам.xls index 2180e12..5ca769e 100644 Binary files a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по переводам.xls and b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по переводам.xls differ