Skip to content

Commit

Permalink
Merge pull request #7 from forevermatt/develop
Browse files Browse the repository at this point in the history
Release 0.3.1
  • Loading branch information
forevermatt authored Jun 5, 2020
2 parents e58bf5d + 7f89690 commit 38caf54
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ https://forevermatt.github.io/svelte-budget/
- [x] Add a financial account
- [ ] Edit a financial account
- [ ] Record an expense
- [ ] Create separate repo to document data structure versions
- [ ] ...
5 changes: 5 additions & 0 deletions src/data/budget.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const addCategoryToBudget = (categoryUuid, budgeted) => {
})
}

export const getBudgetedFor = uuid => {
let budgetCategory = get(budgetStore)[uuid] || {}
return budgetCategory.budgeted || 0
}

const isExistingCategory = uuid => get(budgetStore).hasOwnProperty(uuid)

export const loadBudget = () => {
Expand Down
4 changes: 2 additions & 2 deletions src/views/CategoryAmount.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<script>
import AmountInput from '../components/AmountInput.svelte'
import { setBudgetedForCategory } from '../data/budget'
import { getBudgetedFor, setBudgetedForCategory } from '../data/budget'
import { categories } from '../data/categories'
import { push } from 'svelte-spa-router'
export let params // URL parameters provider by router.
$: uuid = params.uuid
$: category = $categories.find(category => category.uuid === uuid) || {}
$: initialAmount = category.amount || 0
$: initialAmount = getBudgetedFor(uuid) || 0
function onSubmit(event) {
let amount = event.detail
Expand Down
3 changes: 2 additions & 1 deletion src/views/CategoryView.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { getBudgetedFor } from '../data/budget'
import { categories, updateCategory } from '../data/categories'
import { formatAmount } from '../helpers/numbers'
Expand All @@ -25,7 +26,7 @@ const renameCategory = () => {
<b class="editable" on:click={renameCategory}
title="(Click to rename)">{ category.name }:</b>
<a class="btn btn-default" href="#/category/{ uuid }/amount">
<sup>$</sup> { formatAmount(category.amount) }
<sup>$</sup> { formatAmount(getBudgetedFor(uuid)) }
</a>
</h2>
<hr class="small" />

0 comments on commit 38caf54

Please sign in to comment.