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();
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace OperatorApp.Controllers
|
||||
{
|
||||
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]
|
||||
@ -97,7 +97,7 @@ namespace OperatorApp.Controllers
|
||||
{
|
||||
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)
|
||||
{
|
||||
throw new Exception("Неверный логин/пароль");
|
||||
@ -155,12 +155,12 @@ namespace OperatorApp.Controllers
|
||||
{
|
||||
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]
|
||||
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();
|
||||
}
|
||||
[HttpPost]
|
||||
@ -173,7 +173,7 @@ namespace OperatorApp.Controllers
|
||||
Dictionary<int, IDealModel> DealPayments = new();
|
||||
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);
|
||||
}
|
||||
_paymentLogic.Create(new PaymentBindingModel { OperatorId = APIClient.Operator.Id, DealPayments = DealPayments, });
|
||||
@ -182,7 +182,7 @@ namespace OperatorApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult Payment(int id)
|
||||
{
|
||||
return View(_paymentLogic.ReadElement(new PaymentSearchModel { Id = id }));
|
||||
return View(_paymentLogic.ReadElement(new PaymentSearchModel { Id = id}));
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Transfers()
|
||||
@ -211,18 +211,9 @@ namespace OperatorApp.Controllers
|
||||
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");
|
||||
}
|
||||
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()
|
||||
@ -253,8 +244,8 @@ namespace OperatorApp.Controllers
|
||||
}
|
||||
//if (word)
|
||||
//{
|
||||
MemoryStream list = _reportLogic.SavePaymentPurchaseToWord(new ReportBindingModel { FileName = "test" }, paymentBindings);
|
||||
return File(list, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "testDoc.docx");
|
||||
MemoryStream list = _reportLogic.SavePaymentPurchaseToWord(new ReportBindingModel { FileName = "test" }, paymentBindings);
|
||||
return File(list, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "testDoc.docx");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
@ -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