Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Goals: Save full goal value and add an indicator of goal status #1780

Merged
merged 70 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
28899ea
first pass at progress bar
shall0pass Jul 30, 2023
8622b77
db migration / enter goal in db
shall0pass Aug 1, 2023
cad101c
add getGoal function
shall0pass Aug 1, 2023
f1a9aeb
stabilize
shall0pass Aug 1, 2023
1eab530
Merge branch 'master' into goalProgressBar
shall0pass Aug 1, 2023
2c8c5a6
whoops
shall0pass Aug 1, 2023
756e73f
TS
shall0pass Aug 1, 2023
66fc6a6
reset goal in db if no template found
shall0pass Aug 1, 2023
2033e52
Merge branch 'master' into goalProgressBar
shall0pass Aug 8, 2023
9c7f6b3
Merge branch 'actualbudget:master' into goalProgressBar
shall0pass Aug 8, 2023
81318e8
merge master into branch
shall0pass Sep 11, 2023
19064b8
reconfirm
shall0pass Sep 11, 2023
58aa791
release note
shall0pass Sep 11, 2023
fd423a9
typo
shall0pass Sep 11, 2023
425a6ca
rename migration
shall0pass Sep 11, 2023
7837e11
to ms
shall0pass Sep 11, 2023
b00fc8e
move priority logic, consistent variable names,
shall0pass Sep 11, 2023
115c14e
Merge branch 'master' into goalProgressBar
shall0pass Sep 11, 2023
ac4c3eb
fixup
shall0pass Sep 11, 2023
2c9d33f
clear goal if template removed
shall0pass Sep 15, 2023
c55797b
Visual goals (#40)
youngcw Sep 16, 2023
e6889b9
Merge branch 'actualbudget:master' into goalProgressBar
shall0pass Sep 16, 2023
13e3f00
update release note
shall0pass Sep 16, 2023
edeb3ff
lint
shall0pass Sep 16, 2023
774fa8f
use null as cleared state
shall0pass Sep 17, 2023
39cb601
show goal status via colors (#41)
youngcw Sep 19, 2023
4ce9b13
Merge pull request #1 from shall0pass/goalProgressBar
youngcw Sep 19, 2023
f0d5755
fix report budget, by adding in the goal coloring
youngcw Sep 19, 2023
740d769
fix the error by adding colors to the report side (#42)
youngcw Sep 20, 2023
108c9c4
Merge branch 'actualbudget:master' into goalProgressBar
shall0pass Sep 20, 2023
3282dd3
report budget database updates
shall0pass Sep 20, 2023
05af4ef
Merge remote-tracking branch 'shall0pass/goalProgressBar' into goal_c…
youngcw Sep 21, 2023
42b9b60
Goal progress bar (#1734)
shall0pass Sep 24, 2023
94fb9c9
Merge remote-tracking branch 'upstream/shall0pass/goalsProgress' into…
youngcw Sep 25, 2023
8b5ee1c
working dynamic colors. Need to figure out what changes are actually…
youngcw Sep 28, 2023
c8cb06c
cleanup
youngcw Sep 28, 2023
b1b5a64
more cleanup
youngcw Sep 28, 2023
9e44463
lint
youngcw Sep 28, 2023
682528d
reset the goal when applying a single template
youngcw Sep 29, 2023
119f94d
make getCategory function
youngcw Sep 29, 2023
9677b41
remove some unneeded changes
youngcw Sep 29, 2023
e887ec9
actually remove the changes, not just comment
youngcw Sep 29, 2023
3e8020d
Merge branch 'goal_colors_working' into youngcw/goal_progress
youngcw Sep 30, 2023
5514eaf
cleanup some unneeded code that was causing some bugs. Works for me, …
youngcw Sep 30, 2023
05b3b42
lint
youngcw Sep 30, 2023
412768b
add json definitions to database
shall0pass Oct 1, 2023
be4cf83
use template feature flag to enable colors
youngcw Oct 1, 2023
9f3835a
some fixes
shall0pass Oct 1, 2023
f0ca495
Merge branch 'master' into youngcw/goal_progress
youngcw Oct 10, 2023
e60b04a
don't set goals for remainders, remove unneeded change
youngcw Oct 10, 2023
edd5778
lint
youngcw Oct 10, 2023
2185755
release note
youngcw Oct 10, 2023
d82198b
lint again
youngcw Oct 10, 2023
e8faf90
Merge branch 'master' into youngcw/goal_progress
youngcw Oct 10, 2023
c97e8d9
Merge branch 'master' into youngcw/goal_progress
youngcw Oct 14, 2023
90f9cd7
Merge branch 'master' into youngcw/goal_progress
youngcw Oct 19, 2023
6d0308a
Merge branch 'master' into youngcw/goal_progress
youngcw Oct 31, 2023
1255fe6
Merge branch 'master' into youngcw/goal_progress
youngcw Nov 4, 2023
f8d36a8
Merge branch 'master' into youngcw/goal_progress
youngcw Nov 5, 2023
aefd755
Merge branch 'master' into youngcw/goal_progress
youngcw Nov 5, 2023
ac2d7b1
fix mobile crash
youngcw Nov 5, 2023
c194f53
Merge branch 'master' into youngcw/goal_progress
youngcw Nov 6, 2023
a41e010
undo changes in CellValue.tsx
youngcw Nov 6, 2023
f76afd9
lint
youngcw Nov 6, 2023
daef6de
use getStyle
youngcw Nov 6, 2023
db9705a
move status calc to helper
youngcw Nov 6, 2023
3c1e2c2
lint
youngcw Nov 6, 2023
e6bc21d
recommendations
youngcw Nov 7, 2023
61205b3
Merge branch 'master' into youngcw/goal_progress
youngcw Nov 7, 2023
1e86760
suggestion
youngcw Nov 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { type ComponentProps } from 'react';

import useFeatureFlag from '../../hooks/useFeatureFlag';
import ArrowThinRight from '../../icons/v1/ArrowThinRight';
import { type CSSProperties } from '../../style';
import View from '../common/View';
Expand All @@ -11,6 +12,8 @@ import { makeAmountStyle } from './util';
type BalanceWithCarryoverProps = {
carryover: ComponentProps<typeof CellValue>['binding'];
balance: ComponentProps<typeof CellValue>['binding'];
goal?: ComponentProps<typeof CellValue>['binding'];
budgeted?: ComponentProps<typeof CellValue>['binding'];
disabled?: boolean;
style?: CSSProperties;
balanceStyle?: CSSProperties;
Expand All @@ -19,27 +22,37 @@ type BalanceWithCarryoverProps = {
export default function BalanceWithCarryover({
carryover,
balance,
goal,
budgeted,
disabled,
style,
balanceStyle,
carryoverStyle,
}: BalanceWithCarryoverProps) {
let carryoverValue = useSheetValue(carryover);
let balanceValue = useSheetValue(balance);

let goalValue = useSheetValue(goal);
let budgetedValue = useSheetValue(budgeted);
let isGoalTemplatesEnabled = useFeatureFlag('goalTemplatesEnabled');
youngcw marked this conversation as resolved.
Show resolved Hide resolved
// if a goal is passed in then check if that goal is met or not.
let goalStatus = goalValue != null ? budgetedValue >= goalValue : null;
return (
<View style={style}>
<CellValue
binding={balance}
type="financial"
getStyle={makeAmountStyle}
getStyle={null}
youngcw marked this conversation as resolved.
Show resolved Hide resolved
style={{
textAlign: 'right',
...(!disabled && {
cursor: 'pointer',
':hover': { textDecoration: 'underline' },
}),
...balanceStyle,
...makeAmountStyle(
useSheetValue(balance),
isGoalTemplatesEnabled ? goalStatus : null,
),
}}
/>
{carryoverValue && (
Expand All @@ -58,7 +71,7 @@ export default function BalanceWithCarryover({
<ArrowThinRight
width={7}
height={7}
style={makeAmountStyle(balanceValue)}
style={makeAmountStyle(balanceValue, goalStatus)}
/>
</View>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ const ExpenseCategory = memo(function ExpenseCategory({
<BalanceWithCarryover
carryover={rolloverBudget.catCarryover(category.id)}
balance={rolloverBudget.catBalance(category.id)}
goal={reportBudget.catGoal(category.id)}
budgeted={reportBudget.catBudgeted(category.id)}
balanceStyle={{
...styles.smallText,
...styles.underlinedText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ export const CategoryMonth = memo(function CategoryMonth({
disabled={category.is_income}
carryover={reportBudget.catCarryover(category.id)}
balance={reportBudget.catBalance(category.id)}
goal={reportBudget.catGoal(category.id)}
budgeted={reportBudget.catBudgeted(category.id)}
/>
</span>
{balanceTooltip.isOpen && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ export const ExpenseCategoryMonth = memo(function ExpenseCategoryMonth({
<BalanceWithCarryover
carryover={rolloverBudget.catCarryover(category.id)}
balance={rolloverBudget.catBalance(category.id)}
goal={rolloverBudget.catGoal(category.id)}
budgeted={rolloverBudget.catBudgeted(category.id)}
/>
</span>
{balanceTooltip.isOpen && (
Expand Down
19 changes: 13 additions & 6 deletions packages/desktop-client/src/components/budget/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,22 @@ export function makeAmountGrey(value: number | string) {
: null;
}

export function makeAmountStyle(value: number) {
const greyed = makeAmountGrey(value);
if (greyed) {
return greyed;
}

export function makeAmountStyle(value: number, status: boolean | string) {
youngcw marked this conversation as resolved.
Show resolved Hide resolved
if (value < 0) {
return { color: theme.errorText };
}

if (status === null || status === '') {
const greyed = makeAmountGrey(value);
if (greyed) {
return greyed;
}
} else {
if (!status) {
return { color: theme.warningText };
}
return { color: theme.noticeText };
}
}

export function makeAmountFullStyle(value: number) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BEGIN TRANSACTION;

ALTER TABLE zero_budgets ADD column goal INTEGER DEFAULT null;
ALTER TABLE reflect_budgets ADD column goal INTEGER DEFAULT null;
ALTER TABLE categories ADD column goal_def TEXT DEFAULT null;

COMMIT;
2 changes: 2 additions & 0 deletions packages/loot-core/src/client/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export const rolloverBudget = {
catSumAmount: id => `sum-amount-${id}`,
catBalance: id => `leftover-${id}`,
catCarryover: id => `carryover-${id}`,
catGoal: id => `goal-${id}`,
};

export const reportBudget = {
Expand All @@ -195,4 +196,5 @@ export const reportBudget = {
catSumAmount: id => `sum-amount-${id}`,
catBalance: id => `leftover-${id}`,
catCarryover: id => `carryover-${id}`,
catGoal: id => `goal-${id}`,
};
18 changes: 18 additions & 0 deletions packages/loot-core/src/server/budget/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@ export function setBudget({
});
}

export function setGoal({ month, category, goal }): Promise<void> {
const table = getBudgetTable();
let existing = db.firstSync(
`SELECT id FROM ${table} WHERE month = ? AND category = ?`,
[dbMonth(month), category],
);
if (existing) {
return db.update(table, {
id: existing.id,
goal: goal,
});
}
return db.insert(table, {
id: month,
goal: goal,
});
}

export function setBuffer(month: string, amount: unknown): Promise<void> {
let existing = db.firstSync(
`SELECT id FROM zero_budget_months WHERE id = ?`,
Expand Down
1 change: 1 addition & 0 deletions packages/loot-core/src/server/budget/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ function handleBudgetChange(budget) {
`${sheetName}!carryover-${budget.category}`,
budget.carryover === 1 ? true : false,
);
sheet.get().set(`${sheetName}!goal-${budget.category}`, budget.goal);
}
}

Expand Down
Loading