Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/soker90/finper/llms.txt

Use this file to discover all available pages before exploring further.

The Supplies module lets you model the utility contracts attached to one or more properties. You can record periodic meter readings or invoices, track consumption costs over time, and — for electricity contracts — project your historical readings against alternative tariff structures to estimate potential savings.

Data model hierarchy

Property
└── Supply (1 : N)
     └── SupplyReading (1 : N)
EntityPurpose
PropertyA home or premises. Parent container for all supplies.
SupplyA single utility contract (electricity, water, gas, other) attached to a property. Holds tariff and contracted-power settings for electricity.
SupplyReadingA meter reading or invoice for a supply, covering a period between startDate and endDate. Stores total cost and consumption figures.

Supply types

ValueDescription
electricityElectricity contract. Supports full tariff and power configuration.
waterWater supply.
gasGas supply.
otherAny other utility (requires a name field).

Properties

Properties have no dedicated GET endpoint. They are returned as part of the GET /api/supplies response, which groups supplies by their parent property.
MethodRouteDescription
POST/api/supplies/propertiesCreate a new property
PUT/api/supplies/properties/:idUpdate a property
DELETE/api/supplies/properties/:idDelete a property
Property fields:
FieldTypeRequiredDescription
namestringName or address label for the property

Supplies

MethodRouteDescription
GET/api/suppliesList all supplies, grouped by property
POST/api/suppliesCreate a new supply contract
PUT/api/supplies/:idUpdate a supply contract
DELETE/api/supplies/:idDelete a supply contract
GET/api/supplies/:id/tariffs-comparisonCompare current tariff against alternatives (electricity only)
Supply fields:
FieldTypeRequiredDescription
propertyIdstringID of the parent property
typeelectricity | water | gas | otherUtility type
namestringWhen type is otherDisplay name — required when type is other, optional for all other types
contractedPowerPeaknumberContracted peak power (kW) — electricity only
contractedPowerOffPeaknumberContracted off-peak power (kW) — electricity only
currentPricePowerPeaknumberPower term price, peak period — electricity only
currentPricePowerOffPeaknumberPower term price, off-peak period — electricity only
currentPriceEnergyPeaknumberEnergy price, peak period (€/kWh) — electricity only
currentPriceEnergyFlatnumberEnergy price, flat period (€/kWh) — electricity only
currentPriceEnergyOffPeaknumberEnergy price, off-peak period (€/kWh) — electricity only

Supply Readings

MethodRouteDescription
GET/api/supplies/readings/supply/:supplyIdList all readings for a supply
POST/api/supplies/readingsCreate a new reading
PUT/api/supplies/readings/:idUpdate a reading
DELETE/api/supplies/readings/:idDelete a reading
Supply reading fields:
FieldTypeRequiredDescription
supplyIdstringID of the parent supply
startDatenumberUnix timestamp (ms) — beginning of the billing period
endDatenumberUnix timestamp (ms) — end of the billing period (must be after startDate)
amountnumberTotal cost for the period
consumptionnumberTotal consumption for the period (kWh, m³, etc.)
consumptionPeaknumberPeak-period consumption — electricity only
consumptionFlatnumberFlat-period consumption — electricity only
consumptionOffPeaknumberOff-peak-period consumption — electricity only
consumption, consumptionPeak, consumptionFlat, and consumptionOffPeak are all optional. For electricity readings you can supply the three time-of-use breakdown fields instead of (or in addition to) the aggregate consumption field.

Tariff comparison

GET /api/supplies/:id/tariffs-comparison is available for electricity supplies only. Before calling this endpoint, ensure the supply has all of the following configured:
  1. contractedPowerPeak and contractedPowerOffPeak — the contracted power settings.
  2. All five currentPrice* fields — currentPricePowerPeak, currentPricePowerOffPeak, currentPriceEnergyPeak, currentPriceEnergyFlat, and currentPriceEnergyOffPeak.
The endpoint returns a 400 error if the supply is not of type electricity, or if any of the required power or price configuration fields are missing. The endpoint fetches a list of alternative market tariffs and projects each one against the supply’s existing readings to calculate what you would have paid. The result lets you compare your actual spend against competing offers without manually recalculating. Tariff definitions are fetched from an external cache (https://soker90.github.io/tarifas-luz/tarifas.json) and cached for 12 hours.

Route ordering

In server.ts, the /api/supplies/properties and /api/supplies/readings routers are mounted before /api/supplies. This ensures that paths like /api/supplies/properties and /api/supplies/readings/supply/:supplyId are matched by their dedicated routers and do not fall through to the generic /:id handler.

Example: Create a property, supply, and reading in sequence

Step 1 — Create the property:
curl -X POST http://localhost:3008/api/supplies/properties \
  -H 'token: <your-jwt>' \
  -H 'Content-Type: application/json' \
  -d '{ "name": "Main Apartment" }'
Note the id returned (e.g. "prop_abc"). Step 2 — Create an electricity supply for that property:
curl -X POST http://localhost:3008/api/supplies \
  -H 'token: <your-jwt>' \
  -H 'Content-Type: application/json' \
  -d '{
    "propertyId": "prop_abc",
    "type": "electricity",
    "contractedPowerPeak": 5.75,
    "contractedPowerOffPeak": 5.75,
    "currentPricePowerPeak": 0.104,
    "currentPricePowerOffPeak": 0.057,
    "currentPriceEnergyPeak": 0.18,
    "currentPriceEnergyFlat": 0.14,
    "currentPriceEnergyOffPeak": 0.09
  }'
Note the id returned (e.g. "sup_xyz"). Step 3 — Record a meter reading / invoice:
curl -X POST http://localhost:3008/api/supplies/readings \
  -H 'token: <your-jwt>' \
  -H 'Content-Type: application/json' \
  -d '{
    "supplyId": "sup_xyz",
    "startDate": 1714521600000,
    "endDate": 1717200000000,
    "amount": 87.45,
    "consumption": 415,
    "consumptionPeak": 120,
    "consumptionFlat": 85,
    "consumptionOffPeak": 210
  }'

Build docs developers (and LLMs) love