15 double last_program_crps = 0.0;
22 typedef eosio::multi_index<
23 "capwallets"_n, capital_wallet,
24 indexed_by<
"byusername"_n, const_mem_fun<capital_wallet, uint64_t, &capital_wallet::by_username>>
41 double last_membership_reward_per_share = 0.0;
53 typedef eosio::multi_index<
54 "projwallets"_n, project_wallet,
55 indexed_by<
"byproject"_n, const_mem_fun<project_wallet, checksum256, &project_wallet::by_project_hash>>,
56 indexed_by<
"byusername"_n, const_mem_fun<project_wallet, uint64_t, &project_wallet::by_username>>,
57 indexed_by<
"byprojuser"_n, const_mem_fun<project_wallet, uint128_t, &project_wallet::by_project_user>>
83 auto idx = capital_wallets.get_index<
"byusername"_n>();
85 auto itr = idx.find(username.value);
86 if (itr == idx.end()) {
98 eosio::check(wallet_opt.has_value(), msg);
106 eosio::name username,
107 int64_t last_program_crps,
108 eosio::asset capital_available) {
110 auto idx = capital_wallets.get_index<
"byusername"_n>();
112 auto itr = idx.find(username.value);
113 if (itr == idx.end()) {
115 capital_wallets.emplace(coopname, [&](
auto &w) {
117 w.coopname = coopname;
118 w.username = username;
119 w.last_program_crps = last_program_crps;
120 w.capital_available = capital_available;
124 idx.modify(itr, coopname, [&](
auto &w) {
125 if (last_program_crps != 0) w.last_program_crps = last_program_crps;
126 if (capital_available.amount != 0) w.capital_available += capital_available;
134 inline std::optional<project_wallet>
get_project_wallet(eosio::name coopname,
const checksum256 &project_hash, eosio::name username) {
136 auto idx = project_wallets.get_index<
"byprojuser"_n>();
139 auto itr = idx.find(key);
140 if (itr == idx.end()) {
152 eosio::check(wallet_opt.has_value(), msg);
160 const eosio::asset &shares, eosio::name payer =
_capital) {
162 auto idx = project_wallets.get_index<
"byprojuser"_n>();
165 auto itr = idx.find(key);
166 if (itr == idx.end()) {
168 project_wallets.emplace(payer, [&](
auto &w) {
170 w.coopname = coopname;
171 w.project_hash = project_hash;
172 w.username = username;
177 idx.modify(itr, payer, [&](
auto &w) {
static constexpr eosio::name _capital
Definition: consts.hpp:150
static constexpr eosio::symbol _root_govern_symbol
Definition: consts.hpp:210
static constexpr eosio::name _capital_program
Кошелёк программы "Капитализация".
Definition: consts.hpp:83
contract
Definition: eosio.msig_tests.cpp:977
uint64_t get_global_id_in_scope(eosio::name _me, eosio::name scope, eosio::name key)
Definition: counts.hpp:61
void upsert_capital_wallet(eosio::name coopname, eosio::name username, int64_t last_program_crps, eosio::asset capital_available)
Создает или обновляет кошелек капитализации
Definition: wallets.hpp:105
std::optional< progwallet > get_program_capital_wallet(eosio::name coopname, eosio::name username)
Definition: wallets.hpp:62
project_wallet get_project_wallet_or_fail(eosio::name coopname, const checksum256 &project_hash, eosio::name username, const char *msg="Кошелек проекта не найден")
Получает кошелек проекта или падает с ошибкой
Definition: wallets.hpp:150
std::optional< project_wallet > get_project_wallet(eosio::name coopname, const checksum256 &project_hash, eosio::name username)
Получает кошелек проекта по хэшу проекта и имени пользователя
Definition: wallets.hpp:134
capital_wallet get_capital_wallet_or_fail(eosio::name coopname, eosio::name username, const char *msg="Кошелек капитализации не найден")
Получает кошелек капитализации или падает с ошибкой
Definition: wallets.hpp:96
std::optional< capital_wallet > get_capital_wallet_by_username(eosio::name coopname, eosio::name username)
Получает кошелек капитализации по имени пользователя
Definition: wallets.hpp:81
void upsert_project_wallet(eosio::name coopname, const checksum256 &project_hash, eosio::name username, const eosio::asset &shares, eosio::name payer=_capital)
Создает или обновляет кошелек проекта, добавляя доли к существующим
Definition: wallets.hpp:159
Definition: balances.cpp:6
eosio::multi_index< "capwallets"_n, capital_wallet, indexed_by<"byusername"_n, const_mem_fun< capital_wallet, uint64_t, &capital_wallet::by_username > > > capital_wallets_index
Definition: wallets.hpp:25
eosio::multi_index< "projwallets"_n, project_wallet, indexed_by<"byproject"_n, const_mem_fun< project_wallet, checksum256, &project_wallet::by_project_hash > >, indexed_by<"byusername"_n, const_mem_fun< project_wallet, uint64_t, &project_wallet::by_username > >, indexed_by<"byprojuser"_n, const_mem_fun< project_wallet, uint128_t, &project_wallet::by_project_user > > > project_wallets_index
Definition: wallets.hpp:58
Definition: eosio.msig.hpp:34
program get_program_or_fail(eosio::name coopname, uint64_t program_id)
Definition: programs.hpp:57
std::optional< progwallet > get_program_wallet(eosio::name coopname, eosio::name username, name type)
Definition: programs.hpp:156
uint64_t get_program_id(const eosio::name &type)
Definition: programs.hpp:142
Кошелек программы капитализации для учёта CRPS и доступных средств от членских взносов
Definition: wallets.hpp:11
uint64_t primary_key() const
Первичный ключ (1)
Definition: wallets.hpp:18
uint64_t id
ID кошелька (внутренний ключ)
Definition: wallets.hpp:12
eosio::name username
Имя пользователя
Definition: wallets.hpp:14
eosio::name coopname
Имя кооператива
Definition: wallets.hpp:13
uint64_t by_username() const
Индекс по имени пользователя (2)
Definition: wallets.hpp:19
Таблица кошельков проектов хранит данные о долях участников в проектах для получения членских взносов...
Definition: wallets.hpp:35
uint128_t by_project_user() const
Definition: wallets.hpp:48
uint64_t by_username() const
Индекс по имени пользователя (3)
Definition: wallets.hpp:46
uint64_t primary_key() const
Первичный ключ (1)
Definition: wallets.hpp:44
eosio::name coopname
Имя кооператива
Definition: wallets.hpp:37
checksum256 project_hash
Хэш проекта
Definition: wallets.hpp:38
checksum256 by_project_hash() const
Индекс по хэшу проекта (2)
Definition: wallets.hpp:45
eosio::name username
Имя пользователя
Definition: wallets.hpp:39
uint64_t id
ID кошелька проекта (внутренний ключ)
Definition: wallets.hpp:36
Таблица программ кооператива
Definition: programs.hpp:14
static uint128_t combine_checksum_ids(const checksum256 &hash, eosio::name username)
Definition: utils.hpp:9