← Platform API v1.32.0

POST /tenants/{tenantId}/sales/invoices/{id}/recognize-revenue

tenantSalesPostInvoicesByIdRecognizeRevenue · Sales

Human Supabase USER only; permissions sales.read, accounting.post. Commercial documents, not fiscal ones: no tax, fiscal numbering, electronic issuance, rounding or currency conversion. An invoice is DRAFT (editable), ISSUED (frozen) or VOID (only when nothing was applied). Its total is the exact sum of its lines and must fit 6 decimals. Balances are never stored: an invoice balance is its total minus applications; a payment has an unapplied remainder; a credit is REQUESTED until a real document recognises it, and only a RECOGNIZED credit has an available balance, reduced by applications and refunds. Applications are immutable and join documents of the same party, legal entity, currency and side; they never exceed either balance. A payment states its method (cash, transfer, card, cheque, other), for a card whether debit or credit, and may name the money account it lands in or leaves from; a PENDING payment is money announced and not confirmed: it carries no applications and settles nothing until it is confirmed. Card numbers and security codes are never accepted. A sales order collected at the register is settled only by that receipt, recorded once as one payment per payment component, so the collection is never counted twice and linking never brings money in again; the POS records are not changed. Credits and physical returns are independent: neither creates the other, and naming a variant or unit moves no inventory. Saving or issuing an invoice moves none either: the devices typed on a bill and the units chosen on a sales invoice are only what its lines carry, until the invoice is confirmed together with its receipt or its delivery (see those operations). A draft may be incomplete. An invoice is posted (issued, confirmed or recognised) only with every unit of every line of a serialized article identified and linked to it, exactly as many as the line bills, and it is never completed afterwards. How an article is tracked is read from its product, whatever the request says; a line that names a physical unit without its SKU is a line of a serialized article too (409 FULFILMENT_INCOMPLETE). Issuing alone therefore works for a bill whose purchase order already received the units its lines name, and for a sales invoice whose order reserved or delivered them, the sales of the register included: the invoice keeps those units from the instant it is issued, and nothing enters or leaves again. An invoice with no order behind it that bills a serialized article is not issued alone, whatever it carries and with or without a price list (409 FULFILMENT_REQUIRED): it is confirmed together with its receipt or its delivery. A line short of units is refused with 409 UNIT_COUNT_MISMATCH. Each place in `errors` says how many units the line bills (`required`) and how many are identified (`identified`): counts, never an identifier. Recognising revenue or expense by decision is refused the same way for an invoice that bills a serialized article. Quantity articles and services need no units and behave as before. A credit is financial unless a supplier credit states COST_CORRECTION and names the receipt lines it corrects: only then does recognising it change what those goods are worth, where they still are, and never by more than they cost. A stated money account is validated against the active accounts of the entity that fit the method (PAYMENT_ACCOUNT_INVALID). Cash refunded to a customer from the cash account of the tills names the open session it leaves (CASH_SESSION_REQUIRED): the refund lowers the expected cash of that session and posts one entry; cash from anywhere else names another cash account and touches no session. When the legal entity keeps books, issuing, paying, applying, recognising and refunding each post their entry in the same transaction or fail with ACCOUNTING_SETUP_REQUIRED, ACCOUNTING_PERIOD_CLOSED, ACCOUNTING_CURRENCY_UNSUPPORTED or ACCOUNTING_AMOUNT_PRECISION; voiding posts the mirror entry. An invoice never recognises revenue by itself: revenue is earned on delivery of its order, or by an explicit recognition when it has no order. Writes are idempotent and tenant scoped; state changes carry expectedVersion.

Autenticación
SupabaseBearer · http bearer

Ejemplo

Los valores entre <> y {} son marcadores: sustitúyelos por los tuyos antes de ejecutarlo.

curl --request POST \
  --url 'https://api.marky.ec/v1/tenants/{tenantId}/sales/invoices/{id}/recognize-revenue' \
  --header 'Authorization: Bearer <SupabaseBearer>' \
  --header 'Idempotency-Key: <Idempotency-Key>' \
  --header 'Content-Type: application/json' \
  --data @body.json

Parámetros

Nombre En Tipo Descripción
tenantIdobligatorio path stringformato uuidpatrón ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-7[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$
idobligatorio path stringformato uuidpatrón ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-7[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$
Idempotency-Keyobligatorio header stringformato uuid UUIDv4/v7. Fresh user/membership/permissions before replay.

Cuerpo (obligatorio)

application/json
OperationVersionInput
objectsin otras propiedades
  • expectedVersionobligatorio
    integermín. 1

Respuestas

200 Success
application/json
InvoiceRecognition
objectsin otras propiedades
  • idobligatorio
    stringformato uuidpatrón ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-7[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$
  • statusobligatorio
    uno de "ISSUED"
  • versionobligatorio
    integermín. 1
  • createdAtobligatorio
    stringformato date-time
  • updatedAtobligatorio
    stringformato date-time
  • entryIdobligatorio
    stringformato uuidpatrón ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-7[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$
400 Invalid request/idempotency key
application/problem+json
ProblemDetails
objectsin otras propiedades
  • typeobligatorio
    valor fijo "about:blank"
  • statusobligatorio
    integer
  • codeobligatorio
    string
  • titleobligatorio
    string
  • detailobligatorio
    string
  • requestIdobligatorio
    stringformato uuid
  • errors
    arrayelementos máx. 200

    Where each problem is, for the codes that can say it: a JSON pointer into the request or the record (`/items/0/devices/1/imei1`) and the reason. A line of a serialized article that is short of units also says how many it bills and how many are identified. Never a value typed by the user, and never an identifier of a unit.

    Cada elemento
    objectsin otras propiedades
    • pointerobligatorio
      string
    • codeobligatorio
      string
    • required
      integermín. 0máx. 1000

      For a line short of units (UNITS_DIFFER_FROM_QUANTITY, RECEIPT_REQUIRED, DELIVERY_REQUIRED): how many units the line bills.

    • identified
      integermín. 0máx. 1000

      For the same line: how many units are identified and linked to it. Given to every reader of the document; no IMEI or serial number is.

401 Missing/invalid Supabase JWT
application/problem+json
ProblemDetails
objectsin otras propiedades
  • typeobligatorio
    valor fijo "about:blank"
  • statusobligatorio
    integer
  • codeobligatorio
    string
  • titleobligatorio
    string
  • detailobligatorio
    string
  • requestIdobligatorio
    stringformato uuid
  • errors
    arrayelementos máx. 200

    Where each problem is, for the codes that can say it: a JSON pointer into the request or the record (`/items/0/devices/1/imei1`) and the reason. A line of a serialized article that is short of units also says how many it bills and how many are identified. Never a value typed by the user, and never an identifier of a unit.

    Cada elemento
    objectsin otras propiedades
    • pointerobligatorio
      string
    • codeobligatorio
      string
    • required
      integermín. 0máx. 1000

      For a line short of units (UNITS_DIFFER_FROM_QUANTITY, RECEIPT_REQUIRED, DELIVERY_REQUIRED): how many units the line bills.

    • identified
      integermín. 0máx. 1000

      For the same line: how many units are identified and linked to it. Given to every reader of the document; no IMEI or serial number is.

403 Wrong identity family or permissions
application/problem+json
ProblemDetails
objectsin otras propiedades
  • typeobligatorio
    valor fijo "about:blank"
  • statusobligatorio
    integer
  • codeobligatorio
    string
  • titleobligatorio
    string
  • detailobligatorio
    string
  • requestIdobligatorio
    stringformato uuid
  • errors
    arrayelementos máx. 200

    Where each problem is, for the codes that can say it: a JSON pointer into the request or the record (`/items/0/devices/1/imei1`) and the reason. A line of a serialized article that is short of units also says how many it bills and how many are identified. Never a value typed by the user, and never an identifier of a unit.

    Cada elemento
    objectsin otras propiedades
    • pointerobligatorio
      string
    • codeobligatorio
      string
    • required
      integermín. 0máx. 1000

      For a line short of units (UNITS_DIFFER_FROM_QUANTITY, RECEIPT_REQUIRED, DELIVERY_REQUIRED): how many units the line bills.

    • identified
      integermín. 0máx. 1000

      For the same line: how many units are identified and linked to it. Given to every reader of the document; no IMEI or serial number is.

404 Unknown tenant resource
application/problem+json
ProblemDetails
objectsin otras propiedades
  • typeobligatorio
    valor fijo "about:blank"
  • statusobligatorio
    integer
  • codeobligatorio
    string
  • titleobligatorio
    string
  • detailobligatorio
    string
  • requestIdobligatorio
    stringformato uuid
  • errors
    arrayelementos máx. 200

    Where each problem is, for the codes that can say it: a JSON pointer into the request or the record (`/items/0/devices/1/imei1`) and the reason. A line of a serialized article that is short of units also says how many it bills and how many are identified. Never a value typed by the user, and never an identifier of a unit.

    Cada elemento
    objectsin otras propiedades
    • pointerobligatorio
      string
    • codeobligatorio
      string
    • required
      integermín. 0máx. 1000

      For a line short of units (UNITS_DIFFER_FROM_QUANTITY, RECEIPT_REQUIRED, DELIVERY_REQUIRED): how many units the line bills.

    • identified
      integermín. 0máx. 1000

      For the same line: how many units are identified and linked to it. Given to every reader of the document; no IMEI or serial number is.

409 Version, state, insufficient balance, mismatched party/entity/currency, duplicate number, register receipt rule, or a specific block: PAYMENT_ACCOUNT_INVALID, CASH_SESSION_REQUIRED, CASH_INSUFFICIENT, COST_SOURCE_NOT_VALUED, COST_ADJUSTMENT_EXCEEDS_COST
application/problem+json
ProblemDetails
objectsin otras propiedades
  • typeobligatorio
    valor fijo "about:blank"
  • statusobligatorio
    integer
  • codeobligatorio
    string
  • titleobligatorio
    string
  • detailobligatorio
    string
  • requestIdobligatorio
    stringformato uuid
  • errors
    arrayelementos máx. 200

    Where each problem is, for the codes that can say it: a JSON pointer into the request or the record (`/items/0/devices/1/imei1`) and the reason. A line of a serialized article that is short of units also says how many it bills and how many are identified. Never a value typed by the user, and never an identifier of a unit.

    Cada elemento
    objectsin otras propiedades
    • pointerobligatorio
      string
    • codeobligatorio
      string
    • required
      integermín. 0máx. 1000

      For a line short of units (UNITS_DIFFER_FROM_QUANTITY, RECEIPT_REQUIRED, DELIVERY_REQUIRED): how many units the line bills.

    • identified
      integermín. 0máx. 1000

      For the same line: how many units are identified and linked to it. Given to every reader of the document; no IMEI or serial number is.

429 Rate/quota exceeded
application/problem+json
ProblemDetails
objectsin otras propiedades
  • typeobligatorio
    valor fijo "about:blank"
  • statusobligatorio
    integer
  • codeobligatorio
    string
  • titleobligatorio
    string
  • detailobligatorio
    string
  • requestIdobligatorio
    stringformato uuid
  • errors
    arrayelementos máx. 200

    Where each problem is, for the codes that can say it: a JSON pointer into the request or the record (`/items/0/devices/1/imei1`) and the reason. A line of a serialized article that is short of units also says how many it bills and how many are identified. Never a value typed by the user, and never an identifier of a unit.

    Cada elemento
    objectsin otras propiedades
    • pointerobligatorio
      string
    • codeobligatorio
      string
    • required
      integermín. 0máx. 1000

      For a line short of units (UNITS_DIFFER_FROM_QUANTITY, RECEIPT_REQUIRED, DELIVERY_REQUIRED): how many units the line bills.

    • identified
      integermín. 0máx. 1000

      For the same line: how many units are identified and linked to it. Given to every reader of the document; no IMEI or serial number is.

503 Runtime/auth/governance unavailable
application/problem+json
ProblemDetails
objectsin otras propiedades
  • typeobligatorio
    valor fijo "about:blank"
  • statusobligatorio
    integer
  • codeobligatorio
    string
  • titleobligatorio
    string
  • detailobligatorio
    string
  • requestIdobligatorio
    stringformato uuid
  • errors
    arrayelementos máx. 200

    Where each problem is, for the codes that can say it: a JSON pointer into the request or the record (`/items/0/devices/1/imei1`) and the reason. A line of a serialized article that is short of units also says how many it bills and how many are identified. Never a value typed by the user, and never an identifier of a unit.

    Cada elemento
    objectsin otras propiedades
    • pointerobligatorio
      string
    • codeobligatorio
      string
    • required
      integermín. 0máx. 1000

      For a line short of units (UNITS_DIFFER_FROM_QUANTITY, RECEIPT_REQUIRED, DELIVERY_REQUIRED): how many units the line bills.

    • identified
      integermín. 0máx. 1000

      For the same line: how many units are identified and linked to it. Given to every reader of the document; no IMEI or serial number is.