mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 02:45:58 +00:00
Account for renamed variable.
This commit is contained in:
@@ -39,12 +39,12 @@ export default () => ({
|
|||||||
loading: false,
|
loading: false,
|
||||||
loadingAccounts: false,
|
loadingAccounts: false,
|
||||||
accountList: [],
|
accountList: [],
|
||||||
autoConversion: false,
|
convertToNative: false,
|
||||||
autoConversionAvailable: false,
|
convertToNativeAvailable: false,
|
||||||
chartOptions: null,
|
chartOptions: null,
|
||||||
switchAutoConversion() {
|
switchconvertToNative() {
|
||||||
this.autoConversion = !this.autoConversion;
|
this.convertToNative = !this.convertToNative;
|
||||||
setVariable('autoConversion', this.autoConversion);
|
setVariable('convertToNative', this.convertToNative);
|
||||||
},
|
},
|
||||||
localCacheKey(type) {
|
localCacheKey(type) {
|
||||||
return 'ds_accounts_' + type;
|
return 'ds_accounts_' + type;
|
||||||
@@ -90,13 +90,13 @@ export default () => ({
|
|||||||
dataset.label = current.label;
|
dataset.label = current.label;
|
||||||
|
|
||||||
// use the "native" currency code and use the "native_entries" as array
|
// use the "native" currency code and use the "native_entries" as array
|
||||||
if (this.autoConversion) {
|
if (this.convertToNative) {
|
||||||
currencies.push(current.native_currency_code);
|
currencies.push(current.native_currency_code);
|
||||||
dataset.currency_code = current.native_currency_code;
|
dataset.currency_code = current.native_currency_code;
|
||||||
collection = Object.values(current.native_entries);
|
collection = Object.values(current.native_entries);
|
||||||
yAxis = 'y' + current.native_currency_code;
|
yAxis = 'y' + current.native_currency_code;
|
||||||
}
|
}
|
||||||
if (!this.autoConversion) {
|
if (!this.convertToNative) {
|
||||||
yAxis = 'y' + current.currency_code;
|
yAxis = 'y' + current.currency_code;
|
||||||
dataset.currency_code = current.currency_code;
|
dataset.currency_code = current.currency_code;
|
||||||
currencies.push(current.currency_code);
|
currencies.push(current.currency_code);
|
||||||
@@ -266,12 +266,12 @@ export default () => ({
|
|||||||
|
|
||||||
init() {
|
init() {
|
||||||
// console.log('accounts init');
|
// console.log('accounts init');
|
||||||
Promise.all([getVariable('viewRange', '1M'), getVariable('autoConversion', false), getVariable('language', 'en_US'),
|
Promise.all([getVariable('viewRange', '1M'), getVariable('convertToNative', false), getVariable('language', 'en_US'),
|
||||||
getConfiguration('cer.enabled', false)
|
getConfiguration('cer.enabled', false)
|
||||||
]).then((values) => {
|
]).then((values) => {
|
||||||
//console.log('accounts after promises');
|
//console.log('accounts after promises');
|
||||||
this.autoConversion = values[1] && values[3];
|
this.convertToNative = values[1] && values[3];
|
||||||
this.autoConversionAvailable = values[3];
|
this.convertToNativeAvailable = values[3];
|
||||||
afterPromises = true;
|
afterPromises = true;
|
||||||
|
|
||||||
// main dashboard chart:
|
// main dashboard chart:
|
||||||
@@ -289,11 +289,11 @@ export default () => ({
|
|||||||
this.loadChart();
|
this.loadChart();
|
||||||
this.loadAccounts();
|
this.loadAccounts();
|
||||||
});
|
});
|
||||||
window.store.observe('autoConversion', () => {
|
window.store.observe('convertToNative', () => {
|
||||||
if (!afterPromises) {
|
if (!afterPromises) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// console.log('accounts observe autoconversion');
|
// console.log('accounts observe convertToNative');
|
||||||
this.loadChart();
|
this.loadChart();
|
||||||
this.loadAccounts();
|
this.loadAccounts();
|
||||||
});
|
});
|
||||||
|
@@ -31,7 +31,7 @@ export default () => ({
|
|||||||
billBox: {paid: [], unpaid: []},
|
billBox: {paid: [], unpaid: []},
|
||||||
leftBox: {left: [], perDay: []},
|
leftBox: {left: [], perDay: []},
|
||||||
netBox: {net: []},
|
netBox: {net: []},
|
||||||
autoConversion: false,
|
convertToNative: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
boxData: null,
|
boxData: null,
|
||||||
boxOptions: null,
|
boxOptions: null,
|
||||||
@@ -42,8 +42,9 @@ export default () => ({
|
|||||||
const boxesCacheKey = getCacheKey('ds_boxes_data', {start: start, end: end});
|
const boxesCacheKey = getCacheKey('ds_boxes_data', {start: start, end: end});
|
||||||
cleanupCache();
|
cleanupCache();
|
||||||
|
|
||||||
const cacheValid = window.store.get('cacheValid');
|
//const cacheValid = window.store.get('cacheValid');
|
||||||
let cachedData = window.store.get(boxesCacheKey);
|
let cachedData = window.store.get(boxesCacheKey);
|
||||||
|
const cacheValid = false; // force refresh
|
||||||
|
|
||||||
if (cacheValid && typeof cachedData !== 'undefined') {
|
if (cacheValid && typeof cachedData !== 'undefined') {
|
||||||
this.boxData = cachedData;
|
this.boxData = cachedData;
|
||||||
@@ -76,7 +77,8 @@ export default () => ({
|
|||||||
}
|
}
|
||||||
let key = current.key;
|
let key = current.key;
|
||||||
// native (auto conversion):
|
// native (auto conversion):
|
||||||
if (this.autoConversion) {
|
if (this.convertToNative) {
|
||||||
|
console.error('convertToNative does not work in boxes.');
|
||||||
if (key.startsWith('balance-in-native')) {
|
if (key.startsWith('balance-in-native')) {
|
||||||
this.balanceBox.amounts.push(formatMoney(current.value, current.currency_code));
|
this.balanceBox.amounts.push(formatMoney(current.value, current.currency_code));
|
||||||
// prep subtitles (for later)
|
// prep subtitles (for later)
|
||||||
@@ -132,9 +134,10 @@ export default () => ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// not native
|
// not native
|
||||||
if (!this.autoConversion && !key.endsWith('native')) {
|
if (!this.convertToNative && !key.endsWith('native')) {
|
||||||
|
console.log('NOT NATIVE');
|
||||||
if (key.startsWith('balance-in-')) {
|
if (key.startsWith('balance-in-')) {
|
||||||
this.balanceBox.amounts.push(formatMoney(current.value, current.currency_code));
|
this.balanceBox.amounts.push(formatMoney(current.monetary_value , current.currency_code));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// spent info is used in subtitle:
|
// spent info is used in subtitle:
|
||||||
@@ -146,7 +149,7 @@ export default () => ({
|
|||||||
// append the amount spent.
|
// append the amount spent.
|
||||||
subtitles[current.currency_code] =
|
subtitles[current.currency_code] =
|
||||||
subtitles[current.currency_code] +
|
subtitles[current.currency_code] +
|
||||||
formatMoney(current.value, current.currency_code);
|
formatMoney(current.monetary_value , current.currency_code);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// earned info is used in subtitle:
|
// earned info is used in subtitle:
|
||||||
@@ -157,30 +160,30 @@ export default () => ({
|
|||||||
}
|
}
|
||||||
// prepend the amount earned.
|
// prepend the amount earned.
|
||||||
subtitles[current.currency_code] =
|
subtitles[current.currency_code] =
|
||||||
formatMoney(current.value, current.currency_code) + ' + ' +
|
formatMoney(current.monetary_value , current.currency_code) + ' + ' +
|
||||||
subtitles[current.currency_code];
|
subtitles[current.currency_code];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (key.startsWith('bills-unpaid-in-')) {
|
if (key.startsWith('bills-unpaid-in-')) {
|
||||||
this.billBox.unpaid.push(formatMoney(current.value, current.currency_code));
|
this.billBox.unpaid.push(formatMoney(current.monetary_value , current.currency_code));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (key.startsWith('bills-paid-in-')) {
|
if (key.startsWith('bills-paid-in-')) {
|
||||||
this.billBox.paid.push(formatMoney(current.value, current.currency_code));
|
this.billBox.paid.push(formatMoney(current.monetary_value , current.currency_code));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (key.startsWith('left-to-spend-in-')) {
|
if (key.startsWith('left-to-spend-in-')) {
|
||||||
this.leftBox.left.push(formatMoney(current.value, current.currency_code));
|
this.leftBox.left.push(formatMoney(current.monetary_value , current.currency_code));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (key.startsWith('left-per-day-to-spend-in-')) {
|
if (key.startsWith('left-per-day-to-spend-in-')) {
|
||||||
this.leftBox.perDay.push(formatMoney(current.value, current.currency_code));
|
this.leftBox.perDay.push(formatMoney(current.monetary_value , current.currency_code));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (key.startsWith('net-worth-in-')) {
|
if (key.startsWith('net-worth-in-')) {
|
||||||
this.netBox.net.push(formatMoney(current.value, current.currency_code));
|
this.netBox.net.push(formatMoney(current.monetary_value , current.currency_code));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,10 +213,10 @@ export default () => ({
|
|||||||
init() {
|
init() {
|
||||||
// console.log('boxes init');
|
// console.log('boxes init');
|
||||||
// TODO can be replaced by "getVariables"
|
// TODO can be replaced by "getVariables"
|
||||||
Promise.all([getVariable('viewRange'), getVariable('autoConversion', false)]).then((values) => {
|
Promise.all([getVariable('viewRange'), getVariable('convertToNative', false)]).then((values) => {
|
||||||
// console.log('boxes after promises');
|
// console.log('boxes after promises');
|
||||||
afterPromises = true;
|
afterPromises = true;
|
||||||
this.autoConversion = values[1];
|
this.convertToNative = values[1];
|
||||||
this.loadBoxes();
|
this.loadBoxes();
|
||||||
});
|
});
|
||||||
window.store.observe('end', () => {
|
window.store.observe('end', () => {
|
||||||
@@ -224,12 +227,12 @@ export default () => ({
|
|||||||
this.boxData = null;
|
this.boxData = null;
|
||||||
this.loadBoxes();
|
this.loadBoxes();
|
||||||
});
|
});
|
||||||
window.store.observe('autoConversion', (newValue) => {
|
window.store.observe('convertToNative', (newValue) => {
|
||||||
if (!afterPromises) {
|
if (!afterPromises) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// console.log('boxes observe autoConversion');
|
// console.log('boxes observe convertToNative');
|
||||||
this.autoConversion = newValue;
|
this.convertToNative = newValue;
|
||||||
this.loadBoxes();
|
this.loadBoxes();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@@ -34,7 +34,7 @@ let afterPromises = false;
|
|||||||
|
|
||||||
export default () => ({
|
export default () => ({
|
||||||
loading: false,
|
loading: false,
|
||||||
autoConversion: false,
|
convertToNative: false,
|
||||||
loadChart() {
|
loadChart() {
|
||||||
if (true === this.loading) {
|
if (true === this.loading) {
|
||||||
return;
|
return;
|
||||||
@@ -134,7 +134,7 @@ export default () => ({
|
|||||||
// // convert to EUR yes no?
|
// // convert to EUR yes no?
|
||||||
let label = current.label + ' (' + current.currency_code + ')';
|
let label = current.label + ' (' + current.currency_code + ')';
|
||||||
options.data.labels.push(label);
|
options.data.labels.push(label);
|
||||||
if (this.autoConversion) {
|
if (this.convertToNative) {
|
||||||
currencies.push(current.native_currency_code);
|
currencies.push(current.native_currency_code);
|
||||||
// series 0: spent
|
// series 0: spent
|
||||||
options.data.datasets[0].data.push(parseFloat(current.native_entries.spent) * -1);
|
options.data.datasets[0].data.push(parseFloat(current.native_entries.spent) * -1);
|
||||||
@@ -143,7 +143,7 @@ export default () => ({
|
|||||||
// series 2: overspent
|
// series 2: overspent
|
||||||
options.data.datasets[2].data.push(parseFloat(current.native_entries.overspent));
|
options.data.datasets[2].data.push(parseFloat(current.native_entries.overspent));
|
||||||
}
|
}
|
||||||
if (!this.autoConversion) {
|
if (!this.convertToNative) {
|
||||||
currencies.push(current.currency_code);
|
currencies.push(current.currency_code);
|
||||||
// series 0: spent
|
// series 0: spent
|
||||||
options.data.datasets[0].data.push(parseFloat(current.entries.spent) * -1);
|
options.data.datasets[0].data.push(parseFloat(current.entries.spent) * -1);
|
||||||
@@ -172,8 +172,8 @@ export default () => ({
|
|||||||
|
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
Promise.all([getVariable('autoConversion', false)]).then((values) => {
|
Promise.all([getVariable('convertToNative', false)]).then((values) => {
|
||||||
this.autoConversion = values[0];
|
this.convertToNative = values[0];
|
||||||
afterPromises = true;
|
afterPromises = true;
|
||||||
if (false === this.loading) {
|
if (false === this.loading) {
|
||||||
this.loadChart();
|
this.loadChart();
|
||||||
@@ -189,12 +189,12 @@ export default () => ({
|
|||||||
this.loadChart();
|
this.loadChart();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
window.store.observe('autoConversion', (newValue) => {
|
window.store.observe('convertToNative', (newValue) => {
|
||||||
if (!afterPromises) {
|
if (!afterPromises) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// console.log('boxes observe autoConversion');
|
// console.log('boxes observe convertToNative');
|
||||||
this.autoConversion = newValue;
|
this.convertToNative = newValue;
|
||||||
if (false === this.loading) {
|
if (false === this.loading) {
|
||||||
this.loadChart();
|
this.loadChart();
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ let afterPromises = false;
|
|||||||
|
|
||||||
export default () => ({
|
export default () => ({
|
||||||
loading: false,
|
loading: false,
|
||||||
autoConversion: false,
|
convertToNative: false,
|
||||||
generateOptions(data) {
|
generateOptions(data) {
|
||||||
currencies = [];
|
currencies = [];
|
||||||
let options = getDefaultChartSettings('column');
|
let options = getDefaultChartSettings('column');
|
||||||
@@ -44,7 +44,7 @@ export default () => ({
|
|||||||
let current = data[i];
|
let current = data[i];
|
||||||
let code = current.currency_code;
|
let code = current.currency_code;
|
||||||
// only use native code when doing auto conversion.
|
// only use native code when doing auto conversion.
|
||||||
if (this.autoConversion) {
|
if (this.convertToNative) {
|
||||||
code = current.native_currency_code;
|
code = current.native_currency_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ export default () => ({
|
|||||||
let yAxis = 'y';
|
let yAxis = 'y';
|
||||||
let current = data[i];
|
let current = data[i];
|
||||||
let code = current.currency_code;
|
let code = current.currency_code;
|
||||||
if (this.autoConversion) {
|
if (this.convertToNative) {
|
||||||
code = current.native_currency_code;
|
code = current.native_currency_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ export default () => ({
|
|||||||
// this series' currency matches this column's currency.
|
// this series' currency matches this column's currency.
|
||||||
amount = parseFloat(current.amount);
|
amount = parseFloat(current.amount);
|
||||||
yAxis = 'y' + current.currency_code;
|
yAxis = 'y' + current.currency_code;
|
||||||
if (this.autoConversion) {
|
if (this.convertToNative) {
|
||||||
amount = parseFloat(current.native_amount);
|
amount = parseFloat(current.native_amount);
|
||||||
yAxis = 'y' + current.native_currency_code;
|
yAxis = 'y' + current.native_currency_code;
|
||||||
}
|
}
|
||||||
@@ -183,8 +183,8 @@ export default () => ({
|
|||||||
},
|
},
|
||||||
init() {
|
init() {
|
||||||
// console.log('categories init');
|
// console.log('categories init');
|
||||||
Promise.all([getVariable('autoConversion', false),]).then((values) => {
|
Promise.all([getVariable('convertToNative', false),]).then((values) => {
|
||||||
this.autoConversion = values[0];
|
this.convertToNative = values[0];
|
||||||
afterPromises = true;
|
afterPromises = true;
|
||||||
this.loadChart();
|
this.loadChart();
|
||||||
});
|
});
|
||||||
@@ -195,11 +195,11 @@ export default () => ({
|
|||||||
this.chartData = null;
|
this.chartData = null;
|
||||||
this.loadChart();
|
this.loadChart();
|
||||||
});
|
});
|
||||||
window.store.observe('autoConversion', (newValue) => {
|
window.store.observe('convertToNative', (newValue) => {
|
||||||
if (!afterPromises) {
|
if (!afterPromises) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.autoConversion = newValue;
|
this.convertToNative = newValue;
|
||||||
this.loadChart();
|
this.loadChart();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@@ -29,7 +29,7 @@ const PIGGY_CACHE_KEY = 'ds_pg_data';
|
|||||||
|
|
||||||
export default () => ({
|
export default () => ({
|
||||||
loading: false,
|
loading: false,
|
||||||
autoConversion: false,
|
convertToNative: false,
|
||||||
sankeyGrouping: 'account',
|
sankeyGrouping: 'account',
|
||||||
piggies: [],
|
piggies: [],
|
||||||
getFreshData() {
|
getFreshData() {
|
||||||
@@ -96,14 +96,14 @@ export default () => ({
|
|||||||
id: current.id,
|
id: current.id,
|
||||||
name: current.attributes.name,
|
name: current.attributes.name,
|
||||||
percentage: parseInt(current.attributes.percentage),
|
percentage: parseInt(current.attributes.percentage),
|
||||||
amount: this.autoConversion ? current.attributes.native_current_amount : current.attributes.current_amount,
|
amount: this.convertToNative ? current.attributes.native_current_amount : current.attributes.current_amount,
|
||||||
// left to save
|
// left to save
|
||||||
left_to_save: this.autoConversion ? current.attributes.native_left_to_save : current.attributes.left_to_save,
|
left_to_save: this.convertToNative ? current.attributes.native_left_to_save : current.attributes.left_to_save,
|
||||||
// target amount
|
// target amount
|
||||||
target_amount: this.autoConversion ? current.attributes.native_target_amount : current.attributes.target_amount,
|
target_amount: this.convertToNative ? current.attributes.native_target_amount : current.attributes.target_amount,
|
||||||
// save per month
|
// save per month
|
||||||
save_per_month: this.autoConversion ? current.attributes.native_save_per_month : current.attributes.save_per_month,
|
save_per_month: this.convertToNative ? current.attributes.native_save_per_month : current.attributes.save_per_month,
|
||||||
currency_code: this.autoConversion ? current.attributes.native_currency_code : current.attributes.currency_code,
|
currency_code: this.convertToNative ? current.attributes.native_currency_code : current.attributes.currency_code,
|
||||||
|
|
||||||
};
|
};
|
||||||
dataSet[groupName].piggies.push(piggy);
|
dataSet[groupName].piggies.push(piggy);
|
||||||
@@ -129,10 +129,10 @@ export default () => ({
|
|||||||
init() {
|
init() {
|
||||||
// console.log('piggies init');
|
// console.log('piggies init');
|
||||||
apiData = [];
|
apiData = [];
|
||||||
Promise.all([getVariable('autoConversion', false)]).then((values) => {
|
Promise.all([getVariable('convertToNative', false)]).then((values) => {
|
||||||
|
|
||||||
afterPromises = true;
|
afterPromises = true;
|
||||||
this.autoConversion = values[0];
|
this.convertToNative = values[0];
|
||||||
this.loadPiggyBanks();
|
this.loadPiggyBanks();
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -144,12 +144,12 @@ export default () => ({
|
|||||||
apiData = [];
|
apiData = [];
|
||||||
this.loadPiggyBanks();
|
this.loadPiggyBanks();
|
||||||
});
|
});
|
||||||
window.store.observe('autoConversion', (newValue) => {
|
window.store.observe('convertToNative', (newValue) => {
|
||||||
if (!afterPromises) {
|
if (!afterPromises) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// console.log('piggies observe autoConversion');
|
// console.log('piggies observe convertToNative');
|
||||||
this.autoConversion = newValue;
|
this.convertToNative = newValue;
|
||||||
this.loadPiggyBanks();
|
this.loadPiggyBanks();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@@ -33,7 +33,7 @@ let currencies = [];
|
|||||||
let afterPromises = false;
|
let afterPromises = false;
|
||||||
let chart = null;
|
let chart = null;
|
||||||
let transactions = [];
|
let transactions = [];
|
||||||
let autoConversion = false;
|
let convertToNative = false;
|
||||||
let translations = {
|
let translations = {
|
||||||
category: null,
|
category: null,
|
||||||
unknown_category: null,
|
unknown_category: null,
|
||||||
@@ -83,37 +83,37 @@ function getObjectName(type, name, direction, code) {
|
|||||||
|
|
||||||
// category 4x
|
// category 4x
|
||||||
if ('category' === type && null !== name && 'in' === direction) {
|
if ('category' === type && null !== name && 'in' === direction) {
|
||||||
return translations.category + ' "' + name + '" (' + translations.in + (autoConversion ? ', ' + code + ')' : ')');
|
return translations.category + ' "' + name + '" (' + translations.in + (convertToNative ? ', ' + code + ')' : ')');
|
||||||
}
|
}
|
||||||
if ('category' === type && null === name && 'in' === direction) {
|
if ('category' === type && null === name && 'in' === direction) {
|
||||||
return translations.unknown_category + ' (' + translations.in + (autoConversion ? ', ' + code + ')' : ')');
|
return translations.unknown_category + ' (' + translations.in + (convertToNative ? ', ' + code + ')' : ')');
|
||||||
}
|
}
|
||||||
if ('category' === type && null !== name && 'out' === direction) {
|
if ('category' === type && null !== name && 'out' === direction) {
|
||||||
return translations.category + ' "' + name + '" (' + translations.out + (autoConversion ? ', ' + code + ')' : ')');
|
return translations.category + ' "' + name + '" (' + translations.out + (convertToNative ? ', ' + code + ')' : ')');
|
||||||
}
|
}
|
||||||
if ('category' === type && null === name && 'out' === direction) {
|
if ('category' === type && null === name && 'out' === direction) {
|
||||||
return translations.unknown_category + ' (' + translations.out + (autoConversion ? ', ' + code + ')' : ')');
|
return translations.unknown_category + ' (' + translations.out + (convertToNative ? ', ' + code + ')' : ')');
|
||||||
}
|
}
|
||||||
// account 4x
|
// account 4x
|
||||||
if ('account' === type && null === name && 'in' === direction) {
|
if ('account' === type && null === name && 'in' === direction) {
|
||||||
return translations.unknown_source + (autoConversion ? ' (' + code + ')' : '');
|
return translations.unknown_source + (convertToNative ? ' (' + code + ')' : '');
|
||||||
}
|
}
|
||||||
if ('account' === type && null !== name && 'in' === direction) {
|
if ('account' === type && null !== name && 'in' === direction) {
|
||||||
return translations.revenue_account + '"' + name + '"' + (autoConversion ? ' (' + code + ')' : '');
|
return translations.revenue_account + '"' + name + '"' + (convertToNative ? ' (' + code + ')' : '');
|
||||||
}
|
}
|
||||||
if ('account' === type && null === name && 'out' === direction) {
|
if ('account' === type && null === name && 'out' === direction) {
|
||||||
return translations.unknown_dest + (autoConversion ? ' (' + code + ')' : '');
|
return translations.unknown_dest + (convertToNative ? ' (' + code + ')' : '');
|
||||||
}
|
}
|
||||||
if ('account' === type && null !== name && 'out' === direction) {
|
if ('account' === type && null !== name && 'out' === direction) {
|
||||||
return translations.expense_account + ' "' + name + '"' + (autoConversion ? ' (' + code + ')' : '');
|
return translations.expense_account + ' "' + name + '"' + (convertToNative ? ' (' + code + ')' : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// budget 2x
|
// budget 2x
|
||||||
if ('budget' === type && null !== name) {
|
if ('budget' === type && null !== name) {
|
||||||
return translations.budget + ' "' + name + '"' + (autoConversion ? ' (' + code + ')' : '');
|
return translations.budget + ' "' + name + '"' + (convertToNative ? ' (' + code + ')' : '');
|
||||||
}
|
}
|
||||||
if ('budget' === type && null === name) {
|
if ('budget' === type && null === name) {
|
||||||
return translations.unknown_budget + (autoConversion ? ' (' + code + ')' : '');
|
return translations.unknown_budget + (convertToNative ? ' (' + code + ')' : '');
|
||||||
}
|
}
|
||||||
console.error('Cannot handle: type:"' + type + '", dir: "' + direction + '"');
|
console.error('Cannot handle: type:"' + type + '", dir: "' + direction + '"');
|
||||||
}
|
}
|
||||||
@@ -121,25 +121,25 @@ function getObjectName(type, name, direction, code) {
|
|||||||
function getLabelName(type, name, code) {
|
function getLabelName(type, name, code) {
|
||||||
// category
|
// category
|
||||||
if ('category' === type && null !== name) {
|
if ('category' === type && null !== name) {
|
||||||
return translations.category + ' "' + name + '"' + (autoConversion ? ' (' + code + ')' : '');
|
return translations.category + ' "' + name + '"' + (convertToNative ? ' (' + code + ')' : '');
|
||||||
}
|
}
|
||||||
if ('category' === type && null === name) {
|
if ('category' === type && null === name) {
|
||||||
return translations.unknown_category + (autoConversion ? ' (' + code + ')' : '');
|
return translations.unknown_category + (convertToNative ? ' (' + code + ')' : '');
|
||||||
}
|
}
|
||||||
// account
|
// account
|
||||||
if ('account' === type && null === name) {
|
if ('account' === type && null === name) {
|
||||||
return translations.unknown_account + (autoConversion ? ' (' + code + ')' : '');
|
return translations.unknown_account + (convertToNative ? ' (' + code + ')' : '');
|
||||||
}
|
}
|
||||||
if ('account' === type && null !== name) {
|
if ('account' === type && null !== name) {
|
||||||
return name + (autoConversion ? ' (' + code + ')' : '');
|
return name + (convertToNative ? ' (' + code + ')' : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// budget 2x
|
// budget 2x
|
||||||
if ('budget' === type && null !== name) {
|
if ('budget' === type && null !== name) {
|
||||||
return translations.budget + ' "' + name + '"' + (autoConversion ? ' (' + code + ')' : '');
|
return translations.budget + ' "' + name + '"' + (convertToNative ? ' (' + code + ')' : '');
|
||||||
}
|
}
|
||||||
if ('budget' === type && null === name) {
|
if ('budget' === type && null === name) {
|
||||||
return translations.unknown_budget + (autoConversion ? ' (' + code + ')' : '');
|
return translations.unknown_budget + (convertToNative ? ' (' + code + ')' : '');
|
||||||
}
|
}
|
||||||
console.error('Cannot handle: type:"' + type + '"');
|
console.error('Cannot handle: type:"' + type + '"');
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ function getLabelName(type, name, code) {
|
|||||||
|
|
||||||
export default () => ({
|
export default () => ({
|
||||||
loading: false,
|
loading: false,
|
||||||
autoConversion: false,
|
convertToNative: false,
|
||||||
generateOptions() {
|
generateOptions() {
|
||||||
let options = getDefaultChartSettings('sankey');
|
let options = getDefaultChartSettings('sankey');
|
||||||
|
|
||||||
@@ -164,8 +164,8 @@ export default () => ({
|
|||||||
if (group.attributes.transactions.hasOwnProperty(ii)) {
|
if (group.attributes.transactions.hasOwnProperty(ii)) {
|
||||||
// properties of the transaction, used in the generation of the chart:
|
// properties of the transaction, used in the generation of the chart:
|
||||||
let transaction = group.attributes.transactions[ii];
|
let transaction = group.attributes.transactions[ii];
|
||||||
let currencyCode = this.autoConversion ? transaction.native_currency_code : transaction.currency_code;
|
let currencyCode = this.convertToNative ? transaction.native_currency_code : transaction.currency_code;
|
||||||
let amount = this.autoConversion ? parseFloat(transaction.native_amount) : parseFloat(transaction.amount);
|
let amount = this.convertToNative ? parseFloat(transaction.native_amount) : parseFloat(transaction.amount);
|
||||||
let flowKey;
|
let flowKey;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -194,7 +194,7 @@ export default () => ({
|
|||||||
if (!amounts.hasOwnProperty(flowKey)) {
|
if (!amounts.hasOwnProperty(flowKey)) {
|
||||||
amounts[flowKey] = {
|
amounts[flowKey] = {
|
||||||
from: category,
|
from: category,
|
||||||
to: translations.all_money + (this.autoConversion ? ' (' + currencyCode + ')' : ''),
|
to: translations.all_money + (this.convertToNative ? ' (' + currencyCode + ')' : ''),
|
||||||
amount: 0
|
amount: 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -214,7 +214,7 @@ export default () => ({
|
|||||||
|
|
||||||
if (!amounts.hasOwnProperty(flowKey)) {
|
if (!amounts.hasOwnProperty(flowKey)) {
|
||||||
amounts[flowKey] = {
|
amounts[flowKey] = {
|
||||||
from: translations.all_money + (this.autoConversion ? ' (' + currencyCode + ')' : ''),
|
from: translations.all_money + (this.convertToNative ? ' (' + currencyCode + ')' : ''),
|
||||||
to: budget,
|
to: budget,
|
||||||
amount: 0
|
amount: 0
|
||||||
};
|
};
|
||||||
@@ -348,9 +348,9 @@ export default () => ({
|
|||||||
init() {
|
init() {
|
||||||
// console.log('sankey init');
|
// console.log('sankey init');
|
||||||
transactions = [];
|
transactions = [];
|
||||||
Promise.all([getVariable('autoConversion', false)]).then((values) => {
|
Promise.all([getVariable('convertToNative', false)]).then((values) => {
|
||||||
this.autoConversion = values[0];
|
this.convertToNative = values[0];
|
||||||
autoConversion = values[0];
|
convertToNative = values[0];
|
||||||
// some translations:
|
// some translations:
|
||||||
translations.all_money = i18next.t('firefly.all_money');
|
translations.all_money = i18next.t('firefly.all_money');
|
||||||
translations.category = i18next.t('firefly.category');
|
translations.category = i18next.t('firefly.category');
|
||||||
@@ -378,12 +378,12 @@ export default () => ({
|
|||||||
this.transactions = [];
|
this.transactions = [];
|
||||||
this.loadChart();
|
this.loadChart();
|
||||||
});
|
});
|
||||||
window.store.observe('autoConversion', (newValue) => {
|
window.store.observe('convertToNative', (newValue) => {
|
||||||
if (!afterPromises) {
|
if (!afterPromises) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// console.log('sankey observe autoConversion');
|
// console.log('sankey observe convertToNative');
|
||||||
this.autoConversion = newValue;
|
this.convertToNative = newValue;
|
||||||
this.loadChart();
|
this.loadChart();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@@ -79,7 +79,7 @@ function downloadSubscriptions(params) {
|
|||||||
paid: current.attributes.paid_dates.length > 0,
|
paid: current.attributes.paid_dates.length > 0,
|
||||||
};
|
};
|
||||||
// set variables
|
// set variables
|
||||||
bill.expected_amount = params.autoConversion ? formatMoney(bill.native_amount, bill.native_currency_code) :
|
bill.expected_amount = params.convertToNative ? formatMoney(bill.native_amount, bill.native_currency_code) :
|
||||||
formatMoney(bill.amount, bill.currency_code);
|
formatMoney(bill.amount, bill.currency_code);
|
||||||
bill.expected_times = i18next.t('firefly.subscr_expected_x_times', {
|
bill.expected_times = i18next.t('firefly.subscr_expected_x_times', {
|
||||||
times: current.attributes.pay_dates.length,
|
times: current.attributes.pay_dates.length,
|
||||||
@@ -92,22 +92,22 @@ function downloadSubscriptions(params) {
|
|||||||
const currentPayment = current.attributes.paid_dates[iii];
|
const currentPayment = current.attributes.paid_dates[iii];
|
||||||
let percentage = 100;
|
let percentage = 100;
|
||||||
// math: -100+(paid/expected)*100
|
// math: -100+(paid/expected)*100
|
||||||
if (params.autoConversion) {
|
if (params.convertToNative) {
|
||||||
percentage = Math.round(-100 + ((parseFloat(currentPayment.native_amount) * -1) / parseFloat(bill.native_amount)) * 100);
|
percentage = Math.round(-100 + ((parseFloat(currentPayment.native_amount) * -1) / parseFloat(bill.native_amount)) * 100);
|
||||||
}
|
}
|
||||||
if (!params.autoConversion) {
|
if (!params.convertToNative) {
|
||||||
percentage = Math.round(-100 + ((parseFloat(currentPayment.amount) * -1) / parseFloat(bill.amount)) * 100);
|
percentage = Math.round(-100 + ((parseFloat(currentPayment.amount) * -1) / parseFloat(bill.amount)) * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
let currentTransaction = {
|
let currentTransaction = {
|
||||||
amount: params.autoConversion ? formatMoney(currentPayment.native_amount, currentPayment.native_currency_code) : formatMoney(currentPayment.amount, currentPayment.currency_code),
|
amount: params.convertToNative ? formatMoney(currentPayment.native_amount, currentPayment.native_currency_code) : formatMoney(currentPayment.amount, currentPayment.currency_code),
|
||||||
percentage: percentage,
|
percentage: percentage,
|
||||||
date: format(new Date(currentPayment.date), 'PP'),
|
date: format(new Date(currentPayment.date), 'PP'),
|
||||||
foreign_amount: null,
|
foreign_amount: null,
|
||||||
};
|
};
|
||||||
if (null !== currentPayment.foreign_currency_code) {
|
if (null !== currentPayment.foreign_currency_code) {
|
||||||
currentTransaction.foreign_amount = params.autoConversion ? currentPayment.foreign_native_amount : currentPayment.foreign_amount;
|
currentTransaction.foreign_amount = params.convertToNative ? currentPayment.foreign_native_amount : currentPayment.foreign_amount;
|
||||||
currentTransaction.foreign_currency_code = params.autoConversion ? currentPayment.native_currency_code : currentPayment.foreign_currency_code;
|
currentTransaction.foreign_currency_code = params.convertToNative ? currentPayment.native_currency_code : currentPayment.foreign_currency_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
bill.transactions.push(currentTransaction);
|
bill.transactions.push(currentTransaction);
|
||||||
@@ -178,7 +178,7 @@ function downloadSubscriptions(params) {
|
|||||||
|
|
||||||
export default () => ({
|
export default () => ({
|
||||||
loading: false,
|
loading: false,
|
||||||
autoConversion: false,
|
convertToNative: false,
|
||||||
subscriptions: [],
|
subscriptions: [],
|
||||||
startSubscriptions() {
|
startSubscriptions() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
@@ -198,7 +198,7 @@ export default () => ({
|
|||||||
let params = {
|
let params = {
|
||||||
start: format(start, 'y-MM-dd'),
|
start: format(start, 'y-MM-dd'),
|
||||||
end: format(end, 'y-MM-dd'),
|
end: format(end, 'y-MM-dd'),
|
||||||
autoConversion: this.autoConversion,
|
convertToNative: this.convertToNative,
|
||||||
page: 1
|
page: 1
|
||||||
};
|
};
|
||||||
downloadSubscriptions(params).then(() => {
|
downloadSubscriptions(params).then(() => {
|
||||||
@@ -226,9 +226,9 @@ export default () => ({
|
|||||||
drawPieChart(groupId, groupTitle, data) {
|
drawPieChart(groupId, groupTitle, data) {
|
||||||
let id = '#pie_' + groupId + '_' + data.currency_code;
|
let id = '#pie_' + groupId + '_' + data.currency_code;
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
const unpaidAmount = this.autoConversion ? data.native_unpaid : data.unpaid;
|
const unpaidAmount = this.convertToNative ? data.native_unpaid : data.unpaid;
|
||||||
const paidAmount = this.autoConversion ? data.native_paid : data.paid;
|
const paidAmount = this.convertToNative ? data.native_paid : data.paid;
|
||||||
const currencyCode = this.autoConversion ? data.native_currency_code : data.currency_code;
|
const currencyCode = this.convertToNative ? data.native_currency_code : data.currency_code;
|
||||||
const chartData = {
|
const chartData = {
|
||||||
labels: [
|
labels: [
|
||||||
i18next.t('firefly.paid'),
|
i18next.t('firefly.paid'),
|
||||||
@@ -267,8 +267,8 @@ export default () => ({
|
|||||||
},
|
},
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
Promise.all([getVariable('autoConversion', false)]).then((values) => {
|
Promise.all([getVariable('convertToNative', false)]).then((values) => {
|
||||||
this.autoConversion = values[0];
|
this.convertToNative = values[0];
|
||||||
afterPromises = true;
|
afterPromises = true;
|
||||||
|
|
||||||
if (false === this.loading) {
|
if (false === this.loading) {
|
||||||
@@ -285,11 +285,11 @@ export default () => ({
|
|||||||
this.startSubscriptions();
|
this.startSubscriptions();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
window.store.observe('autoConversion', (newValue) => {
|
window.store.observe('convertToNative', (newValue) => {
|
||||||
if (!afterPromises) {
|
if (!afterPromises) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.autoConversion = newValue;
|
this.convertToNative = newValue;
|
||||||
if (false === this.loading) {
|
if (false === this.loading) {
|
||||||
this.startSubscriptions();
|
this.startSubscriptions();
|
||||||
}
|
}
|
||||||
|
@@ -9,17 +9,17 @@
|
|||||||
<div class="card-body p-0" style="position: relative;height:400px;">
|
<div class="card-body p-0" style="position: relative;height:400px;">
|
||||||
<canvas id="account-chart"></canvas>
|
<canvas id="account-chart"></canvas>
|
||||||
</div>
|
</div>
|
||||||
<template x-if="autoConversionAvailable">
|
<template x-if="convertToNativeAvailable">
|
||||||
<div class="card-footer text-end">
|
<div class="card-footer text-end">
|
||||||
<template x-if="autoConversion">
|
<template x-if="convertToNative">
|
||||||
<button type="button" @click="switchAutoConversion"
|
<button type="button" @click="switchconvertToNative"
|
||||||
class="btn btn-outline-info btm-sm">
|
class="btn btn-outline-info btm-sm">
|
||||||
<span
|
<span
|
||||||
class="fa-solid fa-comments-dollar"></span> {{ __('firefly.disable_auto_convert') }}
|
class="fa-solid fa-comments-dollar"></span> {{ __('firefly.disable_auto_convert') }}
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
<template x-if="!autoConversion">
|
<template x-if="!convertToNative">
|
||||||
<button type="button" @click="switchAutoConversion"
|
<button type="button" @click="switchconvertToNative"
|
||||||
class="btn btn-outline-info btm-sm">
|
class="btn btn-outline-info btm-sm">
|
||||||
<span
|
<span
|
||||||
class="fa-solid fa-comments-dollar"></span> {{ __('firefly.enable_auto_convert') }}
|
class="fa-solid fa-comments-dollar"></span> {{ __('firefly.enable_auto_convert') }}
|
||||||
|
@@ -75,7 +75,7 @@
|
|||||||
<ul class="list-unstyled list-no-margin">
|
<ul class="list-unstyled list-no-margin">
|
||||||
<template x-for="transaction in group.transactions">
|
<template x-for="transaction in group.transactions">
|
||||||
<li>
|
<li>
|
||||||
@include('partials.elements.amount', ['autoConversion' => true,'type' => 'transaction.type','amount' => 'transaction.amount','native' => 'transaction.native_amount'])
|
@include('partials.elements.amount', ['convertToNative' => true,'type' => 'transaction.type','amount' => 'transaction.amount','native' => 'transaction.native_amount'])
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
</ul>
|
</ul>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
@if($autoConversion)
|
@if($convertToNative)
|
||||||
<template x-if="autoConversion">
|
<template x-if="convertToNative">
|
||||||
<span>
|
<span>
|
||||||
<template x-if="{{ $native }}_raw < 0">
|
<template x-if="{{ $native }}_raw < 0">
|
||||||
<span class="text-danger">
|
<span class="text-danger">
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<template x-if="!autoConversion">
|
<template x-if="!convertToNative">
|
||||||
<span>
|
<span>
|
||||||
<template x-if="{{ $amount }}_raw < 0">
|
<template x-if="{{ $amount }}_raw < 0">
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user