CashierReportAccounts

This commit is contained in:
shadowik 2023-05-18 12:19:37 +04:00
parent eb8a5172d5
commit 4c40714bf0
8 changed files with 122 additions and 22 deletions

View File

@ -55,7 +55,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
public List<CashWithdrawalViewModel>? ReadList(CashWithdrawalSearchModel? model)
{
_logger.LogInformation("ReadElement. AccountId:{AccountId}. Sum:{Sum}. DateOperation:{DateOperation}. Id:{Id}",
model.AccountId, model.Sum, model.DateTo, model?.Id);
model?.AccountId, model?.Sum, model?.DateTo, model?.Id);
//list хранит весь список в случае, если model пришло со значением null на вход метода
var list = model == null ? _cashWithdrawalStorage.GetFullList() : _cashWithdrawalStorage.GetFilteredList(model);

View File

@ -55,7 +55,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
public List<MoneyTransferViewModel>? ReadList(MoneyTransferSearchModel? model)
{
_logger.LogInformation("ReadElement. AccountSenderId:{AccountSenderId}. AccountPayeeId:{AccountPayeeId}. Sum:{Sum}. Id:{Id}",
model.AccountSenderId, model.AccountPayeeId, model.Sum, model?.Id);
model?.AccountSenderId, model?.AccountPayeeId, model?.Sum, model?.Id);
//list хранит весь список в случае, если model пришло со значением null на вход метода
var list = model == null ? _moneyTransferStorage.GetFullList() : _moneyTransferStorage.GetFilteredList(model);

View File

@ -1,6 +1,7 @@
using BankYouBankruptCashierApp.Models;
using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels;
using BankYouBankruptDataModels.Enums;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using System.Xml.Linq;
@ -420,7 +421,39 @@ namespace BankYouBankruptCashierApp.Controllers
ViewBag.Accounts = APICashier.GetRequest<List<AccountViewModel>>("/api/Account/GetAllAccounts");
return View();
return View(new List<ReportCashierAccountsViewModel>());
}
[HttpPost]
public IActionResult ReportWithAccounts(string accountId)
{
if (APICashier.Cashier == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Accounts = APICashier.GetRequest<List<AccountViewModel>>("/api/Account/GetAllAccounts");
var cashWithdrawals = APICashier.GetRequest<List<CashWithdrawalViewModel>>("api/Account/FindAllCashWithdrawal").Where(x => x.AccountId == int.Parse(accountId))
.Select(x => new ReportCashierAccountsViewModel
{
CashierSurname = x.SurmaneCashier,
Sum = x.Sum,
AccountSenderNumber = x.AccountNumber,
DateOperation = x.DateOperation,
typeOperation = TypeOperationEnum.Снятие
});
var moneyTransfers = APICashier.GetRequest<List<MoneyTransferViewModel>>("/api/Account/FindAllMoneyTransfer").Where(x => (x.AccountPayeeId == int.Parse(accountId) || x.AccountSenderId == int.Parse(accountId)))
.Select(x => new ReportCashierAccountsViewModel
{
CashierSurname = x.CashierSurname,
Sum = x.Sum,
AccountPayeeNumber = x.AccountPayeeNumber,
AccountSenderNumber = x.AccountSenderNumber,
DateOperation = x.DateOperation,
typeOperation = x.AccountSenderId.HasValue ? TypeOperationEnum.Перевод : TypeOperationEnum.Пополнение
});
return View(cashWithdrawals.Concat(moneyTransfers).OrderBy(x => x.DateOperation).ToList());
}
#region Получение отчёта PDF

View File

@ -1,6 +1,6 @@
@using BankYouBankruptContracts.ViewModels
@model ReportClientCardsViewModel
@model List<ReportCashierAccountsViewModel>?
@{
ViewData["Title"] = "Отчет по аккаунтам";
@ -30,28 +30,50 @@
<table class="table">
<thead>
<tr>
<th>
Номер карты
</th>
<th>
Тип операции
</th>
<th>
Сумма
Кассир
</th>
<th>
Статус
1 Счет
</th>
<th>
Дата открытия
2 Счет
</th>
<th>
Дата закрытия
Сумма операции
</th>
<th>
Дата
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.typeOperation)
</td>
<td>
@Html.DisplayFor(modelItem => item.CashierSurname)
</td>
<td>
@Html.DisplayFor(modelItem => item.AccountSenderNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.AccountPayeeNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.Sum)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateOperation)
</td>
</tr>
}
</tbody>
</table>
</div>

View File

@ -43,12 +43,16 @@
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="MoneyTransfers">Переводы</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="ReportWithAccounts">Отчёт по аккаунтам</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="CreateReport">Отчёт</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Личный кабинет</a>
</li>
}
}
<li class="nav-item">

View File

@ -1,5 +1,7 @@
using System;
using BankYouBankruptDataModels.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -8,8 +10,17 @@ namespace BankYouBankruptContracts.ViewModels
{
public class ReportCashierAccountsViewModel
{
public List<CheckboxViewModel>? Accounts { get; set; } = new();
public List<ReportViewModel>? Operations { get; set; } = new();
public int Sum { get; set; }
public string AccountSenderNumber { get; set; } = string.Empty;
public string AccountPayeeNumber { get; set; } = string.Empty;
public DateTime DateOperation { get; set; } = DateTime.Now;
public string CashierSurname { get; set; } = string.Empty;
public TypeOperationEnum typeOperation { get; set; }
}
}

View File

@ -10,6 +10,8 @@ namespace BankYouBankruptDataModels.Enums
{
Снятие = 1,
Пополнение = 2
Пополнение = 2,
Перевод = 3,
}
}

View File

@ -156,6 +156,34 @@ namespace BankYouBankruptRestApi.Controllers
}
}
[HttpGet]
public List<CashWithdrawalViewModel>? FindAllCashWithdrawal()
{
try
{
return _cashLogic.ReadList(null);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка входа в систему");
throw;
}
}
[HttpGet]
public List<MoneyTransferViewModel>? FindAllMoneyTransfer()
{
try
{
return _moneyTransferLogic.ReadList(null);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка входа в систему");
throw;
}
}
//найти все открытые заявки на снятие средств
[HttpGet]
public List<DebitingViewModel>? FindOpenDebiting()