mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-21 02:04:26 +08:00
show transaction pictures in data management page
This commit is contained in:
@@ -26,6 +26,7 @@ type DataManagementsApi struct {
|
|||||||
users *services.UserService
|
users *services.UserService
|
||||||
accounts *services.AccountService
|
accounts *services.AccountService
|
||||||
transactions *services.TransactionService
|
transactions *services.TransactionService
|
||||||
|
pictures *services.TransactionPictureService
|
||||||
categories *services.TransactionCategoryService
|
categories *services.TransactionCategoryService
|
||||||
tags *services.TransactionTagService
|
tags *services.TransactionTagService
|
||||||
templates *services.TransactionTemplateService
|
templates *services.TransactionTemplateService
|
||||||
@@ -43,6 +44,7 @@ var (
|
|||||||
users: services.Users,
|
users: services.Users,
|
||||||
accounts: services.Accounts,
|
accounts: services.Accounts,
|
||||||
transactions: services.Transactions,
|
transactions: services.Transactions,
|
||||||
|
pictures: services.TransactionPictures,
|
||||||
categories: services.TransactionCategories,
|
categories: services.TransactionCategories,
|
||||||
tags: services.TransactionTags,
|
tags: services.TransactionTags,
|
||||||
templates: services.TransactionTemplates,
|
templates: services.TransactionTemplates,
|
||||||
@@ -90,6 +92,13 @@ func (a *DataManagementsApi) DataStatisticsHandler(c *core.WebContext) (any, *er
|
|||||||
return nil, errs.ErrOperationFailed
|
return nil, errs.ErrOperationFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
totalTransactionPictureCount, err := a.pictures.GetTotalTransactionPicturesCountByUid(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf(c, "[data_managements.DataStatisticsHandler] failed to get total transaction picture count for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
|
return nil, errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
|
||||||
totalTransactionTemplateCount, err := a.templates.GetTotalNormalTemplateCountByUid(c, uid)
|
totalTransactionTemplateCount, err := a.templates.GetTotalNormalTemplateCountByUid(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -109,6 +118,7 @@ func (a *DataManagementsApi) DataStatisticsHandler(c *core.WebContext) (any, *er
|
|||||||
TotalTransactionCategoryCount: totalTransactionCategoryCount,
|
TotalTransactionCategoryCount: totalTransactionCategoryCount,
|
||||||
TotalTransactionTagCount: totalTransactionTagCount,
|
TotalTransactionTagCount: totalTransactionTagCount,
|
||||||
TotalTransactionCount: totalTransactionCount,
|
TotalTransactionCount: totalTransactionCount,
|
||||||
|
TotalTransactionPictureCount: totalTransactionPictureCount,
|
||||||
TotalTransactionTemplateCount: totalTransactionTemplateCount,
|
TotalTransactionTemplateCount: totalTransactionTemplateCount,
|
||||||
TotalScheduledTransactionCount: totalScheduledTransactionCount,
|
TotalScheduledTransactionCount: totalScheduledTransactionCount,
|
||||||
}
|
}
|
||||||
@@ -148,6 +158,13 @@ func (a *DataManagementsApi) ClearDataHandler(c *core.WebContext) (any, *errs.Er
|
|||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = a.pictures.DeleteAllPictures(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf(c, "[data_managements.ClearDataHandler] failed to delete all transaction pictures, because %s", err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
err = a.transactions.DeleteAllTransactions(c, uid)
|
err = a.transactions.DeleteAllTransactions(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ type DataStatisticsResponse struct {
|
|||||||
TotalTransactionCategoryCount int64 `json:"totalTransactionCategoryCount,string"`
|
TotalTransactionCategoryCount int64 `json:"totalTransactionCategoryCount,string"`
|
||||||
TotalTransactionTagCount int64 `json:"totalTransactionTagCount,string"`
|
TotalTransactionTagCount int64 `json:"totalTransactionTagCount,string"`
|
||||||
TotalTransactionCount int64 `json:"totalTransactionCount,string"`
|
TotalTransactionCount int64 `json:"totalTransactionCount,string"`
|
||||||
|
TotalTransactionPictureCount int64 `json:"totalTransactionPictureCount,string"`
|
||||||
TotalTransactionTemplateCount int64 `json:"totalTransactionTemplateCount,string"`
|
TotalTransactionTemplateCount int64 `json:"totalTransactionTemplateCount,string"`
|
||||||
TotalScheduledTransactionCount int64 `json:"totalScheduledTransactionCount,string"`
|
TotalScheduledTransactionCount int64 `json:"totalScheduledTransactionCount,string"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,17 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GetTotalTransactionPicturesCountByUid returns total transaction pictures count of user
|
||||||
|
func (s *TransactionPictureService) GetTotalTransactionPicturesCountByUid(c core.Context, uid int64) (int64, error) {
|
||||||
|
if uid <= 0 {
|
||||||
|
return 0, errs.ErrUserIdInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
count, err := s.UserDataDB(uid).NewSession(c).Where("uid=? AND deleted=?", uid, false).Count(&models.TransactionPictureInfo{})
|
||||||
|
|
||||||
|
return count, err
|
||||||
|
}
|
||||||
|
|
||||||
// GetPictureInfoByPictureId returns a transaction picture info model according to transaction picture id
|
// GetPictureInfoByPictureId returns a transaction picture info model according to transaction picture id
|
||||||
func (s *TransactionPictureService) GetPictureInfoByPictureId(c core.Context, uid int64, pictureId int64) (*models.TransactionPictureInfo, error) {
|
func (s *TransactionPictureService) GetPictureInfoByPictureId(c core.Context, uid int64, pictureId int64) (*models.TransactionPictureInfo, error) {
|
||||||
if uid <= 0 {
|
if uid <= 0 {
|
||||||
@@ -138,3 +149,27 @@ func (s *TransactionPictureService) UploadPicture(c core.Context, pictureInfo *m
|
|||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteAllPictures deletes all existed transaction pictures from database
|
||||||
|
func (s *TransactionPictureService) DeleteAllPictures(c core.Context, uid int64) error {
|
||||||
|
if uid <= 0 {
|
||||||
|
return errs.ErrUserIdInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
now := time.Now().Unix()
|
||||||
|
|
||||||
|
updateModel := &models.TransactionPictureInfo{
|
||||||
|
Deleted: true,
|
||||||
|
DeletedUnixTime: now,
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.UserDataDB(uid).DoTransaction(c, func(sess *xorm.Session) error {
|
||||||
|
_, err := sess.Cols("deleted", "deleted_unix_time").Where("uid=? AND deleted=?", uid, false).Update(updateModel)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -1413,6 +1413,7 @@
|
|||||||
"Unable to delete this account": "Unable to delete this account",
|
"Unable to delete this account": "Unable to delete this account",
|
||||||
"Transaction": "Transaction",
|
"Transaction": "Transaction",
|
||||||
"Transactions": "Transactions",
|
"Transactions": "Transactions",
|
||||||
|
"Transaction Pictures": "Transaction Pictures",
|
||||||
"Add Transaction": "Add Transaction",
|
"Add Transaction": "Add Transaction",
|
||||||
"Edit Transaction": "Edit Transaction",
|
"Edit Transaction": "Edit Transaction",
|
||||||
"Add Transaction Template": "Add Transaction Template",
|
"Add Transaction Template": "Add Transaction Template",
|
||||||
|
|||||||
@@ -1413,6 +1413,7 @@
|
|||||||
"Unable to delete this account": "无法删除该账户",
|
"Unable to delete this account": "无法删除该账户",
|
||||||
"Transaction": "交易",
|
"Transaction": "交易",
|
||||||
"Transactions": "交易",
|
"Transactions": "交易",
|
||||||
|
"Transaction Pictures": "交易图片",
|
||||||
"Add Transaction": "添加交易",
|
"Add Transaction": "添加交易",
|
||||||
"Edit Transaction": "编辑交易",
|
"Edit Transaction": "编辑交易",
|
||||||
"Add Transaction Template": "添加交易模板",
|
"Add Transaction Template": "添加交易模板",
|
||||||
|
|||||||
@@ -43,6 +43,12 @@
|
|||||||
icon: icons.tags,
|
icon: icons.tags,
|
||||||
color: 'secondary'
|
color: 'secondary'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Transaction Pictures',
|
||||||
|
count: displayDataStatistics ? displayDataStatistics.totalTransactionPictureCount : '-',
|
||||||
|
icon: icons.pictures,
|
||||||
|
color: 'error-darken-1'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: 'Transaction Templates',
|
title: 'Transaction Templates',
|
||||||
count: displayDataStatistics ? displayDataStatistics.totalTransactionTemplateCount : '-',
|
count: displayDataStatistics ? displayDataStatistics.totalTransactionTemplateCount : '-',
|
||||||
@@ -167,6 +173,7 @@ import {
|
|||||||
mdiViewDashboardOutline,
|
mdiViewDashboardOutline,
|
||||||
mdiTagOutline,
|
mdiTagOutline,
|
||||||
mdiClipboardTextOutline,
|
mdiClipboardTextOutline,
|
||||||
|
mdiImage,
|
||||||
mdiClipboardTextClockOutline,
|
mdiClipboardTextClockOutline,
|
||||||
mdiAlert
|
mdiAlert
|
||||||
} from '@mdi/js';
|
} from '@mdi/js';
|
||||||
@@ -185,6 +192,7 @@ export default {
|
|||||||
accounts: mdiCreditCardOutline,
|
accounts: mdiCreditCardOutline,
|
||||||
categories: mdiViewDashboardOutline,
|
categories: mdiViewDashboardOutline,
|
||||||
tags: mdiTagOutline,
|
tags: mdiTagOutline,
|
||||||
|
pictures: mdiImage,
|
||||||
templates: mdiClipboardTextOutline,
|
templates: mdiClipboardTextOutline,
|
||||||
scheduledTransactions: mdiClipboardTextClockOutline,
|
scheduledTransactions: mdiClipboardTextClockOutline,
|
||||||
alert: mdiAlert
|
alert: mdiAlert
|
||||||
@@ -205,6 +213,7 @@ export default {
|
|||||||
totalAccountCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalAccountCount),
|
totalAccountCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalAccountCount),
|
||||||
totalTransactionCategoryCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalTransactionCategoryCount),
|
totalTransactionCategoryCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalTransactionCategoryCount),
|
||||||
totalTransactionTagCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalTransactionTagCount),
|
totalTransactionTagCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalTransactionTagCount),
|
||||||
|
totalTransactionPictureCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalTransactionPictureCount),
|
||||||
totalTransactionTemplateCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalTransactionTemplateCount),
|
totalTransactionTemplateCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalTransactionTemplateCount),
|
||||||
totalScheduledTransactionCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalScheduledTransactionCount)
|
totalScheduledTransactionCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalScheduledTransactionCount)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
<f7-list-item :title="$t('Accounts')" :after="displayDataStatistics.totalAccountCount"></f7-list-item>
|
<f7-list-item :title="$t('Accounts')" :after="displayDataStatistics.totalAccountCount"></f7-list-item>
|
||||||
<f7-list-item :title="$t('Transaction Categories')" :after="displayDataStatistics.totalTransactionCategoryCount"></f7-list-item>
|
<f7-list-item :title="$t('Transaction Categories')" :after="displayDataStatistics.totalTransactionCategoryCount"></f7-list-item>
|
||||||
<f7-list-item :title="$t('Transaction Tags')" :after="displayDataStatistics.totalTransactionTagCount"></f7-list-item>
|
<f7-list-item :title="$t('Transaction Tags')" :after="displayDataStatistics.totalTransactionTagCount"></f7-list-item>
|
||||||
|
<f7-list-item :title="$t('Transaction Pictures')" :after="displayDataStatistics.totalTransactionPictureCount"></f7-list-item>
|
||||||
<f7-list-item :title="$t('Transaction Templates')" :after="displayDataStatistics.totalTransactionTemplateCount"></f7-list-item>
|
<f7-list-item :title="$t('Transaction Templates')" :after="displayDataStatistics.totalTransactionTemplateCount"></f7-list-item>
|
||||||
<f7-list-item :title="$t('Scheduled Transactions')" :after="displayDataStatistics.totalScheduledTransactionCount"></f7-list-item>
|
<f7-list-item :title="$t('Scheduled Transactions')" :after="displayDataStatistics.totalScheduledTransactionCount"></f7-list-item>
|
||||||
</f7-list>
|
</f7-list>
|
||||||
@@ -111,6 +112,7 @@ export default {
|
|||||||
totalAccountCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalAccountCount),
|
totalAccountCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalAccountCount),
|
||||||
totalTransactionCategoryCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalTransactionCategoryCount),
|
totalTransactionCategoryCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalTransactionCategoryCount),
|
||||||
totalTransactionTagCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalTransactionTagCount),
|
totalTransactionTagCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalTransactionTagCount),
|
||||||
|
totalTransactionPictureCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalTransactionPictureCount),
|
||||||
totalTransactionTemplateCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalTransactionTemplateCount),
|
totalTransactionTemplateCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalTransactionTemplateCount),
|
||||||
totalScheduledTransactionCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalScheduledTransactionCount)
|
totalScheduledTransactionCount: self.$locale.appendDigitGroupingSymbol(self.userStore, self.dataStatistics.totalScheduledTransactionCount)
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user