This commit is contained in:
shadowik 2023-05-19 22:24:11 +04:00
commit b525d939c8
8 changed files with 85 additions and 30 deletions

View File

@ -5,6 +5,7 @@ using BankYouBankruptContracts.BusinessLogicsContracts;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.StoragesContracts; using BankYouBankruptContracts.StoragesContracts;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels;
using BankYouBankruptContracts.ViewModels.Client.Default;
using BankYouBankruptDataModels.Enums; using BankYouBankruptDataModels.Enums;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -22,6 +23,10 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
private readonly IClientStorage _clientStorage; private readonly IClientStorage _clientStorage;
private readonly IDebitingStorage _debitingStorage;
private readonly ICardStorage _cardStorage;
private readonly AbstractSaveToExcel _saveToExcel; private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToWordCashier _saveToWord; private readonly AbstractSaveToWordCashier _saveToWord;
@ -31,7 +36,8 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
//инициализируем поля класса через контейнер //инициализируем поля класса через контейнер
public ReportCashierLogic(IMoneyTransferStorage moneyTransferStorage, ICashWithdrawalStorage cashWithdrawalStorage, public ReportCashierLogic(IMoneyTransferStorage moneyTransferStorage, ICashWithdrawalStorage cashWithdrawalStorage,
IClientStorage clientStorage, AbstractSaveToExcel saveToExcel, IClientStorage clientStorage, AbstractSaveToExcel saveToExcel,
AbstractSaveToWordCashier saveToWord, AbstractSaveToPdf saveToPdf) AbstractSaveToWordCashier saveToWord, AbstractSaveToPdf saveToPdf,
IDebitingStorage debitingStorage, ICardStorage cardStorage)
{ {
_moneyTransferStorage = moneyTransferStorage; _moneyTransferStorage = moneyTransferStorage;
_cashWithdrawalStorage = cashWithdrawalStorage; _cashWithdrawalStorage = cashWithdrawalStorage;
@ -40,6 +46,8 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
_saveToWord = saveToWord; _saveToWord = saveToWord;
_saveToPdf = saveToPdf; _saveToPdf = saveToPdf;
_clientStorage = clientStorage; _clientStorage = clientStorage;
_debitingStorage = debitingStorage;
_cardStorage = cardStorage;
} }
//формирование списка переводов между счетами за период //формирование списка переводов между счетами за период
@ -73,18 +81,33 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
} }
//формирование списка выдаци наличных со счёта за период //формирование списка выдаци наличных со счёта за период
public List<ReportCashierViewModel>? GetDebitings(ReportBindingModel model) public List<DebitingViewModel>? GetDebitings(ReportBindingModel model)
{ {
return _moneyTransferStorage.GetFilteredList(new MoneyTransferSearchModel { ClientId = model.ClientId, DateFrom = model.DateFrom, DateTo = model.DateTo }) List<int> CardIdList = new();
.Select(x => new ReportCashierViewModel
var list = _cardStorage.GetFilteredList(new CardSearchModel
{
AccountId = model.AccountId
});
foreach(var index in list)
{
CardIdList.Add(index.Id);
}
List<DebitingViewModel> totalList = new();
foreach(var index in CardIdList)
{
var result = _debitingStorage.GetFilteredList(new DebitingSearchModel
{ {
OperationId = x.Id, CardId = index
DateComplite = x.DateOperation, });
AccountPayeeNumber = x.AccountPayeeNumber,
AccountSenderNumber = x.AccountSenderNumber, totalList.AddRange(result);
SumOperation = x.Sum }
})
.ToList(); return totalList;
} }
//формирование полного имени клиента для отчёта //формирование полного имени клиента для отчёта
@ -113,7 +136,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
Title = "Заявки на счёт", Title = "Заявки на счёт",
Debiting = null Debiting = GetDebitings(model)
}, ExcelOperationEnum.Дляассира); }, ExcelOperationEnum.Дляассира);
} }

View File

@ -397,27 +397,27 @@ namespace BankYouBankruptBusinessLogic.OfficePackage
{ {
ColumnName = "A", ColumnName = "A",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = "Снятие №" + cr.Id, Text = "Заявка №" + cr.Id,
StyleInfo = ExcelStyleInfoType.Text StyleInfo = ExcelStyleInfoType.Text
}); });
rowIndex++; rowIndex++;
//строчка с номером счёта отправителя //строчка с номером счёта получателя
InsertCellInWorksheet(new ExcelCellParameters InsertCellInWorksheet(new ExcelCellParameters
{ {
ColumnName = "B", ColumnName = "B",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = "Номер карты: ", Text = "Сумма заявки: ",
StyleInfo = ExcelStyleInfoType.TextWithBorder StyleInfo = ExcelStyleInfoType.TextWithBorder
}); });
//вставка номера отправителя //вставка суммы заявки
InsertCellInWorksheet(new ExcelCellParameters InsertCellInWorksheet(new ExcelCellParameters
{ {
ColumnName = "C", ColumnName = "C",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = cr.CardNumber, Text = cr.Sum.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBorder StyleInfo = ExcelStyleInfoType.TextWithBorder
}); });
@ -428,7 +428,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage
{ {
ColumnName = "B", ColumnName = "B",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = "Сумма снятия: ", Text = "Статус: ",
StyleInfo = ExcelStyleInfoType.TextWithBorder StyleInfo = ExcelStyleInfoType.TextWithBorder
}); });
@ -437,7 +437,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage
{ {
ColumnName = "C", ColumnName = "C",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = cr.Sum.ToString(), Text = cr.Status.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBorder StyleInfo = ExcelStyleInfoType.TextWithBorder
}); });
@ -450,21 +450,45 @@ namespace BankYouBankruptBusinessLogic.OfficePackage
{ {
ColumnName = "A", ColumnName = "A",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = "Суммарный объём снятий: ", Text = "Суммарный объём открытых заявок на снятие: ",
StyleInfo = ExcelStyleInfoType.Text StyleInfo = ExcelStyleInfoType.Text
}); });
MergeCells(new ExcelMergeParameters MergeCells(new ExcelMergeParameters
{ {
CellFromName = "A" + rowIndex.ToString(), CellFromName = "A" + rowIndex.ToString(),
CellToName = "B" + rowIndex.ToString() CellToName = "C" + rowIndex.ToString()
}); });
InsertCellInWorksheet(new ExcelCellParameters InsertCellInWorksheet(new ExcelCellParameters
{ {
ColumnName = "C", ColumnName = "D",
RowIndex = rowIndex, 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 StyleInfo = ExcelStyleInfoType.Text
}); });

View File

@ -3,7 +3,7 @@
} }
<div class="text-center"> <div class="text-center">
<h2 class="display-4">Перевод меджу счетами</h2> <h2 class="display-4">Перевод между счетами</h2>
</div> </div>
<form method="post"> <form method="post">
<div class="row"> <div class="row">

View File

@ -10,13 +10,13 @@ namespace BankYouBankruptContracts.BindingModels
//вспомогательная модель для передачи DateTime при формировании отчёта //вспомогательная модель для передачи DateTime при формировании отчёта
public class ReportSupportBindingModel 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 отчёта клиента //для Excel отчёта клиента
public List<int>? CardList { get; set; } public List<int>? CardList { get; set; }

View File

@ -65,6 +65,15 @@ namespace BankYouBankruptDatabaseImplement.Implements
.ToList(); .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 return context.Cards
.Include(x => x.Client) .Include(x => x.Client)
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)

View File

@ -32,7 +32,6 @@ namespace BankYouBankruptDatabaseImplement.Implements
var result = context.Debitings.Include(x => x.Card).ToList(); var result = context.Debitings.Include(x => x.Card).ToList();
//для получения всех заявок на стнятие со статусом "Открыта" //для получения всех заявок на стнятие со статусом "Открыта"
if (model.Status.HasValue) result = result.Where(x => x.Status == model.Status).ToList(); if (model.Status.HasValue) result = result.Where(x => x.Status == model.Status).ToList();

View File

@ -160,7 +160,7 @@ namespace BankYouBankruptRestAPI.Controllers
{ {
_reportCashierLogic.SaveAccountsToExcelFile(new ReportBindingModel _reportCashierLogic.SaveAccountsToExcelFile(new ReportBindingModel
{ {
FileName = "Отчёт по переводам.xls", FileName = "Отчёт по зявкам на снятие.xls",
AccountId = model.AccountId AccountId = model.AccountId
}); });
} }