Add transfer tracking and secure admin access
This commit is contained in:
@@ -17,12 +17,49 @@ public enum AppMode
|
||||
}
|
||||
|
||||
/// <summary>账单类型</summary>
|
||||
public enum TransactionType
|
||||
public enum TransactionType
|
||||
{
|
||||
Expense = 0,
|
||||
Income = 1,
|
||||
Transfer = 2,
|
||||
}
|
||||
}
|
||||
|
||||
public enum TransferDirection
|
||||
{
|
||||
In = 0,
|
||||
Out = 1,
|
||||
}
|
||||
|
||||
public static class TransactionTypeRules
|
||||
{
|
||||
public static bool IsExpense(this TransactionType type, TransferDirection? direction = null) =>
|
||||
type == TransactionType.Expense ||
|
||||
type == TransactionType.Transfer && direction == TransferDirection.Out;
|
||||
|
||||
public static bool IsIncome(this TransactionType type, TransferDirection? direction = null) =>
|
||||
type == TransactionType.Income ||
|
||||
type == TransactionType.Transfer && direction == TransferDirection.In;
|
||||
|
||||
public static TransactionType CategoryType(
|
||||
this TransactionType type,
|
||||
TransferDirection? direction = null) => type == TransactionType.Transfer
|
||||
? direction == TransferDirection.In ? TransactionType.Income : TransactionType.Expense
|
||||
: type;
|
||||
|
||||
public static string ToWire(this TransactionType type) => type switch
|
||||
{
|
||||
TransactionType.Income => "income",
|
||||
TransactionType.Transfer => "transfer",
|
||||
_ => "expense",
|
||||
};
|
||||
|
||||
public static string? ToWire(this TransferDirection? direction) => direction switch
|
||||
{
|
||||
TransferDirection.In => "in",
|
||||
TransferDirection.Out => "out",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>账单来源(决策:AI 记账可追溯)</summary>
|
||||
public enum TransactionSource
|
||||
|
||||
Reference in New Issue
Block a user