From cfb86c683e9789e8c4b506007c2348c223b07d56 Mon Sep 17 00:00:00 2001 From: Sander Dorigo Date: Fri, 1 Aug 2025 12:40:54 +0200 Subject: [PATCH] Replace native with primary --- .../assets/v2/src/pages/dashboard/accounts.js | 26 ++++++++----------- .../assets/v2/src/pages/dashboard/boxes.js | 8 +++--- .../assets/v2/src/pages/dashboard/budgets.js | 6 ++--- .../v2/src/pages/dashboard/categories.js | 6 ++--- .../v2/src/pages/dashboard/dashboard.js | 10 +++---- .../assets/v2/src/pages/dashboard/piggies.js | 14 +++++----- .../assets/v2/src/pages/dashboard/sankey.js | 10 +++---- .../v2/src/pages/dashboard/subscriptions.js | 11 ++++---- .../v2/src/pages/transactions/create.js | 16 ++++++------ .../assets/v2/src/pages/transactions/edit.js | 4 +-- .../transactions/shared/load-currencies.js | 4 +-- 11 files changed, 55 insertions(+), 60 deletions(-) diff --git a/resources/assets/v2/src/pages/dashboard/accounts.js b/resources/assets/v2/src/pages/dashboard/accounts.js index ab05424bdd..1934c73f63 100644 --- a/resources/assets/v2/src/pages/dashboard/accounts.js +++ b/resources/assets/v2/src/pages/dashboard/accounts.js @@ -46,7 +46,7 @@ export default () => ({ }, eventListeners: { - ['@convert-to-native.window'](event){ + ['@convert-to-primary.window'](event){ console.log('I heard that! (dashboard/accounts)'); this.convertToPrimary = event.detail; this.accountList = []; @@ -99,17 +99,17 @@ export default () => ({ } dataset.label = current.label; - // use the "native" currency code and use the "native_entries" as array + // use the "primary" currency code and use the "pc_entries" as array 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.convertToPrimary+') found for account: ', current); + currencies.push(current.primary_currency_code); + dataset.currency_code = current.primary_currency_code; + if(!current.hasOwnProperty('pc_entries')) { + console.error('No primary entries ('+this.convertToPrimary+') found for account: ', current); } - if(current.hasOwnProperty('native_entries')) { - collection = Object.values(current.native_entries); + if(current.hasOwnProperty('pc_entries')) { + collection = Object.values(current.pc_entries); } - yAxis = 'y' + current.native_currency_code; + yAxis = 'y' + current.primary_currency_code; } if (!this.convertToPrimary) { yAxis = 'y' + current.currency_code; @@ -240,12 +240,10 @@ export default () => ({ for (let iii = 0; iii < current.attributes.transactions.length; iii++) { let currentTransaction = current.attributes.transactions[iii]; //console.log(currentTransaction); - //let nativeAmountRaw = 'withdrawal' === currentTransaction.type ? parseFloat(currentTransaction.native_amount) * -1 : parseFloat(currentTransaction.native_amount); let amountRaw = 'withdrawal' === currentTransaction.type ? parseFloat(currentTransaction.amount) * -1 : parseFloat(currentTransaction.amount); // if transfer and source is this account, multiply again if('transfer' === currentTransaction.type && parseInt(currentTransaction.source_id) === accountId) { // - // nativeAmountRaw = nativeAmountRaw * -1; amountRaw = amountRaw * -1; } @@ -255,8 +253,6 @@ export default () => ({ type: currentTransaction.type, amount_raw: amountRaw, amount: formatMoney(amountRaw, currentTransaction.currency_code), - // native_amount_raw: nativeAmountRaw, - // native_amount: formatMoney(nativeAmountRaw, currentTransaction.native_currency_code), }); } groups.push(group); @@ -290,7 +286,7 @@ export default () => ({ // console.log('accounts init'); Promise.all([ getVariable('viewRange', '1M'), // 0 - getVariable('convert_to_native', false), // 1 + getVariable('convert_to_primary', false), // 1 getVariable('language', 'en_US'), // 2 getConfiguration('cer.enabled', false) // 3 ]).then((values) => { @@ -314,7 +310,7 @@ export default () => ({ this.loadChart(); this.loadAccounts(); }); - window.store.observe('convert_to_native', () => { + window.store.observe('convert_to_primary', () => { if (!afterPromises) { return; } diff --git a/resources/assets/v2/src/pages/dashboard/boxes.js b/resources/assets/v2/src/pages/dashboard/boxes.js index 89e7de2228..ef2391f386 100644 --- a/resources/assets/v2/src/pages/dashboard/boxes.js +++ b/resources/assets/v2/src/pages/dashboard/boxes.js @@ -36,7 +36,7 @@ export default () => ({ boxData: null, boxOptions: null, eventListeners: { - ['@convert-to-native.window'](event){ + ['@convert-to-primary.window'](event){ this.convertToPrimary = event.detail; this.accountList = []; console.log('I heard that! (dashboard/boxes)'); @@ -86,7 +86,7 @@ export default () => ({ continue; } let key = current.key; - // console.log('NOT NATIVE'); + // console.log('NOT PRIMARY CURRENCY'); if (key.startsWith('balance-in-')) { this.balanceBox.amounts.push(formatMoney(current.monetary_value, current.currency_code)); continue; @@ -163,7 +163,7 @@ export default () => ({ init() { // console.log('boxes init'); // TODO can be replaced by "getVariables" - Promise.all([getVariable('viewRange'), getVariable('convert_to_native', false)]).then((values) => { + Promise.all([getVariable('viewRange'), getVariable('convert_to_primary', false)]).then((values) => { // console.log('boxes after promises'); afterPromises = true; this.convertToPrimary = values[1]; @@ -177,7 +177,7 @@ export default () => ({ this.boxData = null; this.loadBoxes(); }); - window.store.observe('convert_to_native', (newValue) => { + window.store.observe('convert_to_primary', (newValue) => { if (!afterPromises) { return; } diff --git a/resources/assets/v2/src/pages/dashboard/budgets.js b/resources/assets/v2/src/pages/dashboard/budgets.js index 88868fa93e..34d33d5bc9 100644 --- a/resources/assets/v2/src/pages/dashboard/budgets.js +++ b/resources/assets/v2/src/pages/dashboard/budgets.js @@ -50,7 +50,7 @@ export default () => ({ }, eventListeners: { - ['@convert-to-native.window'](event){ + ['@convert-to-primary.window'](event){ console.log('I heard that! (dashboard/budgets)'); this.convertToPrimary = event.detail; chartData = null; @@ -167,7 +167,7 @@ export default () => ({ init() { - Promise.all([getVariable('convert_to_native', false)]).then((values) => { + Promise.all([getVariable('convert_to_primary', false)]).then((values) => { this.convertToPrimary = values[0]; afterPromises = true; if (false === this.loading) { @@ -184,7 +184,7 @@ export default () => ({ this.loadChart(); } }); - window.store.observe('convert_to_native', (newValue) => { + window.store.observe('convert_to_primary', (newValue) => { if (!afterPromises) { return; } diff --git a/resources/assets/v2/src/pages/dashboard/categories.js b/resources/assets/v2/src/pages/dashboard/categories.js index b316e7b5f3..d75da3acfb 100644 --- a/resources/assets/v2/src/pages/dashboard/categories.js +++ b/resources/assets/v2/src/pages/dashboard/categories.js @@ -35,7 +35,7 @@ export default () => ({ convertToPrimary: false, eventListeners: { - ['@convert-to-native.window'](event){ + ['@convert-to-primary.window'](event){ console.log('I heard that! (dashboard/categories)'); this.convertToPrimary = event.detail; chartData = null; @@ -182,7 +182,7 @@ export default () => ({ }, init() { // console.log('categories init'); - Promise.all([getVariable('convert_to_native', false),]).then((values) => { + Promise.all([getVariable('convert_to_primary', false),]).then((values) => { this.convertToPrimary = values[0]; afterPromises = true; this.loadChart(); @@ -194,7 +194,7 @@ export default () => ({ this.chartData = null; this.loadChart(); }); - window.store.observe('convert_to_native', (newValue) => { + window.store.observe('convert_to_primary', (newValue) => { if (!afterPromises) { return; } diff --git a/resources/assets/v2/src/pages/dashboard/dashboard.js b/resources/assets/v2/src/pages/dashboard/dashboard.js index 80a3ddc531..fd032e97a1 100644 --- a/resources/assets/v2/src/pages/dashboard/dashboard.js +++ b/resources/assets/v2/src/pages/dashboard/dashboard.js @@ -70,15 +70,15 @@ Chart.register({ let index = function () { return { convertToPrimary: false, - saveNativeSettings(event) { + savePrimarySettings(event) { let target = event.currentTarget || event.target; - setVariable('convert_to_native',target.checked).then(() => { - console.log('Set convert to native to: ', target.checked); - this.$dispatch('convert-to-native', target.checked); + setVariable('convert_to_primary',target.checked).then(() => { + console.log('Set convert to primary to: ', target.checked); + this.$dispatch('convert-to-primary', target.checked); }); }, init() { - Promise.all([getVariable('convert_to_native', false)]).then((values) => { + Promise.all([getVariable('convert_to_primary', false)]).then((values) => { this.convertToPrimary = values[0]; }); } diff --git a/resources/assets/v2/src/pages/dashboard/piggies.js b/resources/assets/v2/src/pages/dashboard/piggies.js index 05c7a5f99a..25c9fa60e1 100644 --- a/resources/assets/v2/src/pages/dashboard/piggies.js +++ b/resources/assets/v2/src/pages/dashboard/piggies.js @@ -96,14 +96,14 @@ export default () => ({ id: current.id, name: current.attributes.name, percentage: parseInt(current.attributes.percentage), - amount: this.convertToPrimary ? current.attributes.native_current_amount : current.attributes.current_amount, + amount: this.convertToPrimary ? current.attributes.pc_current_amount : current.attributes.current_amount, // left to save - left_to_save: this.convertToPrimary ? current.attributes.native_left_to_save : current.attributes.left_to_save, + left_to_save: this.convertToPrimary ? current.attributes.pc_left_to_save : current.attributes.left_to_save, // target amount - target_amount: this.convertToPrimary ? current.attributes.native_target_amount : current.attributes.target_amount, + target_amount: this.convertToPrimary ? current.attributes.pc_target_amount : current.attributes.target_amount, // save per month - 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, + save_per_month: this.convertToPrimary ? current.attributes.pc_save_per_month : current.attributes.save_per_month, + currency_code: this.convertToPrimary ? current.attributes.pc_currency_code : current.attributes.currency_code, }; dataSet[groupName].piggies.push(piggy); @@ -129,7 +129,7 @@ export default () => ({ init() { // console.log('piggies init'); apiData = []; - Promise.all([getVariable('convert_to_native', false)]).then((values) => { + Promise.all([getVariable('convert_to_primary', false)]).then((values) => { afterPromises = true; this.convertToPrimary = values[0]; @@ -144,7 +144,7 @@ export default () => ({ apiData = []; this.loadPiggyBanks(); }); - window.store.observe('convert_to_native', (newValue) => { + window.store.observe('convert_to_primary', (newValue) => { if (!afterPromises) { return; } diff --git a/resources/assets/v2/src/pages/dashboard/sankey.js b/resources/assets/v2/src/pages/dashboard/sankey.js index 8f1a3dfa51..9b717e4668 100644 --- a/resources/assets/v2/src/pages/dashboard/sankey.js +++ b/resources/assets/v2/src/pages/dashboard/sankey.js @@ -160,7 +160,7 @@ export default () => ({ convertToPrimary: false, processedData: null, eventListeners: { - ['@convert-to-native.window'](event){ + ['@convert-to-primary.window'](event){ console.log('I heard that! (dashboard/sankey)'); this.convertToPrimary = event.detail; convertToPrimary = event.detail; @@ -227,8 +227,8 @@ export default () => ({ let amount = parseFloat(transaction.amount); let flowKey; if (this.convertToPrimary) { - currencyCode = transaction.native_currency_code; - amount = parseFloat(transaction.native_amount); + currencyCode = transaction.primary_currency_code; + amount = parseFloat(transaction.pc_amount); } if ('deposit' === transaction.type) { this.parseDeposit(transaction, currencyCode, amount); @@ -399,7 +399,7 @@ export default () => ({ init() { // console.log('sankey init'); transactions = []; - Promise.all([getVariable('convert_to_native', false)]).then((values) => { + Promise.all([getVariable('convert_to_primary', false)]).then((values) => { this.convertToPrimary = values[0]; convertToPrimary = values[0]; @@ -430,7 +430,7 @@ export default () => ({ this.transactions = []; this.loadChart(); }); - window.store.observe('convert_to_native', (newValue) => { + window.store.observe('convert_to_primary', (newValue) => { if (!afterPromises) { return; } diff --git a/resources/assets/v2/src/pages/dashboard/subscriptions.js b/resources/assets/v2/src/pages/dashboard/subscriptions.js index 0baae3538f..69c88ae2fc 100644 --- a/resources/assets/v2/src/pages/dashboard/subscriptions.js +++ b/resources/assets/v2/src/pages/dashboard/subscriptions.js @@ -72,7 +72,7 @@ function parseBillInfo(data) { paid: data.attributes.paid_dates.length > 0, }; if(convertToPrimary) { - result.currency_code = data.attributes.native_currency_code; + result.currency_code = data.attributes.primary_currency_code; } @@ -160,9 +160,8 @@ function downloadSubscriptions(params) { subscriptionData[objectGroupId].bills.push(bill); if (false === bill.paid) { // bill is unpaid, count the "pay_dates" and multiply with the "amount". - // since bill is unpaid, this can only be in currency amount and native currency amount. + // since bill is unpaid, this can only be in currency amount and primary currency amount. const totalAmount = current.attributes.pay_dates.length * bill.amount; - // const totalNativeAmount = current.attributes.pay_dates.length * bill.native_amount; // for bill's currency if (!subscriptionData[objectGroupId].payment_info.hasOwnProperty(bill.currency_code)) { subscriptionData[objectGroupId].payment_info[bill.currency_code] = { @@ -217,7 +216,7 @@ export default () => ({ return formatMoney(amount, currencyCode); }, eventListeners: { - ['@convert-to-native.window'](event){ + ['@convert-to-primary.window'](event){ console.log('I heard that! (dashboard/subscriptions)'); this.convertToPrimary = event.detail; convertToPrimary = event.detail; @@ -313,7 +312,7 @@ export default () => ({ }, init() { - Promise.all([getVariable('convert_to_native', false)]).then((values) => { + Promise.all([getVariable('convert_to_primary', false)]).then((values) => { this.convertToPrimary = values[0]; convertToPrimary = values[0]; afterPromises = true; @@ -332,7 +331,7 @@ export default () => ({ this.startSubscriptions(); } }); - window.store.observe('convert_to_native', (newValue) => { + window.store.observe('convert_to_primary', (newValue) => { if (!afterPromises) { return; } diff --git a/resources/assets/v2/src/pages/transactions/create.js b/resources/assets/v2/src/pages/transactions/create.js index 3a2b60beae..b7c3ea5079 100644 --- a/resources/assets/v2/src/pages/transactions/create.js +++ b/resources/assets/v2/src/pages/transactions/create.js @@ -82,7 +82,7 @@ let transactions = function () { formData: { defaultCurrency: null, enabledCurrencies: [], - nativeCurrencies: [], + primaryCurrencies: [], foreignCurrencies: [], budgets: [], piggyBanks: [], @@ -149,7 +149,7 @@ let transactions = function () { // this also locks the amount into the amount of the source account // and the foreign amount (if different) in that of the destination account. console.log('filter down currencies for transfer.'); - this.filterNativeCurrencies(this.entries[0].source_account.currency_code); + this.filterPrimaryCurrencies(this.entries[0].source_account.currency_code); this.filterForeignCurrencies(this.entries[0].destination_account.currency_code); return; } @@ -157,20 +157,20 @@ let transactions = function () { if ('Asset account' === sourceType && ['Expense account', 'Debt', 'Loan', 'Mortgage'].includes(destType)) { this.groupProperties.transactionType = 'withdrawal'; console.log('[a] Transaction type is detected to be "' + this.groupProperties.transactionType + '".'); - this.filterNativeCurrencies(this.entries[0].source_account.currency_code); + this.filterPrimaryCurrencies(this.entries[0].source_account.currency_code); return; } if ('Asset account' === sourceType && 'unknown' === destType) { this.groupProperties.transactionType = 'withdrawal'; console.log('[b] Transaction type is detected to be "' + this.groupProperties.transactionType + '".'); console.log(this.entries[0].source_account); - this.filterNativeCurrencies(this.entries[0].source_account.currency_code); + this.filterPrimaryCurrencies(this.entries[0].source_account.currency_code); return; } if (['Debt', 'Loan', 'Mortgage'].includes(sourceType) && 'Expense account' === destType) { this.groupProperties.transactionType = 'withdrawal'; console.log('[c] Transaction type is detected to be "' + this.groupProperties.transactionType + '".'); - this.filterNativeCurrencies(this.entries[0].source_account.currency_code); + this.filterPrimaryCurrencies(this.entries[0].source_account.currency_code); return; } @@ -237,7 +237,7 @@ let transactions = function () { } }, - filterNativeCurrencies(code) { + filterPrimaryCurrencies(code) { let list = []; let currency; for (let i in this.formData.enabledCurrencies) { @@ -249,7 +249,7 @@ let transactions = function () { } } list.push(currency); - this.formData.nativeCurrencies = list; + this.formData.primaryCurrencies = list; // this also forces the currency_code on ALL entries. for (let i in this.entries) { @@ -296,7 +296,7 @@ let transactions = function () { this.formStates.loadingCurrencies = false; this.formData.defaultCurrency = data.defaultCurrency; this.formData.enabledCurrencies = data.enabledCurrencies; - this.formData.nativeCurrencies = data.nativeCurrencies; + this.formData.primaryCurrencies = data.primaryCurrencies; this.formData.foreignCurrencies = data.foreignCurrencies; }); diff --git a/resources/assets/v2/src/pages/transactions/edit.js b/resources/assets/v2/src/pages/transactions/edit.js index 7698a1b131..e95eca4ca4 100644 --- a/resources/assets/v2/src/pages/transactions/edit.js +++ b/resources/assets/v2/src/pages/transactions/edit.js @@ -87,7 +87,7 @@ let transactions = function () { formData: { defaultCurrency: null, enabledCurrencies: [], - nativeCurrencies: [], + primaryCurrencies: [], foreignCurrencies: [], budgets: [], piggyBanks: [], @@ -332,7 +332,7 @@ let transactions = function () { this.formStates.loadingCurrencies = false; this.formData.defaultCurrency = data.defaultCurrency; this.formData.enabledCurrencies = data.enabledCurrencies; - this.formData.nativeCurrencies = data.nativeCurrencies; + this.formData.primaryCurrencies = data.primaryCurrencies; this.formData.foreignCurrencies = data.foreignCurrencies; }); diff --git a/resources/assets/v2/src/pages/transactions/shared/load-currencies.js b/resources/assets/v2/src/pages/transactions/shared/load-currencies.js index 02497d5a3a..11c05baf67 100644 --- a/resources/assets/v2/src/pages/transactions/shared/load-currencies.js +++ b/resources/assets/v2/src/pages/transactions/shared/load-currencies.js @@ -29,7 +29,7 @@ export function loadCurrencies() { return getter.list(params).then((response) => { let returnData = { defaultCurrency: {}, - nativeCurrencies: [], + primaryCurrencies: [], foreignCurrencies: [], enabledCurrencies: [], }; @@ -55,7 +55,7 @@ export function loadCurrencies() { returnData.defaultCurrency = obj; } returnData.enabledCurrencies.push(obj); - returnData.nativeCurrencies.push(obj); + returnData.primaryCurrencies.push(obj); returnData.foreignCurrencies.push(obj); } }