mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-20 01:34:24 +08:00
add transaction pictures api
This commit is contained in:
+11
-3
@@ -394,9 +394,9 @@ export default {
|
||||
return axios.get(`v1/transactions/amounts.json?use_transaction_timezone=${useTransactionTimezone}` + (queryParams.length ? '&query=' + queryParams.join('|') : ''));
|
||||
},
|
||||
getTransaction: ({ id }) => {
|
||||
return axios.get(`v1/transactions/get.json?id=${id}&trim_account=true&trim_category=true&trim_tag=true`);
|
||||
return axios.get(`v1/transactions/get.json?id=${id}&with_pictures=true&trim_account=true&trim_category=true&trim_tag=true`);
|
||||
},
|
||||
addTransaction: ({ type, categoryId, time, sourceAccountId, destinationAccountId, sourceAmount, destinationAmount, hideAmount, tagIds, comment, geoLocation, utcOffset, clientSessionId }) => {
|
||||
addTransaction: ({ type, categoryId, time, sourceAccountId, destinationAccountId, sourceAmount, destinationAmount, hideAmount, tagIds, pictureIds, comment, geoLocation, utcOffset, clientSessionId }) => {
|
||||
return axios.post('v1/transactions/add.json', {
|
||||
type,
|
||||
categoryId,
|
||||
@@ -407,13 +407,14 @@ export default {
|
||||
destinationAmount,
|
||||
hideAmount,
|
||||
tagIds,
|
||||
pictureIds,
|
||||
comment,
|
||||
geoLocation,
|
||||
utcOffset,
|
||||
clientSessionId
|
||||
});
|
||||
},
|
||||
modifyTransaction: ({ id, type, categoryId, time, sourceAccountId, destinationAccountId, sourceAmount, destinationAmount, hideAmount, tagIds, comment, geoLocation, utcOffset }) => {
|
||||
modifyTransaction: ({ id, type, categoryId, time, sourceAccountId, destinationAccountId, sourceAmount, destinationAmount, hideAmount, tagIds, pictureIds, comment, geoLocation, utcOffset }) => {
|
||||
return axios.post('v1/transactions/modify.json', {
|
||||
id,
|
||||
type,
|
||||
@@ -425,6 +426,7 @@ export default {
|
||||
destinationAmount,
|
||||
hideAmount,
|
||||
tagIds,
|
||||
pictureIds,
|
||||
comment,
|
||||
geoLocation,
|
||||
utcOffset
|
||||
@@ -435,6 +437,12 @@ export default {
|
||||
id
|
||||
});
|
||||
},
|
||||
uploadTransactionPicture: ({ pictureFile, clientSessionId }) => {
|
||||
return axios.postForm('v1/transaction/pictures/upload.json', {
|
||||
picture: pictureFile,
|
||||
clientSessionId: clientSessionId
|
||||
});
|
||||
},
|
||||
getAllTransactionCategories: () => {
|
||||
return axios.get('v1/transaction/categories/list.json');
|
||||
},
|
||||
|
||||
@@ -1414,6 +1414,7 @@
|
||||
"Transaction": "Transaction",
|
||||
"Transactions": "Transactions",
|
||||
"Transaction Pictures": "Transaction Pictures",
|
||||
"Pictures": "Pictures",
|
||||
"Add Transaction": "Add Transaction",
|
||||
"Edit Transaction": "Edit Transaction",
|
||||
"Add Transaction Template": "Add Transaction Template",
|
||||
@@ -1465,6 +1466,7 @@
|
||||
"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 upload transaction picture": "Unable to upload transaction picture",
|
||||
"Search transaction description": "Search transaction description",
|
||||
"Unable to retrieve transaction list": "Unable to retrieve transaction list",
|
||||
"Custom Date Range": "Custom Date Range",
|
||||
|
||||
@@ -1414,6 +1414,7 @@
|
||||
"Transaction": "交易",
|
||||
"Transactions": "交易",
|
||||
"Transaction Pictures": "交易图片",
|
||||
"Pictures": "图片",
|
||||
"Add Transaction": "添加交易",
|
||||
"Edit Transaction": "编辑交易",
|
||||
"Add Transaction Template": "添加交易模板",
|
||||
@@ -1465,6 +1466,7 @@
|
||||
"Unable to save transaction": "无法保存交易",
|
||||
"You have added a new transaction": "您已经添加新交易",
|
||||
"You have saved this transaction": "您已经保存该交易",
|
||||
"Unable to upload transaction picture": "无法上传交易图片",
|
||||
"Search transaction description": "搜索交易描述",
|
||||
"Unable to retrieve transaction list": "无法获取交易列表",
|
||||
"Custom Date Range": "自定义日期范围",
|
||||
|
||||
@@ -864,6 +864,18 @@ export const useTransactionsStore = defineStore('transactions', {
|
||||
return Promise.reject('An error occurred');
|
||||
}
|
||||
|
||||
if (transaction.pictures && transaction.pictures.length > 0) {
|
||||
const pictureIds = [];
|
||||
|
||||
for (let i = 0; i < transaction.pictures.length; i++) {
|
||||
if (transaction.pictures[i].pictureId) {
|
||||
pictureIds.push(transaction.pictures[i].pictureId);
|
||||
}
|
||||
}
|
||||
|
||||
transaction.pictureIds = pictureIds;
|
||||
}
|
||||
|
||||
if (isEdit) {
|
||||
submitTransaction.id = transaction.id;
|
||||
}
|
||||
@@ -991,6 +1003,30 @@ export const useTransactionsStore = defineStore('transactions', {
|
||||
});
|
||||
});
|
||||
},
|
||||
uploadTransactionPicture({ pictureFile, clientSessionId }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
services.uploadTransactionPicture({ pictureFile, clientSessionId }).then(response => {
|
||||
const data = response.data;
|
||||
|
||||
if (!data || !data.success || !data.result) {
|
||||
reject({ message: 'Unable to upload transaction picture' });
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(data.result);
|
||||
}).catch(error => {
|
||||
logger.error('Unable to upload transaction picture', error);
|
||||
|
||||
if (error.response && error.response.data && error.response.data.errorMessage) {
|
||||
reject({ error: error.response.data });
|
||||
} else if (!error.processed) {
|
||||
reject({ message: 'Unable to upload transaction picture' });
|
||||
} else {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
collapseMonthInTransactionList({ month, collapse }) {
|
||||
if (month) {
|
||||
month.opened = !collapse;
|
||||
|
||||
Reference in New Issue
Block a user