ExFattureincloud.Usage (ExFattureincloud v0.1.0)

Copy Markdown View Source

Reads actual company plan limits instead of hardcoding commercial plans.

documents/2 returns the annual document quota, consumption and remaining capacity. This is the plan's document counter, not a dedicated SDI sending counter. plan/3 also supports clients, suppliers and products (global quotas). invoice_capacity/3 combines the document counter with company plan features, license date and invoice permissions. It performs two GETs and never creates or sends an invoice. api/2 retrieves detailed API counters (one additional request); ordinary responses already expose counters in rate_limit for free.

These are point-in-time checks: another user or app can consume the same quota after a check. An unknown/null limit does not mean unlimited. Availability for creating a document does not guarantee SDI acceptance or permission to send an existing document. The provider remains authoritative for every write.

Summary

Functions

Retrieves hourly/monthly API usage, including custom limits and remaining counts. Consumes one request.

Checks document quota for count new documents; returns :unknown when the counter is unavailable.

Reads the annual document quota and computes remaining capacity.

Returns document quota, plan, license and invoice feature/permission checks (two API requests).

Reads a plan quota for :documents, :clients, :suppliers or :products.

Functions

api(client, company_id)

Retrieves hourly/monthly API usage, including custom limits and remaining counts. Consumes one request.

can_create_documents?(client, company_id, count \\ 1)

@spec can_create_documents?(
  ExFattureincloud.Client.t(),
  integer() | String.t(),
  pos_integer()
) ::
  {:ok, boolean() | :unknown} | {:error, ExFattureincloud.Error.t()}

Checks document quota for count new documents; returns :unknown when the counter is unavailable.

documents(client, company_id)

Reads the annual document quota and computes remaining capacity.

invoice_capacity(client, company_id, count \\ 1)

@spec invoice_capacity(
  ExFattureincloud.Client.t(),
  integer() | String.t(),
  pos_integer()
) ::
  {:ok, map()} | {:error, ExFattureincloud.Error.t()}

Returns document quota, plan, license and invoice feature/permission checks (two API requests).

plan(client, company_id, category)

Reads a plan quota for :documents, :clients, :suppliers or :products.