#20 Add transaction type
This commit is contained in:
@@ -39,6 +39,8 @@ public class Transaction {
|
||||
// the inline expense history chart and the expense/income/liability chart
|
||||
// No UI to set the flag as its use is only for very special cases
|
||||
private boolean expenseNeutral;
|
||||
@Enumerated(EnumType.STRING)
|
||||
private TransactionType transactionType;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@@ -123,4 +125,12 @@ public class Transaction {
|
||||
public void setExpenseNeutral(boolean expenseNeutral) {
|
||||
this.expenseNeutral = expenseNeutral;
|
||||
}
|
||||
|
||||
public TransactionType getTransactionType() {
|
||||
return transactionType;
|
||||
}
|
||||
|
||||
public void setTransactionType(TransactionType transactionType) {
|
||||
this.transactionType = transactionType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package de.financer.model;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* This enum specifies constants that specify the type of a transaction. Actual specification which type is used when
|
||||
* is implemented in <code>financer-server#RuleService</code>
|
||||
*/
|
||||
public enum TransactionType {
|
||||
/**
|
||||
* Specifies that a transaction swaps money from one asset account (e.g. {@link AccountType#BANK BANK})
|
||||
* to another one (e.g. {@link AccountType#CASH CASH})
|
||||
*/
|
||||
ASSET_SWAP,
|
||||
|
||||
/**
|
||||
* Specifies that a transaction captured the process of buying something
|
||||
*/
|
||||
EXPENSE,
|
||||
|
||||
/**
|
||||
* Specifies that a transaction was made to pay back a liability
|
||||
*/
|
||||
LIABILITY,
|
||||
|
||||
/**
|
||||
* Specifies a transaction that increases the assets
|
||||
*/
|
||||
INCOME,
|
||||
|
||||
/**
|
||||
* Specifies that a transaction was used to book the starting amount to a liability account.
|
||||
*/
|
||||
START_LIABILITY;
|
||||
|
||||
/**
|
||||
* This method validates whether the given string represents a valid transaction type.
|
||||
*
|
||||
* @param type to check
|
||||
* @return whether the given type represents a valid transaction type
|
||||
*/
|
||||
public static boolean isValidType(String type) {
|
||||
return Arrays.stream(TransactionType.values()).anyMatch((accountType) -> accountType.name().equals(type));
|
||||
}
|
||||
|
||||
public static List<String> valueList() {
|
||||
return Arrays.stream(TransactionType.values()).map(TransactionType::name).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user