3#include <eosio/asset.hpp>
4#include <eosio/eosio.hpp>
6#include "../consts.hpp"
7#include "../core/utils.hpp"
36 uint64_t
by_branch()
const {
return braname.value; }
39typedef eosio::multi_index<
41 eosio::indexed_by<
"bycontrbra"_n, eosio::const_mem_fun<branch_weight, uint128_t, &branch_weight::by_contract_branch>>,
42 eosio::indexed_by<
"bybranch"_n, eosio::const_mem_fun<branch_weight, uint64_t, &branch_weight::by_branch>>>
63 uint64_t
by_branch()
const {
return braname.value; }
66typedef eosio::multi_index<
68 eosio::indexed_by<
"bycontrbra"_n, eosio::const_mem_fun<branch_weight_total, uint128_t, &branch_weight_total::by_contract_branch>>,
69 eosio::indexed_by<
"bybranch"_n, eosio::const_mem_fun<branch_weight_total, uint64_t, &branch_weight_total::by_branch>>>
78 eosio::name
contract, int64_t delta) {
79 if (delta == 0)
return;
82 auto idx = totals.get_index<
"bycontrbra"_n>();
85 if (it == idx.end()) {
86 eosio::check(delta > 0,
"Системная ошибка: агрегат весов распределения отсутствует");
87 totals.emplace(coopname, [&](
auto& t) {
88 t.id = totals.available_primary_key();
91 t.total_weight =
static_cast<uint64_t
>(delta);
96 eosio::check(delta > 0 || it->total_weight >=
static_cast<uint64_t
>(-delta),
97 "Системная ошибка: агрегат весов распределения ушёл бы в минус");
98 const uint64_t new_total = (delta > 0)
99 ? it->total_weight +
static_cast<uint64_t
>(delta)
100 : it->total_weight -
static_cast<uint64_t
>(-delta);
102 if (new_total == 0) {
105 idx.modify(it, coopname, [&](
auto& t) { t.total_weight = new_total; });
114 auto idx = totals.get_index<
"bycontrbra"_n>();
116 return it == idx.end() ? 0 : it->total_weight;
static constexpr eosio::name _branch
Definition: consts.hpp:176
contract
Definition: eosio.msig_tests.cpp:977
Definition: eosio.msig.hpp:34
Агрегат весов по (КУ, контракт-источник): сумма весов всех участников распределения....
Definition: table_branch_weights.hpp:55
uint64_t by_branch() const
Definition: table_branch_weights.hpp:63
uint128_t by_contract_branch() const
Definition: table_branch_weights.hpp:62
uint64_t total_weight
Σ весов участников
Definition: table_branch_weights.hpp:59
eosio::name braname
кооперативный участок
Definition: table_branch_weights.hpp:57
uint64_t id
суррогатный ключ (scope coopname)
Definition: table_branch_weights.hpp:56
uint64_t primary_key() const
Definition: table_branch_weights.hpp:61
eosio::name contract
контракт-источник распределения
Definition: table_branch_weights.hpp:58
Реестр распределения членских взносов кооперативного участка (requirement b6 «Экономика КУ»).
Definition: table_branch_weights.hpp:27
uint64_t primary_key() const
Definition: table_branch_weights.hpp:34
uint128_t by_contract_branch() const
Definition: table_branch_weights.hpp:35
uint64_t id
суррогатный ключ (scope coopname)
Definition: table_branch_weights.hpp:28
eosio::name username
председатель или доверенный КУ
Definition: table_branch_weights.hpp:31
uint64_t weight
вес; доля = weight / Σ weights(braname, contract)
Definition: table_branch_weights.hpp:32
eosio::name braname
кооперативный участок
Definition: table_branch_weights.hpp:29
uint64_t by_branch() const
Definition: table_branch_weights.hpp:36
eosio::name contract
контракт-источник распределения (например, marketplace)
Definition: table_branch_weights.hpp:30
eosio::multi_index< "weights"_n, branch_weight, eosio::indexed_by<"bycontrbra"_n, eosio::const_mem_fun< branch_weight, uint128_t, &branch_weight::by_contract_branch > >, eosio::indexed_by<"bybranch"_n, eosio::const_mem_fun< branch_weight, uint64_t, &branch_weight::by_branch > > > branch_weights_index
Definition: table_branch_weights.hpp:43
uint64_t get_weight_total(eosio::name coopname, eosio::name braname, eosio::name contract)
Σ весов по (braname, contract); 0 — распределение не настроено.
Definition: table_branch_weights.hpp:112
void apply_weight_total_delta(eosio::name coopname, eosio::name braname, eosio::name contract, int64_t delta)
Применить дельту к агрегату весов (braname, contract). Создаёт запись при первой положительной дельте...
Definition: table_branch_weights.hpp:77
eosio::multi_index< "weighttotals"_n, branch_weight_total, eosio::indexed_by<"bycontrbra"_n, eosio::const_mem_fun< branch_weight_total, uint128_t, &branch_weight_total::by_contract_branch > >, eosio::indexed_by<"bybranch"_n, eosio::const_mem_fun< branch_weight_total, uint64_t, &branch_weight_total::by_branch > > > branch_weight_totals_index
Definition: table_branch_weights.hpp:70
static uint128_t combine_ids(const uint64_t &x, const uint64_t &y)
Definition: utils.hpp:7