mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-21 15:36:50 -05:00
[AI] Fix Spending Analysis budget table for tracking budgeting (#7191)
* [AI] Fix Spending Analysis budget table for tracking budgeting Made-with: Cursor * [autofix.ci] apply automated fixes * [AI] Add release note for Spending Analysis tracking budgeting fix Made-with: Cursor * [autofix.ci] apply automated fixes * [AI] Address CodeRabbit nitpicks: use typed narrowing instead of assertion for budgetType Made-with: Cursor --------- Co-authored-by: Pranay Mac M1 <pranayseela@yahoo.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -46,6 +46,7 @@ import { useFormat } from '@desktop-client/hooks/useFormat';
|
||||
import { useLocale } from '@desktop-client/hooks/useLocale';
|
||||
import { useNavigate } from '@desktop-client/hooks/useNavigate';
|
||||
import { useRuleConditionFilters } from '@desktop-client/hooks/useRuleConditionFilters';
|
||||
import { useSyncedPref } from '@desktop-client/hooks/useSyncedPref';
|
||||
import { addNotification } from '@desktop-client/notifications/notificationsSlice';
|
||||
import { useDispatch } from '@desktop-client/redux';
|
||||
import { useUpdateDashboardWidgetMutation } from '@desktop-client/reports/mutations';
|
||||
@@ -73,6 +74,9 @@ function SpendingInternal({ widget }: SpendingInternalProps) {
|
||||
const dispatch = useDispatch();
|
||||
const { t } = useTranslation();
|
||||
const format = useFormat();
|
||||
const [budgetTypePref] = useSyncedPref('budgetType');
|
||||
const budgetType: 'envelope' | 'tracking' =
|
||||
budgetTypePref === 'tracking' ? 'tracking' : 'envelope';
|
||||
|
||||
const {
|
||||
conditions,
|
||||
@@ -145,8 +149,9 @@ function SpendingInternal({ widget }: SpendingInternalProps) {
|
||||
conditionsOp,
|
||||
compare,
|
||||
compareTo,
|
||||
budgetType,
|
||||
}),
|
||||
[conditions, conditionsOp, compare, compareTo],
|
||||
[conditions, conditionsOp, compare, compareTo, budgetType],
|
||||
);
|
||||
|
||||
const data = useReport('default', getGraphData);
|
||||
|
||||
@@ -21,6 +21,7 @@ import { createSpendingSpreadsheet } from '@desktop-client/components/reports/sp
|
||||
import { useDashboardWidgetCopyMenu } from '@desktop-client/components/reports/useDashboardWidgetCopyMenu';
|
||||
import { useReport } from '@desktop-client/components/reports/useReport';
|
||||
import { useFormat } from '@desktop-client/hooks/useFormat';
|
||||
import { useSyncedPref } from '@desktop-client/hooks/useSyncedPref';
|
||||
|
||||
type SpendingCardProps = {
|
||||
widgetId: string;
|
||||
@@ -41,6 +42,9 @@ export function SpendingCard({
|
||||
}: SpendingCardProps) {
|
||||
const { t } = useTranslation();
|
||||
const format = useFormat();
|
||||
const [budgetTypePref] = useSyncedPref('budgetType');
|
||||
const budgetType: 'envelope' | 'tracking' =
|
||||
budgetTypePref === 'tracking' ? 'tracking' : 'envelope';
|
||||
|
||||
const [isCardHovered, setIsCardHovered] = useState(false);
|
||||
const [nameMenuOpen, setNameMenuOpen] = useState(false);
|
||||
@@ -60,8 +64,9 @@ export function SpendingCard({
|
||||
conditionsOp: meta?.conditionsOp,
|
||||
compare,
|
||||
compareTo,
|
||||
budgetType,
|
||||
});
|
||||
}, [meta?.conditions, meta?.conditionsOp, compare, compareTo]);
|
||||
}, [meta?.conditions, meta?.conditionsOp, compare, compareTo, budgetType]);
|
||||
|
||||
const data = useReport('default', getGraphData);
|
||||
const todayDay =
|
||||
|
||||
@@ -20,6 +20,7 @@ type createSpendingSpreadsheetProps = {
|
||||
conditionsOp?: string;
|
||||
compare?: string;
|
||||
compareTo?: string;
|
||||
budgetType?: 'envelope' | 'tracking';
|
||||
};
|
||||
|
||||
export function createSpendingSpreadsheet({
|
||||
@@ -27,6 +28,7 @@ export function createSpendingSpreadsheet({
|
||||
conditionsOp,
|
||||
compare,
|
||||
compareTo,
|
||||
budgetType = 'envelope',
|
||||
}: createSpendingSpreadsheetProps) {
|
||||
const startDate = monthUtils.subMonths(compare, 3) + '-01';
|
||||
const endDate = monthUtils.getMonthEnd(compare + '-01');
|
||||
@@ -113,9 +115,11 @@ export function createSpendingSpreadsheet({
|
||||
const combineDebts = [...debts, ...overlapDebts];
|
||||
|
||||
const budgetMonth = parseInt(compare.replace('-', ''));
|
||||
const budgetTable =
|
||||
budgetType === 'tracking' ? 'reflect_budgets' : 'zero_budgets';
|
||||
const [budgets] = await Promise.all([
|
||||
aqlQuery(
|
||||
q('zero_budgets')
|
||||
q(budgetTable)
|
||||
.filter({
|
||||
$and: [{ month: { $eq: budgetMonth } }],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user