Merge pull request #1546 from automatisch/AUT-583
feat(ynab): add low account balance trigger
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import defineApp from '../../helpers/define-app.js';
|
import defineApp from '../../helpers/define-app.js';
|
||||||
import addAuthHeader from './common/add-auth-header.js';
|
import addAuthHeader from './common/add-auth-header.js';
|
||||||
import auth from './auth/index.js';
|
import auth from './auth/index.js';
|
||||||
|
import triggers from './triggers/index.js';
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'You Need A Budget',
|
name: 'You Need A Budget',
|
||||||
@@ -13,4 +14,5 @@ export default defineApp({
|
|||||||
supportsConnections: true,
|
supportsConnections: true,
|
||||||
beforeRequest: [addAuthHeader],
|
beforeRequest: [addAuthHeader],
|
||||||
auth,
|
auth,
|
||||||
|
triggers,
|
||||||
});
|
});
|
||||||
|
@@ -0,0 +1,35 @@
|
|||||||
|
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||||
|
|
||||||
|
export default defineTrigger({
|
||||||
|
name: 'Category overspent',
|
||||||
|
key: 'categoryOverspent',
|
||||||
|
pollInterval: 15,
|
||||||
|
description:
|
||||||
|
'Triggers when a category exceeds its budget, resulting in a negative balance.',
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const categoryWithNegativeBalance = [];
|
||||||
|
|
||||||
|
const response = await $.http.get('/budgets/default/categories');
|
||||||
|
const categoryGroups = response.data.data.category_groups;
|
||||||
|
|
||||||
|
categoryGroups.forEach((group) => {
|
||||||
|
group.categories.forEach((category) => {
|
||||||
|
if (category.balance < 0) {
|
||||||
|
categoryWithNegativeBalance.push(category);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (categoryWithNegativeBalance?.length) {
|
||||||
|
for (const category of categoryWithNegativeBalance) {
|
||||||
|
$.pushTriggerItem({
|
||||||
|
raw: category,
|
||||||
|
meta: {
|
||||||
|
internalId: category.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
@@ -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/default/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,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
@@ -0,0 +1,11 @@
|
|||||||
|
import categoryOverspent from './category-overspent/index.js';
|
||||||
|
import goalCompleted from './goal-completed/index.js';
|
||||||
|
import lowAccountBalance from './low-account-balance/index.js';
|
||||||
|
import newTransactions from './new-transactions/index.js';
|
||||||
|
|
||||||
|
export default [
|
||||||
|
categoryOverspent,
|
||||||
|
goalCompleted,
|
||||||
|
lowAccountBalance,
|
||||||
|
newTransactions,
|
||||||
|
];
|
@@ -0,0 +1,39 @@
|
|||||||
|
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||||
|
|
||||||
|
export default defineTrigger({
|
||||||
|
name: 'Low account balance',
|
||||||
|
key: 'lowAccountBalance',
|
||||||
|
pollInterval: 15,
|
||||||
|
description:
|
||||||
|
'Triggers when the balance of a Checking or Savings account falls below a specified amount within a given month.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Balance Below Amount',
|
||||||
|
key: 'balanceBelowAmount',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
description: 'Account balance falls below this amount (e.g. "250.00")',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const balanceBelowAmount = $.step.parameters.balanceBelowAmount;
|
||||||
|
const formattedBalance = balanceBelowAmount * 1000;
|
||||||
|
|
||||||
|
const response = await $.http.get('/budgets/default/accounts');
|
||||||
|
|
||||||
|
if (response.data?.data?.accounts?.length) {
|
||||||
|
for (const account of response.data.data.accounts) {
|
||||||
|
if (account.balance < formattedBalance) {
|
||||||
|
$.pushTriggerItem({
|
||||||
|
raw: account,
|
||||||
|
meta: {
|
||||||
|
internalId: account.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
@@ -0,0 +1,24 @@
|
|||||||
|
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||||
|
|
||||||
|
export default defineTrigger({
|
||||||
|
name: 'New transactions',
|
||||||
|
key: 'newTransactions',
|
||||||
|
pollInterval: 15,
|
||||||
|
description: 'Triggers when a new transaction is created.',
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const response = await $.http.get('/budgets/default/transactions');
|
||||||
|
const transactions = response.data.data?.transactions;
|
||||||
|
|
||||||
|
if (transactions?.length) {
|
||||||
|
for (const transaction of transactions) {
|
||||||
|
$.pushTriggerItem({
|
||||||
|
raw: transaction,
|
||||||
|
meta: {
|
||||||
|
internalId: transaction.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
@@ -480,6 +480,7 @@ export default defineConfig({
|
|||||||
collapsible: true,
|
collapsible: true,
|
||||||
collapsed: true,
|
collapsed: true,
|
||||||
items: [
|
items: [
|
||||||
|
{ text: 'Triggers', link: '/apps/you-need-a-budget/triggers' },
|
||||||
{ text: 'Connection', link: '/apps/you-need-a-budget/connection' },
|
{ text: 'Connection', link: '/apps/you-need-a-budget/connection' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@@ -11,8 +11,9 @@ connection in Automatisch. If any of the steps are outdated, please let us know!
|
|||||||
4. Click on the **New Application** under the **OAuth Applications** section.
|
4. Click on the **New Application** under the **OAuth Applications** section.
|
||||||
5. Fill the new application form.
|
5. Fill the new application form.
|
||||||
6. Copy **OAuth Redirect URL** from Automatisch and paste it in **Redirect URI(s)** section.
|
6. Copy **OAuth Redirect URL** from Automatisch and paste it in **Redirect URI(s)** section.
|
||||||
7. Click on the **Save Application** button.
|
7. Enable the option **Enable default budget selection when users authorize this application**.
|
||||||
8. Copy the **Client ID** value to the **Client ID** field on Automatisch.
|
8. Click on the **Save Application** button.
|
||||||
9. Copy the **Client Secret** value to the **Client Secret** field on Automatisch.
|
9. Copy the **Client ID** value to the **Client ID** field on Automatisch.
|
||||||
10. Fill the **Screen Name** field on Automatisch.
|
10. Copy the **Client Secret** value to the **Client Secret** field on Automatisch.
|
||||||
11. Congrats! Start using your new You Need A Budget connection within the flows.
|
11. Fill the **Screen Name** field on Automatisch.
|
||||||
|
12. Congrats! Start using your new You Need A Budget connection within the flows.
|
||||||
|
18
packages/docs/pages/apps/you-need-a-budget/triggers.md
Normal file
18
packages/docs/pages/apps/you-need-a-budget/triggers.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
favicon: /favicons/you-need-a-budget.svg
|
||||||
|
items:
|
||||||
|
- name: Category overspent
|
||||||
|
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
|
||||||
|
desc: Triggers when the balance of a Checking or Savings account falls below a specified amount within a given month.
|
||||||
|
- name: New transactions
|
||||||
|
desc: Triggers when a new transaction is created.
|
||||||
|
---
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import CustomListing from '../../components/CustomListing.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<CustomListing />
|
@@ -50,5 +50,6 @@ The following integrations are currently supported by Automatisch.
|
|||||||
- [Webhooks](/apps/webhooks/triggers)
|
- [Webhooks](/apps/webhooks/triggers)
|
||||||
- [WordPress](/apps/wordpress/triggers)
|
- [WordPress](/apps/wordpress/triggers)
|
||||||
- [Xero](/apps/xero/triggers)
|
- [Xero](/apps/xero/triggers)
|
||||||
|
- [You Need A Budget](/apps/you-need-a-budget/triggers)
|
||||||
- [Youtube](/apps/youtube/triggers)
|
- [Youtube](/apps/youtube/triggers)
|
||||||
- [Zendesk](/apps/zendesk/actions)
|
- [Zendesk](/apps/zendesk/actions)
|
||||||
|
Reference in New Issue
Block a user