|
217 | 217 | paternity_adoption ? ap_adoption_date_formatted : date_of_birth
|
218 | 218 | end
|
219 | 219 |
|
220 |
| - next_node_if(:employee_still_employed_on_birth_date?, responded_with('yes')) |
221 |
| - next_node_if(:paternity_not_entitled_to_leave_or_pay, variable_matches(:has_contract, 'no')) |
222 |
| - next_node :employee_start_paternity? |
| 220 | + permitted_next_nodes = [ |
| 221 | + :employee_start_paternity?, |
| 222 | + :employee_still_employed_on_birth_date?, |
| 223 | + :paternity_not_entitled_to_leave_or_pay |
| 224 | + ] |
| 225 | + next_node(permitted: permitted_next_nodes) do |response| |
| 226 | + if response == 'yes' |
| 227 | + :employee_still_employed_on_birth_date? |
| 228 | + elsif has_contract == 'no' |
| 229 | + :paternity_not_entitled_to_leave_or_pay |
| 230 | + else |
| 231 | + :employee_start_paternity? |
| 232 | + end |
| 233 | + end |
223 | 234 | end
|
224 | 235 |
|
225 | 236 | ## QP7
|
|
228 | 239 | option :no
|
229 | 240 | save_input_as :employed_dob
|
230 | 241 |
|
231 |
| - next_node_if(:paternity_not_entitled_to_leave_or_pay, variable_matches(:has_contract, 'no') & responded_with('no')) |
232 |
| - next_node :employee_start_paternity? |
| 242 | + permitted_next_nodes = [ |
| 243 | + :employee_start_paternity?, |
| 244 | + :paternity_not_entitled_to_leave_or_pay |
| 245 | + ] |
| 246 | + next_node(permitted: permitted_next_nodes) do |response| |
| 247 | + if has_contract == 'no' && response == 'no' |
| 248 | + :paternity_not_entitled_to_leave_or_pay |
| 249 | + else |
| 250 | + :employee_start_paternity? |
| 251 | + end |
| 252 | + end |
233 | 253 | end
|
234 | 254 |
|
235 | 255 | ## QP8
|
|
267 | 287 | calculator.pay_end_date
|
268 | 288 | end
|
269 | 289 |
|
270 |
| - next_node_if(:paternity_not_entitled_to_leave_or_pay, variable_matches(:has_contract, 'yes') & |
271 |
| - (variable_matches(:on_payroll, 'no') | variable_matches(:employed_dob, 'no'))) |
272 |
| - next_node :last_normal_payday_paternity? |
| 290 | + permitted_next_nodes = [ |
| 291 | + :last_normal_payday_paternity?, |
| 292 | + :paternity_not_entitled_to_leave_or_pay |
| 293 | + ] |
| 294 | + next_node(permitted: permitted_next_nodes) do |
| 295 | + if has_contract == 'yes' && (on_payroll == 'no' || employed_dob == 'no') |
| 296 | + :paternity_not_entitled_to_leave_or_pay |
| 297 | + else |
| 298 | + :last_normal_payday_paternity? |
| 299 | + end |
| 300 | + end |
273 | 301 | end
|
274 | 302 |
|
275 | 303 | ## QP10
|
|
338 | 366 | calculator
|
339 | 367 | end
|
340 | 368 |
|
341 |
| - define_predicate(:average_weekly_earnings_under_lower_earning_limit?) do |
| 369 | + next_node_calculation(:average_weekly_earnings_under_lower_earning_limit) do |
342 | 370 | calculator.average_weekly_earnings < calculator.lower_earning_limit
|
343 | 371 | end
|
344 | 372 |
|
345 |
| - next_node_if(:paternity_leave_and_pay, average_weekly_earnings_under_lower_earning_limit?) |
346 |
| - next_node :how_do_you_want_the_spp_calculated? |
| 373 | + permitted_next_nodes = [ |
| 374 | + :how_do_you_want_the_spp_calculated?, |
| 375 | + :paternity_leave_and_pay |
| 376 | + ] |
| 377 | + next_node(permitted: permitted_next_nodes) do |
| 378 | + if average_weekly_earnings_under_lower_earning_limit |
| 379 | + :paternity_leave_and_pay |
| 380 | + else |
| 381 | + :how_do_you_want_the_spp_calculated? |
| 382 | + end |
| 383 | + end |
347 | 384 | end
|
348 | 385 |
|
349 | 386 | ## QP14
|
|
353 | 390 |
|
354 | 391 | save_input_as :spp_calculation_method
|
355 | 392 |
|
356 |
| - next_node_if(:paternity_leave_and_pay, responded_with('weekly_starting')) |
357 |
| - next_node_if(:monthly_pay_paternity?, variable_matches(:pay_pattern, 'monthly')) |
358 |
| - next_node :next_pay_day_paternity? |
| 393 | + permitted_next_nodes = [ |
| 394 | + :monthly_pay_paternity?, |
| 395 | + :next_pay_day_paternity?, |
| 396 | + :paternity_leave_and_pay |
| 397 | + ] |
| 398 | + next_node(permitted: permitted_next_nodes) do |response| |
| 399 | + if response == 'weekly_starting' |
| 400 | + :paternity_leave_and_pay |
| 401 | + elsif pay_pattern == 'monthly' |
| 402 | + :monthly_pay_paternity? |
| 403 | + else |
| 404 | + :next_pay_day_paternity? |
| 405 | + end |
| 406 | + end |
359 | 407 | end
|
360 | 408 |
|
361 | 409 | ## QP15 - Also shared with adoption calculator here onwards
|
|
381 | 429 |
|
382 | 430 | save_input_as :monthly_pay_method
|
383 | 431 |
|
384 |
| - next_node_if(:specific_date_each_month_paternity?, responded_with('specific_date_each_month')) |
385 |
| - next_node_if(:days_of_the_week_paternity?, responded_with('last_working_day_of_the_month')) |
386 |
| - next_node_if(:day_of_the_month_paternity?, responded_with('a_certain_week_day_each_month')) |
387 |
| - next_node_if(:adoption_leave_and_pay, variable_matches(:leave_type, 'adoption')) |
388 |
| - next_node :paternity_leave_and_pay |
| 432 | + permitted_next_nodes = [ |
| 433 | + :adoption_leave_and_pay, |
| 434 | + :day_of_the_month_paternity?, |
| 435 | + :days_of_the_week_paternity?, |
| 436 | + :paternity_leave_and_pay, |
| 437 | + :specific_date_each_month_paternity? |
| 438 | + ] |
| 439 | + next_node(permitted: permitted_next_nodes) do |response| |
| 440 | + if response == 'specific_date_each_month' |
| 441 | + :specific_date_each_month_paternity? |
| 442 | + elsif response == 'last_working_day_of_the_month' |
| 443 | + :days_of_the_week_paternity? |
| 444 | + elsif response == 'a_certain_week_day_each_month' |
| 445 | + :day_of_the_month_paternity? |
| 446 | + elsif leave_type == 'adoption' |
| 447 | + :adoption_leave_and_pay |
| 448 | + else |
| 449 | + :paternity_leave_and_pay |
| 450 | + end |
| 451 | + end |
389 | 452 | end
|
390 | 453 |
|
391 | 454 | ## QP17
|
|
397 | 460 | calculator.pay_day_in_month = day
|
398 | 461 | end
|
399 | 462 |
|
400 |
| - next_node_if(:adoption_leave_and_pay, variable_matches(:leave_type, 'adoption')) |
401 |
| - next_node :paternity_leave_and_pay |
| 463 | + permitted_next_nodes = [ |
| 464 | + :adoption_leave_and_pay, |
| 465 | + :paternity_leave_and_pay |
| 466 | + ] |
| 467 | + next_node(permitted: permitted_next_nodes) do |
| 468 | + if leave_type == 'adoption' |
| 469 | + :adoption_leave_and_pay |
| 470 | + else |
| 471 | + :paternity_leave_and_pay |
| 472 | + end |
| 473 | + end |
402 | 474 | end
|
403 | 475 |
|
404 | 476 | ## QP18
|
|
410 | 482 | calculator.pay_day_in_week = response.split(",").sort.last.to_i
|
411 | 483 | end
|
412 | 484 |
|
413 |
| - next_node_if(:adoption_leave_and_pay, variable_matches(:leave_type, 'adoption')) |
414 |
| - next_node :paternity_leave_and_pay |
| 485 | + permitted_next_nodes = [ |
| 486 | + :adoption_leave_and_pay, |
| 487 | + :paternity_leave_and_pay |
| 488 | + ] |
| 489 | + next_node(permitted: permitted_next_nodes) do |
| 490 | + if leave_type == 'adoption' |
| 491 | + :adoption_leave_and_pay |
| 492 | + else |
| 493 | + :paternity_leave_and_pay |
| 494 | + end |
| 495 | + end |
415 | 496 | end
|
416 | 497 |
|
417 | 498 | ## QP19
|
|
444 | 525 | calculator.pay_week_in_month = response
|
445 | 526 | end
|
446 | 527 |
|
447 |
| - next_node_if(:adoption_leave_and_pay, variable_matches(:leave_type, 'adoption')) |
448 |
| - next_node :paternity_leave_and_pay |
| 528 | + permitted_next_nodes = [ |
| 529 | + :adoption_leave_and_pay, |
| 530 | + :paternity_leave_and_pay |
| 531 | + ] |
| 532 | + next_node(permitted: permitted_next_nodes) do |
| 533 | + if leave_type == 'adoption' |
| 534 | + :adoption_leave_and_pay |
| 535 | + else |
| 536 | + :paternity_leave_and_pay |
| 537 | + end |
| 538 | + end |
449 | 539 | end
|
450 | 540 |
|
451 | 541 | # Paternity outcomes
|
|
0 commit comments