FOSSredder 0.5.0
Loading...
Searching...
No Matches
Transaction.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include <algorithm>
9#include <string>
10#include <utility>
11#include <vector>
12
17
18namespace core::domain {
19
21public:
22 enum class Status : int {
27 };
28
29 Transaction() noexcept;
38 Transaction(std::string nameValue,
39 std::string bookingDateValue,
40 std::string valutaValue,
41 double amountValue,
42 bool allocatableValue = false);
43
44 Transaction(const Transaction&) = delete;
45 Transaction& operator=(const Transaction&) = delete;
47 Transaction& operator=(Transaction&&) = delete;
48
53 void setName(EntityName value);
58 void setName(std::string value);
63 void setBookingDate(BookingDate value);
68 void setBookingDate(std::string value);
73 void setValuta(std::string value);
78 void setAmount(MoneyAmount value);
83 void setAmount(double value);
88 void setStatus(Status value);
93 void setContractId(std::string value);
98 void setActorId(std::string value);
103 void setStatementId(std::string value);
108 void setAllocatable(bool value);
112 void clearContract();
116 void clearActor();
120 void clearStatement();
124 void clearProperties();
125
131 [[nodiscard]] bool hasStatus(Status value) const noexcept;
132
137 [[nodiscard]] bool hasStatement() const noexcept;
142 [[nodiscard]] bool hasContract() const noexcept;
147 [[nodiscard]] bool hasActor() const noexcept;
152 [[nodiscard]] bool hasProperties() const noexcept;
157 [[nodiscard]] std::size_t propertyCount() const noexcept;
163 [[nodiscard]] bool belongsToStatement(const std::string& value) const;
168 [[nodiscard]] bool isAllocatable() const noexcept;
172 void markUnverified();
176 void markVerified();
180 void markCompleted();
185 [[nodiscard]] bool hasRelations() const noexcept;
190 [[nodiscard]] bool isStandalone() const noexcept;
191
196 void setPropertyIds(std::vector<std::string> value);
197
202 void addPropertyId(std::string value);
203
208 void removePropertyId(const std::string& value);
209
215 [[nodiscard]] bool containsPropertyId(const std::string& value) const;
216
217private:
218 std::string id_;
219 std::string name_;
220 std::string bookingDate_;
221 std::string valuta_;
222 double amount_ = 0.0;
223 Status status_ = Status::Neutral;
224 std::string contractId_;
225 std::string actorId_;
226 std::string statementId_;
227 bool allocatable_ = false;
228 std::vector<std::string> propertyIds_;
229 std::string createdAt_;
230 std::string updatedAt_;
231
232public:
233 // Read accessors
234 [[nodiscard]] const std::string& id() const noexcept;
235 [[nodiscard]] const std::string& name() const noexcept;
236 [[nodiscard]] const std::string& bookingDate() const noexcept;
237 [[nodiscard]] const std::string& valuta() const noexcept;
238 [[nodiscard]] const double& amount() const noexcept;
239 [[nodiscard]] const Status& status() const noexcept;
240 [[nodiscard]] const std::string& contractId() const noexcept;
241 [[nodiscard]] const std::string& actorId() const noexcept;
242 [[nodiscard]] const std::string& statementId() const noexcept;
243 [[nodiscard]] const std::vector<std::string>& propertyIds() const noexcept;
244 [[nodiscard]] const std::string& createdAt() const noexcept;
245 [[nodiscard]] const std::string& updatedAt() const noexcept;
246
247 // Technical hydration
248 void setId(std::string value);
249 void setCreatedAt(std::string value);
250 void setUpdatedAt(std::string value);
251};
252
253} // namespace core::domain
Value object for normalized booking dates.
Small value object for normalized entity display names.
Value object for monetary transaction amounts.
Shared transaction transition and normalization helpers.
bool hasRelations() const noexcept
Checks whether the transaction has any relations.
void clearActor()
Clears the linked actor id.
void setAmount(MoneyAmount value)
Sets the amount from a value object.
void setStatementId(std::string value)
Sets the statement id.
bool isStandalone() const noexcept
Checks whether the transaction is standalone.
void removePropertyId(const std::string &value)
Removes a property id from the transaction.
void setActorId(std::string value)
Sets the actor id.
bool containsPropertyId(const std::string &value) const
Checks whether a property id exists.
bool hasStatus(Status value) const noexcept
Checks whether the transaction has a given status.
void clearProperties()
Clears linked property ids.
void setName(EntityName value)
Sets the transaction name from a value object.
void setStatus(Status value)
Sets the transaction status.
void setValuta(std::string value)
Sets the valuta text.
void setContractId(std::string value)
Sets the contract id.
std::size_t propertyCount() const noexcept
Returns the number of linked properties.
bool hasProperties() const noexcept
Checks whether the transaction is linked to properties.
const std::string & name() const noexcept
const std::vector< std::string > & propertyIds() const noexcept
const std::string & statementId() const noexcept
void markVerified()
Advances the transaction to verified status when allowed.
void setPropertyIds(std::vector< std::string > value)
Replaces the property id list with normalized values.
const std::string & actorId() const noexcept
void addPropertyId(std::string value)
Adds a property id when it is not already present.
const std::string & updatedAt() const noexcept
bool belongsToStatement(const std::string &value) const
Checks whether the transaction belongs to a statement.
bool isAllocatable() const noexcept
Checks whether the transaction can be allocated.
const std::string & createdAt() const noexcept
const std::string & bookingDate() const noexcept
const std::string & valuta() const noexcept
void markUnverified()
Advances the transaction to unverified status when allowed.
void markCompleted()
Advances the transaction to completed status when allowed.
bool hasActor() const noexcept
Checks whether the transaction is linked to an actor.
bool hasStatement() const noexcept
Checks whether the transaction is linked to a statement.
const Status & status() const noexcept
void setCreatedAt(std::string value)
void setBookingDate(BookingDate value)
Sets the booking date from a value object.
void setId(std::string value)
void setUpdatedAt(std::string value)
void setAllocatable(bool value)
Sets the allocatable flag.
bool hasContract() const noexcept
Checks whether the transaction is linked to a contract.
const double & amount() const noexcept
const std::string & contractId() const noexcept
void clearContract()
Clears the linked contract id.
void clearStatement()
Clears the linked statement id.