A local-first personal finance app
Add Reset Hold and Hold For Next Month api (#3140)
rodriguestiago02b1ba8898318
diff --git a/packages/api/methods.ts b/packages/api/methods.tsindex 06109bf837..fc34550635 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.tsindex 84e5384050..6d49fb8131 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.tsindex 2b9bd08808..cf26bac83a 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.mdnew file mode 100644index 0000000000..0802097b93--- /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