Photo by dlxmedia.hu on Unsplash

Coda recurrent payments

A simple solution easily implemented

Christiaan Huizer
5 min readMar 26, 2024

--

I have done a great deal of work related to all kind of recurrent payments. This time I share a simple approach that covers most use cases that help you to remind you of an upcoming payment a number of days in advance.

The basics

We have a table with an invoice and the start date, that is the date you had to pay your first invoice. The ‘Name’ column I use to show the name of the file so we have 3 columns. I add number 4 which is the interval: yearly, bi-monthly or monthly.

For each interval we need a proper date and that means that for each option we create a formula to get the next date.

Monthly

There is no native function, so we need a formula to calculate this option. In this option we look at date we are on and we check if the day is before or after the date the invoice has to be paid.

SwitchIf(thisRow.interval.Contains(monthly),

withName(thisRow.startDate.Day() - Today().Day(),base,

If(base <= 0,
Date(
Today().Year(),
Today().RelativeDate(1).Month(),
thisRow.startDate.Day()),
Date(
Today().Year(),
Today().RelativeDate(0).month(),
thisRow.startDate.Day())
)
))

Bi — Monthly

This is a variation on the above, but we need to add an extra step to check if we are already in the right month or we need an extra month (+ 1).

thisRow.interval.Contains([bi-monthly]),

withName(thisRow.startDate.Day() - Today().Day(),base,

If(base <= 0,
Date(
Today().Year(),
Today().RelativeDate(1).Month(),
thisRow.startDate.Day()),
Date(
Today().Year(),
Today().RelativeDate(0).month(),
thisRow.startDate.Day())
)
).WithName(outcome,

If(thisRow.startDate.Month().IsEven() and outcome.Month().IsEven(),
outcome,
outcome.RelativeDate(1)
))

The extra step follows after ‘outcome’. We check on even (could have been odd as well) and in case it fits, we use the outcome, if not we add one month.

Last but not least, the yearly variation.

Yearly

The last one should not come as a surprise, it is the birthday logic we bend a bit using Sign(), a function I wrote about before.

 thisRow.interval.Contains(yearly),

thisRow.startDate.ToDate()
.Substitute(
thisRow.startDate.Year(),
Max(
0,
Sign(
Today() -
thisRow.startDate.Substitute(thisRow.startDate.Year(), Today().Year())
.ToDateTime()
)
) + Today().Year()
)
.ToDate()

We have thus 3 variations and so the hardest part of the job is done. All we have to do next is to reflect on when we want to be notified. As we said, we keep it simple, so only one option. In my subscription template we have many more variation which you only need in a context of many contracts.

We only want to have a notification when the date of today is the same as the date corresponding to the next date minus the notification days.

getting a true of false

This was just to show the logic, the next step is the implementation of it.

Setting the automation

Here we select the time based automation, every day early in the morning the automation checks if there is some work to do. We skip the condition part which is more often than not confusing and we open the formula editor. The well intended suggestions are also confusing, certainly in this scenario.

The outcome in the automation is the same as with the checkbox

We don’t need the step1 logic because this type of automation does not bring in data, it runs on a time based condition. Step1 is needed to reference input like in the context of a webhook.

Use a button in the table

I promised to keep it simple, so instead of solving the notification in the automation, we use a button and that goes as follows.

the notification text

we then add to the filter in the automation this button as a reference and we are done.

I hope you learned a few things. Once you see how this works, you can become creative. In this doc you find the set up I used for the screenshots.

My name is Christiaan and blog about Coda. Since the summer of 2023 often (but not only) about how to Coda with AI to support organisations dealing with texts and templates. The latest major Coda AI update was on Dec 7, 2023.

Why I focus on Coda AI you can read here: ⤵️

I hope you enjoyed this article. If you have questions feel free to reach out. Though this article is for free, my work (including advice) won’t be, but there is always room for a chat to see what can be done. You find my (for free) contributions to the Coda Community and on Twitter.

Coda comes with a set of building blocks ー like pages for infinite depth, tables that talk to each other, and buttons that take action inside or outside your doc ーso anyone can make a doc as powerful as an app (source).

Not to forget: the Coda Community provides great insights for free once you add a sample doc.

--

--

Christiaan Huizer
Christiaan Huizer

Written by Christiaan Huizer

I write about how to Coda . You find blogs for beginners and experienced makers. I publish about 1 / week. Welcome!

No responses yet