mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Replace native with primary where possible
This commit is contained in:
@@ -407,7 +407,7 @@ let index = function () {
|
||||
interest: current.attributes.interest,
|
||||
interest_period: current.attributes.interest_period,
|
||||
balance: current.attributes.balance,
|
||||
native_balance: current.attributes.native_balance,
|
||||
pc_balance: current.attributes.pc_balance,
|
||||
balances: current.attributes.balances,
|
||||
};
|
||||
// get group info:
|
||||
|
@@ -39,7 +39,7 @@ export default () => ({
|
||||
loading: false,
|
||||
loadingAccounts: false,
|
||||
accountList: [],
|
||||
convertToNative: false,
|
||||
convertToPrimary: false,
|
||||
chartOptions: null,
|
||||
localCacheKey(type) {
|
||||
return 'ds_accounts_' + type;
|
||||
@@ -48,7 +48,7 @@ export default () => ({
|
||||
eventListeners: {
|
||||
['@convert-to-native.window'](event){
|
||||
console.log('I heard that! (dashboard/accounts)');
|
||||
this.convertToNative = event.detail;
|
||||
this.convertToPrimary = event.detail;
|
||||
this.accountList = [];
|
||||
chartData = null;
|
||||
this.loadChart();
|
||||
@@ -60,7 +60,7 @@ export default () => ({
|
||||
getFreshData() {
|
||||
const start = new Date(window.store.get('start'));
|
||||
const end = new Date(window.store.get('end'));
|
||||
const chartCacheKey = getCacheKey(this.localCacheKey('chart'), {convertToNative: this.convertToNative, start: start, end: end})
|
||||
const chartCacheKey = getCacheKey(this.localCacheKey('chart'), {convertToPrimary: this.convertToPrimary, start: start, end: end})
|
||||
|
||||
const cacheValid = window.store.get('cacheValid');
|
||||
let cachedData = window.store.get(chartCacheKey);
|
||||
@@ -100,18 +100,18 @@ export default () => ({
|
||||
dataset.label = current.label;
|
||||
|
||||
// use the "native" currency code and use the "native_entries" as array
|
||||
if (this.convertToNative) {
|
||||
if (this.convertToPrimary) {
|
||||
currencies.push(current.native_currency_code);
|
||||
dataset.currency_code = current.native_currency_code;
|
||||
if(!current.hasOwnProperty('native_entries')) {
|
||||
console.error('No native entries ('+this.convertToNative+') found for account: ', current);
|
||||
console.error('No native entries ('+this.convertToPrimary+') found for account: ', current);
|
||||
}
|
||||
if(current.hasOwnProperty('native_entries')) {
|
||||
collection = Object.values(current.native_entries);
|
||||
}
|
||||
yAxis = 'y' + current.native_currency_code;
|
||||
}
|
||||
if (!this.convertToNative) {
|
||||
if (!this.convertToPrimary) {
|
||||
yAxis = 'y' + current.currency_code;
|
||||
dataset.currency_code = current.currency_code;
|
||||
currencies.push(current.currency_code);
|
||||
@@ -295,9 +295,9 @@ export default () => ({
|
||||
getConfiguration('cer.enabled', false) // 3
|
||||
]).then((values) => {
|
||||
//console.log('accounts after promises');
|
||||
this.convertToNative = values[1] && values[3];
|
||||
this.convertToPrimary = values[1] && values[3];
|
||||
afterPromises = true;
|
||||
//console.log('convertToNative in accounts.js: ', values);
|
||||
//console.log('convertToPrimary in accounts.js: ', values);
|
||||
|
||||
// main dashboard chart:
|
||||
this.loadChart();
|
||||
@@ -318,7 +318,7 @@ export default () => ({
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
// console.log('accounts observe convertToNative');
|
||||
// console.log('accounts observe convertToPrimary');
|
||||
this.loadChart();
|
||||
this.loadAccounts();
|
||||
});
|
||||
|
@@ -31,13 +31,13 @@ export default () => ({
|
||||
billBox: {paid: [], unpaid: []},
|
||||
leftBox: {left: [], perDay: []},
|
||||
netBox: {net: []},
|
||||
convertToNative: false,
|
||||
convertToPrimary: false,
|
||||
loading: false,
|
||||
boxData: null,
|
||||
boxOptions: null,
|
||||
eventListeners: {
|
||||
['@convert-to-native.window'](event){
|
||||
this.convertToNative = event.detail;
|
||||
this.convertToPrimary = event.detail;
|
||||
this.accountList = [];
|
||||
console.log('I heard that! (dashboard/boxes)');
|
||||
this.boxData = null;
|
||||
@@ -49,7 +49,7 @@ export default () => ({
|
||||
const start = new Date(window.store.get('start'));
|
||||
const end = new Date(window.store.get('end'));
|
||||
// TODO cache key is hard coded, problem?
|
||||
const boxesCacheKey = getCacheKey('ds_boxes_data', {convertToNative: this.convertToNative, start: start, end: end});
|
||||
const boxesCacheKey = getCacheKey('ds_boxes_data', {convertToPrimary: this.convertToPrimary, start: start, end: end});
|
||||
cleanupCache();
|
||||
|
||||
//const cacheValid = window.store.get('cacheValid');
|
||||
@@ -166,7 +166,7 @@ export default () => ({
|
||||
Promise.all([getVariable('viewRange'), getVariable('convert_to_native', false)]).then((values) => {
|
||||
// console.log('boxes after promises');
|
||||
afterPromises = true;
|
||||
this.convertToNative = values[1];
|
||||
this.convertToPrimary = values[1];
|
||||
this.loadBoxes();
|
||||
});
|
||||
window.store.observe('end', () => {
|
||||
@@ -181,8 +181,8 @@ export default () => ({
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
// console.log('boxes observe convertToNative');
|
||||
this.convertToNative = newValue;
|
||||
// console.log('boxes observe convertToPrimary');
|
||||
this.convertToPrimary = newValue;
|
||||
this.loadBoxes();
|
||||
});
|
||||
},
|
||||
|
@@ -34,7 +34,7 @@ let afterPromises = false;
|
||||
|
||||
export default () => ({
|
||||
loading: false,
|
||||
convertToNative: false,
|
||||
convertToPrimary: false,
|
||||
loadChart() {
|
||||
if (true === this.loading) {
|
||||
return;
|
||||
@@ -52,7 +52,7 @@ export default () => ({
|
||||
eventListeners: {
|
||||
['@convert-to-native.window'](event){
|
||||
console.log('I heard that! (dashboard/budgets)');
|
||||
this.convertToNative = event.detail;
|
||||
this.convertToPrimary = event.detail;
|
||||
chartData = null;
|
||||
this.loadChart();
|
||||
}
|
||||
@@ -69,7 +69,7 @@ export default () => ({
|
||||
getFreshData() {
|
||||
const start = new Date(window.store.get('start'));
|
||||
const end = new Date(window.store.get('end'));
|
||||
const cacheKey = getCacheKey('ds_bdg_chart', {convertToNative: this.convertToNative, start: start, end: end});
|
||||
const cacheKey = getCacheKey('ds_bdg_chart', {convertToPrimary: this.convertToPrimary, start: start, end: end});
|
||||
//const cacheValid = window.store.get('cacheValid');
|
||||
const cacheValid = false;
|
||||
let cachedData = window.store.get(cacheKey);
|
||||
@@ -168,7 +168,7 @@ export default () => ({
|
||||
|
||||
init() {
|
||||
Promise.all([getVariable('convert_to_native', false)]).then((values) => {
|
||||
this.convertToNative = values[0];
|
||||
this.convertToPrimary = values[0];
|
||||
afterPromises = true;
|
||||
if (false === this.loading) {
|
||||
this.loadChart();
|
||||
@@ -188,8 +188,8 @@ export default () => ({
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
// console.log('boxes observe convertToNative');
|
||||
this.convertToNative = newValue;
|
||||
// console.log('boxes observe convertToPrimary');
|
||||
this.convertToPrimary = newValue;
|
||||
if (false === this.loading) {
|
||||
this.loadChart();
|
||||
}
|
||||
|
@@ -32,12 +32,12 @@ let afterPromises = false;
|
||||
|
||||
export default () => ({
|
||||
loading: false,
|
||||
convertToNative: false,
|
||||
convertToPrimary: false,
|
||||
|
||||
eventListeners: {
|
||||
['@convert-to-native.window'](event){
|
||||
console.log('I heard that! (dashboard/categories)');
|
||||
this.convertToNative = event.detail;
|
||||
this.convertToPrimary = event.detail;
|
||||
chartData = null;
|
||||
this.loadChart();
|
||||
}
|
||||
@@ -146,7 +146,7 @@ export default () => ({
|
||||
getFreshData() {
|
||||
const start = new Date(window.store.get('start'));
|
||||
const end = new Date(window.store.get('end'));
|
||||
const cacheKey = getCacheKey('ds_ct_chart', {convertToNative: this.convertToNative, start: start, end: end});
|
||||
const cacheKey = getCacheKey('ds_ct_chart', {convertToPrimary: this.convertToPrimary, start: start, end: end});
|
||||
|
||||
const cacheValid = window.store.get('cacheValid');
|
||||
let cachedData = window.store.get(cacheKey);
|
||||
@@ -183,7 +183,7 @@ export default () => ({
|
||||
init() {
|
||||
// console.log('categories init');
|
||||
Promise.all([getVariable('convert_to_native', false),]).then((values) => {
|
||||
this.convertToNative = values[0];
|
||||
this.convertToPrimary = values[0];
|
||||
afterPromises = true;
|
||||
this.loadChart();
|
||||
});
|
||||
@@ -198,7 +198,7 @@ export default () => ({
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
this.convertToNative = newValue;
|
||||
this.convertToPrimary = newValue;
|
||||
this.loadChart();
|
||||
});
|
||||
},
|
||||
|
@@ -69,7 +69,7 @@ Chart.register({
|
||||
|
||||
let index = function () {
|
||||
return {
|
||||
convertToNative: false,
|
||||
convertToPrimary: false,
|
||||
saveNativeSettings(event) {
|
||||
let target = event.currentTarget || event.target;
|
||||
setVariable('convert_to_native',target.checked).then(() => {
|
||||
@@ -79,7 +79,7 @@ let index = function () {
|
||||
},
|
||||
init() {
|
||||
Promise.all([getVariable('convert_to_native', false)]).then((values) => {
|
||||
this.convertToNative = values[0];
|
||||
this.convertToPrimary = values[0];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -29,14 +29,14 @@ const PIGGY_CACHE_KEY = 'ds_pg_data';
|
||||
|
||||
export default () => ({
|
||||
loading: false,
|
||||
convertToNative: false,
|
||||
convertToPrimary: false,
|
||||
sankeyGrouping: 'account',
|
||||
piggies: [],
|
||||
getFreshData() {
|
||||
const start = new Date(window.store.get('start'));
|
||||
const end = new Date(window.store.get('end'));
|
||||
// needs user data.
|
||||
const cacheKey = getCacheKey(PIGGY_CACHE_KEY, {convertToNative: this.convertToNative, start: start, end: end});
|
||||
const cacheKey = getCacheKey(PIGGY_CACHE_KEY, {convertToPrimary: this.convertToPrimary, start: start, end: end});
|
||||
|
||||
const cacheValid = window.store.get('cacheValid');
|
||||
let cachedData = window.store.get(cacheKey);
|
||||
@@ -96,14 +96,14 @@ export default () => ({
|
||||
id: current.id,
|
||||
name: current.attributes.name,
|
||||
percentage: parseInt(current.attributes.percentage),
|
||||
amount: this.convertToNative ? current.attributes.native_current_amount : current.attributes.current_amount,
|
||||
amount: this.convertToPrimary ? current.attributes.native_current_amount : current.attributes.current_amount,
|
||||
// left to save
|
||||
left_to_save: this.convertToNative ? current.attributes.native_left_to_save : current.attributes.left_to_save,
|
||||
left_to_save: this.convertToPrimary ? current.attributes.native_left_to_save : current.attributes.left_to_save,
|
||||
// target amount
|
||||
target_amount: this.convertToNative ? current.attributes.native_target_amount : current.attributes.target_amount,
|
||||
target_amount: this.convertToPrimary ? current.attributes.native_target_amount : current.attributes.target_amount,
|
||||
// save per month
|
||||
save_per_month: this.convertToNative ? current.attributes.native_save_per_month : current.attributes.save_per_month,
|
||||
currency_code: this.convertToNative ? current.attributes.native_currency_code : current.attributes.currency_code,
|
||||
save_per_month: this.convertToPrimary ? current.attributes.native_save_per_month : current.attributes.save_per_month,
|
||||
currency_code: this.convertToPrimary ? current.attributes.native_currency_code : current.attributes.currency_code,
|
||||
|
||||
};
|
||||
dataSet[groupName].piggies.push(piggy);
|
||||
@@ -132,7 +132,7 @@ export default () => ({
|
||||
Promise.all([getVariable('convert_to_native', false)]).then((values) => {
|
||||
|
||||
afterPromises = true;
|
||||
this.convertToNative = values[0];
|
||||
this.convertToPrimary = values[0];
|
||||
this.loadPiggyBanks();
|
||||
|
||||
});
|
||||
@@ -148,8 +148,8 @@ export default () => ({
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
// console.log('piggies observe convertToNative');
|
||||
this.convertToNative = newValue;
|
||||
// console.log('piggies observe convertToPrimary');
|
||||
this.convertToPrimary = newValue;
|
||||
this.loadPiggyBanks();
|
||||
});
|
||||
},
|
||||
|
@@ -33,7 +33,7 @@ let currencies = [];
|
||||
let afterPromises = false;
|
||||
let chart = null;
|
||||
let transactions = [];
|
||||
let convertToNative = false;
|
||||
let convertToPrimary = false;
|
||||
let translations = {
|
||||
category: null,
|
||||
unknown_category: null,
|
||||
@@ -79,7 +79,7 @@ const getColor = function (key) {
|
||||
|
||||
// little helper
|
||||
function getObjectName(type, name, direction, code) {
|
||||
if(convertToNative) {
|
||||
if(convertToPrimary) {
|
||||
return getObjectNameWithoutCurrency(type, name, direction);
|
||||
}
|
||||
return getObjectNameWithCurrency(type, name, direction, code);
|
||||
@@ -123,7 +123,7 @@ function getObjectNameWithCurrency(type, name, direction, code) {
|
||||
|
||||
|
||||
function getLabel(type, name, code) {
|
||||
if(convertToNative) {
|
||||
if(convertToPrimary) {
|
||||
return getLabelWithoutCurrency(type, name);
|
||||
}
|
||||
return getLabelWithCurrency(type, name, code);
|
||||
@@ -157,13 +157,13 @@ function getLabelWithCurrency(type, name, code) {
|
||||
|
||||
export default () => ({
|
||||
loading: false,
|
||||
convertToNative: false,
|
||||
convertToPrimary: false,
|
||||
processedData: null,
|
||||
eventListeners: {
|
||||
['@convert-to-native.window'](event){
|
||||
console.log('I heard that! (dashboard/sankey)');
|
||||
this.convertToNative = event.detail;
|
||||
convertToNative = event.detail;
|
||||
this.convertToPrimary = event.detail;
|
||||
convertToPrimary = event.detail;
|
||||
this.processedData = null;
|
||||
this.loadChart();
|
||||
}
|
||||
@@ -226,7 +226,7 @@ export default () => ({
|
||||
let currencyCode = transaction.currency_code;
|
||||
let amount = parseFloat(transaction.amount);
|
||||
let flowKey;
|
||||
if (this.convertToNative) {
|
||||
if (this.convertToPrimary) {
|
||||
currencyCode = transaction.native_currency_code;
|
||||
amount = parseFloat(transaction.native_amount);
|
||||
}
|
||||
@@ -254,7 +254,7 @@ export default () => ({
|
||||
|
||||
if (!this.processedData.amounts.hasOwnProperty(flowKey)) {
|
||||
this.processedData.amounts[flowKey] = {
|
||||
from: translations.all_money + (this.convertToNative ? ' (' + currencyCode + ')' : ''),
|
||||
from: translations.all_money + (this.convertToPrimary ? ' (' + currencyCode + ')' : ''),
|
||||
to: budget,
|
||||
amount: 0
|
||||
};
|
||||
@@ -319,7 +319,7 @@ export default () => ({
|
||||
if (!this.processedData.amounts.hasOwnProperty(flowKey)) {
|
||||
this.processedData.amounts[flowKey] = {
|
||||
from: category,
|
||||
to: translations.all_money + (this.convertToNative ? ' (' + currencyCode + ')' : ''),
|
||||
to: translations.all_money + (this.convertToPrimary ? ' (' + currencyCode + ')' : ''),
|
||||
amount: 0
|
||||
};
|
||||
}
|
||||
@@ -363,7 +363,7 @@ export default () => ({
|
||||
downloadTransactions(params) {
|
||||
const start = new Date(window.store.get('start'));
|
||||
const end = new Date(window.store.get('end'));
|
||||
const cacheKey = getCacheKey(SANKEY_CACHE_KEY, {convertToNative: this.convertToNative, start: start, end: end});
|
||||
const cacheKey = getCacheKey(SANKEY_CACHE_KEY, {convertToPrimary: this.convertToPrimary, start: start, end: end});
|
||||
|
||||
//console.log('Downloading page ' + params.page + '...');
|
||||
const getter = new Get();
|
||||
@@ -400,8 +400,8 @@ export default () => ({
|
||||
// console.log('sankey init');
|
||||
transactions = [];
|
||||
Promise.all([getVariable('convert_to_native', false)]).then((values) => {
|
||||
this.convertToNative = values[0];
|
||||
convertToNative = values[0];
|
||||
this.convertToPrimary = values[0];
|
||||
convertToPrimary = values[0];
|
||||
|
||||
// some translations:
|
||||
translations.all_money = i18next.t('firefly.all_money');
|
||||
@@ -434,8 +434,8 @@ export default () => ({
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
// console.log('sankey observe convertToNative');
|
||||
this.convertToNative = newValue;
|
||||
// console.log('sankey observe convertToPrimary');
|
||||
this.convertToPrimary = newValue;
|
||||
this.loadChart();
|
||||
});
|
||||
},
|
||||
|
@@ -30,7 +30,7 @@ import i18next from "i18next";
|
||||
let afterPromises = false;
|
||||
let apiData = [];
|
||||
let subscriptionData = {};
|
||||
let convertToNative = false;
|
||||
let convertToPrimary = false;
|
||||
|
||||
function addObjectGroupInfo(data) {
|
||||
let objectGroupId = parseInt(data.object_group_id);
|
||||
@@ -71,7 +71,7 @@ function parseBillInfo(data) {
|
||||
pay_dates: parsePayDates(data.attributes.pay_dates),
|
||||
paid: data.attributes.paid_dates.length > 0,
|
||||
};
|
||||
if(convertToNative) {
|
||||
if(convertToPrimary) {
|
||||
result.currency_code = data.attributes.native_currency_code;
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ function downloadSubscriptions(params) {
|
||||
|
||||
export default () => ({
|
||||
loading: false,
|
||||
convertToNative: false,
|
||||
convertToPrimary: false,
|
||||
subscriptions: [],
|
||||
formatMoney(amount, currencyCode) {
|
||||
return formatMoney(amount, currencyCode);
|
||||
@@ -219,8 +219,8 @@ export default () => ({
|
||||
eventListeners: {
|
||||
['@convert-to-native.window'](event){
|
||||
console.log('I heard that! (dashboard/subscriptions)');
|
||||
this.convertToNative = event.detail;
|
||||
convertToNative = event.detail;
|
||||
this.convertToPrimary = event.detail;
|
||||
convertToPrimary = event.detail;
|
||||
this.startSubscriptions();
|
||||
}
|
||||
},
|
||||
@@ -243,7 +243,7 @@ export default () => ({
|
||||
let params = {
|
||||
start: format(start, 'y-MM-dd'),
|
||||
end: format(end, 'y-MM-dd'),
|
||||
// convertToNative: this.convertToNative,
|
||||
// convertToPrimary: this.convertToPrimary,
|
||||
page: 1
|
||||
};
|
||||
downloadSubscriptions(params).then(() => {
|
||||
@@ -314,8 +314,8 @@ export default () => ({
|
||||
|
||||
init() {
|
||||
Promise.all([getVariable('convert_to_native', false)]).then((values) => {
|
||||
this.convertToNative = values[0];
|
||||
convertToNative = values[0];
|
||||
this.convertToPrimary = values[0];
|
||||
convertToPrimary = values[0];
|
||||
afterPromises = true;
|
||||
|
||||
if (false === this.loading) {
|
||||
@@ -336,7 +336,7 @@ export default () => ({
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
this.convertToNative = newValue;
|
||||
this.convertToPrimary = newValue;
|
||||
if (false === this.loading) {
|
||||
this.startSubscriptions();
|
||||
}
|
||||
|
Reference in New Issue
Block a user