fix(subscriptions): a payment made around a past due date counts as paid, runway refetches on focus
A bill paid a day before its due date showed as overdue in the runway because past due dates were never matched against payments; now any payment within a third of the cycle around the date settles it. The runway's bills and payments refetch when the tab gets focus, so entries the bot made meanwhile show up.
This commit is contained in:
1 parent
4a03ab8e1a
commit
9c15b81409
2 files changed
+3
-5
No files matched your search
@@ -28,10 +28,12 @@ export const runwayQueries = {
|
||||
bills: (start: string, end: string) => ({
|
||||
queryFn: () => all<Bill>("/v1/bills", { end, start }),
|
||||
queryKey: ["subscriptions", "runway", start, end],
|
||||
refetchOnWindowFocus: true,
|
||||
}),
|
||||
paid: () => ({
|
||||
queryFn: async () => toPayments(await search("has_any_bill:true")),
|
||||
queryKey: ["subscriptions", "payments"],
|
||||
refetchOnWindowFocus: true,
|
||||
}),
|
||||
unlinked: (day: string) => {
|
||||
const after = addDays(day, -UNLINKED_DAYS);
|
||||
|
||||
@@ -208,11 +208,7 @@ function occurrences(bill: Bill, day: string) {
|
||||
return (bill.pay_dates ?? [])
|
||||
.map((raw) => raw.slice(0, 10))
|
||||
.filter((date) => !end || date <= end)
|
||||
.filter(
|
||||
(date) =>
|
||||
date < day ||
|
||||
!paid.some((p) => p <= date && daysBetween(p, date) < early)
|
||||
)
|
||||
.filter((date) => !paid.some((p) => Math.abs(daysBetween(p, date)) < early))
|
||||
.map((date) => ({ date: date < day ? day : date, overdue: date < day }));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user