If you modify the $weekEndDate to check is the DayOfWeek value returned is a 1, you can then either just keep the date as is, as its the last day of the week, or minus the days as you were doing.
Can also simplify the second part of the calculation by saying "- 8" instead of "-7 ... + 1", see below:
$WeekEndDate = SelectedDate + If ( DayOfWeek ( SelectedDate ) = 1 ; 0 ; ( 8 - ( DayOfWeek ( SelectedDate ) ) ) )
I hope this helps
I just added this,
If ( DayOfWeek ( Get ( CurrentDate ) ) ≠ 1 ;(Get ( CurrentDate ) + (7 - DayOfWeek ( Get ( CurrentDate ) ) ) + 1); Get ( CurrentDate ) )
and it works.