Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • A ledger can be viewed as a type of case property
  • But unlike the case property the ledgers can be update updated directly in the form-builder with the transactions.
  • The row of the ledger is called an "entry" and corresponds to a product id.
  • The column of a ledger is called a "section":
    • You can create your own section when creating a ledger (stock, balance, price, order amounts ...)
    • You can define as many sections as you want for a ledger.
    • Some section ids, such as consumption (which store the average monthly consumption) are reserved by the application.
  • The number saved for each row and column is called a "quantity":
    • The quantities of a ledger are of integer type. Decimals are not supported.

...

  • Balance: set the ledger quantity to a specific value 
  • Receive: increment the ledger quantity by a specific value 
  • Dispense: decrement the ledger quantity by a specific value 
  • Transfer: decrement the ledger quantity by a specific value on a case A & increment the ledger quantity by a specific value on a case B 
Good to know !!! 
  • Transactions are atomic – so if your phone shuts down mid-transfer, things don’t get lost.
  • Transactions are also resolved meaningfully. In CommCare, if 2 phones increments the same number, whichever phone writes last wins. In CommCare Supply, the increments are summed.

 

 

How to setup a transaction question?

  • Question ID: anything you want
  • Case: id of the case where your ledger will be saved. 
    • This can take different values depending on which case you want to use to save your ledger.
    • In order to save the ledger in the current selected case, use: instance('commcaresession')/session/data/case_id.
    • In order to save the ledger in the user supply-point, use: instance('commcaresession')/session/user/data/commtrack-supply-point.
    • ...
  • Balance ID: id of the section (i.e. stock, balance, ...)
  • Product: id of the product
    • When used in a repeat group over products, the syntax to use is current()/../../../@id. However this will depend if you put the transaction question in question groups or not (see here).
  • Quantity: value to set to the ledger.