diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a7033e2 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,6 @@ +repos: + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.1.0 + hooks: + - id: ruff + args: [--fix] \ No newline at end of file diff --git a/credit_card_abacus_da/abacus_cc_loader_from_centaur.py b/credit_card_abacus_da/abacus_cc_loader_from_centaur.py index a467c4c..382234e 100644 --- a/credit_card_abacus_da/abacus_cc_loader_from_centaur.py +++ b/credit_card_abacus_da/abacus_cc_loader_from_centaur.py @@ -36,7 +36,7 @@ def load(is_service): return AbacusCCLoaderFromCentaur.clean_and_load_cc(centaur, abacus, is_service) else: return AbacusCCLoaderFromCentaur.LoadStatus.FINISHED - except Exception as ex: + except Exception: # abacus.write_cc_log_file(start, pd.Timestamp.now(), "0", 0, str(ex)) return AbacusCCLoaderFromCentaur.LoadStatus.ERROR diff --git a/credit_card_abacus_da/cc_abacus_da.py b/credit_card_abacus_da/cc_abacus_da.py index 5b738bf..460933f 100644 --- a/credit_card_abacus_da/cc_abacus_da.py +++ b/credit_card_abacus_da/cc_abacus_da.py @@ -83,7 +83,7 @@ def do_atmp_abacus_cc_job(self, dt_atmp_t17, is_service): return True - except Exception as ex: + except Exception: if is_service: self.update_load_log_cc('1', self.WorkingDay.strftime("%d/%m/%Y")) # set load to true # self.write_cc_log(self.start, datetime.now(), '0', 0, str(ex)) @@ -212,12 +212,12 @@ def build_data_table_atmp_t18_for_single_product(self, atmp_t18, t18rows, atmp_t # Update ATMP_t17_row's "DATE_SINCE_PAST_DUE" field atmp_t17_row["DATE_SINCE_PAST_DUE"] = self.WorkingDay - pd.to_timedelta(int(atmp_t17_row["DAYS_PAST_DUE"]), unit='d') - last_payment_amount = 0.0 - last_minimum_payment = 0.0 - last_sum_of_payment = 0.0 - last_period = 30000101 + #last_payment_amount = 0.0 + #last_minimum_payment = 0.0 + #last_sum_of_payment = 0.0 + #last_period = 30000101 nr_payments_past_due = 0 - last_due_date_dlq = pd.NaT # Pandas equivalent of DateTime.MinValue + #last_due_date_dlq = pd.NaT # Pandas equivalent of DateTime.MinValue # Check if there are rows in t18rows if not t18rows.empty: @@ -242,7 +242,7 @@ def build_data_table_atmp_t18_for_single_product(self, atmp_t18, t18rows, atmp_t # Compare PERIOD values to decide further logic if int(t18row["PERIOD"]) == int(atmp_t17_row["PERIOD"]): atmp_t18_row["LAST_SUM_OF_PAYMENT"] = atmp_t17_row["SUM_OF_PAYMENTS"] - last_payment_amount = float(atmp_t17_row["SUM_OF_PAYMENTS"]) - float(t18row["LAST_SUM_OF_PAYMENT"]) + #last_payment_amount = float(atmp_t17_row["SUM_OF_PAYMENTS"]) - float(t18row["LAST_SUM_OF_PAYMENT"]) if self.WorkingDay > pd.to_datetime(atmp_t18_row["PRINCIPAL_PAYMENT_DATE"]): atmp_t18_row["IS_PASTDUE"] = "1" @@ -255,10 +255,10 @@ def build_data_table_atmp_t18_for_single_product(self, atmp_t18, t18rows, atmp_t nr_payments_past_due += 1 # Convert fields to the appropriate types and store the values - last_minimum_payment = float(atmp_t18_row.get("MINIMUM_PAYMENT", 0)) - last_period = int(atmp_t18_row.get("PERIOD", 30000101)) - last_due_date_dlq = pd.to_datetime(atmp_t18_row.get("DUE_DATE_DLQ", pd.NaT)) - last_sum_of_payment = float(atmp_t18_row.get("LAST_SUM_OF_PAYMENT", 0)) + #last_minimum_payment = float(atmp_t18_row.get("MINIMUM_PAYMENT", 0)) + #last_period = int(atmp_t18_row.get("PERIOD", 30000101)) + #last_due_date_dlq = pd.to_datetime(atmp_t18_row.get("DUE_DATE_DLQ", pd.NaT)) + #last_sum_of_payment = float(atmp_t18_row.get("LAST_SUM_OF_PAYMENT", 0)) # Append the new row to ATMP_T18 DataFrame atmp_t18 = atmp_t18.append(atmp_t18_row, ignore_index=True) diff --git a/credit_card_abacus_da/cc_centaur_da.py b/credit_card_abacus_da/cc_centaur_da.py index c838a5e..b961c63 100644 --- a/credit_card_abacus_da/cc_centaur_da.py +++ b/credit_card_abacus_da/cc_centaur_da.py @@ -61,6 +61,6 @@ def parse_crown_date(self, value): month = int(value[4:6]) day = int(value[6:8]) return datetime(year, month, day) - except Exception as ex: + except Exception: # If parsing fails, return a default date or handle error appropriately return datetime.min diff --git a/credit_card_abacus_da/log.py b/credit_card_abacus_da/log.py index 14a06bb..c5bfea7 100644 --- a/credit_card_abacus_da/log.py +++ b/credit_card_abacus_da/log.py @@ -1,6 +1,4 @@ -import psycopg2 import pandas as pd -from datetime import datetime class Log: def __init__(self): diff --git a/credit_card_abacus_service.py b/credit_card_abacus_service.py index 3f51e13..55a7565 100644 --- a/credit_card_abacus_service.py +++ b/credit_card_abacus_service.py @@ -4,7 +4,6 @@ from zeep import Client from zeep.transports import Transport from requests import Session -from requests.exceptions import Timeout from credit_card_abacus_da.abacus_cc_loader_from_centaur import AbacusCCLoaderFromCentaur class CreditCardAbacusService: diff --git a/pyproject.toml b/pyproject.toml index a7240c3..da118d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,8 @@ requests-file = "2.1.0" requests-toolbelt = "1.0.0" pandas = "2.2.3" numpy = "2.1.2" +pre-commit = "^4.0.1" +ruff = "^0.7.2" [build-system] requires = ["poetry-core"]