mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 07:57:33 +08:00
support importing transaction in frontend
This commit is contained in:
@@ -7,6 +7,7 @@ import timezoneConstants from '@/consts/timezone.js';
|
||||
import currencyConstants from '@/consts/currency.js';
|
||||
import colorConstants from '@/consts/color.js';
|
||||
import accountConstants from '@/consts/account.js';
|
||||
import fileConstants from '@/consts/file.js';
|
||||
import categoryConstants from '@/consts/category.js';
|
||||
import transactionConstants from '@/consts/transaction.js';
|
||||
import templateConstants from '@/consts/template.js';
|
||||
@@ -1252,6 +1253,22 @@ function getAllDisplayExchangeRates(exchangeRatesData, translateFn) {
|
||||
return availableExchangeRates;
|
||||
}
|
||||
|
||||
function getAllSupportedImportFileTypes(translateFn) {
|
||||
const allSupportedImportFileTypes = [];
|
||||
|
||||
for (let i = 0; i < fileConstants.supportedImportFileTypes.length; i++) {
|
||||
const fileType = fileConstants.supportedImportFileTypes[i];
|
||||
|
||||
allSupportedImportFileTypes.push({
|
||||
type: fileType.type,
|
||||
displayName: translateFn(fileType.name),
|
||||
extensions: fileType.extensions
|
||||
});
|
||||
}
|
||||
|
||||
return allSupportedImportFileTypes;
|
||||
}
|
||||
|
||||
function getEnableDisableOptions(translateFn) {
|
||||
return [{
|
||||
value: true,
|
||||
@@ -1595,6 +1612,7 @@ export function i18nFunctions(i18nGlobal) {
|
||||
getAllTransactionScheduledFrequencyTypes: () => getAllTransactionScheduledFrequencyTypes(i18nGlobal.t),
|
||||
getAllTransactionDefaultCategories: (categoryType, locale) => getAllTransactionDefaultCategories(categoryType, locale, i18nGlobal.t),
|
||||
getAllDisplayExchangeRates: (exchangeRatesData) => getAllDisplayExchangeRates(exchangeRatesData, i18nGlobal.t),
|
||||
getAllSupportedImportFileTypes: () => getAllSupportedImportFileTypes(i18nGlobal.t),
|
||||
getEnableDisableOptions: () => getEnableDisableOptions(i18nGlobal.t),
|
||||
getCategorizedAccountsWithDisplayBalance: (allVisibleAccounts, showAccountBalance, defaultCurrency, settingsStore, userStore, exchangeRatesStore) => getCategorizedAccountsWithDisplayBalance(allVisibleAccounts, showAccountBalance, defaultCurrency, userStore, settingsStore, exchangeRatesStore, i18nGlobal.t),
|
||||
joinMultiText: (textArray) => joinMultiText(textArray, i18nGlobal.t),
|
||||
|
||||
@@ -53,6 +53,10 @@ export function isDataExportingEnabled() {
|
||||
return getServerSetting('e') === '1';
|
||||
}
|
||||
|
||||
export function isDataImportingEnabled() {
|
||||
return getServerSetting('i') === '1';
|
||||
}
|
||||
|
||||
export function getMapProvider() {
|
||||
return getServerSetting('m');
|
||||
}
|
||||
|
||||
@@ -437,6 +437,18 @@ export default {
|
||||
id
|
||||
});
|
||||
},
|
||||
parseImportTransaction: ({ fileType, importFile }) => {
|
||||
return axios.postForm('v1/transactions/parse_import.json', {
|
||||
fileType: fileType,
|
||||
file: importFile
|
||||
});
|
||||
},
|
||||
importTransactions: ({ transactions, clientSessionId }) => {
|
||||
return axios.post('v1/transactions/import.json', {
|
||||
transactions: transactions,
|
||||
clientSessionId: clientSessionId
|
||||
});
|
||||
},
|
||||
uploadTransactionPicture: ({ pictureFile, clientSessionId }) => {
|
||||
return axios.postForm('v1/transaction/pictures/upload.json', {
|
||||
picture: pictureFile,
|
||||
|
||||
Reference in New Issue
Block a user