Skip to content

Commit cdf8a6f

Browse files
committed
fix: add electric amount
1 parent f36f467 commit cdf8a6f

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

app/api/v1/endpoints/pdf_processing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ async def sales(params: PdfContentRequest = Depends()):
9292
with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as temp_pdf:
9393
temp_pdf.write(await params.file.read())
9494

95-
total_amount, total_saldo, total_propia, total_movil, total_nauta, total_nauta_hogar, total_factura, profits, pdf_data = PdfAnalyzer(temp_pdf.name).sales(transaction_status=status)
95+
total_amount, total_saldo, total_propia, total_movil, total_nauta, total_nauta_hogar, total_factura, total_electrica, profits, pdf_data = PdfAnalyzer(temp_pdf.name).sales(transaction_status=status)
9696

9797
# If no exist `page` and `limit`, return all data
9898
if page is None or limit is None:
@@ -104,6 +104,7 @@ async def sales(params: PdfContentRequest = Depends()):
104104
total_nauta=total_nauta,
105105
total_nauta_hogar=total_nauta_hogar,
106106
total_factura=total_factura,
107+
total_electrica=total_electrica,
107108
profits=profits,
108109
results=pdf_data
109110
)
@@ -122,6 +123,7 @@ async def sales(params: PdfContentRequest = Depends()):
122123
total_nauta=total_nauta,
123124
total_nauta_hogar=total_nauta_hogar,
124125
total_factura=total_factura,
126+
total_electrica=total_electrica,
125127
profits=profits,
126128
results=paginated_data
127129
)

app/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from fastapi import FastAPI
22
from app.api.v1.endpoints import pdf_processing
3+
from fastapi.responses import ORJSONResponse
34

45
app = FastAPI(
56
title="Estado de Cuenta API",
@@ -11,7 +12,8 @@
1112
"- Obtener el contenido completo del estado de cuenta en formato estructurado\n\n"
1213
"- Extraer información específica, como **depósitos**, **recargas** realizadas, **ganancias** y otros detalles relevantes\n\n"
1314
),
14-
version="1.0.0"
15+
version="1.0.0",
16+
default_response_class=ORJSONResponse
1517
)
1618

1719
app.include_router(pdf_processing.router, prefix="/pdf", tags=['Procesar PDF'])

app/schemas/pdf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ class PdfSalesResponse(BaseModel):
3333
total_nauta: float
3434
total_nauta_hogar: float
3535
total_factura: float
36+
total_electrica: float
3637
profits: float
3738
results: List[TransactionData]

app/services/pdf_analyzer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def deposits(self, transaction_status: str = 'successful') -> List[Dict]:
6666
def sales(self, transaction_status: str = 'successful') -> List[Dict]:
6767
"""Calculates the total amount deducted for recharges"""
6868
total_amount, total_saldo, total_movil, total_nauta = 0, 0, 0, 0
69-
total_nauta_hogar, total_factura, total_propia = 0, 0, 0
69+
total_nauta_hogar, total_factura, total_propia, total_electrica = 0, 0, 0, 0
7070
data = []
7171
for row in self.transactions(transaction_status):
7272
if row['transaction_type'] == 'Venta de Saldo AT':
@@ -81,8 +81,10 @@ def sales(self, transaction_status: str = 'successful') -> List[Dict]:
8181
total_nauta_hogar += row['amount_paid']
8282
if row['transaction_type'] == 'Pago Factura AT':
8383
total_factura += row['amount_paid']
84+
if row['transaction_type'] == 'Factura Electrica':
85+
total_electrica += row['amount_paid']
8486
if row['transaction_type'] not in ['Estado de Cuenta', 'Recarga Bolsa CUP']:
8587
data.append(row)
8688
total_amount += row['amount_paid']
8789
profits = total_amount / 0.9 - total_amount
88-
return round(total_amount, 2), round(total_saldo, 2), round(total_propia, 2), round(total_movil, 2), round(total_nauta, 2), round(total_nauta_hogar, 2), round(total_factura, 2), round(profits, 2), data
90+
return round(total_amount, 2), round(total_saldo, 2), round(total_propia, 2), round(total_movil, 2), round(total_nauta, 2), round(total_nauta_hogar, 2), round(total_factura, 2), round(total_electrica, 2), round(profits, 2), data

requirements.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
annotated-types==0.7.0
22
anyio==4.8.0
3+
bcrypt==3.2.0
34
certifi==2025.1.31
5+
cffi==1.17.1
46
click==8.1.8
57
colorama==0.4.6
8+
cryptography==44.0.3
69
distro==1.9.0
710
dnspython==2.7.0
11+
ecdsa==0.19.1
812
email_validator==2.2.0
913
et_xmlfile==2.0.0
1014
fastapi==0.115.8
1115
fastapi-cli==0.0.7
16+
greenlet==3.2.2
1217
h11==0.14.0
1318
httpcore==1.0.7
1419
httptools==0.6.4
@@ -20,20 +25,28 @@ MarkupSafe==3.0.2
2025
mdurl==0.1.2
2126
numpy==2.2.3
2227
openpyxl==3.1.5
28+
orjson==3.10.18
2329
pandas==2.2.3
30+
passlib==1.7.4
31+
pyasn1==0.4.8
32+
pycparser==2.22
2433
pydantic==2.10.6
2534
pydantic_core==2.27.2
2635
Pygments==2.19.1
2736
python-dateutil==2.9.0.post0
2837
python-dotenv==1.0.1
38+
python-jose==3.4.0
2939
python-multipart==0.0.20
3040
pytz==2025.1
3141
PyYAML==6.0.2
3242
rich==13.9.4
3343
rich-toolkit==0.13.2
44+
rsa==4.9.1
3445
shellingham==1.5.4
3546
six==1.17.0
3647
sniffio==1.3.1
48+
SQLAlchemy==2.0.41
49+
sqlmodel==0.0.24
3750
starlette==0.45.3
3851
tabula-py==2.10.0
3952
typer==0.15.1

0 commit comments

Comments
 (0)