FOSSredder 0.5.0
Loading...
Searching...
No Matches
DraftMatcherResolution.cpp
Go to the documentation of this file.
1
5
6#include "core/pch.h"
9
11
12namespace policy = core::domain::policies::matching;
13
14std::string resolveActorId(const core::domain::catalog::WorkspaceCatalog& state, const std::string& text)
15{
16 const auto key = policy::normalizeText(text);
17 if (key.empty()) return {};
18
19 for (const auto& actor : state.actors()) {
20 if (!actor) continue;
21 if (policy::normalizeText(actor->name()) == key) return actor->id();
22 for (const auto& alias : actor->aliases()) {
23 if (policy::normalizeText(alias.value()) == key) return actor->id();
24 }
25 }
26 return {};
27}
28
29std::string resolveContractId(const core::domain::catalog::WorkspaceCatalog& state, const std::string& text)
30{
31 const auto key = policy::normalizeText(text);
32 if (key.empty()) return {};
33
34 for (const auto& contract : state.contracts()) {
35 if (!contract) continue;
36 if (policy::normalizeText(contract->type()) == key) return contract->id();
37 if (policy::normalizeText(contract->name()) == key) return contract->id();
38 for (const auto& alias : contract->aliases()) {
39 if (policy::normalizeText(alias.value()) == key) return contract->id();
40 }
41 }
42 return {};
43}
44
45bool contractIsFullyAllocatable(const core::domain::catalog::WorkspaceCatalog& state, const std::string& contractId)
46{
47 if (contractId.empty()) return false;
48
49 bool hasTransactions = false;
50 for (const auto& transaction : state.transactions()) {
51 if (!transaction || transaction->contractId() != contractId) continue;
52 hasTransactions = true;
53 if (!transaction->isAllocatable()) return false;
54 }
55 return hasTransactions;
56}
57
60{
61 if (primary.actors().empty()) primary.setActors(secondary.actors());
62 if (primary.properties().empty()) primary.setProperties(secondary.properties());
63 if (primary.contracts().empty()) primary.setContracts(secondary.contracts());
64 if (primary.statements().empty()) primary.setStatements(secondary.statements());
65 if (primary.transactions().empty()) primary.setTransactions(secondary.transactions());
66 if (primary.analyses().empty()) primary.setAnalyses(secondary.analyses());
67 if (primary.annuals().empty()) primary.setAnnuals(secondary.annuals());
68 return primary;
69}
70
71}
Declares import-draft matching helpers shared by the import pipeline and draft finalization.
Declares draft matching policy helpers for import-time bank statement inference.
void setAnnuals(AnnualList value)
Replaces all annuals in the catalog.
const PropertyList & properties() const noexcept
Returns all properties in the catalog.
void setAnalyses(AnalysisList value)
Replaces all analyses in the catalog.
void setProperties(PropertyList value)
Replaces all properties in the catalog.
void setStatements(StatementList value)
Replaces all statements in the catalog.
const AnnualList & annuals() const noexcept
Returns all annuals in the catalog.
const StatementList & statements() const noexcept
Returns all statements in the catalog.
const TransactionList & transactions() const noexcept
Returns all transactions in the catalog.
void setActors(ActorList value)
Replaces all actors in the catalog.
const ActorList & actors() const noexcept
Returns all actors in the catalog.
void setContracts(ContractList value)
Replaces all contracts in the catalog.
const ContractList & contracts() const noexcept
Returns all contracts in the catalog.
const AnalysisList & analyses() const noexcept
Returns all analyses in the catalog.
void setTransactions(TransactionList value)
Replaces all transactions in the catalog.
Collects common core includes and aliases for precompiled-header builds.
core::domain::catalog::WorkspaceCatalog mergeCatalogState(core::domain::catalog::WorkspaceCatalog primary, const core::domain::catalog::WorkspaceCatalog &secondary)
Merges two catalog states by keeping populated primary collections and filling gaps from a secondary ...
bool contractIsFullyAllocatable(const core::domain::catalog::WorkspaceCatalog &state, const std::string &contractId)
Checks whether all transactions assigned to a contract are allocatable.
std::string resolveContractId(const core::domain::catalog::WorkspaceCatalog &state, const std::string &text)
Resolves the best matching contract identifier for the provided text.
std::string resolveActorId(const core::domain::catalog::WorkspaceCatalog &state, const std::string &text)
Resolves the best matching actor identifier for the provided text.