mirror of
https://github.com/linuxserver/budge.git
synced 2026-01-20 20:23:52 +08:00
Merge branch 'main' into account-table-rewrite
This commit is contained in:
commit
da9ba2ffe4
@ -26,3 +26,6 @@ BudgE (pronounced "budgie", like the bird) is an open source "budgeting with env
|
||||
|
||||
# Getting Started
|
||||
See [linuxserver/docker-BudgE](https://github.com/linuxserver/docker-BudgE).
|
||||
|
||||
# Support
|
||||
(https://discord.gg/hKJWjDqCBz)[https://discord.gg/hKJWjDqCBz] or through GitHub issues
|
||||
|
||||
10316
frontend/package-lock.json
generated
10316
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "wenab-react-js",
|
||||
"version": "0.1.0",
|
||||
"name": "BudgE",
|
||||
"version": "0.0.2",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@dinero.js/currencies": "^2.0.0-alpha.8",
|
||||
|
||||
@ -23,6 +23,7 @@ import CardContent from '@mui/material/CardContent'
|
||||
import CardActions from '@mui/material/CardActions'
|
||||
import Table from '@mui/material/Table'
|
||||
import TableContainer from '@mui/material/TableContainer'
|
||||
import TableBody from '@mui/material/TableBody'
|
||||
import TableRow from '@mui/material/TableRow'
|
||||
import TableCell from '@mui/material/TableCell'
|
||||
import TableBody from '@mui/material/TableBody'
|
||||
|
||||
@ -43,6 +43,7 @@ import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank'
|
||||
import CheckBoxIcon from '@mui/icons-material/CheckBox'
|
||||
import { styled } from '@mui/material/styles'
|
||||
import UploadIcon from '@mui/icons-material/Upload'
|
||||
import EventIcon from '@mui/icons-material/Event'
|
||||
import ImportCSV from '../ImportCSV'
|
||||
import { useGlobalFilter, useRowSelect, useSortBy, useTable, useAsyncDebounce } from 'react-table'
|
||||
import Checkbox from '@mui/material/Checkbox'
|
||||
@ -243,7 +244,7 @@ export default function Account(props) {
|
||||
const classes = useStyles()
|
||||
|
||||
// const whyDidYouRender = true
|
||||
let tableProps = null
|
||||
let tableProps = {}
|
||||
|
||||
const theme = useTheme()
|
||||
const dispatch = useDispatch()
|
||||
|
||||
@ -5,16 +5,19 @@ import Dialog from '@mui/material/Dialog'
|
||||
import DialogActions from '@mui/material/DialogActions'
|
||||
import DialogContent from '@mui/material/DialogContent'
|
||||
import DialogTitle from '@mui/material/DialogTitle'
|
||||
import { createAccount } from '../redux/slices/Accounts'
|
||||
import { useDispatch } from 'react-redux'
|
||||
import { createAccount, fetchAccounts } from '../redux/slices/Accounts'
|
||||
import { useDispatch, useSelector } from 'react-redux'
|
||||
import MenuItem from '@mui/material/MenuItem'
|
||||
import { fetchCategories } from '../redux/slices/CategoryGroups'
|
||||
import { refreshBudget } from '../redux/slices/Budgets'
|
||||
import { refreshBudgetMonth } from '../redux/slices/BudgetMonths'
|
||||
import { inputToDinero } from '../utils/Currency'
|
||||
|
||||
const accountTypes = ['Bank', 'Credit Card', 'Off Budget Account']
|
||||
|
||||
export default function AddAccountDialog(props) {
|
||||
const month = useSelector(state => state.budgets.currentMonth)
|
||||
|
||||
/**
|
||||
* State block
|
||||
*/
|
||||
@ -41,9 +44,11 @@ export default function AddAccountDialog(props) {
|
||||
)
|
||||
|
||||
dispatch(refreshBudget())
|
||||
dispatch(fetchAccounts())
|
||||
|
||||
// If adding a credit card, update all categories since we have added a payment category for it
|
||||
if (accountType === accountTypes[1]) {
|
||||
if (accountType === 1) {
|
||||
console.log('fetching cats')
|
||||
dispatch(fetchCategories())
|
||||
}
|
||||
reset()
|
||||
|
||||
@ -103,16 +103,16 @@ export default function ImportCSV({ accountId, open, close }) {
|
||||
case 'Ignore':
|
||||
break
|
||||
case 'Amount':
|
||||
newTransaction.amount = inputToDinero(parseFloat(value.replace(/[^0-9\.]/, '')))
|
||||
newTransaction.amount = inputToDinero(parseFloat(value.replace(/[^0-9\.-]/, '')))
|
||||
break
|
||||
case 'Inflow':
|
||||
if (parseFloat(value) !== 0) {
|
||||
newTransaction.amount = inputToDinero(parseFloat(value.replace(/[^0-9\.]/, '')))
|
||||
newTransaction.amount = inputToDinero(parseFloat(value.replace(/[^0-9\.-]/, '')))
|
||||
}
|
||||
break
|
||||
case 'Outflow':
|
||||
if (parseFloat(value) !== 0) {
|
||||
newTransaction.amount = multiply(inputToDinero(parseFloat(value.replace(/[^0-9\.]/, ''))), -1)
|
||||
newTransaction.amount = multiply(inputToDinero(parseFloat(value.replace(/[^0-9\.-]/, ''))), -1)
|
||||
}
|
||||
break
|
||||
case 'Memo':
|
||||
|
||||
@ -18,20 +18,17 @@ export const fetchBudgetMonth = createAsyncThunk('budgetMonths/fetchMonth', asyn
|
||||
}
|
||||
})
|
||||
|
||||
export const refreshBudgetMonth = createAsyncThunk(
|
||||
'budgetMonths/refreshMonth',
|
||||
async ({ month, categoryId }, { getState }) => {
|
||||
const store = getState()
|
||||
const budgetMonth = await api.fetchBudgetMonth(store.budgets.activeBudgetId, month)
|
||||
// console.log(budgetMonth)
|
||||
// budgetMonth.categories = budgetMonth.categories.filter(categoryMonth => categoryMonth.categoryId === categoryId)
|
||||
const normalized = normalize(budgetMonth, budgetMonthEntity)
|
||||
return {
|
||||
month,
|
||||
entities: normalized.entities,
|
||||
}
|
||||
},
|
||||
)
|
||||
export const refreshBudgetMonth = createAsyncThunk('budgetMonths/refreshMonth', async ({ month }, { getState }) => {
|
||||
const store = getState()
|
||||
const budgetMonth = await api.fetchBudgetMonth(store.budgets.activeBudgetId, month)
|
||||
// console.log(budgetMonth)
|
||||
// budgetMonth.categories = budgetMonth.categories.filter(categoryMonth => categoryMonth.categoryId === categoryId)
|
||||
const normalized = normalize(budgetMonth, budgetMonthEntity)
|
||||
return {
|
||||
month,
|
||||
entities: normalized.entities,
|
||||
}
|
||||
})
|
||||
|
||||
export const fetchBudgetMonths = createAsyncThunk('budgetMonths/fetchMonths', async ({ month }, { getState }) => {
|
||||
const store = getState()
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { dinero, toFormat, isPositive, isNegative, multiply } from 'dinero.js'
|
||||
import { dinero, toFormat, isPositive, isNegative, multiply, toUnit } from 'dinero.js'
|
||||
import { USD } from '@dinero.js/currencies'
|
||||
|
||||
export function inputToDinero(amount) {
|
||||
@ -24,6 +24,10 @@ export function valueToDinero(value) {
|
||||
return dinero({ amount: value, currency: USD })
|
||||
}
|
||||
|
||||
export function valueToUnit(value) {
|
||||
return toUnit(valueToDinero(value), { digits: 2 })
|
||||
}
|
||||
|
||||
export function dineroToValue(dineroObj) {
|
||||
return dineroObj.toJSON().amount
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user