102 lines
3.5 KiB
C#
102 lines
3.5 KiB
C#
using BankYouBankruptBusinessLogic.OfficePackage;
|
||
using BankYouBankruptBusinessLogic.OfficePackage.HelperModels;
|
||
using BankYouBankruptContracts.BindingModels;
|
||
using BankYouBankruptContracts.BusinessLogicsContracts;
|
||
using BankYouBankruptContracts.SearchModels;
|
||
using BankYouBankruptContracts.StoragesContracts;
|
||
using BankYouBankruptContracts.ViewModels;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||
{
|
||
public class ReportCashierLogic : IReportCashierLogic
|
||
{
|
||
private readonly IMoneyTransferStorage _moneyTransferStorage;
|
||
|
||
private readonly ICashWithdrawalStorage _cashWithdrawalStorage;
|
||
|
||
private readonly IAccountStorage _accountStorage;
|
||
|
||
private readonly AbstractSaveToExcelCashier _saveToExcel;
|
||
|
||
private readonly AbstractSaveToWordCashier _saveToWord;
|
||
|
||
private readonly AbstractSaveToPdfClient _saveToPdf;
|
||
|
||
//инициализируем поля класса через контейнер
|
||
public ReportCashierLogic(IMoneyTransferStorage moneyTransferStorage, ICashWithdrawalStorage cashWithdrawalStorage,
|
||
IAccountStorage accountStorage, AbstractSaveToExcelCashier saveToExcel, AbstractSaveToWordCashier saveToWord,
|
||
AbstractSaveToPdfClient saveToPdf)
|
||
{
|
||
_moneyTransferStorage = moneyTransferStorage;
|
||
_cashWithdrawalStorage = cashWithdrawalStorage;
|
||
_accountStorage = accountStorage;
|
||
|
||
_saveToExcel = saveToExcel;
|
||
_saveToWord = saveToWord;
|
||
_saveToPdf = saveToPdf;
|
||
}
|
||
|
||
//формирование списка переводов между счетами за период
|
||
public List<ReportCashierViewModel>? GetMoneyTransfers(ReportBindingModel model)
|
||
{
|
||
return _moneyTransferStorage.GetFilteredList(new MoneyTransferSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo})
|
||
.Select(x => new ReportCashierViewModel
|
||
{
|
||
OperationId = x.Id,
|
||
DateComplite = x.DateOperation,
|
||
AccountPayeeNumber = x.AccountPayeeNumber,
|
||
AccountSenderNumber = x.AccountSenderNumber,
|
||
SumOperation = x.Sum
|
||
})
|
||
.ToList();
|
||
}
|
||
|
||
//формирование списка выдаци наличных со счёта за период
|
||
public List<ReportCashierViewModel>? GetCashWithrawals(ReportBindingModel model)
|
||
{
|
||
return _cashWithdrawalStorage.GetFilteredList(new CashWithdrawalSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo })
|
||
.Select(x => new ReportCashierViewModel
|
||
{
|
||
OperationId = x.Id,
|
||
DebitingId = x.DebitingId,
|
||
AccountPayeeNumber = x.AccountNumber,
|
||
DateComplite = x.DateOperation,
|
||
SumOperation = x.Sum
|
||
})
|
||
.ToList();
|
||
}
|
||
|
||
//Сохранение мороженных в файл-Word
|
||
public void SaveAccountsToWordFile(ReportBindingModel model)
|
||
{
|
||
throw new NotImplementedException();
|
||
}
|
||
|
||
//Сохранение заготовок с указаеним изделий в файл-Excel
|
||
public void SaveAccountsToExcelFile(ReportBindingModel model)
|
||
{
|
||
throw new NotImplementedException();
|
||
}
|
||
|
||
//Сохранение заказов в файл-Pdf
|
||
public void SaveAccountsToPdfFile(ReportBindingModel model)
|
||
{
|
||
_saveToPdf.CreateDoc(new PdfInfo
|
||
{
|
||
ForClient = false,
|
||
FileName = model.FileName,
|
||
Title = "Отчёт по операциям начислений и переводов между счетами",
|
||
DateFrom = model.DateFrom!.Value,
|
||
DateTo = model.DateTo!.Value,
|
||
ReportMoneyTransfer = GetMoneyTransfers(model),
|
||
ReportCashWithdrawal = GetCashWithrawals(model)
|
||
});
|
||
}
|
||
}
|
||
}
|