4#include "../core/ram_payer.hpp"
5#include <eosio/asset.hpp>
6#include <eosio/eosio.hpp>
8#include "../consts.hpp"
9#include "../core/utils.hpp"
38 uint64_t
by_branch()
const {
return braname.value; }
41typedef eosio::multi_index<
43 eosio::indexed_by<
"bycontrbra"_n, eosio::const_mem_fun<branch_weight, uint128_t, &branch_weight::by_contract_branch>>,
44 eosio::indexed_by<
"bybranch"_n, eosio::const_mem_fun<branch_weight, uint64_t, &branch_weight::by_branch>>>
65 uint64_t
by_branch()
const {
return braname.value; }
68typedef eosio::multi_index<
70 eosio::indexed_by<
"bycontrbra"_n, eosio::const_mem_fun<branch_weight_total, uint128_t, &branch_weight_total::by_contract_branch>>,
71 eosio::indexed_by<
"bybranch"_n, eosio::const_mem_fun<branch_weight_total, uint64_t, &branch_weight_total::by_branch>>>
80 eosio::name
contract, int64_t delta) {
81 if (delta == 0)
return;
84 auto idx = totals.get_index<
"bycontrbra"_n>();
87 if (it == idx.end()) {
88 eosio::check(delta > 0,
"Системная ошибка: агрегат весов распределения отсутствует");
89 totals.emplace(
RamPayer::of(totals, coopname), [&](
auto& t) {
90 t.id = totals.available_primary_key();
93 t.total_weight =
static_cast<uint64_t
>(delta);
98 eosio::check(delta > 0 || it->total_weight >=
static_cast<uint64_t
>(-delta),
99 "Системная ошибка: агрегат весов распределения ушёл бы в минус");
100 const uint64_t new_total = (delta > 0)
101 ? it->total_weight +
static_cast<uint64_t
>(delta)
102 : it->total_weight -
static_cast<uint64_t
>(-delta);
104 if (new_total == 0) {
107 idx.modify(it,
RamPayer::of(idx, coopname), [&](
auto& t) { t.total_weight = new_total; });
116 auto idx = totals.get_index<
"bycontrbra"_n>();
118 return it == idx.end() ? 0 : it->total_weight;
static constexpr eosio::name _branch
Definition: consts.hpp:181
contract
Definition: eosio.msig_tests.cpp:977
eosio::name of(const Table &table, eosio::name coopname)
Definition: ram_payer.hpp:78
Definition: eosio.msig.hpp:34
Агрегат весов по (КУ, контракт-источник): сумма весов всех участников распределения....
Definition: table_branch_weights.hpp:57
uint64_t by_branch() const
Definition: table_branch_weights.hpp:65
uint128_t by_contract_branch() const
Definition: table_branch_weights.hpp:64
uint64_t total_weight
Σ весов участников
Definition: table_branch_weights.hpp:61
eosio::name braname
кооперативный участок
Definition: table_branch_weights.hpp:59
uint64_t id
суррогатный ключ (scope coopname)
Definition: table_branch_weights.hpp:58
uint64_t primary_key() const
Definition: table_branch_weights.hpp:63
eosio::name contract
контракт-источник распределения
Definition: table_branch_weights.hpp:60
Реестр распределения членских взносов кооперативного участка (requirement b6 «Экономика КУ»).
Definition: table_branch_weights.hpp:29
uint64_t primary_key() const
Definition: table_branch_weights.hpp:36
uint128_t by_contract_branch() const
Definition: table_branch_weights.hpp:37
uint64_t id
суррогатный ключ (scope coopname)
Definition: table_branch_weights.hpp:30
eosio::name username
председатель или доверенный КУ
Definition: table_branch_weights.hpp:33
uint64_t weight
вес; доля = weight / Σ weights(braname, contract)
Definition: table_branch_weights.hpp:34
eosio::name braname
кооперативный участок
Definition: table_branch_weights.hpp:31
uint64_t by_branch() const
Definition: table_branch_weights.hpp:38
eosio::name contract
контракт-источник распределения (например, marketplace)
Definition: table_branch_weights.hpp:32
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:45
RAM_PAYER_CLASS(branch_weight, contract)
uint64_t get_weight_total(eosio::name coopname, eosio::name braname, eosio::name contract)
Σ весов по (braname, contract); 0 — распределение не настроено.
Definition: table_branch_weights.hpp:114
void apply_weight_total_delta(eosio::name coopname, eosio::name braname, eosio::name contract, int64_t delta)
Применить дельту к агрегату весов (braname, contract). Создаёт запись при первой положительной дельте...
Definition: table_branch_weights.hpp:79
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:72
static uint128_t combine_ids(const uint64_t &x, const uint64_t &y)
Definition: utils.hpp:7