Compare commits
No commits in common. "f6fbc96b4fb95acae1d631d73f53c594b9dbfaf7" and "fceffcf0b6f1fcc67c32b78914a93e2c0f5bc605" have entirely different histories.
f6fbc96b4f
...
fceffcf0b6
@ -22,9 +22,8 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
|
||||
private readonly AbstractSaveToWord _saveToWord;
|
||||
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;
|
||||
_paymentStorage = paymentStorage;
|
||||
@ -32,7 +31,6 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
_currencyPurchaseStorage = currencyPurchaseStorage;
|
||||
_saveToWord = saveToWord;
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToPdf = saveToPdf;
|
||||
}
|
||||
|
||||
public List<ReportPaymentCurrencyPurchaseViewModel> GetPaymentPurchase(List<PaymentBindingModel> payments)
|
||||
@ -86,9 +84,9 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
{
|
||||
TransferId = transfer.Id,
|
||||
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)
|
||||
{
|
||||
throw new InvalidOperationException("Платеж не был найден!");
|
||||
@ -106,7 +104,7 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
{
|
||||
if (currencyPurchase.CurrencyId == currencyId)
|
||||
{
|
||||
record.Purchases.Add(currencyPurchase);
|
||||
record.Purchases.Add(new(currencyPurchase.Id, currencyPurchase.Amount));
|
||||
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);
|
||||
return _saveToPdf.CreateOperatorDoc(new PdfInfo
|
||||
{
|
||||
Title = "Отчёт о зачислениях",
|
||||
DateFrom = model.DateFrom.Value,
|
||||
DateTo = model.DateTo.Value,
|
||||
Transfers = result
|
||||
});
|
||||
//создание файла будет реализовано в будующих версиях
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveCurrencyTransfersToExcel(List<CurrencyBindingModel> currencies)
|
||||
|
@ -10,41 +10,33 @@ namespace ConfectioneryBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToPdf
|
||||
{
|
||||
public MemoryStream CreateOperatorDoc(PdfInfo info)
|
||||
public void CreateOperatorDoc(PdfInfo info)
|
||||
{
|
||||
CreatePdf(info);
|
||||
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 });
|
||||
|
||||
CreateTable(new List<string> { "4cm", "3cm", "3cm", "2cm", "3cm", "3cm" });
|
||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
|
||||
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Номер зачисления", "Дата зачисления", "Номер закупки", "Сумма", "Валюта", "Дата закупки" },
|
||||
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Статус", "Сумма" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
foreach (var transfer in info.Transfers)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Зачисление №" + transfer.TransferId, transfer.TransferDate.ToShortDateString(), "", "", "", "" },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
foreach(var purchase in transfer.Purchases)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "", "", "Закупка №" + purchase.Id, purchase.Amount.ToString(), purchase.CurrencyName.ToString(), purchase.PurchaseDate.ToShortDateString()},
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
}
|
||||
//foreach (var order in info.Orders)
|
||||
//{
|
||||
// CreateRow(new PdfRowParameters
|
||||
// {
|
||||
// Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.PastryName, order.Status, order.Sum.ToString() },
|
||||
// Style = "Normal",
|
||||
// ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
// });
|
||||
//}
|
||||
//CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth });
|
||||
|
||||
return SavePdf();
|
||||
//SavePdf(info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -77,6 +69,6 @@ namespace ConfectioneryBusinessLogic.OfficePackage
|
||||
/// Сохранение файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract MemoryStream SavePdf();
|
||||
protected abstract void SavePdf(PdfInfo info);
|
||||
}
|
||||
}
|
||||
|
@ -106,21 +106,14 @@ namespace ConfectioneryBusinessLogic.OfficePackage.Implements
|
||||
}
|
||||
}
|
||||
|
||||
protected override MemoryStream SavePdf()
|
||||
protected override void SavePdf(PdfInfo info)
|
||||
{
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
|
||||
MemoryStream stream = new MemoryStream();
|
||||
|
||||
renderer.PdfDocument.Save(stream, false);
|
||||
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
return stream;
|
||||
renderer.PdfDocument.Save(info.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace BankContracts.BusinessLogicsContracts
|
||||
List<ReportTransferCurrencyPurchaseViewModel> GetTransferPurchase(ReportBindingModel model);
|
||||
MemoryStream SavePaymentPurchaseToWord(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<ReportCurrencyPurchasePaymentViewModel> GetPurchasePayment(ReportBindingModel model);
|
||||
|
@ -10,6 +10,6 @@ namespace BankContracts.ViewModels
|
||||
{
|
||||
public int TransferId { get; set; }
|
||||
public DateTime TransferDate { get; set; }
|
||||
public List<CurrencyPurchaseViewModel> Purchases { get; set; } = new();
|
||||
public List<(int PurchaseId, float Amount)> Purchases { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -214,15 +214,6 @@ namespace OperatorApp.Controllers
|
||||
_transferLogic.Create(new TransferBindingModel { OperatorId = APIClient.Operator.Id, Amount = (float)Convert.ToDouble(amount), PaymentId = payment});
|
||||
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]
|
||||
public IActionResult PaymentsReport()
|
||||
@ -262,17 +253,5 @@ namespace OperatorApp.Controllers
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
}
|
@ -37,8 +37,6 @@
|
||||
<th>
|
||||
Номер выплаты
|
||||
</th>
|
||||
<th>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -57,9 +55,6 @@
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PaymentId)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="DeleteTransfer" asp-route-id="@item.Id">Удалить</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
@ -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>
|
@ -8,8 +8,6 @@
|
||||
<link rel="stylesheet" href="~/css/site.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>
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
@ -41,10 +39,7 @@
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<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>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="PaymentsReport">Регистрация</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user