2023-04-04 23:22:23 +04:00
|
|
|
|
using BankYouBankruptBusinessLogic.OfficePackage;
|
|
|
|
|
using BankYouBankruptBusinessLogic.OfficePackage.HelperModels;
|
|
|
|
|
using BankYouBankruptContracts.BindingModels;
|
|
|
|
|
using BankYouBankruptContracts.BusinessLogicsContracts;
|
|
|
|
|
using BankYouBankruptContracts.SearchModels;
|
|
|
|
|
using BankYouBankruptContracts.StoragesContracts;
|
|
|
|
|
using BankYouBankruptContracts.ViewModels;
|
2023-05-19 20:41:17 +04:00
|
|
|
|
using BankYouBankruptDataModels.Enums;
|
2023-04-04 23:22:23 +04:00
|
|
|
|
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;
|
|
|
|
|
|
2023-05-18 14:45:28 +04:00
|
|
|
|
private readonly IClientStorage _clientStorage;
|
2023-04-04 23:22:23 +04:00
|
|
|
|
|
2023-05-19 13:04:22 +04:00
|
|
|
|
private readonly AbstractSaveToExcel _saveToExcel;
|
2023-04-04 23:22:23 +04:00
|
|
|
|
|
|
|
|
|
private readonly AbstractSaveToWordCashier _saveToWord;
|
|
|
|
|
|
2023-05-19 13:04:22 +04:00
|
|
|
|
private readonly AbstractSaveToPdf _saveToPdf;
|
2023-04-04 23:22:23 +04:00
|
|
|
|
|
|
|
|
|
//инициализируем поля класса через контейнер
|
|
|
|
|
public ReportCashierLogic(IMoneyTransferStorage moneyTransferStorage, ICashWithdrawalStorage cashWithdrawalStorage,
|
2023-05-19 13:04:22 +04:00
|
|
|
|
IClientStorage clientStorage, AbstractSaveToExcel saveToExcel,
|
|
|
|
|
AbstractSaveToWordCashier saveToWord, AbstractSaveToPdf saveToPdf)
|
2023-04-04 23:22:23 +04:00
|
|
|
|
{
|
|
|
|
|
_moneyTransferStorage = moneyTransferStorage;
|
|
|
|
|
_cashWithdrawalStorage = cashWithdrawalStorage;
|
|
|
|
|
|
|
|
|
|
_saveToExcel = saveToExcel;
|
|
|
|
|
_saveToWord = saveToWord;
|
|
|
|
|
_saveToPdf = saveToPdf;
|
2023-05-18 14:45:28 +04:00
|
|
|
|
_clientStorage = clientStorage;
|
2023-04-04 23:22:23 +04:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-18 12:48:45 +04:00
|
|
|
|
//формирование списка переводов между счетами за период
|
2023-04-04 23:22:23 +04:00
|
|
|
|
public List<ReportCashierViewModel>? GetMoneyTransfers(ReportBindingModel model)
|
|
|
|
|
{
|
2023-05-18 14:45:28 +04:00
|
|
|
|
return _moneyTransferStorage.GetFilteredList(new MoneyTransferSearchModel { ClientId = model.ClientId, DateFrom = model.DateFrom, DateTo = model.DateTo})
|
2023-04-04 23:22:23 +04:00
|
|
|
|
.Select(x => new ReportCashierViewModel
|
|
|
|
|
{
|
2023-05-18 12:48:45 +04:00
|
|
|
|
OperationId = x.Id,
|
2023-04-04 23:30:30 +04:00
|
|
|
|
DateComplite = x.DateOperation,
|
2023-05-18 12:48:45 +04:00
|
|
|
|
AccountPayeeNumber = x.AccountPayeeNumber,
|
|
|
|
|
AccountSenderNumber = x.AccountSenderNumber,
|
2023-04-04 23:39:03 +04:00
|
|
|
|
SumOperation = x.Sum
|
2023-04-04 23:22:23 +04:00
|
|
|
|
})
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-18 12:48:45 +04:00
|
|
|
|
//формирование списка выдаци наличных со счёта за период
|
2023-04-04 23:22:23 +04:00
|
|
|
|
public List<ReportCashierViewModel>? GetCashWithrawals(ReportBindingModel model)
|
|
|
|
|
{
|
2023-05-18 14:45:28 +04:00
|
|
|
|
return _cashWithdrawalStorage.GetFilteredList(new CashWithdrawalSearchModel { ClientId = model.ClientId, DateFrom = model.DateFrom, DateTo = model.DateTo })
|
2023-04-04 23:30:30 +04:00
|
|
|
|
.Select(x => new ReportCashierViewModel
|
2023-04-04 23:22:23 +04:00
|
|
|
|
{
|
2023-05-18 12:48:45 +04:00
|
|
|
|
OperationId = x.Id,
|
|
|
|
|
DebitingId = x.DebitingId,
|
|
|
|
|
AccountPayeeNumber = x.AccountNumber,
|
2023-04-04 23:30:30 +04:00
|
|
|
|
DateComplite = x.DateOperation,
|
2023-04-04 23:39:03 +04:00
|
|
|
|
SumOperation = x.Sum
|
2023-04-04 23:22:23 +04:00
|
|
|
|
})
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-19 20:40:03 +04:00
|
|
|
|
//формирование списка выдаци наличных со счёта за период
|
2023-05-19 20:41:17 +04:00
|
|
|
|
public List<ReportCashierViewModel>? GetDebitings(ReportBindingModel model)
|
2023-05-19 20:40:03 +04:00
|
|
|
|
{
|
|
|
|
|
return _moneyTransferStorage.GetFilteredList(new MoneyTransferSearchModel { ClientId = model.ClientId, 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();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-18 14:45:28 +04:00
|
|
|
|
//формирование полного имени клиента для отчёта
|
|
|
|
|
public string GetFullName(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
var client = _clientStorage.GetElement(new ClientSearchModel
|
|
|
|
|
{
|
|
|
|
|
Id = model.ClientId
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return client.Surname + " " + client.Name + " " + client.Patronymic;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-04 23:22:23 +04:00
|
|
|
|
//Сохранение мороженных в файл-Word
|
|
|
|
|
public void SaveAccountsToWordFile(ReportBindingModel model)
|
|
|
|
|
{
|
2023-04-04 23:39:03 +04:00
|
|
|
|
throw new NotImplementedException();
|
2023-04-04 23:22:23 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Сохранение заготовок с указаеним изделий в файл-Excel
|
|
|
|
|
public void SaveAccountsToExcelFile(ReportBindingModel model)
|
|
|
|
|
{
|
2023-05-19 20:40:03 +04:00
|
|
|
|
_saveToExcel.CreateReport(new ExcelInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
|
|
|
|
|
|
|
|
|
Title = "Заявки на счёт",
|
|
|
|
|
|
2023-05-19 20:41:17 +04:00
|
|
|
|
Debiting = null
|
|
|
|
|
}, ExcelOperationEnum.Для_кассира);
|
2023-04-04 23:22:23 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Сохранение заказов в файл-Pdf
|
2023-05-18 23:52:40 +04:00
|
|
|
|
public ReportCashierViewModelForHTML SaveAccountsToPdfFile(ReportBindingModel model)
|
2023-04-04 23:22:23 +04:00
|
|
|
|
{
|
2023-05-18 23:52:40 +04:00
|
|
|
|
var listMoneyTransfers = GetMoneyTransfers(model);
|
|
|
|
|
var listCashWithdrawals = GetCashWithrawals(model);
|
|
|
|
|
|
2023-05-18 12:48:45 +04:00
|
|
|
|
_saveToPdf.CreateDoc(new PdfInfo
|
|
|
|
|
{
|
|
|
|
|
ForClient = false,
|
|
|
|
|
FileName = model.FileName,
|
2023-05-18 14:45:28 +04:00
|
|
|
|
FullClientName = GetFullName(model),
|
2023-05-18 12:48:45 +04:00
|
|
|
|
Title = "Отчёт по операциям начислений и переводов между счетами",
|
|
|
|
|
DateFrom = model.DateFrom!.Value,
|
|
|
|
|
DateTo = model.DateTo!.Value,
|
2023-05-18 23:52:40 +04:00
|
|
|
|
ReportMoneyTransfer = listMoneyTransfers,
|
|
|
|
|
ReportCashWithdrawal = listCashWithdrawals
|
2023-05-18 12:48:45 +04:00
|
|
|
|
});
|
2023-05-18 23:52:40 +04:00
|
|
|
|
|
|
|
|
|
//возврат полученных списков для отображения на вебе
|
|
|
|
|
return new ReportCashierViewModelForHTML
|
|
|
|
|
{
|
|
|
|
|
ReportCashWithdrawal = listCashWithdrawals,
|
|
|
|
|
|
|
|
|
|
ReportMoneyTransfer = listMoneyTransfers
|
|
|
|
|
};
|
2023-04-04 23:22:23 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|