I’m trying to display paid bills in a repeating group, but only those that match the current month. I have created a state that displays the month and year like this: December 2023.
I tried to solve your problem with your current design (Paid On is a list of dates) but nothing useful so far.
If I may suggest a design change (just one new field), it would be extremely easy though. I am assuming whenever a bill is paid, you add another date to this (paid on) field of the bill. If you add another field called Last Paid On which is just a date and is updated whenever the bill is paid and always keeps the last date the bill is paid on. The logic you have designed would work perfectly (but using the Last PAid On field). You will still continue to add the payment dates to the list of dates field called Paid On. And whenever you add something to this list, you also set the LAst Paid On field.
But what if the user decides to go back three months on the month switcher to see which bills were paid on what date of the currently selected month? So that’s why I wanted to store multiple entries of the bill paid date. And then just use this to show them.
I also can’t understand why this function is not working. Like it should match dates that are stored in database with the currentMonth state which is displayed like this : December 2023, that’s why I used rounded down to month
In your case, you are right. Even my approach won’t work.
But the reason your approach doesn’t work is hidden in the contains function. It tries to find an exact match, not looking for a range. That’s why it cant find it.
If you are willing to change your design a little bit, here is the solution I have found. The basic idea is to make the paid on a single field instead of a list. So, I made another type called Payment which links to the Bill itself. And the Bill has a list of Payments.
Now, whenever a bill is paid, a new Bill Payment will be created with a link to the original bill and this payment is added to the payments link of the bill:
After saving these and making the links successfully. The rest is easy. I have created the following UI in bubble to show all the bills and their payments in nested repeating groups: