Skip to content

CustomUnit

Hugh Jeremy edited this page Mar 27, 2019 · 2 revisions

Documentation > CustomUnit

Custom Units are units of account created by Amatino users. Their scope is limited to the Entity in which they are created. They can be used anywhere a Global Unit would be used, allowing you to denominate Transactions and Accounts as you please.

Custom Unit identifiers need not be unique with reference to Global Units. Therefore, it is possible to create a Custom Unit substitute of a Global Unit. For example, a USD Custom Unit using a preferred source of foreign exchange rates, with higher temporal resolution, or some other desired characteristic.

Properties

.session - Session

The Session used to initialise this CustomUnit


.entity - Entity

The Entity of which this CustomUnit is a member


.id_ - int

The integer identifier of this Custom Unit, unique within an Entity

Example: 420


.code - str

A string short-hand name for this Custom Unit

Example: 'BTC'


.name - str

A human readable long-form name for this Custom Units

Example: Bitcoin


.priority - int

An integer sorting priority useful when displaying this CustomUnit in lists

Example: 0


.description - str

A long-form description of this Custom Unit

Example: BTC @ 0600UTC per CoinBase


.exponent - int

The integer number of base-10 digits required to store this CustomUnit's smallest fractional unit. For example, a U.S. Dollar has an exponent of 2, as its smallest fractional unit is one-hundredth - a cent.

Example: 6

Methods

classmethod .create() -> CustomUnit

Return a newly created CustomUnit

Parameters

  1. entity: Entity
  2. name: str
  3. code: str
  4. exponent: int
  5. description: Optional[str]
  6. priority: Optional[int]

Example

btc = CustomUnit.create(
  entity=mega_corp,
  name='Bitcoin',
  code='BTC',
  exponent=6
)

classmethod .retrieve() -> CustomUnit

Return an existing CustomUnit

Parameters

  1. entity: Entity
  2. custom_unit_id: int

Example

btc = CustomUnit.retrieve(
  entity=mega_corp,
  custom_unit_id=420
)

.update() -> CustomUnit

Return a CustomUnit whose metadata have been updated. NB that the original CustomUnit instance is not updated in place. The returned CustomUnit instance is updated.

All parameters are optional. Those parameters that you don't supply will

Parameters

  1. name: Optional[str]
  2. code: Optional[str]
  3. priority: Optional[int]
  4. description: Optional[str]
  5. exponent: Optional[str]

Example

updated_btc = original_btc.update(
  description='New, fancier description'
)

### `.delete()` -> None

_Not yet implemented_

Clone this wiki locally