fix symbols in transacion name

This commit is contained in:
2025-11-09 13:02:04 -03:00
parent b305173b9d
commit 5474644580
4 changed files with 11 additions and 2 deletions

2
.gitignore vendored
View File

@@ -0,0 +1,2 @@
*.log
__*

View File

@@ -8,6 +8,7 @@ import datetime
from correpy.domain.enums import TransactionType from correpy.domain.enums import TransactionType
from correpy.parsers.brokerage_notes.parser_factory import ParserFactory from correpy.parsers.brokerage_notes.parser_factory import ParserFactory
from fastapi import UploadFile from fastapi import UploadFile
import re
account_id = '1590f1bb-b3ee-4dc8-ac46-bd1f15a83e87' account_id = '1590f1bb-b3ee-4dc8-ac46-bd1f15a83e87'
@@ -52,10 +53,12 @@ def convert_to_ghostfolio(brokerage_list: list, filename: str):
elif transaction.transaction_type == TransactionType.SELL: elif transaction.transaction_type == TransactionType.SELL:
transaction_type = 'SELL' transaction_type = 'SELL'
name = re.sub(r'@|#' , '', transaction.security.name.strip())
activity = {'accountId': account_id, 'comment': filename, 'date': reference_date, activity = {'accountId': account_id, 'comment': filename, 'date': reference_date,
'type': transaction_type, 'type': transaction_type,
'fee': fees, 'unitPrice': transaction.unit_price, 'quantity': transaction.amount, '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', 'currency': 'BRL',
'dataSource': 'YAHOO'} 'dataSource': 'YAHOO'}
activities['activities'].append(activity) activities['activities'].append(activity)

View File

@@ -10,7 +10,11 @@ import io
app = FastAPI() app = FastAPI()
logger = logging.getLogger(__name__) 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") @app.post("/brokerage")
async def convert_pdf(file: UploadFile = File(...)): async def convert_pdf(file: UploadFile = File(...)):