Skip to content

/admin/invoices/:id/accounting_equations

Path: /admin/invoices/:id/accounting_equations

Namespace: admin

Parent Resource: invoices

Overview

Accounting equations represent double-entry accounting transactions associated with an invoice. Each equation ensures debits equal credits and links to accounting accounts.

Available Operations

List Accounting Equations (GET)

Endpoint: GET /admin/invoices/:id/accounting_equations.json

Description: Retrieve all accounting equations for a specific invoice.

Request Example:

bash
GET /admin/invoices/123/accounting_equations.json

Response (200 OK):

json
{
  "accounting_equations": [
    {
      "id": 1,
      "invoice_id": 123,
      "debit_account_id": 1000,
      "credit_account_id": 4000,
      "amount_cents": 100000,
      "description": "Invoice accounting entry"
    }
  ]
}

Show Accounting Equation (GET /:id)

Endpoint: GET /admin/invoices/:id/accounting_equations/:id.json

Description: Retrieve a specific accounting equation.

Request Example:

bash
GET /admin/invoices/123/accounting_equations/1.json

Response (200 OK):

json
{
  "accounting_equation": {
    "id": 1,
    "invoice_id": 123,
    "debit_account_id": 1000,
    "credit_account_id": 4000,
    "amount_cents": 100000
  }
}

Create Accounting Equation (POST)

Endpoint: POST /admin/invoices/:id/accounting_equations.json

Description: Create a new accounting equation for an invoice.

Request Example:

bash
POST /admin/invoices/123/accounting_equations.json
Content-Type: application/json

{
  "accounting_equation": {
    "debit_account_id": 1000,
    "credit_account_id": 4000,
    "amount_cents": 100000,
    "description": "Invoice accounting entry"
  }
}

Response (201 Created):

json
{
  "accounting_equation": {
    "id": 1,
    "invoice_id": 123,
    "debit_account_id": 1000,
    "credit_account_id": 4000,
    "amount_cents": 100000
  }
}

Update Accounting Equation (PATCH /:id)

Endpoint: PATCH /admin/invoices/:id/accounting_equations/:id.json

Description: Update an existing accounting equation.

Request Example:

bash
PATCH /admin/invoices/123/accounting_equations/1.json
Content-Type: application/json

{
  "accounting_equation": {
    "amount_cents": 120000
  }
}

Response (200 OK):

json
{
  "accounting_equation": {
    "id": 1,
    "amount_cents": 120000
  }
}

Delete Accounting Equation (DELETE /:id)

Endpoint: DELETE /admin/invoices/:id/accounting_equations/:id.json

Description: Delete an accounting equation.

Request Example:

bash
DELETE /admin/invoices/123/accounting_equations/1.json

Response (204 No Content)

Batch Actions (POST /batch_action)

Endpoint: POST /admin/invoices/:id/accounting_equations/batch_action.json

Description: Perform batch operations on selected accounting equations.

Request Example:

bash
POST /admin/invoices/123/accounting_equations/batch_action.json
Content-Type: application/json

{
  "batch_action": "update",
  "collection_selection": [1, 2, 3],
  "batch_action_inputs": {
    "description": "Updated description"
  }
}

Response (200 OK):

json
{
  "message": "Batch action completed",
  "affected_count": 3
}

Released under an open source license.