public static function getAssetMatchingInvestmentProfiles($assetID)
 {
     global $db;
     $result = array("matching" => [], "notMatching" => []);
     $assetRow = $db->get('assets', 'sellingProfile', ['id' => $assetID]);
     if ($assetRow === false) {
         return false;
     }
     $sellingProfile = json_decode($assetRow, true);
     $investmentProfileRows = $db->select('investmentProfiles', ['id', 'investmentProfile']);
     foreach ($investmentProfileRows as $investmentProfileRow) {
         $investmentProfile = json_decode($investmentProfileRow['investmentProfile'], true);
         $matchResult = Assets::checkMatch($sellingProfile, $investmentProfile);
         $toPush = array("id" => $investmentProfileRow['id'], "investor" => Investors::getInvestorFromProfile($investmentProfileRow['id']), "percentage" => $matchResult['percentage'], "reasons" => array("negative" => $matchResult['negativeReasons'], "positive" => $matchResult['positiveReasons']), "matched" => Logs::isLogExists($assetID, $investmentProfileRow['id']));
         if ($matchResult['notMatching']) {
             array_push($result['notMatching'], $toPush);
         } else {
             array_push($result['matching'], $toPush);
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
 public static function getInvestmentProfileMatchingAssets($investmentProfileID)
 {
     global $db;
     $result = array("notMatching" => [], "matching" => array("forSale" => [], "notForSale" => []));
     $investmentProfileRow = $db->get('investmentProfiles', 'investmentProfile', ['id' => $investmentProfileID]);
     if ($investmentProfileRow === false) {
         return false;
     }
     $investmentProfile = json_decode($investmentProfileRow, true);
     $investor = Investors::getInvestorFromProfile($investmentProfileID);
     $assets = self::getNotInvestorAssets($investor['id']);
     foreach ($assets as $asset) {
         $sellingProfile = json_decode($asset['sellingProfile'], true);
         $matchResult = Assets::checkMatch($sellingProfile, $investmentProfile);
         $toPush = array("id" => $asset['id'], "name" => $asset['name'], "percentage" => $matchResult['percentage'], "reasons" => array("negative" => $matchResult['negativeReasons'], "positive" => $matchResult['positiveReasons']), "matched" => Logs::isLogExists($asset['id'], $investmentProfileID));
         if ($matchResult['notMatching']) {
             array_push($result['notMatching'], $toPush);
         } else {
             if ($asset['isForSale'] == 1) {
                 array_push($result['matching']['forSale'], $toPush);
             } else {
                 array_push($result['matching']['notForSale'], $toPush);
             }
         }
     }
     return $result;
 }