hidden transaction tags are not allowed when importing transactions or using the add_transaction mcp tool
This commit is contained in:
@@ -1447,7 +1447,7 @@ func (a *TransactionsApi) TransactionParseImportFileHandler(c *core.WebContext)
|
||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||
}
|
||||
|
||||
tagMap := a.transactionTags.GetTagNameMapByList(tags)
|
||||
tagMap := a.transactionTags.GetVisibleTagNameMapByList(tags)
|
||||
|
||||
parsedTransactions, _, _, _, _, _, err := dataImporter.ParseImportedData(c, user, fileData, utcOffset, accountMap, expenseCategoryMap, incomeCategoryMap, transferCategoryMap, tagMap)
|
||||
|
||||
|
||||
@@ -957,7 +957,7 @@ func (l *UserDataCli) getUserEssentialDataForImport(c *core.CliContext, uid int6
|
||||
return nil, nil, nil, nil, nil, err
|
||||
}
|
||||
|
||||
tagMap = l.tags.GetTagNameMapByList(tags)
|
||||
tagMap = l.tags.GetVisibleTagNameMapByList(tags)
|
||||
|
||||
return accountMap, expenseCategoryMap, incomeCategoryMap, transferCategoryMap, tagMap, nil
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ func (h *mcpAddTransactionToolHandler) Handle(c *core.WebContext, callToolReq *M
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
tagMaps := services.GetTransactionTagService().GetTagNameMapByList(allTags)
|
||||
tagMaps := services.GetTransactionTagService().GetVisibleTagNameMapByList(allTags)
|
||||
tagIds = make([]int64, 0, len(addTransactionRequest.Tags))
|
||||
|
||||
for _, tagName := range addTransactionRequest.Tags {
|
||||
|
||||
@@ -508,14 +508,20 @@ func (s *TransactionTagService) GetTagMapByList(tags []*models.TransactionTag) m
|
||||
return tagMap
|
||||
}
|
||||
|
||||
// GetTagNameMapByList returns a transaction tag map by a list
|
||||
func (s *TransactionTagService) GetTagNameMapByList(tags []*models.TransactionTag) map[string]*models.TransactionTag {
|
||||
// GetVisibleTagNameMapByList returns a visible transaction tag map by a list
|
||||
func (s *TransactionTagService) GetVisibleTagNameMapByList(tags []*models.TransactionTag) map[string]*models.TransactionTag {
|
||||
tagMap := make(map[string]*models.TransactionTag)
|
||||
|
||||
for i := 0; i < len(tags); i++ {
|
||||
tag := tags[i]
|
||||
|
||||
if tag.Hidden {
|
||||
continue
|
||||
}
|
||||
|
||||
tagMap[tag.Name] = tag
|
||||
}
|
||||
|
||||
return tagMap
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user