Service/Calc/Value/Tv/Calc.php
public function exec($dwnlBonus)
    {
        $result = [];
        $mapById = $this->hlpDwnlTree->mapById($dwnlBonus, EBonDwnl::A_CUST_REF);
        $mapTeams = $this->hlpDwnlTree->mapByTeams($dwnlBonus, EBonDwnl::A_CUST_REF, EBonDwnl::A_PARENT_REF);
        /** @var \Praxigento\BonusHybrid\Repo\Data\Downline $one */
        foreach ($dwnlBonus as $one) {
            $custId = $one->getCustomerRef();
            /** @var \Praxigento\BonusHybrid\Repo\Data\Downline $cust */
            $cust = $mapById[$custId];
            /* initial TV equal to own PV */
            $tv = $cust->getPv();
            if (isset($mapTeams[$custId])) {
                /* add PV of the front line team (first generation) */
                $frontTeam = $mapTeams[$custId];
                foreach ($frontTeam as $teamMemberId) {
                    /** @var \Praxigento\BonusHybrid\Repo\Data\Downline $member */
                    $member = $mapById[$teamMemberId];
                    $memberPv = $member->getPv();
                    $tv += $memberPv;
                }
            }
            $cust->setTv($tv);
            $result[$custId] = $cust;
        }
        return $result;
    }
public function exec($dwnlBonus)
    {
        $result = [];
        $mapById = $this->hlpDwnlTree->mapById($dwnlBonus, EBonDwnl::A_CUST_REF);
        $mapTeams = $this->hlpDwnlTree->mapByTeams($dwnlBonus, EBonDwnl::A_CUST_REF, EBonDwnl::A_PARENT_REF);
        /** @var \Praxigento\BonusHybrid\Repo\Data\Downline $one */
        foreach ($dwnlBonus as $one) {
            $custId = $one->getCustomerRef();
            /** @var \Praxigento\BonusHybrid\Repo\Data\Downline $cust */
            $cust = $mapById[$custId];
            /* initial TV equal to own PV */
            $tv = $cust->getPv();
            if (isset($mapTeams[$custId])) {
                /* add PV of the front line team (first generation) */
                $frontTeam = $mapTeams[$custId];
                foreach ($frontTeam as $teamMemberId) {
                    /** @var \Praxigento\BonusHybrid\Repo\Data\Downline $member */
                    $member = $mapById[$teamMemberId];
                    $memberPv = $member->getPv();
                    $tv += $memberPv;
                }
            }
            $cust->setTv($tv);
            $result[$custId] = $cust;
        }
        return $result;
    }
Calculate TV for the downline tree.

@param \Praxigento\BonusHybrid\Repo\Data\Downline[] $dwnlBonus
@return \Praxigento\BonusHybrid\Repo\Data\Downline[] updated tree (with TV)