diff --git a/pkg/models/transaction.go b/pkg/models/transaction.go index 039df7f8..09357dad 100644 --- a/pkg/models/transaction.go +++ b/pkg/models/transaction.go @@ -59,7 +59,7 @@ type TransactionModifyRequest struct { // TransactionListByMaxTimeRequest represents all parameters of transaction listing by max time request type TransactionListByMaxTimeRequest struct { - MaxTime int64 `form:"max_time" binding:"required,min=1"` + MaxTime int64 `form:"max_time" binding:"min=0"` Count int `form:"count" binding:"required,min=1,max=50"` } @@ -134,5 +134,9 @@ func (c TransactionInfoResponseSlice) Swap(i, j int) { // Less reports whether the first item is less than the second one func (c TransactionInfoResponseSlice) Less(i, j int) bool { - return c[i].Time < c[j].Time + if c[i].Time != c[j].Time { + return c[i].Time > c[j].Time + } + + return c[i].Id > c[j].Id } diff --git a/pkg/services/transactions.go b/pkg/services/transactions.go index eb6e6736..fb6fb5bb 100644 --- a/pkg/services/transactions.go +++ b/pkg/services/transactions.go @@ -42,7 +42,13 @@ func (s *TransactionService) GetTransactionsByMaxTime(uid int64, maxTime int64, } var transactions []*models.Transaction - err := s.UserDataDB(uid).Where("uid=? AND deleted=? AND transaction_time<=?", uid, false, maxTime).Limit(count, 0).OrderBy("transaction_time desc").Find(&transactions) + var err error + + if maxTime > 0 { + err = s.UserDataDB(uid).Where("uid=? AND deleted=? AND transaction_time<=?", uid, false, maxTime).Limit(count, 0).OrderBy("transaction_time desc").Find(&transactions) + } else { + err = s.UserDataDB(uid).Where("uid=? AND deleted=?", uid, false).Limit(count, 0).OrderBy("transaction_time desc").Find(&transactions) + } return transactions, err } diff --git a/src/lib/services.js b/src/lib/services.js index c469f4a2..695e0fef 100644 --- a/src/lib/services.js +++ b/src/lib/services.js @@ -213,6 +213,9 @@ export default { id }); }, + getTransactions: ({ maxTime }) => { + return axios.get('v1/transactions/list.json?max_time=' + maxTime + '&count=20'); + }, getTransaction: ({ id }) => { return axios.get('v1/transactions/get.json?id=' + id); }, diff --git a/src/lib/utils.js b/src/lib/utils.js index 02fdc134..041f570e 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -33,6 +33,10 @@ function isBoolean(val) { return typeof(val) === 'boolean'; } +function parseDateFromUnixtime(unixTime) { + return moment.unix(unixTime); +} + function formatDate(date, format) { return moment(date).format(format); } @@ -45,6 +49,22 @@ function getUnixTime(date) { return moment(date).unix(); } +function getYear(date) { + return moment(date).year(); +} + +function getMonth(date) { + return moment(date).month() + 1; +} + +function getDay(date) { + return moment(date).date(); +} + +function getDayOfWeek(date) { + return moment(date).format('dddd'); +} + function copyObjectTo(fromObject, toObject) { if (!isObject(fromObject)) { return toObject; @@ -369,6 +389,8 @@ function getAllFilteredAccountsBalance(categorizedAccounts, accountFilter) { if (account.type === accountConstants.allAccountTypes.SingleAccount) { ret.push({ balance: account.balance, + isAsset: account.isAsset, + isLiability: account.isLiability, currency: account.currency }); } else if (account.type === accountConstants.allAccountTypes.MultiSubAccounts) { @@ -381,6 +403,8 @@ function getAllFilteredAccountsBalance(categorizedAccounts, accountFilter) { ret.push({ balance: subAccount.balance, + isAsset: subAccount.isAsset, + isLiability: subAccount.isLiability, currency: subAccount.currency }); } @@ -398,9 +422,14 @@ export default { isString, isNumber, isBoolean, + parseDateFromUnixtime, formatDate, formatUnixTime, getUnixTime, + getYear, + getMonth, + getDay, + getDayOfWeek, copyObjectTo, copyArrayTo, appendThousandsSeparator, diff --git a/src/locales/en.js b/src/locales/en.js index b3e6d4ad..e88bf9b9 100644 --- a/src/locales/en.js +++ b/src/locales/en.js @@ -9,15 +9,42 @@ export default { }, 'format': { 'date': { - 'long': 'MM/DD/YYYY' + 'long': 'MM/DD/YYYY', + 'yearMonth': 'YYYY-MM' }, 'datetime': { 'long': 'MM/DD/YYYY HH:mm:ss', }, + 'time': { + 'hourMinute': 'HH:mm' + }, 'currency': { 'symbol': '{amount} {symbol}' } }, + 'datetime': { + 'Monday': { + 'short': 'Mon' + }, + 'Tuesday': { + 'short': 'Tue' + }, + 'Wednesday': { + 'short': 'Wed' + }, + 'Thursday': { + 'short': 'Thu' + }, + 'Friday': { + 'short': 'Fri' + }, + 'Saturday': { + 'short': 'Sat' + }, + 'Sunday': { + 'short': 'Sun' + } + }, 'currency': { 'AED': 'United Arab Emirates dirham', 'AFN': 'Afghan afghani', @@ -498,8 +525,10 @@ export default { 'Unable to move account': 'Unable to move account', 'Are you sure you want to delete this account?': 'Are you sure you want to delete this account?', 'Unable to delete this account': 'Unable to delete this account', + 'Transaction': 'Transaction', 'Add Transaction': 'Add Transaction', 'Edit Transaction': 'Edit Transaction', + 'Modify Balance': 'Modify Balance', 'Expense Amount': 'Expense Amount', 'Income Amount': 'Income Amount', 'Transfer Out Amount': 'Transfer Out Amount', @@ -516,6 +545,10 @@ export default { 'Unable to save transaction': 'Unable to save transaction', 'You have added a new transaction': 'You have added a new transaction', 'You have saved this transaction': 'You have saved this transaction', + 'Unable to get transaction list': 'Unable to get transaction list', + 'No transaction data': 'No transaction data', + 'Are you sure you want to delete this transaction?': 'Are you sure you want to delete this transaction?', + 'Unable to delete this transaction': 'Unable to delete this transaction', 'User Profile': 'User Profile', 'Language': 'Language', 'Auto Update Exchange Rates Data': 'Auto Update Exchange Rates Data', diff --git a/src/locales/zh_Hans.js b/src/locales/zh_Hans.js index 7b6fcc1d..228975e7 100644 --- a/src/locales/zh_Hans.js +++ b/src/locales/zh_Hans.js @@ -9,15 +9,42 @@ export default { }, 'format': { 'date': { - 'long': 'YYYY年MM月DD日' + 'long': 'YYYY年MM月DD日', + 'yearMonth': 'YYYY年MM月' }, 'datetime': { 'long': 'YYYY年MM月DD日 HH:mm:ss', }, + 'time': { + 'hourMinute': 'HH:mm' + }, 'currency': { 'symbol': '{symbol} {amount}' } }, + 'datetime': { + 'Monday': { + 'short': '周一' + }, + 'Tuesday': { + 'short': '周二' + }, + 'Wednesday': { + 'short': '周三' + }, + 'Thursday': { + 'short': '周四' + }, + 'Friday': { + 'short': '周五' + }, + 'Saturday': { + 'short': '周六' + }, + 'Sunday': { + 'short': '周日' + } + }, 'currency': { 'AED': '阿联酋迪拉姆', 'AFN': '阿富汗阿富汗尼', @@ -498,8 +525,10 @@ export default { 'Unable to move account': '无法移动账户', 'Are you sure you want to delete this account?': '您确定要删除该账户?', 'Unable to delete this account': '无法删除该账户', + 'Transaction': '交易', 'Add Transaction': '添加交易', 'Edit Transaction': '编辑交易', + 'Modify Balance': '修改余额', 'Expense Amount': '支出金额', 'Income Amount': '收入金额', 'Transfer Out Amount': '转出金额', @@ -516,6 +545,10 @@ export default { 'Unable to save transaction': '无法保存交易', 'You have added a new transaction': '您已经添加新交易', 'You have saved this transaction': '您已经保存该交易', + 'Unable to get transaction list': '无法获取交易列表', + 'No transaction data': '没有交易数据', + 'Are you sure you want to delete this transaction?': '您确定要删除该交易?', + 'Unable to delete this transaction': '无法删除该交易', 'User Profile': '用户信息', 'Language': '语言', 'Auto Update Exchange Rates Data': '自动更新汇率数据', diff --git a/src/mobile-main.js b/src/mobile-main.js index 642eb63a..2b099875 100644 --- a/src/mobile-main.js +++ b/src/mobile-main.js @@ -8,7 +8,6 @@ import VueMoment from 'vue-moment'; import VueClipboard from 'vue-clipboard2'; import moment from 'moment'; -import 'moment/min/locales'; import 'framework7/css/framework7.bundle.css'; import 'framework7-icons'; diff --git a/src/views/mobile/transactions/Detail.vue b/src/views/mobile/transactions/Detail.vue index f201f255..b9fe8554 100644 --- a/src/views/mobile/transactions/Detail.vue +++ b/src/views/mobile/transactions/Detail.vue @@ -1,17 +1,586 @@ + + + +