Skip to content

Commit

Permalink
enhancement(TransactionsCSV): split accounting category fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed Jan 30, 2024
1 parent 6fe6897 commit df1f110
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/server/controllers/account-transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,9 @@ const formatAccountName = (account) => {
}
};

const formatAccountingCategory = (accountingCategory) => {
if (!accountingCategory) {
return '';
} else {
return `${accountingCategory.code} - ${accountingCategory.name}`;
}
};

const csvMapping = {
accountingCategory: (t) => formatAccountingCategory(get(t, 'expense.accountingCategory')),
accountingCategoryCode: (t) => get(t, 'expense.accountingCategory.code') || '',
accountingCategoryName: (t) => get(t, 'expense.accountingCategory.name') || '',
date: (t) => moment.utc(t.createdAt).format('YYYY-MM-DD'),
datetime: (t) => moment.utc(t.createdAt).format('YYYY-MM-DDTHH:mm:ss'),
id: 'id',
Expand Down Expand Up @@ -529,7 +522,7 @@ const accountTransactions = async (req, res) => {
const fetchAll = variables.offset ? false : parseToBooleanDefaultFalse(req.query.fetchAll);

// Add fields info to the query, to prevent fetching what's not needed
variables.hasAccountingCategoryField = fields.includes('accountingCategory');
variables.hasAccountingCategoryField = fields.some((field) => field.startsWith('accountingCategory'));

try {
// Forward Api Key or Authorization header
Expand Down

0 comments on commit df1f110

Please sign in to comment.