use super::super::element::{attributes, elements};
use super::{spec, BusinessNode, Json, Kind::*, TagSpec};
elements! {
round = "Round": children;
investment = "Investment": leaf;
}
attributes! {
pub trait EquityAttrs {
pre_money; raise; pool_target; pool_top_up; price_places; stock_class; stakeholder; instrument;
}
}
pub(super) const EQUITY_TAGS: &[TagSpec] = &[
TagSpec {
tag: "Round",
props: &[
("name", Text),
("date", Text),
("preMoney", Amount),
("raise", Amount),
("currency", Text),
("poolTarget", Amount),
("poolTopUp", Amount),
("pricePlaces", Amount),
("stockClass", Text),
],
required: &["name", "preMoney"],
one: &[],
many: &[("investments", "Investment")],
},
spec("Investment", &[("stakeholder", Text), ("amount", Amount), ("instrument", Text)], &["stakeholder", "amount"]),
];
pub(super) fn rounds_of(node: &BusinessNode) -> Vec<Json> {
node.many("rounds")
.iter()
.map(|r| Json::Obj(r.props.clone()).with("investments", r.many("investments").iter().map(|i| Json::Obj(i.props.clone())).collect::<Vec<_>>()))
.collect()
}