\r\n \r\n \r\n \r\n \r\n \r\n TOTAL: {{formattedTableTotal}}\r\n \r\n SHOW MORE\r\n \r\n \r\n
\r\n\r\n\r\n\r\n\r\n","import mod from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--12-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!../../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./budgetWidget.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--12-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!../../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./budgetWidget.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./budgetWidget.vue?vue&type=template&id=45ae4c7a&\"\nimport script from \"./budgetWidget.vue?vue&type=script&lang=js&\"\nexport * from \"./budgetWidget.vue?vue&type=script&lang=js&\"\nimport style0 from \"./budgetWidget.vue?vue&type=style&index=0&lang=css&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n null,\n null\n \n)\n\nexport default component.exports\n\n/* vuetify-loader */\nimport installComponents from \"!../../../../node_modules/vuetify-loader/lib/runtime/installComponents.js\"\nimport { VChip } from 'vuetify/lib/components/VChip';\nimport { VContainer } from 'vuetify/lib/components/VGrid';\nimport { VDivider } from 'vuetify/lib/components/VDivider';\nimport { VLayout } from 'vuetify/lib/components/VGrid';\nimport { VSpacer } from 'vuetify/lib/components/VGrid';\ninstallComponents(component, {VChip,VContainer,VDivider,VLayout,VSpacer})\n","import { store } from '../store/storeMain'\r\n//import { transactionManager } from './transactionManager'\r\nimport { globalFunctions } from './globalFunctions'\r\nimport { budgetManager } from './budgetManager'\r\n\r\nexport const widgetManager = {\r\n tableData: [],\r\n tableTotal: 0,\r\n itemsMinusDeleted: [],\r\n tableRow: {\r\n name: '',\r\n value: 0,\r\n percentage: 0\r\n },\r\n clearTableRow: function () {\r\n this.tableRow.name = ''\r\n this.tableRow.value = 0\r\n this.tableRow.percentage = 0\r\n },\r\n buildTable: function (period) {\r\n for (let i = 0; i < this.itemsMinusDeleted.length; i++) {\r\n\r\n if (this.isItemWithinPeriod(\r\n this.itemsMinusDeleted[i].transactionBalances[this.itemsMinusDeleted[i].transactionBalances.length - 1].transactionDate,\r\n period)) {\r\n\r\n this.convertToTableRow(this.itemsMinusDeleted[i])\r\n\r\n this.addToTableData()\r\n\r\n this.calculatePercentages()\r\n }\r\n }\r\n },\r\n calculatePercentages: function () {\r\n for (let i = 0; i < this.tableData.length; i++) {\r\n this.tableData[i].percentage = ((parseFloat(this.tableData[i].value) / parseFloat(this.tableTotal)) * 100).toFixed(2)\r\n }\r\n },\r\n addToTableData: function () {\r\n let item = this.tableRow\r\n\r\n if (this.tableData.length === 0) {\r\n this.tableData.push(globalFunctions.stringify(item))\r\n this.tableTotal = parseFloat(this.tableTotal) + parseFloat(item.value)\r\n }\r\n else {\r\n for (let i = 0; i < this.tableData.length; i++) {\r\n if (this.tableData[i].name === item.name) {\r\n this.tableData[i].value = parseFloat(this.tableData[i].value) + parseFloat(item.value)\r\n this.tableTotal = parseFloat(this.tableTotal) + parseFloat(item.value)\r\n break\r\n }\r\n else if (i === this.tableData.length - 1) {\r\n this.tableData.push(globalFunctions.stringify(item))\r\n this.tableTotal = parseFloat(this.tableTotal) + parseFloat(item.value)\r\n break\r\n }\r\n }\r\n }\r\n },\r\n convertToTableRow: function (item) {\r\n this.clearTableRow()\r\n\r\n this.tableRow.name = item.category\r\n\r\n for (let i = 0; i < item.transactionBalances.length; i++) {\r\n this.tableRow.value = parseFloat(this.tableRow.value) + parseFloat(item.transactionBalances[i].transactionAmount)\r\n }\r\n },\r\n clearOldData: function () {\r\n this.tableData = []\r\n this.tableTotal = 0,\r\n this.itemsMinusDeleted = []\r\n },\r\n isItemWithinPeriod: function (itemDate, period) {\r\n let start = ''\r\n let end = ''\r\n let date = new Date(this.returnFormattedDateFromCalendar(itemDate))\r\n\r\n let dateSplit = period.split(\" - \")\r\n\r\n start = new Date(dateSplit[0])\r\n end = new Date(dateSplit[1])\r\n\r\n if (date >= start && date <= end) {\r\n return true\r\n }\r\n\r\n return false\r\n },\r\n returnFormattedDateFromCalendar(date) {\r\n let dateSplit = date.split(\"-\")\r\n\r\n return (dateSplit[0] + \"-\" + parseInt(dateSplit[1]) + \"-\" + (parseInt(dateSplit[2])))\r\n },\r\n \r\n\r\n ///////////////////////////////////////////////////////////////////////\r\n //Income Specific\r\n ///////////////////////////////////////////////////////////////////////\r\n\r\n buildIncomeCategoryTotals: function (period) {\r\n this.clearOldData()\r\n this.getIncomeItemsFromStoreAndRemoveDeletedItems()\r\n\r\n this.buildTable(period)\r\n\r\n return {\r\n tableData: this.tableData,\r\n tableTotal: this.tableTotal\r\n }\r\n },\r\n getIncomeItemsFromStoreAndRemoveDeletedItems: function () {\r\n this.items = this.getIncomeTransactions(store.state.Transactions)\r\n\r\n\r\n ///Remove deleted items from items array\r\n this.itemsMinusDeleted = globalFunctions.removeDeletedObjectsFromItems(this.items)\r\n },\r\n getIncomeTransactions: function (items) {\r\n let incomes = []\r\n\r\n for (let i = 0; i < items.length; i++) {\r\n if (items[i].transactionType === \"income\") {\r\n incomes.push(items[i])\r\n }\r\n }\r\n\r\n return incomes\r\n },\r\n\r\n\r\n ///////////////////////////////////////////////////////////////////////\r\n //Expense Specific\r\n ///////////////////////////////////////////////////////////////////////\r\n\r\n buildExpenseCategoryTotals: function (period) {\r\n this.clearOldData()\r\n this.getExpenseItemsFromStoreAndRemoveDeletedItems()\r\n\r\n this.buildTable(period)\r\n\r\n return {\r\n tableData: this.tableData,\r\n tableTotal: this.tableTotal\r\n }\r\n },\r\n getExpenseItemsFromStoreAndRemoveDeletedItems: function () {\r\n this.items = this.getExpenseTransactions(store.state.Transactions)\r\n\r\n ///Remove deleted items from items array\r\n this.itemsMinusDeleted = globalFunctions.removeDeletedObjectsFromItems(this.items)\r\n },\r\n getExpenseTransactions: function (items) {\r\n let expenses = []\r\n\r\n for (let i = 0; i < items.length; i++) {\r\n if (items[i].transactionType === \"expense\") {\r\n expenses.push(items[i])\r\n }\r\n }\r\n\r\n return expenses\r\n },\r\n\r\n\r\n ///////////////////////////////////////////////////////////////////////\r\n //Budget Specific\r\n ///////////////////////////////////////////////////////////////////////\r\n\r\n buildBudgetTotals: function (date) {\r\n this.clearOldData()\r\n this.getBudgetItemsFromStoreAndRemoveDeletedItems()\r\n\r\n this.createTableRows()\r\n\r\n this.buildBudgetTable(date)\r\n\r\n if (this.tableData[0].value === 0 && this.tableData[1].value === 0) {\r\n this.tableData = []\r\n }\r\n\r\n return {\r\n tableData: this.tableData,\r\n tableTotal: this.tableTotal\r\n }\r\n },\r\n buildSingleBudgetTotals: function (budgetId, date) {\r\n this.clearOldData()\r\n this.getBudgetItemsFromStoreAndRemoveDeletedItems()\r\n\r\n this.createTableRows()\r\n\r\n this.buildSingleBudgetTable(budgetManager.findBudgetById(budgetId), date)\r\n\r\n if (this.tableData[0].value === 0 && this.tableData[1].value === 0) {\r\n this.tableData = []\r\n }\r\n\r\n return {\r\n tableData: this.tableData,\r\n tableTotal: this.tableTotal\r\n }\r\n },\r\n getBudgetItemsFromStoreAndRemoveDeletedItems: function () {\r\n this.items = store.state.Budgets\r\n\r\n\r\n ///Remove deleted items from items array\r\n this.itemsMinusDeleted = globalFunctions.removeDeletedObjectsFromItems(this.items)\r\n },\r\n createTableRows: function () {\r\n this.tableData.push({\r\n name: 'Spent',\r\n value: 0,\r\n percentage: 0\r\n },\r\n {\r\n name: 'Remaining',\r\n value: 0,\r\n percentage: 0\r\n })\r\n },\r\n buildBudgetTable: function (date) {\r\n for (let i = 0; i < this.itemsMinusDeleted.length; i++) {\r\n let budgetBalance = budgetManager.getActiveBudgetBalance(this.itemsMinusDeleted[i], date)\r\n\r\n this.addToBudgetTableData(budgetBalance)\r\n\r\n this.calculatePercentages()\r\n }\r\n },\r\n buildSingleBudgetTable: function (budget, date) {\r\n for (let i = 0; i < this.itemsMinusDeleted.length; i++) {\r\n if (this.itemsMinusDeleted[i].budgetName === budget.budgetName) {\r\n let budgetBalance = budgetManager.getActiveBudgetBalance(this.itemsMinusDeleted[i], date)\r\n\r\n this.addToBudgetTableData(budgetBalance)\r\n\r\n this.calculatePercentages()\r\n }\r\n }\r\n },\r\n addToBudgetTableData: function (item) {\r\n //Update Spent\r\n this.tableData[0].value = parseFloat(this.tableData[0].value) + parseFloat(item.amountSpent)\r\n\r\n //Update Remaining\r\n this.tableData[1].value = parseFloat(this.tableData[1].value) + (parseFloat(item.budgetAmount) - parseFloat(item.amountSpent))\r\n\r\n this.tableTotal = parseFloat(this.tableTotal) + parseFloat(item.budgetAmount)\r\n },\r\n\r\n}\r\n\r\n\r\n///////////////////////////////////////////////////////////////////////\r\n//Income Items By Category Functions\r\n///////////////////////////////////////////////////////////////////////\r\n\r\nexport const returnIncomeCategoriesAndThereItems = (period) => {\r\n let items = getIncomeItemsFromStoreAndRemoveDeletedItems()\r\n\r\n return buildJsonObject(period, items)\r\n}\r\n\r\nexport const getIncomeItemsFromStoreAndRemoveDeletedItems = () => {\r\n let items = widgetManager.getIncomeTransactions(store.state.Transactions)\r\n\r\n ///Remove deleted items from items array\r\n return globalFunctions.removeDeletedObjectsFromItems(items)\r\n}\r\n\r\nexport const buildJsonObject = (period, items) => {\r\n let jsonObject = []\r\n\r\n for (let i = 0; i < items.length; i++) {\r\n\r\n if (widgetManager.isItemWithinPeriod(\r\n items[i].transactionBalances[items[0].transactionBalances.length - 1].transactionDate,\r\n period)) {\r\n\r\n if (jsonObject.length === 0) {\r\n jsonObject[0] = [items[i].category, [items[i]]]\r\n\r\n continue\r\n }\r\n\r\n for (let k = 0; k < jsonObject.length; k++) {\r\n if (jsonObject[k][0] === items[i].category) {\r\n jsonObject[k][1].push(items[i])\r\n\r\n continue\r\n } else if (k === jsonObject.length - 1) {\r\n jsonObject.push([items[i].category, [items[i]]])\r\n break\r\n }\r\n }\r\n }\r\n }\r\n\r\n return jsonObject\r\n}\r\n\r\n///////////////////////////////////////////////////////////////////////\r\n//End Of Income Items By Category Functions\r\n///////////////////////////////////////////////////////////////////////\r\n\r\n\r\n///////////////////////////////////////////////////////////////////////\r\n//Expense Items By Category Functions\r\n///////////////////////////////////////////////////////////////////////\r\n\r\nexport const returnExpenseCategoriesAndThereItems = (period) => {\r\n let items = getExpenseItemsFromStoreAndRemoveDeletedItems()\r\n\r\n return buildJsonObject(period, items)\r\n}\r\n\r\nexport const getExpenseItemsFromStoreAndRemoveDeletedItems = () => {\r\n let items = widgetManager.getExpenseTransactions(store.state.Transactions)\r\n\r\n ///Remove deleted items from items array\r\n return globalFunctions.removeDeletedObjectsFromItems(items)\r\n}\r\n\r\n///////////////////////////////////////////////////////////////////////\r\n//End Of Expense Items By Category Functions\r\n///////////////////////////////////////////////////////////////////////\r\n\r\n","// Styles\nimport './VChip.sass'\n\n// Types\nimport { VNode } from 'vue'\nimport mixins from '../../util/mixins'\n\n// Components\nimport { VExpandXTransition } from '../transitions'\nimport VIcon from '../VIcon'\n\n// Mixins\nimport Colorable from '../../mixins/colorable'\nimport { factory as GroupableFactory } from '../../mixins/groupable'\nimport Themeable from '../../mixins/themeable'\nimport { factory as ToggleableFactory } from '../../mixins/toggleable'\nimport Routable from '../../mixins/routable'\nimport Sizeable from '../../mixins/sizeable'\n\n// Utilities\nimport { breaking } from '../../util/console'\n\n// Types\nimport { PropValidator, PropType } from 'vue/types/options'\n\n/* @vue/component */\nexport default mixins(\n Colorable,\n Sizeable,\n Routable,\n Themeable,\n GroupableFactory('chipGroup'),\n ToggleableFactory('inputValue')\n).extend({\n name: 'v-chip',\n\n props: {\n active: {\n type: Boolean,\n default: true,\n },\n activeClass: {\n type: String,\n default (): string | undefined {\n if (!this.chipGroup) return ''\n\n return this.chipGroup.activeClass\n },\n } as any as PropValidator