Skip to content

[CA-13] Update generate_charges.py to save charges in Supabase #22

Description

@luigischmitt

Goal

Modify the charge generation job to save each created charge in Supabase, enabling complete txid tracking per member.

Context

Currently generate_charges.py creates the charge in Efí and sends an email, but doesn't store the txid anywhere. This makes it difficult to:

  • Know which txid belongs to which member
  • Reconcile payments correctly
  • Audit old charges

Required Changes

src/jobs/generate_charges.py

# After creating charge in Efí
charge = efi_service.create_pix_charge(...)

# Save to Supabase
supabase_service.create_charge(
    member_name=member.name,
    txid=charge.txid,
    amount=CHARGE_AMOUNT,
    month=month_column,
    year=date.today().year,
)

Tasks

  • Import SupabaseService in generate_charges.py
  • Add call to save charge after creation
  • Ensure Supabase errors don't block the main flow (try/except with logging)

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions