81 std::shared_ptr<ui::adapters::ImportAdapter> importAdapter,
82 std::shared_ptr<core::ports::diagnostics::IErrorReporter> errorReporter,
108 QString
phase() const;
111 QString
error() const;
253 const QString& contractType,
254 const QString& allocatableMode);
279 const QString& draftId);
289 void addFiles(const QStringList& paths);
354 const QString& message);
361 bool hasActiveImportHandle() const noexcept;
365 void clearActiveImportSubscription();
371 void rejectImportStart(const QString& errorMessage, const
char* traceMessage);
378 void requestImportCancellation(
bool clearQueue, const
char* origin,
379 const
char* traceMessage);
384 void setImportPaused(
bool paused);
394 void handleImportCanceled();
400 void handleImportFailed(const QString& errorMessage,
401 const
char* traceMessage);
406 bool populateDraftFromResult();
410 void startNextQueuedImport();
415 void startImportForFile(const QString& path);
421 void reportException(const
char* origin, std::exception_ptr exception) const;
432 void saveImportLog(const QString& logId, const QString& status,
433 const QString& message,
bool draftAttached = false,
434 const QString& draftId = {},
435 const QString& statementId = {},
436 const QString& importFile = {});
441 void clearStoredDraft(
const QString& draftId);
445 void rememberCurrentDraftTransactionIndex();
451 bool applyCurrentTransactionPatch(
452 const core::ports::importing::draft::TransactionDraftPatch& patch);
457 core::ports::importing::draft::TransactionDraft* currentTransactionDraft();
462 const core::ports::importing::draft::TransactionDraft*
463 currentTransactionDraft()
const;
468 core::ports::workspace::WorkspaceSnapshot stateSnapshot()
const;
473 core::ports::workspace::WorkspaceSnapshot catalogSnapshotForDraft()
const;
477 void notifyDraftChanged();
482 core::ports::workspace::StatementDraftSnapshot
483 currentStatementDraftSnapshot()
const;
488 QString finalizeCurrentStatementDraft();
493 core::ports::importing::draft::StatementDraft* statementDraft() noexcept;
498 const core::ports::importing::draft::StatementDraft*
499 statementDraft() const noexcept;
505 bool restoreDraftFromState(
506 const core::ports::workspace::WorkspaceSnapshot& snapshot);
511 QString resolveDraftContextId() const;
517 int rememberedDraftTransactionIndex(const QString& draftId) const;
519 std::unique_ptr<importing::ImportWorkflowState> state_;
520 std::shared_ptr<ui::adapters::ImportAdapter> importAdapter_;
522 WorkspaceCommands* commands_ =
nullptr;
523 WorkspaceSelectors* selectors_ =
nullptr;
524 std::shared_ptr<core::ports::diagnostics::IErrorReporter> errorReporter_;
526 QString activeDraftId_;
527 QHash<QString,
int> draftTransactionIndexByDraftId_;
528 QString activeImportLogId_;
529 bool activeImportTerminalHandled_ = false;
530 bool hasPendingTerminalEvent_ = false;
531 bool hasActiveImportHandle_ = false;
532 core::ports::importing::StatementImportHandle activeImportHandle_;
533 core::ports::importing::StatementImportState pendingTerminalState_ =
534 core::ports::importing::StatementImportState::Pending;
535 QString pendingTerminalMessage_;
Declares the structured diagnostics reporting port.
Import runner port consumed by UI workflows.
Immutable workspace read-model snapshot exposed through workspace ports.
bool clearCurrentTransactionContract()
Clears the contract selection for the current transaction draft.
void startStatementImport()
Starts importing the selected or next queued statement file.
void discardActiveDraft()
Discards the active draft and removes its workspace draft state.
bool createActorForCurrentTransaction(const QString &actorName)
Creates or reuses an actor and selects it for the current draft.
bool setCurrentTransactionPropertySelected(const QString &propertyId, bool selected)
Selects or deselects a property for the current transaction draft.
ImportWorkflow(std::shared_ptr< ui::adapters::ImportAdapter > importAdapter, std::shared_ptr< core::ports::diagnostics::IErrorReporter > errorReporter, StateSnapshotProvider stateSnapshotProvider={}, WorkspaceCommands *commands=nullptr, WorkspaceSelectors *selectors=nullptr, QObject *parent=nullptr)
Creates an import workflow.
void cancelImport()
Cancels the current running import.
void setSelectedFile(const QString &path)
Sets the selected import file.
QString currentDraftId() const
Returns the active draft id.
void setWorkspaceRoles(WorkspaceCommands *commands, WorkspaceSelectors *selectors)
Rebinds workspace roles used by the workflow.
bool commitCurrentTransactionName(const QString &name)
Updates the current transaction draft name.
void addFiles(const QStringList &paths)
Adds files to the import selection or queue.
bool clearCurrentTransactionActor()
Clears the actor selection for the current transaction draft.
bool openStoredDraft(const QString &draftId={})
Opens a statement draft stored in workspace state.
void finalizeActiveDraft()
Finalizes the active draft into workspace statement data.
void resumeImport()
Resumes the current paused import.
bool commitCurrentTransactionValuta(const QString &valuta)
Updates the current transaction draft valuta date.
bool createOrSelectContractForCurrentTransaction(const QString &contractName, const QString &contractType, const QString &allocatableMode)
Creates or reuses a contract and selects it for the current draft.
bool selectCurrentTransactionContract(const QString &contractId)
Selects a contract for the current transaction draft.
bool setCurrentTransactionStatus(int status)
Updates the current transaction draft status.
void setCurrentTransactionIndex(int index)
Selects the current transaction draft by index.
void importFailed(const QString &error)
Emitted when an import failed.
void pauseImport()
Pauses the current running import.
bool isRunning() const noexcept
Reports whether an import is running.
QString selectedFile() const
Returns the selected import file.
TransactionDraftView currentTransactionView() const
Builds the QML-facing view of the current transaction draft.
void clearDraft()
Clears the active draft and may continue queued imports.
double progress() const noexcept
Returns import progress.
bool selectCurrentTransactionActor(const QString &actorId)
Selects an actor for the current transaction draft.
bool hasDraft() const noexcept
Reports whether an active statement draft exists.
int queuedCount() const noexcept
Returns queued import file count.
bool applyCurrentTransactionAmountText(const QString &amountText)
Applies user-entered amount text to the current transaction draft.
void stateChanged()
Emitted when import workflow state changed.
void removeAttachedImportLog(const QString &logId, bool draftAttached, const QString &draftId)
Removes an import log and optionally its attached draft.
void cancelQueuedImports()
Cancels the running import and clears queued imports.
void flushActiveDraftToWorkspace()
Saves the active in-memory draft into workspace draft state.
bool createPropertyForCurrentTransaction(const QString &propertyName)
Creates or reuses a property and selects it for the current draft.
bool isPaused() const noexcept
Reports whether the running import is paused.
void importFinished()
Emitted when an import reached a finished state.
bool commitCurrentTransactionBookingDate(const QString &bookingDate)
Updates the current transaction draft booking date.
~ImportWorkflow() override
Destroys the workflow and its internal state.
QString currentStatementName() const
Returns the editable name of the active statement draft.
int insertTransactionAfterCurrent()
Inserts a transaction draft after the current one.
void resetStatus()
Resets import status fields when no import is running.
void pauseActiveDraft()
Saves the active draft and returns to the import overview.
int removeCurrentTransaction()
Removes the current transaction draft.
int currentTransactionIndex() const noexcept
Returns the selected transaction draft index.
QString phase() const
Returns the current import phase text.
QStringList queuedFiles() const
Returns queued import files.
void importCanceled()
Emitted when an import was canceled.
QString error() const
Returns the current import error text.
std::function< core::ports::workspace::WorkspaceSnapshot()> StateSnapshotProvider
bool renameCurrentStatementDraft(const QString &name)
Renames the active statement draft.
int transactionCount() const noexcept
Returns transaction count in the active draft.
bool setCurrentTransactionAllocatable(bool allocatable)
Updates the current transaction draft allocatable flag.
Maps UI intent to core workspace writer commands.
Projects workspace store data into QML-facing read models.
Qt-friendly projection of the currently edited import transaction.
QString propertySuggestionSummary
bool effectiveAllocatable
QString contractSuggestionSummary
double propertySuggestionConfidence
QString allocatableSuggestionSummary
double allocatableSuggestionConfidence
double contractSuggestionConfidence
double actorSuggestionConfidence
QString actorSuggestionSummary