support importing transaction by csv/tsv file via command line

This commit is contained in:
MaysWind
2024-09-02 00:40:00 +08:00
parent 366311edbb
commit 7c59e8386e
27 changed files with 1496 additions and 208 deletions
+19
View File
@@ -1,6 +1,7 @@
package models
import (
"fmt"
"strings"
"github.com/mayswind/ezbookkeeping/pkg/errs"
@@ -30,6 +31,24 @@ const (
TRANSACTION_DB_TYPE_TRANSFER_IN TransactionDbType = 5
)
// String returns a textual representation of the transaction types for db enum
func (s TransactionDbType) String() string {
switch s {
case TRANSACTION_DB_TYPE_MODIFY_BALANCE:
return "Modify Balance"
case TRANSACTION_DB_TYPE_INCOME:
return "Income"
case TRANSACTION_DB_TYPE_EXPENSE:
return "Expense"
case TRANSACTION_DB_TYPE_TRANSFER_OUT:
return "Transfer Out"
case TRANSACTION_DB_TYPE_TRANSFER_IN:
return "Transfer In"
default:
return fmt.Sprintf("Invalid(%d)", int(s))
}
}
// Transaction represents transaction data stored in database
type Transaction struct {
TransactionId int64 `xorm:"PK"`