24 bool is_external_contract =
false;
41 checksum256
by_hash()
const {
return contributor_hash; }
48 uint64_t
by_rating()
const {
return contributed_as_investor.amount + contributed_as_creator.amount + contributed_as_author.amount + contributed_as_coordinator.amount + contributed_as_contributor.amount + contributed_as_propertor.amount; }
51typedef eosio::multi_index<
53 indexed_by<
"byusername"_n, const_mem_fun<contributor, uint64_t, &contributor::by_username>>,
54 indexed_by<
"byhash"_n, const_mem_fun<contributor, checksum256, &contributor::by_hash>>,
55 indexed_by<
"byinvrate"_n, const_mem_fun<contributor, uint64_t, &contributor::by_investor_rating>>,
56 indexed_by<
"bycreatorate"_n, const_mem_fun<contributor, uint64_t, &contributor::by_creator_rating>>,
57 indexed_by<
"byauthorate"_n, const_mem_fun<contributor, uint64_t, &contributor::by_author_rating>>,
58 indexed_by<
"bycoordrate"_n, const_mem_fun<contributor, uint64_t, &contributor::by_coordinator_rating>>,
59 indexed_by<
"bycontrate"_n, const_mem_fun<contributor, uint64_t, &contributor::by_contributor_rating>>,
60 indexed_by<
"byprprate"_n, const_mem_fun<contributor, uint64_t, &contributor::by_propertor_rating>>,
61 indexed_by<
"byrating"_n, const_mem_fun<contributor, uint64_t, &contributor::by_rating>>
75 const eosio::name
ACTIVE =
"active"_n;
81 contributors.emplace(coopname, [&](
auto &c) {
83 c.coopname = coopname;
84 c.username = username;
85 c.contributor_hash = contributor_hash;
87 c.is_external_contract = is_external_contract;
89 c.created_at = eosio::current_time_point();
90 c.rate_per_hour = rate_per_hour;
95 inline void import_contributor(eosio::name coopname, eosio::name username, checksum256 contributor_hash, std::string memo, eosio::asset rate_per_hour){
98 contributors.emplace(coopname, [&](
auto &c) {
100 c.coopname = coopname;
101 c.username = username;
102 c.contributor_hash = contributor_hash;
104 c.is_external_contract =
true;
105 c.created_at = eosio::current_time_point();
107 c.rate_per_hour = rate_per_hour;
117 auto username_index = contributors.get_index<
"byusername"_n>();
119 auto itr = username_index.find(username.value);
121 username_index.modify(*itr,
_capital, [&](
auto &c) {
122 c.appendixes.push_back(project_hash);
129 inline std::optional<contributor>
get_contributor(eosio::name coopname, eosio::name username) {
131 auto username_index = contributors.get_index<
"byusername"_n>();
133 auto itr = username_index.find(username.value);
134 if (itr == username_index.end()) {
149 auto hash_index = contributors.get_index<
"byhash"_n>();
151 auto itr = hash_index.find(contributor_hash);
152 if (itr == hash_index.end()) {
171 if (appendix_project_hash == project_hash) {
185 eosio::check(
contributor.has_value(),
"Создатель не подписывал договор УХД");
197 "Пайщик не подписывал приложение к договору УХД для данного проекта");
206 auto username_index = contributors.get_index<
"byusername"_n>();
208 auto itr = username_index.find(segment.
username.value);
210 eosio::check(itr != username_index.end(),
"Контрибьютор не найден");
212 username_index.modify(itr,
_capital, [&](
auto &c) {
214 c.contributed_as_investor += segment.investor_base;
218 c.contributed_as_author += (segment.author_base + segment.author_bonus);
222 c.contributed_as_creator += (segment.creator_base + segment.creator_bonus);
226 c.contributed_as_coordinator += segment.coordinator_base;
230 c.contributed_as_contributor += segment.contributor_bonus;
234 c.contributed_as_propertor += segment.property_base;
244 auto username_index = contributors.get_index<
"byusername"_n>();
245 auto contributor_itr = username_index.find(username.value);
248 username_index.modify(contributor_itr,
_capital, [&](
auto &c) {
258 auto username_index = contributors.get_index<
"byusername"_n>();
259 auto contributor_itr = username_index.find(username.value);
261 eosio::check(contributor_itr->debt_amount >=
amount,
"Недостаточно долга для погашения");
264 username_index.modify(contributor_itr,
_capital, [&](
auto &c) {
Контракт Contributor управляет вкладами, распределением вознаграждений и выводом средств для участник...
Definition: contributor.hpp:17
static constexpr eosio::name _capital
Definition: consts.hpp:150
static constexpr eosio::symbol _root_govern_symbol
Definition: consts.hpp:210
contract
Definition: eosio.msig_tests.cpp:977
share_type amount
Definition: eosio.token_tests.cpp:174
uint64_t get_global_id_in_scope(eosio::name _me, eosio::name scope, eosio::name key)
Definition: counts.hpp:61
const eosio::name ACTIVE
Авторизован/активен
Definition: contributors.hpp:75
const eosio::name PENDING
Ожидает подтверждения
Definition: contributors.hpp:74
Definition: contributors.hpp:65
void update_contributor_ratings_from_segment(eosio::name coopname, const Capital::Segments::segment &segment)
Обновляет накопительные показатели контрибьютора на основе его ролей и вкладов в сегменте
Definition: contributors.hpp:204
void decrease_debt_amount(eosio::name coopname, eosio::name username, eosio::asset amount)
Увеличивает долг контрибьютора
Definition: contributors.hpp:256
std::optional< contributor > get_active_contributor_with_appendix_or_fail(eosio::name coopname, const checksum256 &project_hash, eosio::name username)
Получает участника по имени аккаунта, проверяет активность и членство в проекте.
Definition: contributors.hpp:194
void import_contributor(eosio::name coopname, eosio::name username, checksum256 contributor_hash, std::string memo, eosio::asset rate_per_hour)
Definition: contributors.hpp:95
void increase_debt_amount(eosio::name coopname, eosio::name username, eosio::asset amount)
Увеличивает долг контрибьютора
Definition: contributors.hpp:242
std::optional< contributor > get_contributor_by_hash(eosio::name coopname, const checksum256 &contributor_hash)
Получает участника по хэшу контрибьютора.
Definition: contributors.hpp:147
void create_contributor(eosio::name coopname, eosio::name username, checksum256 contributor_hash, bool is_external_contract, document2 contract, eosio::asset rate_per_hour)
Definition: contributors.hpp:78
std::optional< contributor > get_contributor(eosio::name coopname, eosio::name username)
Получает участника по имени аккаунта.
Definition: contributors.hpp:129
std::optional< contributor > get_active_contributor_or_fail(eosio::name coopname, eosio::name username)
Получает участника по имени аккаунта и проверяет на активность.
Definition: contributors.hpp:183
bool is_contributor_has_appendix_in_project(eosio::name coopname, const checksum256 &project_hash, eosio::name username)
Проверяет есть ли у контрибьютора приложение для проекта
Definition: contributors.hpp:163
void push_appendix_to_contributor(eosio::name coopname, eosio::name username, checksum256 project_hash)
Добавляет project_hash в вектор appendixes у контрибьютора
Definition: contributors.hpp:115
Definition: balances.cpp:6
eosio::multi_index< "contributors"_n, contributor, indexed_by<"byusername"_n, const_mem_fun< contributor, uint64_t, &contributor::by_username > >, indexed_by<"byhash"_n, const_mem_fun< contributor, checksum256, &contributor::by_hash > >, indexed_by<"byinvrate"_n, const_mem_fun< contributor, uint64_t, &contributor::by_investor_rating > >, indexed_by<"bycreatorate"_n, const_mem_fun< contributor, uint64_t, &contributor::by_creator_rating > >, indexed_by<"byauthorate"_n, const_mem_fun< contributor, uint64_t, &contributor::by_author_rating > >, indexed_by<"bycoordrate"_n, const_mem_fun< contributor, uint64_t, &contributor::by_coordinator_rating > >, indexed_by<"bycontrate"_n, const_mem_fun< contributor, uint64_t, &contributor::by_contributor_rating > >, indexed_by<"byprprate"_n, const_mem_fun< contributor, uint64_t, &contributor::by_propertor_rating > >, indexed_by<"byrating"_n, const_mem_fun< contributor, uint64_t, &contributor::by_rating > > > contributor_index
Definition: contributors.hpp:62
Definition: eosio.msig.hpp:34
Таблица сегментов хранит данные о вкладах участника в проект.
Definition: segments.hpp:30
bool is_investor
Является ли участник инвестором
Definition: segments.hpp:43
bool is_coordinator
Является ли участник координатором
Definition: segments.hpp:42
eosio::name username
Имя участника
Definition: segments.hpp:34
bool is_creator
Является ли участник создателем
Definition: segments.hpp:41
bool is_author
Является ли участник автором
Definition: segments.hpp:40
bool is_propertor
Является ли участник пропертором
Definition: segments.hpp:44
bool is_contributor
Является ли участник вкладчиком
Definition: segments.hpp:45
Таблица участников хранит данные индивидуального участника кооператива.
Definition: contributors.hpp:16
std::string memo
Мемо для импортированных контрибьюторов
Definition: contributors.hpp:23
uint64_t id
ID контрибьютора (внутренний ключ)
Definition: contributors.hpp:17
uint64_t primary_key() const
Первичный ключ (1)
Definition: contributors.hpp:39
time_point_sec created_at
Время создания контрибьютора
Definition: contributors.hpp:21
uint64_t by_contributor_rating() const
Индекс по рейтингу контрибьютора (8)
Definition: contributors.hpp:46
uint64_t by_rating() const
Индекс по общему рейтингу (10)
Definition: contributors.hpp:48
name coopname
Имя кооператива
Definition: contributors.hpp:18
name status
Статус контрибьютора
Definition: contributors.hpp:22
document2 contract
Договор УХД
Definition: contributors.hpp:25
uint64_t by_propertor_rating() const
Индекс по рейтингу пропертора (9)
Definition: contributors.hpp:47
uint64_t by_username() const
Индекс по имени пользователя (2)
Definition: contributors.hpp:40
uint64_t by_author_rating() const
Индекс по рейтингу автора (6)
Definition: contributors.hpp:44
uint64_t by_coordinator_rating() const
Индекс по рейтингу координатора (7)
Definition: contributors.hpp:45
uint64_t by_investor_rating() const
Индекс по рейтингу инвестора (4)
Definition: contributors.hpp:42
uint64_t by_creator_rating() const
Индекс по рейтингу создателя (5)
Definition: contributors.hpp:43
checksum256 by_hash() const
Индекс по хэшу контрибьютора (3)
Definition: contributors.hpp:41
name username
Имя пользователя
Definition: contributors.hpp:19
std::vector< checksum256 > appendixes
Вектор хэшей проектов, для которых подписаны приложения
Definition: contributors.hpp:26
checksum256 contributor_hash
Внешний идентификатор контрибьютора
Definition: contributors.hpp:20
Definition: drafts.hpp:28