Proposal: use Energy Transactions as the unified energy ledger

Context

  • CustomerAccount tracks balances in currency and kW, and currently derives kW balance from EnergyCredit records plus consumed kW from charger transactions. Credits are tallied through CustomerAccount.credits_kw, while consumption is measured via CustomerAccount.total_kw_spent from transactions with meter deltas. [source: apps/energy/models.py]
  • EnergyCredit is a lightweight kW top-up entry tied to an account and optional creator. It stores only the credited kW amount. [source: apps/energy/models.py]
  • EnergyTransaction models kW purchases tied to a tariff, currency amount, and conversion factor, but it is not currently used for decrements. [source: apps/energy/models.py]

This setup splits credit additions (EnergyCredit) from purchase metadata (EnergyTransaction), making it harder to audit balance changes in one place.

Loading remaining sections…