Compare commits

..

No commits in common. "f6fbc96b4fb95acae1d631d73f53c594b9dbfaf7" and "fceffcf0b6f1fcc67c32b78914a93e2c0f5bc605" have entirely different histories.

9 changed files with 36 additions and 118 deletions

View File

@ -22,9 +22,8 @@ namespace BankBusinessLogic.BusinessLogics
private readonly AbstractSaveToWord _saveToWord; private readonly AbstractSaveToWord _saveToWord;
private readonly AbstractSaveToExcel _saveToExcel; private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToPdf _saveToPdf;
public ReportLogic(ITransferStorage transferStorage, IPaymentStorage paymentStorage, ICurrencyStorage currencyStorage, ICurrencyPurchaseStorage currencyPurchaseStorage, AbstractSaveToWord saveToWord, AbstractSaveToExcel saveToExcel, AbstractSaveToPdf saveToPdf) public ReportLogic(ITransferStorage transferStorage, IPaymentStorage paymentStorage, ICurrencyStorage currencyStorage, ICurrencyPurchaseStorage currencyPurchaseStorage, AbstractSaveToWord saveToWord, AbstractSaveToExcel saveToExcel)
{ {
_transferStorage = transferStorage; _transferStorage = transferStorage;
_paymentStorage = paymentStorage; _paymentStorage = paymentStorage;
@ -32,7 +31,6 @@ namespace BankBusinessLogic.BusinessLogics
_currencyPurchaseStorage = currencyPurchaseStorage; _currencyPurchaseStorage = currencyPurchaseStorage;
_saveToWord = saveToWord; _saveToWord = saveToWord;
_saveToExcel = saveToExcel; _saveToExcel = saveToExcel;
_saveToPdf = saveToPdf;
} }
public List<ReportPaymentCurrencyPurchaseViewModel> GetPaymentPurchase(List<PaymentBindingModel> payments) public List<ReportPaymentCurrencyPurchaseViewModel> GetPaymentPurchase(List<PaymentBindingModel> payments)
@ -86,9 +84,9 @@ namespace BankBusinessLogic.BusinessLogics
{ {
TransferId = transfer.Id, TransferId = transfer.Id,
TransferDate = transfer.TransferDateTime, TransferDate = transfer.TransferDateTime,
Purchases = new List<CurrencyPurchaseViewModel>() Purchases = new List<(int, float)>()
}; };
var payment = _paymentStorage.GetElement(new PaymentSearchModel { Id = transfer.PaymentId}); var payment = _paymentStorage.GetElement(new PaymentSearchModel { Id = transfer.Id});
if (payment == null) if (payment == null)
{ {
throw new InvalidOperationException("Платеж не был найден!"); throw new InvalidOperationException("Платеж не был найден!");
@ -106,7 +104,7 @@ namespace BankBusinessLogic.BusinessLogics
{ {
if (currencyPurchase.CurrencyId == currencyId) if (currencyPurchase.CurrencyId == currencyId)
{ {
record.Purchases.Add(currencyPurchase); record.Purchases.Add(new(currencyPurchase.Id, currencyPurchase.Amount));
break; break;
} }
} }
@ -194,20 +192,11 @@ namespace BankBusinessLogic.BusinessLogics
}); });
} }
public MemoryStream SaveTransferPurchaseToPDF(ReportBindingModel model) public void SaveTransferPurchaseToPDF(ReportBindingModel model)
{ {
if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
{
throw new InvalidOperationException("Отсутствуют даты для отчёта!");
}
var result = GetTransferPurchase(model); var result = GetTransferPurchase(model);
return _saveToPdf.CreateOperatorDoc(new PdfInfo //создание файла будет реализовано в будующих версиях
{ throw new NotImplementedException();
Title = "Отчёт о зачислениях",
DateFrom = model.DateFrom.Value,
DateTo = model.DateTo.Value,
Transfers = result
});
} }
public void SaveCurrencyTransfersToExcel(List<CurrencyBindingModel> currencies) public void SaveCurrencyTransfersToExcel(List<CurrencyBindingModel> currencies)

View File

@ -10,41 +10,33 @@ namespace ConfectioneryBusinessLogic.OfficePackage
{ {
public abstract class AbstractSaveToPdf public abstract class AbstractSaveToPdf
{ {
public MemoryStream CreateOperatorDoc(PdfInfo info) public void CreateOperatorDoc(PdfInfo info)
{ {
CreatePdf(info); CreatePdf(info);
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
CreateTable(new List<string> { "4cm", "3cm", "3cm", "2cm", "3cm", "3cm" }); CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {
Texts = new List<string> { "Номер зачисления", "Дата зачисления", "Номер закупки", "Сумма", "Валюта", "Дата закупки" }, Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Статус", "Сумма" },
Style = "NormalTitle", Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center ParagraphAlignment = PdfParagraphAlignmentType.Center
}); });
foreach (var transfer in info.Transfers) //foreach (var order in info.Orders)
{ //{
CreateRow(new PdfRowParameters // CreateRow(new PdfRowParameters
{ // {
Texts = new List<string> { "Зачисление №" + transfer.TransferId, transfer.TransferDate.ToShortDateString(), "", "", "", "" }, // Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.PastryName, order.Status, order.Sum.ToString() },
Style = "Normal", // Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left // ParagraphAlignment = PdfParagraphAlignmentType.Left
}); // });
foreach(var purchase in transfer.Purchases) //}
{ //CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "", "", "Закупка №" + purchase.Id, purchase.Amount.ToString(), purchase.CurrencyName.ToString(), purchase.PurchaseDate.ToShortDateString()},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
}
return SavePdf(); //SavePdf(info);
} }
/// <summary> /// <summary>
@ -77,6 +69,6 @@ namespace ConfectioneryBusinessLogic.OfficePackage
/// Сохранение файла /// Сохранение файла
/// </summary> /// </summary>
/// <param name="info"></param> /// <param name="info"></param>
protected abstract MemoryStream SavePdf(); protected abstract void SavePdf(PdfInfo info);
} }
} }

View File

@ -106,21 +106,14 @@ namespace ConfectioneryBusinessLogic.OfficePackage.Implements
} }
} }
protected override MemoryStream SavePdf() protected override void SavePdf(PdfInfo info)
{ {
var renderer = new PdfDocumentRenderer(true) var renderer = new PdfDocumentRenderer(true)
{ {
Document = _document Document = _document
}; };
renderer.RenderDocument(); renderer.RenderDocument();
renderer.PdfDocument.Save(info.FileName);
MemoryStream stream = new MemoryStream();
renderer.PdfDocument.Save(stream, false);
stream.Seek(0, SeekOrigin.Begin);
return stream;
} }
} }
} }

View File

@ -14,7 +14,7 @@ namespace BankContracts.BusinessLogicsContracts
List<ReportTransferCurrencyPurchaseViewModel> GetTransferPurchase(ReportBindingModel model); List<ReportTransferCurrencyPurchaseViewModel> GetTransferPurchase(ReportBindingModel model);
MemoryStream SavePaymentPurchaseToWord(ReportBindingModel model, List<PaymentBindingModel> payments); MemoryStream SavePaymentPurchaseToWord(ReportBindingModel model, List<PaymentBindingModel> payments);
MemoryStream SavePaymentPurchaseToExcel(ReportBindingModel model, List<PaymentBindingModel> payments); MemoryStream SavePaymentPurchaseToExcel(ReportBindingModel model, List<PaymentBindingModel> payments);
MemoryStream SaveTransferPurchaseToPDF(ReportBindingModel model); void SaveTransferPurchaseToPDF(ReportBindingModel model);
List<ReportCurrencyTransferViewModel> GetCurrencyTransfers(List<CurrencyBindingModel> currencies); List<ReportCurrencyTransferViewModel> GetCurrencyTransfers(List<CurrencyBindingModel> currencies);
List<ReportCurrencyPurchasePaymentViewModel> GetPurchasePayment(ReportBindingModel model); List<ReportCurrencyPurchasePaymentViewModel> GetPurchasePayment(ReportBindingModel model);

View File

@ -10,6 +10,6 @@ namespace BankContracts.ViewModels
{ {
public int TransferId { get; set; } public int TransferId { get; set; }
public DateTime TransferDate { get; set; } public DateTime TransferDate { get; set; }
public List<CurrencyPurchaseViewModel> Purchases { get; set; } = new(); public List<(int PurchaseId, float Amount)> Purchases { get; set; } = new();
} }
} }

View File

@ -36,7 +36,7 @@ namespace OperatorApp.Controllers
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
return View(_dealLogic.ReadList(new DealSearchModel { OperatorId = APIClient.Operator.Id })); return View(_dealLogic.ReadList(new DealSearchModel { OperatorId = APIClient.Operator.Id}));
} }
[HttpGet] [HttpGet]
@ -97,7 +97,7 @@ namespace OperatorApp.Controllers
{ {
throw new Exception("Введите логин и пароль"); throw new Exception("Введите логин и пароль");
} }
APIClient.Operator = _operatorLogic.ReadElement(new OperatorSearchModel { Login = login, Password = password }); APIClient.Operator = _operatorLogic.ReadElement(new OperatorSearchModel { Login = login, Password = password});
if (APIClient.Operator == null) if (APIClient.Operator == null)
{ {
throw new Exception("Неверный логин/пароль"); throw new Exception("Неверный логин/пароль");
@ -155,12 +155,12 @@ namespace OperatorApp.Controllers
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
return View(_paymentLogic.ReadList(new PaymentSearchModel { OperatorId = APIClient.Operator.Id })); return View(_paymentLogic.ReadList(new PaymentSearchModel { OperatorId = APIClient.Operator.Id}));
} }
[HttpGet] [HttpGet]
public IActionResult CreatePayment() public IActionResult CreatePayment()
{ {
ViewBag.Deals = _dealLogic.ReadList(new DealSearchModel { OperatorId = APIClient.Operator.Id }); ViewBag.Deals = _dealLogic.ReadList(new DealSearchModel { OperatorId = APIClient.Operator.Id});
return View(); return View();
} }
[HttpPost] [HttpPost]
@ -173,7 +173,7 @@ namespace OperatorApp.Controllers
Dictionary<int, IDealModel> DealPayments = new(); Dictionary<int, IDealModel> DealPayments = new();
foreach (int id in deals) foreach (int id in deals)
{ {
var deal = _dealLogic.ReadElement(new DealSearchModel { Id = id }); var deal = _dealLogic.ReadElement(new DealSearchModel { Id = id});
if (deal != null) DealPayments.Add(deal.Id, deal); if (deal != null) DealPayments.Add(deal.Id, deal);
} }
_paymentLogic.Create(new PaymentBindingModel { OperatorId = APIClient.Operator.Id, DealPayments = DealPayments, }); _paymentLogic.Create(new PaymentBindingModel { OperatorId = APIClient.Operator.Id, DealPayments = DealPayments, });
@ -182,7 +182,7 @@ namespace OperatorApp.Controllers
[HttpGet] [HttpGet]
public IActionResult Payment(int id) public IActionResult Payment(int id)
{ {
return View(_paymentLogic.ReadElement(new PaymentSearchModel { Id = id })); return View(_paymentLogic.ReadElement(new PaymentSearchModel { Id = id}));
} }
[HttpGet] [HttpGet]
public IActionResult Transfers() public IActionResult Transfers()
@ -211,18 +211,9 @@ namespace OperatorApp.Controllers
throw new Exception("Вы как суда попали? Суда вход только авторизованным"); throw new Exception("Вы как суда попали? Суда вход только авторизованным");
} }
_transferLogic.Create(new TransferBindingModel { OperatorId = APIClient.Operator.Id, Amount = (float)Convert.ToDouble(amount), PaymentId = payment }); _transferLogic.Create(new TransferBindingModel { OperatorId = APIClient.Operator.Id, Amount = (float)Convert.ToDouble(amount), PaymentId = payment});
Response.Redirect("Transfers"); Response.Redirect("Transfers");
} }
public void DeleteTransfer(int id)
{
if (APIClient.Operator == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
_transferLogic.Delete(new TransferBindingModel { Id = id });
Response.Redirect("/Home/Transfers");
}
[HttpGet] [HttpGet]
public IActionResult PaymentsReport() public IActionResult PaymentsReport()
@ -262,17 +253,5 @@ namespace OperatorApp.Controllers
// return File(list, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "testExcel.xlsx"); // return File(list, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "testExcel.xlsx");
//} //}
} }
[HttpGet]
public IActionResult TransfersReport()
{
return View(new ReportBindingModel());
}
[HttpPost]
public IActionResult TransfersReport(DateTime dateFrom, DateTime dateTo)
{
MemoryStream report = _reportLogic.SaveTransferPurchaseToPDF(new ReportBindingModel { DateFrom = dateFrom, DateTo = dateTo });
return File(report, "application/pdf", "test.pdf");
}
} }
} }

View File

@ -37,8 +37,6 @@
<th> <th>
Номер выплаты Номер выплаты
</th> </th>
<th>
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -57,9 +55,6 @@
<td> <td>
@Html.DisplayFor(modelItem => item.PaymentId) @Html.DisplayFor(modelItem => item.PaymentId)
</td> </td>
<td>
<a asp-action="DeleteTransfer" asp-route-id="@item.Id">Удалить</a>
</td>
</tr> </tr>
} }
</tbody> </tbody>

View File

@ -1,25 +0,0 @@
@using BankContracts.BindingModels
@model ReportBindingModel
@{
ViewData["Title"] = "TransfersReport";
}
<div class="text-center">
<h2 class="display-4">Создание отчёта</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">C:</div>
<div class="col-8">
@Html.EditorFor(x => x.DateFrom, new { htmlAttributes = new { @class = "form-control my-3", @type = "date", @name="DateFrom", @required="true", @id="DateFrom" } })
</div>
<div class="col-4">По:</div>
<div class="col-8">
@Html.EditorFor(x => x.DateTo, new { htmlAttributes = new { @class = "form-control my-3", @type = "date", @name="DateTo", @required="true", @id="DateTo" } })
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -8,8 +8,6 @@
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" /> <link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/AbstractShowClientApp.styles.css" asp-append-version="true" /> <link rel="stylesheet" href="~/AbstractShowClientApp.styles.css" asp-append-version="true" />
<script src="~/lib/jquery/dist/jquery.min.js"></script> <script src="~/lib/jquery/dist/jquery.min.js"></script>
</head> </head>
<body> <body>
<header> <header>
@ -41,10 +39,7 @@
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="PaymentsReport">Списки по выплатам</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="PaymentsReport">Регистрация</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="TransfersReport">Отчёт по зачислениям</a>
</li> </li>
</ul> </ul>
</div> </div>