Source

The transaction can have two types of sources: single or multiple.

The sum of the source values (source) must always be equal to the value informed immediately after sending the transaction (send) and equal to the sum of the distributed values (distribute).

Single source

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-source

With multiple sources, you will have the amount deducted from different sources. For example, if Account A does not have enough balance to cover the transaction, the remaining amount will be deducted from Account B.

  • If both accounts together do not have the available balance, we will return an insufficient balance error.

  • To send percentage transactions, the user can enter the value in percentage or a fraction and can use both together.

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
		(oneMoreMatadata hello)
      )
    )
  )
)

Percentage transactions

To send percentage transactions, users can enter the value as a percentage or a fraction or use both together, as shown below.

In this example, 25% would be debited from account 3172933b-50d2-4b17-96aa-9b378d6a6eac, 12% from account 8a1b173c-35fc-41f4-ac94-6b202e0bcd7f, BRL 0.0003 from account dd76761b-68e1-49f7-adcc-6788dd1a3656, and the remainder to top up BRL 0.0030 from account 01de90bf-5d09-461e-8a24-8e5cdb94968e.

The total amount will be sent to account 540b504c-8f9d-480f-9354-3728cf7025ef.

Code example

(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 25)
      (from 8a1b173c-35fc-41f4-ac94-6b202e0bcd7f :share 12)
      (from dd76761b-68e1-49f7-adcc-6788dd1a3656 :amount BRL 4|3)
      (from 01de90bf-5d09-461e-8a24-8e5cdb94968e :remaining)
  )
 )
  (distribute
    (to 540b504c-8f9d-480f-9354-3728cf7025ef :share 100
      (metadata
			(label myText)
			(operationKey operationValue)
      )
    )
  )
)

Last updated