mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-08-30 01:27:40 +00:00
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
/*
|
|
* parse-from-entries.js
|
|
* Copyright (c) 2023 james@firefly-iii.org
|
|
*
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/**
|
|
*
|
|
* @param entries
|
|
*/
|
|
export function parseFromEntries(entries) {
|
|
let returnArray = [];
|
|
for (let i in entries) {
|
|
if (entries.hasOwnProperty(i)) {
|
|
const entry = entries[i];
|
|
let current = {};
|
|
|
|
// fields for transaction
|
|
current.description = entry.description;
|
|
current.source_name = entry.source_account.name;
|
|
current.destination_name = entry.destination_account.name;
|
|
current.amount = entry.amount;
|
|
current.date = entry.date;
|
|
|
|
// TODO transaction type is hard coded:
|
|
current.type = 'withdrawal';
|
|
|
|
|
|
returnArray.push(current);
|
|
}
|
|
}
|
|
return returnArray;
|
|
}
|