diff --git a/.gitignore b/.gitignore index e69de29..a631763 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,2 @@ +*.log +__* \ No newline at end of file diff --git a/converter.py b/converter.py index 6d8feb1..efd05ec 100644 --- a/converter.py +++ b/converter.py @@ -8,6 +8,7 @@ import datetime from correpy.domain.enums import TransactionType from correpy.parsers.brokerage_notes.parser_factory import ParserFactory from fastapi import UploadFile +import re account_id = '1590f1bb-b3ee-4dc8-ac46-bd1f15a83e87' @@ -51,11 +52,13 @@ def convert_to_ghostfolio(brokerage_list: list, filename: str): transaction_type = 'BUY' elif transaction.transaction_type == TransactionType.SELL: transaction_type = 'SELL' + + name = re.sub(r'@|#' , '', transaction.security.name.strip()) activity = {'accountId': account_id, 'comment': filename, 'date': reference_date, 'type': transaction_type, 'fee': fees, 'unitPrice': transaction.unit_price, 'quantity': transaction.amount, - 'symbol': mappings.name_to_tickers[transaction.security.name.strip()].strip(), + 'symbol': mappings.name_to_tickers[name.strip()].strip(), 'currency': 'BRL', 'dataSource': 'YAHOO'} activities['activities'].append(activity) diff --git a/main.py b/main.py index 3e3a90c..d520920 100644 --- a/main.py +++ b/main.py @@ -10,7 +10,11 @@ import io app = FastAPI() logger = logging.getLogger(__name__) -logging.basicConfig(filename='rico-to-ghostfolio.log', level=logging.INFO) +logging.basicConfig( + level=logging.INFO, + format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", + datefmt="%Y-%m-%d %H:%M:%S", +) @app.post("/brokerage") async def convert_pdf(file: UploadFile = File(...)): diff --git a/notas-teste/2025-11-06 NotaNegociacao-11775539-04-11-2025-0.pdf b/notas-teste/2025-11-06 NotaNegociacao-11775539-04-11-2025-0.pdf new file mode 100644 index 0000000..e2556af Binary files /dev/null and b/notas-teste/2025-11-06 NotaNegociacao-11775539-04-11-2025-0.pdf differ