Hi,
In my Entity Opportunities is an 1:n Relation to a custom entity called "Kredite". The Entity "Kredite" has an not storable field "Restschuld" that is calculated in the loadAdditionalFields Method. Now I want to show the sum of all "Kredite" belong to an Opportunity in an not storable field but when I try to get the field "Restschuld" it is "0" (maybe because it is not storable) is the a way to get the data from the field?
public function loadAdditionalFields(Entity $entity)
{
parent::loadAdditionalFields($entity);
$entity->loadLinkMultipleField('kredites');
$kredite = $entity->get('kredites');
$restschuldsum = 0;
foreach ($kredite as $kredit){
$restschuldsum = $restschuldsum + $kredit->get('restschuld');
}
$entity->set('testing', $restschuldsum." ");
}
Or is there a way to save the Data in the loadAdditionalFields method
public function loadAdditionalFields(Entity $entity)
{
parent::loadAdditionalFields($entity);
$rate = $entity->get('rate');
$zinssatz = $entity->get('zinssatz');
$startdatum = date_create($entity->get('startdatum'));
$laufzeit = $entity->get('laufzeit');
$now = new \DateTime("now");
$startschuld = $entity->get('startschuld');
$interval = date_diff($startdatum, $now);
$month = $interval->y * 12 + $interval->m;
$schuld = $startschuld;
for($i=0; $i < $month; $i++) {
$zinsanteil = $schuld * $zinssatz / 12 / 100;
$tilgung = $rate - $zinsanteil;
$schuld = $schuld - $tilgung;
}
$entity->set('restschuld', $schuld);
//save?
}
In my Entity Opportunities is an 1:n Relation to a custom entity called "Kredite". The Entity "Kredite" has an not storable field "Restschuld" that is calculated in the loadAdditionalFields Method. Now I want to show the sum of all "Kredite" belong to an Opportunity in an not storable field but when I try to get the field "Restschuld" it is "0" (maybe because it is not storable) is the a way to get the data from the field?
public function loadAdditionalFields(Entity $entity)
{
parent::loadAdditionalFields($entity);
$entity->loadLinkMultipleField('kredites');
$kredite = $entity->get('kredites');
$restschuldsum = 0;
foreach ($kredite as $kredit){
$restschuldsum = $restschuldsum + $kredit->get('restschuld');
}
$entity->set('testing', $restschuldsum." ");
}
Or is there a way to save the Data in the loadAdditionalFields method
public function loadAdditionalFields(Entity $entity)
{
parent::loadAdditionalFields($entity);
$rate = $entity->get('rate');
$zinssatz = $entity->get('zinssatz');
$startdatum = date_create($entity->get('startdatum'));
$laufzeit = $entity->get('laufzeit');
$now = new \DateTime("now");
$startschuld = $entity->get('startschuld');
$interval = date_diff($startdatum, $now);
$month = $interval->y * 12 + $interval->m;
$schuld = $startschuld;
for($i=0; $i < $month; $i++) {
$zinsanteil = $schuld * $zinssatz / 12 / 100;
$tilgung = $rate - $zinsanteil;
$schuld = $schuld - $tilgung;
}
$entity->set('restschuld', $schuld);
//save?
}
Comment