mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 00:12:11 +08:00
add logs
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/converters"
|
"github.com/mayswind/ezbookkeeping/pkg/converters"
|
||||||
@@ -706,17 +707,20 @@ func (l *UserDataCli) ImportTransaction(c *core.CliContext, username string, fil
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(newAccounts) > 0 {
|
if len(newAccounts) > 0 {
|
||||||
log.BootErrorf(c, "[user_data.ImportTransaction] there are %d accounts need to be created, please create them manually", len(newAccounts))
|
accountNames := l.accounts.GetAccountNames(newAccounts)
|
||||||
|
log.BootErrorf(c, "[user_data.ImportTransaction] there are %d accounts (%s) need to be created, please create them manually", len(newAccounts), strings.Join(accountNames, ","))
|
||||||
return errs.ErrOperationFailed
|
return errs.ErrOperationFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(newCategories) > 0 {
|
if len(newCategories) > 0 {
|
||||||
log.BootErrorf(c, "[user_data.ImportTransaction] there are %d transaction categories need to be created, please create them manually", len(newCategories))
|
categoryNames := l.categories.GetCategoryNames(newCategories)
|
||||||
|
log.BootErrorf(c, "[user_data.ImportTransaction] there are %d transaction categories (%s) need to be created, please create them manually", len(newCategories), strings.Join(categoryNames, ","))
|
||||||
return errs.ErrOperationFailed
|
return errs.ErrOperationFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(newTags) > 0 {
|
if len(newTags) > 0 {
|
||||||
log.BootErrorf(c, "[user_data.ImportTransaction] there are %d transaction tags need to be created, please create them manually", len(newTags))
|
tagNames := l.tags.GetTagNames(newTags)
|
||||||
|
log.BootErrorf(c, "[user_data.ImportTransaction] there are %d transaction tags (%s) need to be created, please create them manually", len(newTags), strings.Join(tagNames, ","))
|
||||||
return errs.ErrOperationFailed
|
return errs.ErrOperationFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -474,3 +474,14 @@ func (s *AccountService) GetAccountNameMapByList(accounts []*models.Account) map
|
|||||||
}
|
}
|
||||||
return accountMap
|
return accountMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetAccountNames returns a list with account names from account models list
|
||||||
|
func (s *AccountService) GetAccountNames(accounts []*models.Account) []string {
|
||||||
|
accountNames := make([]string, len(accounts))
|
||||||
|
|
||||||
|
for i := 0; i < len(accounts); i++ {
|
||||||
|
accountNames[i] = accounts[i].Name
|
||||||
|
}
|
||||||
|
|
||||||
|
return accountNames
|
||||||
|
}
|
||||||
|
|||||||
@@ -458,3 +458,14 @@ func (s *TransactionCategoryService) GetCategoryNameMapByList(categories []*mode
|
|||||||
}
|
}
|
||||||
return categoryMap
|
return categoryMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetCategoryNames returns a list with transaction category names from transaction category models list
|
||||||
|
func (s *TransactionCategoryService) GetCategoryNames(categories []*models.TransactionCategory) []string {
|
||||||
|
categoryNames := make([]string, len(categories))
|
||||||
|
|
||||||
|
for i := 0; i < len(categories); i++ {
|
||||||
|
categoryNames[i] = categories[i].Name
|
||||||
|
}
|
||||||
|
|
||||||
|
return categoryNames
|
||||||
|
}
|
||||||
|
|||||||
@@ -426,6 +426,17 @@ func (s *TransactionTagService) GetTagNameMapByList(tags []*models.TransactionTa
|
|||||||
return tagMap
|
return tagMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetTagNames returns a list with tag names from tag models list
|
||||||
|
func (s *TransactionTagService) GetTagNames(tags []*models.TransactionTag) []string {
|
||||||
|
tagNames := make([]string, len(tags))
|
||||||
|
|
||||||
|
for i := 0; i < len(tags); i++ {
|
||||||
|
tagNames[i] = tags[i].Name
|
||||||
|
}
|
||||||
|
|
||||||
|
return tagNames
|
||||||
|
}
|
||||||
|
|
||||||
func (s *TransactionTagService) GetGroupedTransactionTagIds(tagIndexes []*models.TransactionTagIndex) map[int64][]int64 {
|
func (s *TransactionTagService) GetGroupedTransactionTagIds(tagIndexes []*models.TransactionTagIndex) map[int64][]int64 {
|
||||||
allTransactionTagIds := make(map[int64][]int64)
|
allTransactionTagIds := make(map[int64][]int64)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user