вывод отчетов на форму
This commit is contained in:
parent
f453017dbb
commit
79527c933a
@ -11,7 +11,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IWorkStorage _workStorage;
|
private readonly IWorkStorage _workStorage;
|
||||||
private readonly IWorkPaymentStorage _workPaymentStorage;
|
private readonly IWorkPaymentStorage _workPaymentStorage;
|
||||||
public ReportLogic(ILogger logger, IWorkStorage workStorage, IWorkPaymentStorage workPaymentStorage)
|
public ReportLogic(ILogger<ReportLogic> logger, IWorkStorage workStorage, IWorkPaymentStorage workPaymentStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_workStorage = workStorage;
|
_workStorage = workStorage;
|
||||||
|
@ -23,10 +23,18 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string WorkName { get; set; } = string.Empty;
|
public string WorkName { get; set; } = string.Empty;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Цена работы
|
||||||
|
/// </summary>
|
||||||
|
public decimal WorkPrice { get; set; }
|
||||||
|
/// <summary>
|
||||||
/// Количество работ
|
/// Количество работ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Общая сумма
|
||||||
|
/// </summary>
|
||||||
|
public decimal TotalSum { get; set; }
|
||||||
|
/// <summary>
|
||||||
/// Внесенная сумма
|
/// Внесенная сумма
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal PaymentSum { get; set; }
|
public decimal PaymentSum { get; set; }
|
||||||
@ -35,7 +43,7 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal Paid { get; set; }
|
public decimal Paid { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Всего не оплачено
|
/// Осталось оплатить
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal NotPaid { get; set; }
|
public decimal NotPaid { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,8 @@ namespace CarServiceDatabase.Implements
|
|||||||
.ThenInclude(wir => wir.RepairRequest)
|
.ThenInclude(wir => wir.RepairRequest)
|
||||||
.ThenInclude(rr => rr.Vehicle)
|
.ThenInclude(rr => rr.Vehicle)
|
||||||
.ThenInclude(v => v.Customer)
|
.ThenInclude(v => v.Customer)
|
||||||
|
.Include(wp => wp.WorkInRequest)
|
||||||
|
.ThenInclude(wp => wp.Work)
|
||||||
.Where(wp => wp.DatePayment >= model.DateFrom && wp.DatePayment <= model.DateTo)
|
.Where(wp => wp.DatePayment >= model.DateFrom && wp.DatePayment <= model.DateTo)
|
||||||
.Select(wp => new ReportWorksWithPaymentsViewModel()
|
.Select(wp => new ReportWorksWithPaymentsViewModel()
|
||||||
{
|
{
|
||||||
@ -59,9 +61,11 @@ namespace CarServiceDatabase.Implements
|
|||||||
VehicleNameAndPlate = wp.WorkInRequest.RepairRequest.Vehicle.Name + " " + wp.WorkInRequest.RepairRequest.Vehicle.Plate,
|
VehicleNameAndPlate = wp.WorkInRequest.RepairRequest.Vehicle.Name + " " + wp.WorkInRequest.RepairRequest.Vehicle.Plate,
|
||||||
WorkName = wp.WorkInRequest.Work.Name,
|
WorkName = wp.WorkInRequest.Work.Name,
|
||||||
Count = wp.WorkInRequest.Count,
|
Count = wp.WorkInRequest.Count,
|
||||||
|
WorkPrice = wp.WorkInRequest.Work.Price,
|
||||||
|
TotalSum = Convert.ToDecimal(wp.WorkInRequest.Count * wp.WorkInRequest.Work.Price),
|
||||||
PaymentSum = wp.Sum,
|
PaymentSum = wp.Sum,
|
||||||
Paid = context.WorkPayments.Where(x => x.WorkInRequestId == wp.WorkInRequestId).Select(x => x.Sum).Sum(),
|
Paid = context.WorkPayments.Where(x => x.WorkInRequestId == wp.WorkInRequestId).Select(x => x.Sum).Sum(),
|
||||||
NotPaid = context.WorksInRequest.Where(y => y.RepairRequestId == wp.WorkInRequest.RepairRequestId).Select(z => z.Cost).Sum() - context.WorkPayments.Where(x => x.WorkInRequestId == wp.WorkInRequestId).Select(x => x.Sum).Sum()
|
NotPaid = Convert.ToDecimal(wp.WorkInRequest.Count * wp.WorkInRequest.Work.Price - context.WorkPayments.Where(x => x.WorkInRequestId == wp.WorkInRequestId).Select(x => x.Sum).Sum())
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
79
CarService/CarServiceWebApp/Controllers/ReportController.cs
Normal file
79
CarService/CarServiceWebApp/Controllers/ReportController.cs
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
using CarServiceContracts.BindingModels;
|
||||||
|
using CarServiceContracts.BusinessLogicsContracts;
|
||||||
|
using CarServiceWebApp.Models;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace CarServiceWebApp.Controllers
|
||||||
|
{
|
||||||
|
public class ReportController : Controller
|
||||||
|
{
|
||||||
|
private readonly IReportLogic _reportLogic;
|
||||||
|
private readonly IWorkLogic _workLogic;
|
||||||
|
private static List<int> SelectedWorks = new();
|
||||||
|
private static ReportBindingModel PaymentsModel = new();
|
||||||
|
|
||||||
|
|
||||||
|
public ReportController(IReportLogic reportLogic, IWorkLogic workLogic)
|
||||||
|
{
|
||||||
|
_reportLogic = reportLogic;
|
||||||
|
_workLogic = workLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
if (CurrentUser.UserId < 1)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
public IActionResult ReportRequestsByWorks()
|
||||||
|
{
|
||||||
|
if (CurrentUser.UserId < 1)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
var requestsByWorks = _reportLogic.GetRequestsByWorks(new() { SelectedWorks = SelectedWorks } );
|
||||||
|
ViewBag.RequestsByWorks = requestsByWorks;
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult WorksSelection()
|
||||||
|
{
|
||||||
|
if (CurrentUser.UserId < 1)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
var works = _workLogic.ReadList(new() { Id = CurrentUser.UserId});
|
||||||
|
ViewBag.Works = works;
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult WorksSelection(List<int> selwor)
|
||||||
|
{
|
||||||
|
SelectedWorks = selwor;
|
||||||
|
return Redirect("~/Report/ReportRequestsByWorks");
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult DateSelection()
|
||||||
|
{
|
||||||
|
if (CurrentUser.UserId < 1)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult DateSelection(DateTime dateFrom, DateTime dateTo)
|
||||||
|
{
|
||||||
|
PaymentsModel = new() { DateFrom = dateFrom, DateTo = dateTo };
|
||||||
|
return Redirect("~/Report/ReportPayments");
|
||||||
|
}
|
||||||
|
public IActionResult ReportPayments()
|
||||||
|
{
|
||||||
|
var payments = _reportLogic.GetPayments(PaymentsModel);
|
||||||
|
ViewBag.Payments = payments;
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,10 @@ builder.Services.AddTransient<IItemForRepairStorage, ItemForRepairStorage>();
|
|||||||
builder.Services.AddTransient<IWorkInRequestLogic, WorkInRequestLogic>();
|
builder.Services.AddTransient<IWorkInRequestLogic, WorkInRequestLogic>();
|
||||||
builder.Services.AddTransient<IWorkInRequestStorage, WorkInRequestStorage>();
|
builder.Services.AddTransient<IWorkInRequestStorage, WorkInRequestStorage>();
|
||||||
|
|
||||||
|
builder.Services.AddTransient<IWorkPaymentStorage, WorkPaymentStorage>();
|
||||||
|
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
@using CarServiceContracts.BindingModels
|
||||||
|
@model ReportBindingModel
|
||||||
|
<div>
|
||||||
|
<form method="post">
|
||||||
|
<input type="date" name="DateFrom" />
|
||||||
|
<input type="date" name="DateTo"/>
|
||||||
|
<div><center><input type="submit" value="Сформировать отчет" class="btn btn-primary" /></center></div>
|
||||||
|
</form>
|
||||||
|
</div>
|
5
CarService/CarServiceWebApp/Views/Report/Index.cshtml
Normal file
5
CarService/CarServiceWebApp/Views/Report/Index.cshtml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<form method="get">
|
||||||
|
<center><h1 class="display-4">Работы</h1></center>
|
||||||
|
<h2><a asp-controller="Report" asp-action="WorksSelection">Список заявок по работам</a></h2>
|
||||||
|
<h2><a asp-controller="Report" asp-action="DateSelection">Сведения по оплатам</a></h2>
|
||||||
|
</form>
|
@ -0,0 +1,60 @@
|
|||||||
|
|
||||||
|
<div>
|
||||||
|
@if (ViewBag.Payments.Count != 0)
|
||||||
|
{
|
||||||
|
@foreach (var payment in ViewBag.Payments)
|
||||||
|
{
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Дата оплаты</td>
|
||||||
|
<td>@payment.PaymentDate</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Имя и фамилия клиента</td>
|
||||||
|
<td>@payment.CustomerName</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Номер заявки</td>
|
||||||
|
<td>@payment.RepairRequestId</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Транспортное средство</td>
|
||||||
|
<td>@payment.VehicleNameAndPlate</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Работа</td>
|
||||||
|
<td>@payment.WorkName</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Количество работ</td>
|
||||||
|
<td>@payment.Count</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Общая стоимость работ</td>
|
||||||
|
<td>@payment.TotalSum</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Внесенная сумма</td>
|
||||||
|
<td>@payment.PaymentSum</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Всего оплачено</td>
|
||||||
|
<td>@payment.Paid</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Осталось оплатить</td>
|
||||||
|
<td>@payment.NotPaid</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<hr />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<p>Нет оплат за указанный период</p>
|
||||||
|
}
|
||||||
|
</div>
|
@ -0,0 +1,46 @@
|
|||||||
|
|
||||||
|
<div>
|
||||||
|
@foreach (var rbw in ViewBag.RequestsByWorks)
|
||||||
|
{
|
||||||
|
<h3>@rbw.WorkName</h3>
|
||||||
|
@if (rbw.RepairRequests.Count != 0)
|
||||||
|
{
|
||||||
|
@foreach (var rr in rbw.RepairRequests)
|
||||||
|
{
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Номер заявки</td>
|
||||||
|
<td>@rr.RepairRequestId</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Дата заявки</td>
|
||||||
|
<td>@rr.RepairRequestDateCreated</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Клиент</td>
|
||||||
|
<td>@rr.CustomerName</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Транспортное средство</td>
|
||||||
|
<td>@rr.VehicleName</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Гос. номер</td>
|
||||||
|
<td>@rr.Plate</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Количество работ</td>
|
||||||
|
<td>@rr.WorksCount</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<hr />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<p>Заявок нет</p>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
@ -0,0 +1,8 @@
|
|||||||
|
@model List<int>
|
||||||
|
<form method="post">
|
||||||
|
@foreach (var work in ViewBag.Works)
|
||||||
|
{
|
||||||
|
<p><input type="checkbox" name="selwor" value="@work.Id" /> @work.Name</p>
|
||||||
|
}
|
||||||
|
<div><center><input type="submit" value="Сформировать отчет" class="btn btn-primary" /></center></div>
|
||||||
|
</form>
|
@ -29,7 +29,7 @@
|
|||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Items">Запчасти</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Items">Запчасти</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Отчет</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Report" asp-action="Index">Отчет</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Logout">Выход</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Logout">Выход</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user