diff --git a/app/Support/Chart/ChartData.php b/app/Support/Chart/ChartData.php index 66585c415f..93a825415d 100644 --- a/app/Support/Chart/ChartData.php +++ b/app/Support/Chart/ChartData.php @@ -46,7 +46,7 @@ class ChartData if (array_key_exists('native_currency_id', $data)) { $data['native_currency_id'] = (string) $data['native_currency_id']; } - $required = ['start', 'date', 'end', 'entries', 'native_entries']; + $required = ['start', 'date', 'end', 'entries']; foreach ($required as $field) { if (!array_key_exists($field, $data)) { throw new FireflyException(sprintf('Data-set is missing the "%s"-variable.', $field)); diff --git a/resources/assets/v2/src/api/v1/chart/account/dashboard.js b/resources/assets/v2/src/api/v1/chart/account/dashboard.js index f36e87574c..f5c1870393 100644 --- a/resources/assets/v2/src/api/v1/chart/account/dashboard.js +++ b/resources/assets/v2/src/api/v1/chart/account/dashboard.js @@ -25,7 +25,7 @@ export default class Dashboard { dashboard(start, end) { let startStr = format(start, 'y-MM-dd'); let endStr = format(end, 'y-MM-dd'); - return api.get('/api/v1/chart/account/dashboard', {params: {filter: {start: startStr, end: endStr}}}); + return api.get('/api/v1/chart/account/dashboard', {params: {fix: true, start: startStr, end: endStr}}); } expense(start, end) { diff --git a/resources/assets/v2/src/api/v1/model/account/get.js b/resources/assets/v2/src/api/v1/model/account/get.js index 0625ab496d..a8d014a42c 100644 --- a/resources/assets/v2/src/api/v1/model/account/get.js +++ b/resources/assets/v2/src/api/v1/model/account/get.js @@ -37,6 +37,18 @@ export default class Get { return api.get('/api/v1/accounts/' + identifier, {params: params}); } + + /** + * + * @param identifier + * @param params + * @returns {Promise>} + */ + show(identifier, params) { + return api.get('/api/v1/accounts/' + identifier, {params: params}); + } + + /** * * @param identifier diff --git a/resources/assets/v2/src/api/v1/model/transaction/get.js b/resources/assets/v2/src/api/v1/model/transaction/get.js index b7bbfdba80..a00b59064a 100644 --- a/resources/assets/v2/src/api/v1/model/transaction/get.js +++ b/resources/assets/v2/src/api/v1/model/transaction/get.js @@ -29,12 +29,9 @@ export default class Get { * @returns {Promise>} */ list(params) { - return api.get('/api/v2/transactions', {params: params}); - } - infiniteList(params) { - return api.get('/api/v2/infinite/transactions', {params: params}); + return api.get('/api/v1/transactions', {params: params}); } show(id, params){ - return api.get('/api/v2/transactions/' + id, {params: params}); + return api.get('/api/v1/transactions/' + id, {params: params}); } } diff --git a/resources/assets/v2/src/api/v1/model/transaction/post.js b/resources/assets/v2/src/api/v1/model/transaction/post.js index 0b02577566..59b97de988 100644 --- a/resources/assets/v2/src/api/v1/model/transaction/post.js +++ b/resources/assets/v2/src/api/v1/model/transaction/post.js @@ -22,7 +22,7 @@ import {api} from "../../../../boot/axios"; export default class Post { post(submission) { - let url = '/api/v2/transactions'; + let url = '/api/v1/transactions'; return api.post(url, submission); } } diff --git a/resources/assets/v2/src/api/v1/model/transaction/put.js b/resources/assets/v2/src/api/v1/model/transaction/put.js index 09efefc8d9..ad38c699e7 100644 --- a/resources/assets/v2/src/api/v1/model/transaction/put.js +++ b/resources/assets/v2/src/api/v1/model/transaction/put.js @@ -22,7 +22,7 @@ import {api} from "../../../../boot/axios"; export default class Put { put(submission, params) { - let url = '/api/v2/transactions/' + parseInt(params.id); + let url = '/api/v1/transactions/' + parseInt(params.id); return api.put(url, submission); } } diff --git a/resources/assets/v2/src/api/v2/chart/account/dashboard.js b/resources/assets/v2/src/api/v2/chart/account/dashboard.js index eb0c336ea0..521bf7405b 100644 --- a/resources/assets/v2/src/api/v2/chart/account/dashboard.js +++ b/resources/assets/v2/src/api/v2/chart/account/dashboard.js @@ -25,7 +25,7 @@ export default class Dashboard { dashboard(start, end) { let startStr = format(start, 'y-MM-dd'); let endStr = format(end, 'y-MM-dd'); - return api.get('/api/v2/chart/account/dashboard', {params: {filter: {start: startStr, end: endStr}}}); + return api.get('/api/v2/chart/account/dashboard', {params: {start: startStr, end: endStr}}); } expense(start, end) { diff --git a/resources/assets/v2/src/pages/dashboard/accounts.js b/resources/assets/v2/src/pages/dashboard/accounts.js index e7db5fd67d..83567dbae4 100644 --- a/resources/assets/v2/src/pages/dashboard/accounts.js +++ b/resources/assets/v2/src/pages/dashboard/accounts.js @@ -42,7 +42,7 @@ export default () => ({ convertToNative: false, convertToNativeAvailable: false, chartOptions: null, - switchconvertToNative() { + switchConvertToNative() { this.convertToNative = !this.convertToNative; setVariable('convertToNative', this.convertToNative); }, @@ -90,18 +90,18 @@ export default () => ({ dataset.label = current.label; // use the "native" currency code and use the "native_entries" as array - if (this.convertToNative) { - currencies.push(current.native_currency_code); - dataset.currency_code = current.native_currency_code; - collection = Object.values(current.native_entries); - yAxis = 'y' + current.native_currency_code; - } - if (!this.convertToNative) { + // if (this.convertToNative) { + // currencies.push(current.native_currency_code); + // dataset.currency_code = current.native_currency_code; + // collection = Object.values(current.native_entries); + // yAxis = 'y' + current.native_currency_code; + // } + // if (!this.convertToNative) { yAxis = 'y' + current.currency_code; dataset.currency_code = current.currency_code; currencies.push(current.currency_code); collection = Object.values(current.entries); - } + // } dataset.yAxisID = yAxis; dataset.data = collection; @@ -217,12 +217,12 @@ 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 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; + // nativeAmountRaw = nativeAmountRaw * -1; amountRaw = amountRaw * -1; } @@ -232,8 +232,8 @@ 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), + // native_amount_raw: nativeAmountRaw, + // native_amount: formatMoney(nativeAmountRaw, currentTransaction.native_currency_code), }); } groups.push(group); @@ -244,7 +244,7 @@ export default () => ({ order: parent.attributes.order, id: parent.id, balance: parent.attributes.balance, - native_balance: parent.attributes.native_balance, + //native_balance: parent.attributes.native_balance, groups: groups, }); // console.log(parent.attributes); diff --git a/resources/assets/v2/src/pages/dashboard/boxes.js b/resources/assets/v2/src/pages/dashboard/boxes.js index 09dac10796..911233af94 100644 --- a/resources/assets/v2/src/pages/dashboard/boxes.js +++ b/resources/assets/v2/src/pages/dashboard/boxes.js @@ -76,116 +76,56 @@ export default () => ({ continue; } let key = current.key; - // native (auto conversion): - if (this.convertToNative) { - console.error('convertToNative does not work in boxes.'); - if (key.startsWith('balance-in-native')) { - this.balanceBox.amounts.push(formatMoney(current.value, current.currency_code)); - // prep subtitles (for later) - if (!subtitles.hasOwnProperty(current.currency_code)) { - subtitles[current.currency_code] = ''; - } - continue; - } - // spent info is used in subtitle: - if (key.startsWith('spent-in-native')) { - // prep subtitles (for later) - if (!subtitles.hasOwnProperty(current.currency_code)) { - subtitles[current.currency_code] = ''; - } - // append the amount spent. - subtitles[current.currency_code] = - subtitles[current.currency_code] + - formatMoney(current.value, current.currency_code); - continue; - } - // earned info is used in subtitle: - if (key.startsWith('earned-in-native')) { - // prep subtitles (for later) - if (!subtitles.hasOwnProperty(current.currency_code)) { - subtitles[current.currency_code] = ''; - } - // prepend the amount earned. - subtitles[current.currency_code] = - formatMoney(current.value, current.currency_code) + ' + ' + - subtitles[current.currency_code]; - continue; - } - - if (key.startsWith('bills-unpaid-in-native')) { - this.billBox.unpaid.push(formatMoney(current.value, current.currency_code)); - continue; - } - if (key.startsWith('bills-paid-in-native')) { - this.billBox.paid.push(formatMoney(current.value, current.currency_code)); - continue; - } - if (key.startsWith('left-to-spend-in-native')) { - this.leftBox.left.push(formatMoney(current.value, current.currency_code)); - continue; - } - if (key.startsWith('left-per-day-to-spend-in-native')) { // per day - this.leftBox.perDay.push(formatMoney(current.value, current.currency_code)); - continue; - } - if (key.startsWith('net-worth-in-native')) { - this.netBox.net.push(formatMoney(current.value, current.currency_code)); - continue; - } + console.log('NOT NATIVE'); + if (key.startsWith('balance-in-')) { + this.balanceBox.amounts.push(formatMoney(current.monetary_value, current.currency_code)); + continue; } - // not native - if (!this.convertToNative && !key.endsWith('native')) { - console.log('NOT NATIVE'); - if (key.startsWith('balance-in-')) { - this.balanceBox.amounts.push(formatMoney(current.monetary_value , current.currency_code)); - continue; + // spent info is used in subtitle: + if (key.startsWith('spent-in-')) { + // prep subtitles (for later) + if (!subtitles.hasOwnProperty(current.currency_code)) { + subtitles[current.currency_code] = ''; } - // spent info is used in subtitle: - if (key.startsWith('spent-in-')) { - // prep subtitles (for later) - if (!subtitles.hasOwnProperty(current.currency_code)) { - subtitles[current.currency_code] = ''; - } - // append the amount spent. - subtitles[current.currency_code] = - subtitles[current.currency_code] + - formatMoney(current.monetary_value , current.currency_code); - continue; - } - // earned info is used in subtitle: - if (key.startsWith('earned-in-')) { - // prep subtitles (for later) - if (!subtitles.hasOwnProperty(current.currency_code)) { - subtitles[current.currency_code] = ''; - } - // prepend the amount earned. - subtitles[current.currency_code] = - formatMoney(current.monetary_value , current.currency_code) + ' + ' + - subtitles[current.currency_code]; - continue; + // append the amount spent. + subtitles[current.currency_code] = + subtitles[current.currency_code] + + formatMoney(current.monetary_value, current.currency_code); + continue; + } + // earned info is used in subtitle: + if (key.startsWith('earned-in-')) { + // prep subtitles (for later) + if (!subtitles.hasOwnProperty(current.currency_code)) { + subtitles[current.currency_code] = ''; } + // prepend the amount earned. + subtitles[current.currency_code] = + formatMoney(current.monetary_value, current.currency_code) + ' + ' + + subtitles[current.currency_code]; + continue; + } - if (key.startsWith('bills-unpaid-in-')) { - this.billBox.unpaid.push(formatMoney(current.monetary_value , current.currency_code)); - continue; - } - if (key.startsWith('bills-paid-in-')) { - this.billBox.paid.push(formatMoney(current.monetary_value , current.currency_code)); - continue; - } - if (key.startsWith('left-to-spend-in-')) { - this.leftBox.left.push(formatMoney(current.monetary_value , current.currency_code)); - continue; - } - if (key.startsWith('left-per-day-to-spend-in-')) { - this.leftBox.perDay.push(formatMoney(current.monetary_value , current.currency_code)); - continue; - } - if (key.startsWith('net-worth-in-')) { - this.netBox.net.push(formatMoney(current.monetary_value , current.currency_code)); + if (key.startsWith('bills-unpaid-in-')) { + this.billBox.unpaid.push(formatMoney(current.monetary_value, current.currency_code)); + continue; + } + if (key.startsWith('bills-paid-in-')) { + this.billBox.paid.push(formatMoney(current.monetary_value, current.currency_code)); + continue; + } + if (key.startsWith('left-to-spend-in-')) { + this.leftBox.left.push(formatMoney(current.monetary_value, current.currency_code)); + continue; + } + if (key.startsWith('left-per-day-to-spend-in-')) { + this.leftBox.perDay.push(formatMoney(current.monetary_value, current.currency_code)); + continue; + } + if (key.startsWith('net-worth-in-')) { + this.netBox.net.push(formatMoney(current.monetary_value, current.currency_code)); - } } } } diff --git a/resources/assets/v2/src/pages/dashboard/subscriptions.js b/resources/assets/v2/src/pages/dashboard/subscriptions.js index e99a9fd04b..6b1f35da7a 100644 --- a/resources/assets/v2/src/pages/dashboard/subscriptions.js +++ b/resources/assets/v2/src/pages/dashboard/subscriptions.js @@ -66,10 +66,10 @@ function downloadSubscriptions(params) { currency_code: current.attributes.currency_code, // native amount - native_amount_min: current.attributes.native_amount_min, - native_amount_max: current.attributes.native_amount_max, - native_amount: (parseFloat(current.attributes.native_amount_max) + parseFloat(current.attributes.native_amount_min)) / 2, - native_currency_code: current.attributes.native_currency_code, + // native_amount_min: current.attributes.native_amount_min, + // native_amount_max: current.attributes.native_amount_max, + // native_amount: (parseFloat(current.attributes.native_amount_max) + parseFloat(current.attributes.native_amount_min)) / 2, + // native_currency_code: current.attributes.native_currency_code, // paid transactions: transactions: [], @@ -79,8 +79,7 @@ function downloadSubscriptions(params) { paid: current.attributes.paid_dates.length > 0, }; // set variables - bill.expected_amount = params.convertToNative ? formatMoney(bill.native_amount, bill.native_currency_code) : - formatMoney(bill.amount, bill.currency_code); + bill.expected_amount = formatMoney(bill.amount, bill.currency_code); bill.expected_times = i18next.t('firefly.subscr_expected_x_times', { times: current.attributes.pay_dates.length, amount: bill.expected_amount @@ -98,16 +97,19 @@ function downloadSubscriptions(params) { if (!params.convertToNative) { percentage = Math.round(-100 + ((parseFloat(currentPayment.amount) * -1) / parseFloat(bill.amount)) * 100); } - + // TODO fix me + currentPayment.currency_code = 'EUR'; + console.log('Currency code: "'+currentPayment+'"'); + console.log(currentPayment); let currentTransaction = { - amount: params.convertToNative ? formatMoney(currentPayment.native_amount, currentPayment.native_currency_code) : formatMoney(currentPayment.amount, currentPayment.currency_code), + amount: formatMoney(currentPayment.amount, currentPayment.currency_code), percentage: percentage, date: format(new Date(currentPayment.date), 'PP'), foreign_amount: null, }; if (null !== currentPayment.foreign_currency_code) { - currentTransaction.foreign_amount = params.convertToNative ? currentPayment.foreign_native_amount : currentPayment.foreign_amount; - currentTransaction.foreign_currency_code = params.convertToNative ? currentPayment.native_currency_code : currentPayment.foreign_currency_code; + currentTransaction.foreign_amount = currentPayment.foreign_amount; + currentTransaction.foreign_currency_code = currentPayment.foreign_currency_code; } bill.transactions.push(currentTransaction); @@ -119,7 +121,7 @@ function downloadSubscriptions(params) { // 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. const totalAmount = current.attributes.pay_dates.length * bill.amount; - const totalNativeAmount = current.attributes.pay_dates.length * bill.native_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] = { @@ -128,11 +130,11 @@ function downloadSubscriptions(params) { unpaid: 0, native_currency_code: bill.native_currency_code, native_paid: 0, - native_unpaid: 0, + //native_unpaid: 0, }; } subscriptionData[objectGroupId].payment_info[bill.currency_code].unpaid += totalAmount; - subscriptionData[objectGroupId].payment_info[bill.currency_code].native_unpaid += totalNativeAmount; + //subscriptionData[objectGroupId].payment_info[bill.currency_code].native_unpaid += totalNativeAmount; } if (current.attributes.paid_dates.length > 0) { @@ -149,15 +151,15 @@ function downloadSubscriptions(params) { currency_code: bill.currency_code, paid: 0, unpaid: 0, - native_currency_code: bill.native_currency_code, - native_paid: 0, - native_unpaid: 0, + // native_currency_code: bill.native_currency_code, + // native_paid: 0, + //native_unpaid: 0, }; } const amount = parseFloat(currentJournal.amount) * -1; - const nativeAmount = parseFloat(currentJournal.native_amount) * -1; + // const nativeAmount = parseFloat(currentJournal.native_amount) * -1; subscriptionData[objectGroupId].payment_info[currentJournal.currency_code].paid += amount; - subscriptionData[objectGroupId].payment_info[currentJournal.currency_code].native_paid += nativeAmount; + // subscriptionData[objectGroupId].payment_info[currentJournal.currency_code].native_paid += nativeAmount; } } } @@ -198,7 +200,7 @@ export default () => ({ let params = { start: format(start, 'y-MM-dd'), end: format(end, 'y-MM-dd'), - convertToNative: this.convertToNative, + // convertToNative: this.convertToNative, page: 1 }; downloadSubscriptions(params).then(() => { @@ -226,9 +228,9 @@ export default () => ({ drawPieChart(groupId, groupTitle, data) { let id = '#pie_' + groupId + '_' + data.currency_code; //console.log(data); - const unpaidAmount = this.convertToNative ? data.native_unpaid : data.unpaid; - const paidAmount = this.convertToNative ? data.native_paid : data.paid; - const currencyCode = this.convertToNative ? data.native_currency_code : data.currency_code; + const unpaidAmount = data.unpaid; + const paidAmount = data.paid; + const currencyCode = data.currency_code; const chartData = { labels: [ i18next.t('firefly.paid'), diff --git a/resources/views/v2/partials/dashboard/account-chart.blade.php b/resources/views/v2/partials/dashboard/account-chart.blade.php index 24c085e942..3e173575ec 100644 --- a/resources/views/v2/partials/dashboard/account-chart.blade.php +++ b/resources/views/v2/partials/dashboard/account-chart.blade.php @@ -12,14 +12,14 @@