hypha-dao / accounting-contracts

Double entry accounting contracts for decentralized organizations on the Hypha platform
MIT License
0 stars 0 forks source link

Add action for Create Account #2

Closed mgravitt closed 3 years ago

mgravitt commented 3 years ago

Create an action for add account. This action will add a new account to the graph. It will look similar to the propose action with dao.hypha.

 ACTION create(const name &creator, ContentGroups &content_groups);

The inputs for creating an account are:

Thus, the current balance for an Account (snapshot) is an array indexed by currencyID of the current subtotal (signed amounts per currency).

We likely need to experiment with how opening balances are passed in. It might make sense to use multiple actions rather than trying to bundle it into the account's setup ContentGroups.

The ContentGroups would look something like this:

{
    "content_groups": [
        [
            {
                "label": "content_group_label",
                "value": [
                    "string",
                    "details"
                ]
            },
            {
                "label": "account_name",
                "value": [
                    "string",
                    "Marketing Expenses"
                ]
            },
            {
                "label": "account_type",
                "value": [
                    "int64",
                    1
                ]
            },
            {
                "label": "parent_account",
                "value": [
                    "checksum256",
                    "986daab955823512fe543cb788735430b6a5e5ff9baf211c0dee893d7261f140"
                ]
            }
       ],[
            {
               "label": "content_group_label",
               "value": [
                   "string",
                   "opening_balances"
                  ]
            },
            {
                "label": "opening_balance_usd",
                "value": [
                    "asset",
                    "1.00 USD"
                ]
            },
            {
                 "label": "opening_balance_btc",
                 "value": [
                     "asset",
                     "0.50000000 BTC"
                  ]
            }
       ]
    ]
}

The alternative to including the opening balances in the create action would be to add an action such as:

ACTION addopenbal (const checksum256& account, const asset& opening_balance);

In this case, the blockchain transaction to create the account would have one action to create and then multiple actions for addopenbal, one for each currency. NOTE: all actions within a transaction either pass or fail together, so it's safe.