As with the source, there are two types of destinations: single or multiple.
Single destination
The most basic format. The amount is deducted from the available balance (available.balance) of a single source and transferred to a single destination (distribute).
Multi-destination
With multiple destinations, you will have the amount credited to different destinations. For example, 38% of the total amount will be sent to Account A, 50% to Account B, and the rest will be sent to Account C.
If the total percentage in distribute exceeds 100%, an error will be returned. If any remaining percentage is not used, a message will be returned indicating such.
Code examples
(transaction v1
(chart-of-accounts-group-name PAG_CONTAS_CODE_123182371973821973981)
(metadata
(anyKey anyValue)
(anotherKey anotherValue)
)
(description "description for the transaction not for the operation")
(send BRL 30|4
(source
(from@external/BRL
(description "description shown on the statement")
)
)
)
(distribute
(to 540b504c-8f9d-480f-9354-3728cf7025ef :share 100
(metadata
(label myText)
(operationKey operationValue)
)
)
)
)
(transaction v1
(chart-of-accounts-group-name PAG_CONTAS_CODE_123182371973821973981)
(metadata
(anyKey anyValue)
(anotherKey anotherValue)
)
(description "description for the transaction not for the operation")
(send BRL 30|4
(source
(from 3172933b-50d2-4b17-96aa-9b378d6a6eac :share 100
(metadata
(label myText)
(operationKey operationValue)
)
)
)
)
(distribute
(to 540b504c-8f9d-480f-9354-3728cf7025ef :share 38
(description "debit from PIX")
)
(to 1a9ba2dd-d778-415f-a61a-387d64994eeb :share 50)
(to 54748fc9-53f1-4d5b-bdc3-660c64f1e974 :amount BRL 2|4)
(to 9fe618ed-cec1-4a5b-90d8-2f5819a8c3dd :remaining)
)
)
Multi-source and multi-destination
An example of a multi-source, multi-destination transaction would be a fundraiser aimed at distributing money to several families affected by a flood. In the example below, a transaction of BRL 0.0030 is sent, with the amount coming from various sources and going to different destinations, according to specific weights (previously explained).
We are not working with percentage points. Therefore, in the example above, :share 5 of 25 translates to 5% of 25%, which is 0.05 * 0.25 = 0.0125, or 1.25%.