feat(ynab): add goal completed trigger
This commit is contained in:
@@ -0,0 +1,34 @@
|
|||||||
|
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||||
|
|
||||||
|
export default defineTrigger({
|
||||||
|
name: 'Goal completed',
|
||||||
|
key: 'goalCompleted',
|
||||||
|
pollInterval: 15,
|
||||||
|
description: 'Triggers when a goal is completed.',
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const goalCompletedCategories = [];
|
||||||
|
|
||||||
|
const response = await $.http.get('/budgets/last-used/categories');
|
||||||
|
const categoryGroups = response.data.data.category_groups;
|
||||||
|
|
||||||
|
categoryGroups.forEach((group) => {
|
||||||
|
group.categories.forEach((category) => {
|
||||||
|
if (category.goal_percentage_complete === 100) {
|
||||||
|
goalCompletedCategories.push(category);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (goalCompletedCategories?.length) {
|
||||||
|
for (const category of goalCompletedCategories) {
|
||||||
|
$.pushTriggerItem({
|
||||||
|
raw: category,
|
||||||
|
meta: {
|
||||||
|
internalId: category.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
@@ -1,4 +1,5 @@
|
|||||||
import categoryOverspent from './category-overspent/index.js';
|
import categoryOverspent from './category-overspent/index.js';
|
||||||
|
import goalCompleted from './goal-completed/index.js';
|
||||||
import lowAccountBalance from './low-account-balance/index.js';
|
import lowAccountBalance from './low-account-balance/index.js';
|
||||||
|
|
||||||
export default [categoryOverspent, lowAccountBalance];
|
export default [categoryOverspent, goalCompleted, lowAccountBalance];
|
||||||
|
@@ -3,6 +3,8 @@ favicon: /favicons/you-need-a-budget.svg
|
|||||||
items:
|
items:
|
||||||
- name: Category overspent
|
- name: Category overspent
|
||||||
desc: Triggers when a category exceeds its budget, resulting in a negative balance.
|
desc: Triggers when a category exceeds its budget, resulting in a negative balance.
|
||||||
|
- name: Goal completed
|
||||||
|
desc: Triggers when a goal is completed.
|
||||||
- name: Low account balance
|
- name: Low account balance
|
||||||
desc: Triggers when the balance of a Checking or Savings account falls below a specified amount within a given month.
|
desc: Triggers when the balance of a Checking or Savings account falls below a specified amount within a given month.
|
||||||
---
|
---
|
||||||
|
Reference in New Issue
Block a user