1
0
forked from BRT/arc
arc/android/dushanbe/GetLastTransactionsScript.h

58 lines
2.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include "CommonScript.h"
#include <QDateTime>
#include <QJsonObject>
#include <QList>
#include <QPair>
#include "db/DeviceInfo.h"
#include "db/BankProfileInfo.h"
namespace Dushanbe {
class GetLastTransactionsScript final : public CommonScript {
Q_OBJECT
public:
explicit GetLastTransactionsScript(
QString deviceId,
QString appCode,
QList<QPair<double, QDateTime>> targets = {},
QString materialId = {},
QObject *parent = nullptr
);
~GetLastTransactionsScript() override;
signals:
// Испускается на КАЖДУЮ найденную транзакцию из списка целей.
// EventHandler использует эти данные напрямую для task_result вместо
// повторного чтения из БД.
void transactionParsed(const QJsonObject &tx);
protected:
void doStart() override;
private:
enum class SearchResult { Found, NotFound, PastWindow };
// Поиск одной цели по сумме и времени на экране "Выписка".
// Found — нашли, transactionParsed эмитирован.
// NotFound — не нашли, список прокручен до maxScrolls.
// PastWindow — список старше окна today+yesterday, retry бессмысленен.
// Прерывание выставляет m_error="Interrupted" и возвращает NotFound.
SearchResult searchOne(const DeviceInfo &device, int accountId,
double searchAmount, const QDateTime &searchTime);
// Возврат к началу списка "Выписка" между поисками целей.
void scrollHistoryToTop(const DeviceInfo &device);
QString m_deviceId;
const QString m_appCode;
// Список целей: пары (сумма в сомони со знаком, примерное время UTC).
const QList<QPair<double, QDateTime>> m_targets;
const QString m_materialId; // UUID задачи (для сохранения дампов)
QString m_error;
};
} // namespace Dushanbe