Skip to content

Commit

Permalink
fix(bug): Fixed DTStart bug in rrule processing. (#1468)
Browse files Browse the repository at this point in the history
* fix(bug): Fixed DTStart bug in rrule processing.

Right now we kind of guess the dtstart, but several months ago I added
some code to set a marker for a usable dtstart on the record itself.
This way we can use that more accurately.

* chore: Improved tests

* fix(bug): Fixed bug with forecasting calculation.

* chore: Fixing timezone issues :(

* chore: Fixed dtstart issue in pkg models too
  • Loading branch information
elliotcourant committed Jul 5, 2023
1 parent 5d1976f commit c9cf496
Show file tree
Hide file tree
Showing 15 changed files with 2,274 additions and 37 deletions.
1 change: 1 addition & 0 deletions pkg/controller/funding_schedules.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func (c *Controller) postFundingSchedules(ctx echo.Context) error {

// It has never occurred so this needs to be nil.
fundingSchedule.LastOccurrence = nil
fundingSchedule.DateStarted = fundingSchedule.NextOccurrence

if err = repo.CreateFundingSchedule(c.getContext(ctx), &fundingSchedule); err != nil {
return c.wrapPgError(ctx, err, "failed to create funding schedule")
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/spending.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func (c *Controller) postSpending(ctx echo.Context) error {
}

spending.NextRecurrence = nextRecurrence
spending.DateStarted = nextRecurrence

// Once we have all that data we can calculate the new expenses next contribution amount.
if err = spending.CalculateNextContribution(
Expand Down
10 changes: 10 additions & 0 deletions pkg/forecast/fixtures/elliots-funding-20230705.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"fundingScheduleId": 1,
"rule": "FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=15,-1",
"excludeWeekends": true,
"lastOccurrence": "2023-06-30T05:00:00Z",
"nextOccurrence": "2023-07-14T05:00:00Z",
"dateStarted": "2023-02-28T06:00:00Z"
}
]
Loading

0 comments on commit c9cf496

Please sign in to comment.