-
Total you paid for
+
Your total {balance}
-
- {formatCurrency(currency, totalYourSpendings)}
+
+ {formatCurrency(currency, Math.abs(totalYourSpendings))}
)
diff --git a/src/components/expense-form.tsx b/src/components/expense-form.tsx
index fbc0099e..758e93d1 100644
--- a/src/components/expense-form.tsx
+++ b/src/components/expense-form.tsx
@@ -64,14 +64,15 @@ export type Props = {
const enforceCurrencyPattern = (value: string) =>
value
- // replace first comma with #
- .replace(/[.,]/, '#')
- // remove all other commas
- .replace(/[.,]/g, '')
- // change back # to dot
- .replace(/#/, '.')
- // remove all non-numeric and non-dot characters
- .replace(/[^\d.]/g, '')
+ .replace(/^\s*-/, '_') // replace leading minus with _
+ .replace(/[.,]/, '#') // replace first comma with #
+ .replace(/[-.,]/g, '') // remove other minus and commas characters
+ .replace(/_/, '-') // change back _ to minus
+ .replace(/#/, '.') // change back # to dot
+ .replace(/[^-\d.]/g, '') // remove all non-numeric characters
+
+const capitalize = (value: string) =>
+ value.charAt(0).toUpperCase() + value.slice(1)
const getDefaultSplittingOptions = (group: Props['group']) => {
const defaultValue = {
@@ -243,14 +244,16 @@ export function ExpenseForm({
return onSubmit(values, activeUserId ?? undefined)
}
+ const [isIncome, setIsIncome] = useState(Number(form.getValues().amount) < 0)
+ const sExpense = isIncome ? 'income' : 'expense'
+ const sPaid = isIncome ? 'received' : 'paid'
+
return (