31 lines
900 B
Python
31 lines
900 B
Python
import sys
|
|
import os
|
|
from datetime import datetime
|
|
|
|
# Add backend directory to path
|
|
sys.path.append('/home/josmar/dev/anexo76/backend')
|
|
|
|
from api.v1.modules.a76.general_catalogs.exchange_rate.services import ExchangeRateService
|
|
from core.database import get_core_db
|
|
# from api.v1.common.tenant_crud_routes import get_core_db # This might be needing another import path
|
|
|
|
db = next(get_core_db())
|
|
|
|
today = datetime.now().strftime("%Y-%m-%d")
|
|
tenant_id = 1
|
|
company_id = 1
|
|
|
|
print(f"Checking for exchange rate on {today}...")
|
|
filters = {"date": today}
|
|
rates, total = ExchangeRateService.get_all(db, tenant_id, company_id, filters=filters)
|
|
|
|
if total > 0:
|
|
print(f"Found {total} exchange rate(s) for today. Deleting...")
|
|
for rate in rates:
|
|
ExchangeRateService.delete(db, rate.id, tenant_id, company_id)
|
|
print("Deleted.")
|
|
else:
|
|
print("No exchange rate found for today.")
|
|
|
|
db.close()
|