Skip to content

Commit

Permalink
Fix incorrect calculation
Browse files Browse the repository at this point in the history
V1E18MF{some_date} means "add 17 months and go to the last day of that month"

We had been calculating "add 18 months and go to the last day of that month"
  • Loading branch information
jdowd committed Sep 1, 2024
1 parent abfbb64 commit ecc0e0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/sof/cycles/end_of.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def to_s
end

def final_date(_ = nil) = time_span
.end_date(start_date)
.end_date(start_date - 1.send(period))
.end_of_month

def start_date(_ = nil) = from_date.to_date
Expand Down
6 changes: 3 additions & 3 deletions spec/sof/cycles/end_of_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module SOF
let(:notation) { "V2E18MF#{from_date}" }
let(:anchor) { nil }

let(:end_date) { (from_date.to_date + 18.months).end_of_month }
let(:end_date) { (from_date.to_date + 17.months).end_of_month }
let(:from_date) { "2020-01-01" }

let(:completed_dates) do
Expand Down Expand Up @@ -38,7 +38,7 @@ module SOF
end
end

@end_date = ("2020-01-01".to_date + 18.months).end_of_month
@end_date = ("2020-01-01".to_date + 17.months).end_of_month
it_behaves_like "#to_s returns",
"2x by #{@end_date.to_fs(:american)}"

Expand All @@ -52,7 +52,7 @@ module SOF
it_behaves_like "#notation returns the notation"
it_behaves_like "#as_json returns the notation"
it_behaves_like "it computes #final_date(given)",
given: nil, returns: ("2020-01-01".to_date + 18.months).end_of_month
given: nil, returns: ("2020-01-01".to_date + 17.months).end_of_month

describe "#covered_dates" do
it "given an anchor date, returns dates that fall within it's window" do
Expand Down

0 comments on commit ecc0e0f

Please sign in to comment.