Skip to content

Commit

Permalink
update effective date for Ascensus 360 (#51)
Browse files Browse the repository at this point in the history
* update effective date

* update according to pai_vanguard

* lint fixes

* version update

* missed types

* update tests

* pr review updates

* update version
  • Loading branch information
kshitesh authored Mar 18, 2024
1 parent e7de69f commit 8b5dfbf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
20 changes: 12 additions & 8 deletions flux_sdk/pension/utils/ascensus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from decimal import ROUND_HALF_UP, Decimal
from enum import Enum
from io import IOBase, StringIO
from typing import Optional, Union
from typing import Any, Optional, Union

from flux_sdk.flux_core.data_models import (
ContributionType,
Expand Down Expand Up @@ -420,17 +420,17 @@ def _create_eds_for_value(
percentage: bool,
ssn: str,
effective_date: datetime,
):
) -> EmployeeDeductionSetting:
eds = EmployeeDeductionSetting()
eds.ssn = ssn
eds.effective_date = effective_date
eds.deduction_type = deduction_type
eds.value = Decimal(value) #type: ignore
eds.value = Decimal(value) # type: ignore
eds.is_percentage = percentage
return eds

@staticmethod
def _is_valid_amount(value):
def _is_valid_amount(value) -> bool:
try:
Decimal(value)
return True
Expand All @@ -452,11 +452,15 @@ def get_deduction_type(given_ded_type) -> Optional[DeductionType]:
return ded_match_map.get(given_ded_type, None)

@staticmethod
def _parse_deduction_rows(row, result):
def _parse_deduction_rows(
row: dict[str, Any], result: list[EmployeeDeductionSetting]
) -> list[EmployeeDeductionSetting]:
ssn = row["EmployeeSSN"]
deduction_type = UpdateDeductionElectionsAscensusUtil.get_deduction_type(row["ContributionCode"])
eligibility_date = (
datetime.strptime(row["EmployeeEligibilityDate"], "%m%d%Y").date() if row["EmployeeEligibilityDate"] else ""
datetime.strptime(row["EmployeeEligibilityDate"], "%m%d%Y")
if row["EmployeeEligibilityDate"]
else datetime.now()
)

if (
Expand All @@ -479,7 +483,7 @@ def _parse_deduction_rows(row, result):
return result

@staticmethod
def _parse_loan_rows(row, ssn_to_loan_sum_map):
def _parse_loan_rows(row: dict[str, Any], ssn_to_loan_sum_map: dict[str, Decimal]) -> dict[str, Decimal]:
ssn = row["EmployeeSSN"]
if UpdateDeductionElectionsAscensusUtil._is_valid_amount(row["LoanPaymentAmount"]):
loan_value = Decimal(row["LoanPaymentAmount"])
Expand All @@ -502,7 +506,7 @@ def parse_deductions_for_ascensus(uri: str, stream: IOBase) -> list[EmployeeDedu
result: list[EmployeeDeductionSetting] = []

try:
reader = csv.DictReader(stream) #type: ignore
reader = csv.DictReader(stream) # type: ignore
except Exception as e:
logger.error(f"[UpdateDeductionElectionsImpl.parse_deductions] Parse deductions failed due to message {e}")
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def get_file_data_for_test_update_deduction(self, date):
"D,222222-00000,DOE,JOHN,,{},03312019,401K,10.00,0.00,5102022,,,,\n"
"D,222222-00000,DOE,JOHN,,{},03312019,4ROTH,0,2.00,,,,,\n"
"D,222222-00000,DOE,JOHN,,{},03312019,401K,5.00,0.00,,,,,,\n"
"D,222222-00000,DOE,JOHN,,{},03312019,4ROTH,0,1.00,,,,,\n"
"L,222222-00000,DOE,JOHN,,{},04122018,401L,,,,20181031922XXX,00000000101.19 ,00000005524.17,\n"
"D,222222-00000,DOE,JOHN,,{},03312019,4ROTH,0,1.00,,03312019,,,\n"
"L,222222-00000,DOE,JOHN,,{},04122018,401L,,,03312019,20181031922XXX,00000000101.19 ,00000005524.17,\n"
"L,222222-00000,DOE,JOHN,,{},04192018,401L,,,,20180817923XXX,00000000061.30 ,00000007171.35,\n"
"L,222222-00000,DOE,JOHN,,{},04122018,401L,,,,20181031924XXX,00000000100.00 ,00000005524.17,\n"
"L,222222-00000,DOE,JOHN,,{},04192018,401L,,,,20180817925XXX,00000000100.00 ,00000007171.35,\n"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rippling-flux-sdk"
version = "0.19"
version = "0.20"
description = "Defines the interfaces and data-models used by Rippling Flux Apps."
authors = ["Rippling Apps <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 8b5dfbf

Please sign in to comment.