mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-22 20:16:22 +00:00 
			
		
		
		
	Repair charts and balances.
This commit is contained in:
		| @@ -211,14 +211,6 @@ export default () => ({ | ||||
|                     (new Get).show(accountId, new Date(window.store.get('end'))).then((response) => { | ||||
|                         let parent = response.data.data; | ||||
|  | ||||
|                         // apply function to each element of parent: | ||||
|                         // parent.attributes.balances = parent.attributes.balances.map((balance) => { | ||||
|                         //     balance.amount_formatted = formatMoney(balance.amount, balance.currency_code); | ||||
|                         //     return balance; | ||||
|                         // }); | ||||
|                         // console.log(parent); | ||||
|  | ||||
|  | ||||
|                         // get groups for account: | ||||
|                         const params = { | ||||
|                             page: 1, | ||||
| @@ -261,11 +253,14 @@ export default () => ({ | ||||
|                             accounts.push({ | ||||
|                                 name: parent.attributes.name, | ||||
|                                 order: parent.attributes.order, | ||||
|  | ||||
|                                 current_balance: formatMoney(parent.attributes.current_balance, parent.attributes.currency_code), | ||||
|                                 pc_current_balance: null === parent.attributes.pc_current_balance ? null : formatMoney(parent.attributes.pc_current_balance, parent.attributes.primary_currency_code), | ||||
|  | ||||
|                                 id: parent.id, | ||||
|                                 balances: parent.attributes.balances, | ||||
|                                 //balances: parent.attributes.balances, | ||||
|                                 groups: groups, | ||||
|                             }); | ||||
|                             // console.log(parent.attributes); | ||||
|                             count++; | ||||
|                             if (count === totalAccounts) { | ||||
|                                 accounts.sort((a, b) => a.order - b.order); // b - a for reverse sort | ||||
|   | ||||
| @@ -64,13 +64,17 @@ export default () => ({ | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // loop data again to add amounts to each series. | ||||
|         for (const i in data) { | ||||
|             if (data.hasOwnProperty(i)) { | ||||
|                 let yAxis = 'y'; | ||||
|                 let current = data[i]; | ||||
|  | ||||
|                 // allow switch to primary currency. | ||||
|                 let code = current.currency_code; | ||||
|                 if(this.convertToPrimary) { | ||||
|                     code = current.primary_currency_code; | ||||
|                 } | ||||
|  | ||||
|                 // loop series, add 0 if not present or add actual amount. | ||||
|                 for (const ii in series) { | ||||
| @@ -78,8 +82,11 @@ export default () => ({ | ||||
|                         let amount = 0.0; | ||||
|                         if (code === ii) { | ||||
|                             // this series' currency matches this column's currency. | ||||
|                             amount = parseFloat(current.amount); | ||||
|                             yAxis = 'y' + current.currency_code; | ||||
|                             amount = parseFloat(current.entries.spent); | ||||
|                             if(this.convertToPrimary) { | ||||
|                                 amount = parseFloat(current.entries.pc_entries.spent); | ||||
|                             } | ||||
|                             yAxis = 'y' + code; | ||||
|                         } | ||||
|                         if (series[ii].data.hasOwnProperty(current.label)) { | ||||
|                             // there is a value for this particular currency. The amount from this column will be added. | ||||
| @@ -103,7 +110,6 @@ export default () => ({ | ||||
|         // loop the series and create ChartJS-compatible data sets. | ||||
|         let count = 0; | ||||
|         for (const i in series) { | ||||
|             // console.log('series'); | ||||
|             let yAxisID = 'y' + i; | ||||
|             let dataset = { | ||||
|                 label: i, | ||||
| @@ -148,16 +154,15 @@ export default () => ({ | ||||
|         const end = new Date(window.store.get('end')); | ||||
|         const cacheKey = getCacheKey('ds_ct_chart', {convertToPrimary: this.convertToPrimary, start: start, end: end}); | ||||
|  | ||||
|         const cacheValid = window.store.get('cacheValid'); | ||||
|         // const cacheValid = window.store.get('cacheValid'); | ||||
|         const cacheValid = false; | ||||
|         let cachedData = window.store.get(cacheKey); | ||||
|  | ||||
|         if (cacheValid && typeof cachedData !== 'undefined') { | ||||
|             chartData = cachedData; // save chart data for later. | ||||
|             this.drawChart(this.generateOptions(chartData)); | ||||
|             this.loading = false; | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         const dashboard = new Dashboard(); | ||||
|         dashboard.dashboard(start, end, null).then((response) => { | ||||
|             chartData = response.data; // save chart data for later. | ||||
| @@ -181,7 +186,6 @@ export default () => ({ | ||||
|         this.getFreshData(); | ||||
|     }, | ||||
|     init() { | ||||
|         // console.log('categories init'); | ||||
|         Promise.all([getVariable('convert_to_primary', false),]).then((values) => { | ||||
|             this.convertToPrimary = values[0]; | ||||
|             afterPromises = true; | ||||
|   | ||||
| @@ -9,16 +9,10 @@ | ||||
|             <div class="card"> | ||||
|                 <div class="card-header"> | ||||
|                     <h3 class="card-title"> | ||||
|                         <a :href="'{{ route('accounts.show', '') }}/' + account.id" | ||||
|                            x-text="account.name"></a> | ||||
| 
 | ||||
|                         <a :href="'{{ route('accounts.show', '') }}/' + account.id" x-text="account.name"></a> | ||||
|                         <span class="small"> | ||||
|                             <template x-for="balance in account.balances"> | ||||
|                                 <template x-if="balance.type === 'current'"> | ||||
|                                     <span class="text-muted">(<span x-text="balance.amount_formatted"></span>) | ||||
|                                         </span> | ||||
|                                 </template> | ||||
|                             </template> | ||||
|                             <span class="text-muted">(<span x-text="account.current_balance"></span>)</span> | ||||
|                             <template x-if="null !== account.pc_current_balance"><span class="text-muted">(<span x-text="account.pc_current_balance"></span>)</span></template> | ||||
|                         </span> | ||||
|                     </h3> | ||||
|                 </div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user