Conditions within Conditions (Fractals)

All structures can have internal subdivisions, allowing for nested levels of operations. For example, we can distribute and divide the remaining value into additional levels as needed.

Example

A transaction of R$150 will be made, with R$100 taken from João's account, R$10 taken from Leo's account, and the rest taken from John's savings account. Out of the R$150, Maria will receive R$20. From the remaining amount (R$130), Jose will receive 20% (R$26), and Pedro will receive 10% (R$13). From the amount left (R$91), Beatriz will receive R$5, Charlie will receive 90% (R$78.26), and the remaining amount will be given to charity.

Code example
(transaction v1
  (chart-of-accounts-group-name PIX_OUT)
  (metadata
      (anyKey anyValue)
      (anotherKey anotherValue)
  )
  (code PIX_OUT)
  (description "description for the transaction not for the operation")
  (pending true)
  (send BRL 150|0 
    (source
      (from @joao :amount BRL 100|0
        (chart-of-accounts pix_out_debit_82891231)
      )
      (source
        (from @leo :amount BRL 10|0
          (chart-of-accounts 00929312)
        )
        (source
          (from @poupança_joao :remaining
            (chart-of-accounts 5215235)
            (description "Completing the amount")
          )
        )
      )  
    )
 )
  (distribute
    (to @maria :amount BRL 20|0
      (chart-of-accounts 781238123)
    )
    (distribute
      (to @jose :share 20 :of 100
        (chart-of-accounts 9828732)
      )
      (to @pedro :share 100 :of 100
        (chart-of-accounts 24131231)
      )
      (distribute
        (to @beatriz :amount BRL 5|0
          (chart-of-accounts 231231)
        )
        (to @charlie :share 90 :of 100
          (chart-of-accounts 1231231)
        )
        (to @caridade :remaining
          (chart-of-accounts caridade)
          (description "Donation from @joao")
        )
      )
    )   
  )
)

Last updated