From be2d5e2d5ec329434a451052b4ce7c9f069d6a59 Mon Sep 17 00:00:00 2001 From: Rodrigo Barraza Date: Sun, 10 Dec 2023 19:06:27 -0800 Subject: [PATCH] Cleanup --- .../pay_api/models/non_sufficient_funds.py | 2 +- .../pay_api/services/non_sufficient_funds.py | 88 ++----------------- 2 files changed, 9 insertions(+), 81 deletions(-) diff --git a/pay-api/src/pay_api/models/non_sufficient_funds.py b/pay-api/src/pay_api/models/non_sufficient_funds.py index b5debc521..ba9f8afd0 100644 --- a/pay-api/src/pay_api/models/non_sufficient_funds.py +++ b/pay-api/src/pay_api/models/non_sufficient_funds.py @@ -63,7 +63,7 @@ class Meta(BaseSchema.Meta): # pylint: disable=too-few-public-methods @define -class NonSufficientFundsSearchModel: +class NonSufficientFundsSearchModel: # pylint: disable=too-few-public-methods """Used to search for NSF records.""" id: int diff --git a/pay-api/src/pay_api/services/non_sufficient_funds.py b/pay-api/src/pay_api/services/non_sufficient_funds.py index 55599b120..352760d2e 100644 --- a/pay-api/src/pay_api/services/non_sufficient_funds.py +++ b/pay-api/src/pay_api/services/non_sufficient_funds.py @@ -15,14 +15,13 @@ from __future__ import annotations from datetime import datetime -from typing import Optional from flask import current_app from pay_api.models import CfsAccount as CfsAccountModel from pay_api.models import Invoice as InvoiceModel from pay_api.models import InvoiceReference as InvoiceReferenceModel -from pay_api.models import InvoiceSchema, NonSufficientFundsModel, NonSufficientFundsSchema +from pay_api.models import InvoiceSchema, NonSufficientFundsModel from pay_api.models import Payment as PaymentModel from pay_api.models import PaymentAccount as PaymentAccountModel from pay_api.models import PaymentLineItem as PaymentLineItemModel @@ -33,89 +32,18 @@ from .oauth_service import OAuthService -class NonSufficientFundsService: # pylint: disable=too-many-instance-attributes,too-many-public-methods +class NonSufficientFundsService: """Service to manage Non-Sufficient Funds related operations.""" def __init__(self): """Initialize the service.""" - self.__dao = None - self._id: int = None - self._invoice_id: int = None - self._description: Optional[str] = None - - @property - def _dao(self): - if not self.__dao: - self.__dao = NonSufficientFundsModel() - return self.__dao - - @_dao.setter - def _dao(self, value): - self.__dao = value - self.id: int = self._dao.id - self.invoice_id: int = self._dao.invoice_id - self.description: str = self._dao.description - - @property - def id(self): - """Return the _id.""" - return self._id - - @id.setter - def id(self, value: int): - """Set the _id.""" - self._id = value - self._dao.id = value - - @property - def invoice_id(self): - """Return the _invoice_id.""" - return self._invoice_id - - @invoice_id.setter - def invoice_id(self, value: int): - """Set the _invoice_id.""" - self._invoice_id = value - self._dao.invoice_id = value - - @property - def description(self): - """Return the Non-Sufficient Funds description.""" - return self._description - - @description.setter - def description(self, value: str): - """Set the Non-Sufficient Funds description.""" - self._description = value - self._dao.description = value - - def commit(self): - """Save the information to the DB.""" - return self._dao.commit() - - def rollback(self): - """Rollback.""" - return self._dao.rollback() - - def flush(self): - """Save the information to the DB.""" - return self._dao.flush() - - def save(self): - """Save the information to the DB.""" - return self._dao.save() - - def asdict(self): - """Return the Non-Sufficient Funds as a python dict.""" - non_sufficient_funds_schema = NonSufficientFundsSchema() - d = non_sufficient_funds_schema.dump(self._dao) - return d + self.dao = NonSufficientFundsModel() @staticmethod def populate(value: NonSufficientFundsModel): """Populate Non-Sufficient Funds Service.""" - non_sufficient_funds_service: NonSufficientFundsService = NonSufficientFundsService() - non_sufficient_funds_service._dao = value # pylint: disable=protected-access + non_sufficient_funds_service = NonSufficientFundsService() + non_sufficient_funds_service.dao = value return non_sufficient_funds_service @staticmethod @@ -124,9 +52,9 @@ def save_non_sufficient_funds(invoice_id: int, description: str) -> NonSufficien current_app.logger.debug('save_non_sufficient_funds')