2026-10-06 15:39:17 +02:00
|
|
|
//SPDX-License-Identifier: LGPL-3.0-only
|
|
|
|
|
//SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
|
|
|
|
|
|
|
|
|
export module Nostro:Account;
|
|
|
|
|
|
|
|
|
|
import std;
|
|
|
|
|
import :Currency;
|
|
|
|
|
import :Transaction;
|
|
|
|
|
|
|
|
|
|
namespace Nostro {
|
|
|
|
|
export struct Account {
|
|
|
|
|
std::string name;
|
|
|
|
|
std::string bic;
|
|
|
|
|
std::string iban;
|
|
|
|
|
Currency currency;
|
|
|
|
|
std::int64_t balance;
|
|
|
|
|
std::vector<Transaction> transactions;
|
2026-10-31 20:50:57 +01:00
|
|
|
|
|
|
|
|
std::chrono::system_clock::time_point GetLastTransactionTime(std::string_view connector) const;
|
|
|
|
|
void SaveTransactions(std::string_view connector);
|
|
|
|
|
void LoadTransactions(std::string_view connector);
|
|
|
|
|
void LoadTransactions(std::string_view connector, std::chrono::system_clock::time_point from);
|
|
|
|
|
void LoadTransactions(std::string_view connector, std::chrono::system_clock::time_point from, std::chrono::system_clock::time_point to);
|
|
|
|
|
void LoadTransactionsByDescription(std::string_view connector, std::string_view description);
|
|
|
|
|
void LoadTransactionsByIban(std::string_view connector, std::string_view iban);
|
|
|
|
|
void LoadTransactions(std::string_view connector, std::int64_t amount);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::ifstream LoadUntilFrom(std::string_view connector, std::chrono::system_clock::time_point from);
|
|
|
|
|
Transaction& LoadTransaction(std::ifstream& file);
|
2026-10-06 15:39:17 +02:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<std::derived_from<Nostro::Account> T>
|
|
|
|
|
struct std::formatter<T> : std::formatter<std::string> {
|
|
|
|
|
auto format(const Nostro::Account& obj, std::format_context& ctx) const {
|
|
|
|
|
return std::formatter<std::string>::format(std::format("{}\t{} {}\t{}{}", obj.name, obj.bic, obj.iban, obj.currency, Nostro::FormatAmount(obj.balance, obj.currency)), ctx);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|