Xero.Assets (Xero v1.0.0)

Copy Markdown View Source

Xero Assets API – Fixed asset lifecycle management. Base URL: https://api.xero.com/assets.xro/1.0/ Scopes: assets or assets.read

Status Flow

DRAFT  REGISTERED  DISPOSED
DRAFT  DISPOSED (direct)

Depreciation Methods

  • StraightLine — equal annual charge
  • DiminishingValue100 / DiminishingValue150 / DiminishingValue200
  • FullDepreciation — 100% in year of purchase
  • NoDepreciation

Averaging Methods

  • ActualDays — based on the number of days in the period
  • FullMonth — depreciation for the full month

Examples

{:ok, %{"items" => assets}} = Xero.Assets.list(token, tenant_id, status: "REGISTERED")

{:ok, asset} = Xero.Assets.create(token, tenant_id, %{
  "assetName"    => "Office Laptop",
  "assetNumber"  => "LAPTOP-001",
  "purchaseDate" => "2024-01-15",
  "purchasePrice" => 1200.00,
  "assetStatus"  => "DRAFT",
  "bookDepreciationSetting" => %{
    "depreciationMethod"    => "StraightLine",
    "averagingMethod"       => "ActualDays",
    "depreciationRate"      => 0.25,
    "depreciationCalculationMethod" => "None"
  }
})

# Move from DRAFT → REGISTERED
{:ok, _} = Xero.Assets.update(token, tenant_id, asset_id, %{"assetStatus" => "REGISTERED"})

# Dispose of a registered asset
{:ok, _} = Xero.Assets.dispose(token, tenant_id, asset_id, %{
  "disposalDate"   => "2024-06-30",
  "disposalPrice"  => 200.00,
  "disposalType"   => "SOLD"
})

Summary

Functions

Returns all asset types defined in the organisation.

Creates a new fixed asset. Assets start in DRAFT status.

Creates a new asset type.

Deletes a DRAFT asset. Only DRAFT assets can be deleted. REGISTERED assets must be disposed of instead.

Returns depreciation schedules for all registered assets.

Disposes of a REGISTERED asset.

Retrieves a single asset by ID.

Lists fixed assets.

Runs depreciation for all assets up to a specific date.

Returns asset settings (default depreciation accounts) for the organisation.

Updates a DRAFT asset. Only DRAFT assets can be updated. To register an asset, update with assetStatus: "REGISTERED".

Updates an existing asset type.

Functions

asset_types(t, tid)

@spec asset_types(Xero.Auth.Token.t(), String.t()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Returns all asset types defined in the organisation.

create(t, tid, attrs)

@spec create(Xero.Auth.Token.t(), String.t(), map()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Creates a new fixed asset. Assets start in DRAFT status.

Required fields

  • "assetName" — Display name
  • "assetStatus""DRAFT" or "REGISTERED"
  • "bookDepreciationSetting" — Depreciation config map

create_asset_type(t, tid, attrs)

@spec create_asset_type(Xero.Auth.Token.t(), String.t(), map()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Creates a new asset type.

Required fields

  • "assetTypeName" — Display name for the type
  • "fixedAssetAccountId" — GL account for the asset value
  • "depreciationExpenseAccountId" — GL account for depreciation expense
  • "accumulatedDepreciationAccountId" — GL account for accumulated depreciation
  • "bookDepreciationSetting" — Default depreciation settings for this type

delete(t, tid, id)

@spec delete(Xero.Auth.Token.t(), String.t(), String.t()) ::
  :ok | {:error, Xero.Error.t()}

Deletes a DRAFT asset. Only DRAFT assets can be deleted. REGISTERED assets must be disposed of instead.

depreciation_schedules(t, tid, opts \\ [])

@spec depreciation_schedules(Xero.Auth.Token.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Returns depreciation schedules for all registered assets.

Options

  • :book_effective_date_of_depreciation — Date to calculate from (YYYY-MM-DD)

dispose(t, tid, id, disposal_attrs)

@spec dispose(Xero.Auth.Token.t(), String.t(), String.t(), map()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Disposes of a REGISTERED asset.

Required disposal fields

  • "disposalDate" — Date of disposal (YYYY-MM-DD)
  • "disposalType""SOLD", "SCRAPPED", or "WRITTEN_OFF"

Optional fields

  • "disposalPrice" — Proceeds from sale (default 0)
  • "disposalAccount" — Account code for disposal proceeds

get(t, tid, id)

@spec get(Xero.Auth.Token.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Retrieves a single asset by ID.

list(t, tid, opts \\ [])

@spec list(Xero.Auth.Token.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Lists fixed assets.

Options

  • :status"DRAFT", "REGISTERED", or "DISPOSED"
  • :page — Page number (default 1)
  • :page_size — Items per page (max 100, default 10)
  • :order_by — Field to order by: "AssetName", "AssetNumber", "AssetStatus", "DepreciableAmount", "TotalDepreciationAmount", "BookValue"
  • :sort_direction"ASC" or "DESC"
  • :filter_by — Free-text search across name, number, serial number

run_depreciation(t, tid, attrs)

@spec run_depreciation(Xero.Auth.Token.t(), String.t(), map()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Runs depreciation for all assets up to a specific date.

Required fields

  • "depreciationDate" — Run depreciation up to this date (YYYY-MM-DD)

settings(t, tid)

@spec settings(Xero.Auth.Token.t(), String.t()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Returns asset settings (default depreciation accounts) for the organisation.

update(t, tid, id, attrs)

@spec update(Xero.Auth.Token.t(), String.t(), String.t(), map()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Updates a DRAFT asset. Only DRAFT assets can be updated. To register an asset, update with assetStatus: "REGISTERED".

update_asset_type(t, tid, id, attrs)

@spec update_asset_type(Xero.Auth.Token.t(), String.t(), String.t(), map()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Updates an existing asset type.