diff --git a/packages/api/methods.ts b/packages/api/methods.ts index 06109bf8374bb20def85d4872d5ec85c84e3773e..fc3455063526a80c088743db4d5cd692a367a3c0 100644 --- a/packages/api/methods.ts +++ b/packages/api/methods.ts @@ -208,3 +208,11 @@ export function updateRule(rule) { export function deleteRule(id) { return send('api/rule-delete', { id }); } + +export function holdBudgetForNextMonth(month, amount) { + return send('api/budget-hold-for-next-month', { month, amount }); +} + +export function resetBudgetHold(month) { + return send('api/budget-reset-hold', { month }); +} diff --git a/packages/loot-core/src/server/api.ts b/packages/loot-core/src/server/api.ts index 84e53840501a301f6f3a253a226e26067874ea1e..6d49fb81316ee404889f43f38efdaa0d07b2b05d 100644 --- a/packages/loot-core/src/server/api.ts +++ b/packages/loot-core/src/server/api.ts @@ -406,6 +406,27 @@ handlers['api/budget-set-carryover'] = withMutation(async function ({ }); }); +handlers['api/budget-hold-for-next-month'] = withMutation(async function ({ + month, + amount, +}) { + checkFileOpen(); + await validateMonth(month); + if (amount <= 0) { + throw APIError('Amount to hold needs to be greater than 0'); + } + return handlers['budget/hold-for-next-month']({ + month, + amount, + }); +}); + +handlers['api/budget-reset-hold'] = withMutation(async function ({ month }) { + checkFileOpen(); + await validateMonth(month); + return handlers['budget/reset-hold']({ month }); +}); + handlers['api/transactions-export'] = async function ({ transactions, categoryGroups, diff --git a/packages/loot-core/src/types/api-handlers.d.ts b/packages/loot-core/src/types/api-handlers.d.ts index 2b9bd088081dac7802b24b069489a6d5436124e9..cf26bac83abe73493fe5cc35c173981b2e6921dc 100644 --- a/packages/loot-core/src/types/api-handlers.d.ts +++ b/packages/loot-core/src/types/api-handlers.d.ts @@ -63,6 +63,13 @@ export interface ApiHandlers { flag: boolean; }) => Promise<void>; + 'api/budget-hold-for-next-month': (arg: { + month: string; + amount: number; + }) => Promise<void>; + + 'api/budget-reset-hold': (arg: { month: string }) => Promise<void>; + 'api/transactions-export': (arg: { transactions; categoryGroups; diff --git a/upcoming-release-notes/3140.md b/upcoming-release-notes/3140.md new file mode 100644 index 0000000000000000000000000000000000000000..0802097b93cf8ba8a079b6899cf2ec19e9ee4ab5 --- /dev/null +++ b/upcoming-release-notes/3140.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [rodriguestiago0] +--- + +Add `reset-hold` and `hold-for-next-month` methods to the API \ No newline at end of file