Permalink
Browse files

fixing issue with demo data load for currencies

  • Loading branch information...
digimagic
digimagic committed Oct 19, 2011
1 parent e054630 commit ac1337a8d0e0f42c9269fc9a16df439824cf520c
View
@@ -1,4 +1,4 @@
-**<h2>Zurmo Open Source CRM</h2>**
+**Zurmo Open Source CRM**
Zurmo is an open source CRM application written in PHP utilizing jQuery, Yii Framework, and RedBeanPHP.
@@ -75,7 +75,6 @@ public function getRandomByModelName($modelName)
assert('is_int($this->demoData[$modelName]["startId"])');
assert('is_int($this->demoData[$modelName]["endId"])');
assert('$this->demoData[$modelName]["endId"] > $this->demoData[$modelName]["startId"]');
-
$randomId = mt_rand($this->demoData[$modelName]["startId"], $this->demoData[$modelName]["endId"]);
$model = $modelName::getById($randomId);
assert('$model instanceof $modelName');
@@ -43,21 +43,21 @@ public function makeAll(& $demoDataHelper)
assert('$demoDataHelper->isSetRange("User")');
assert('$demoDataHelper->isSetRange("Account")');
assert('$demoDataHelper->isSetRange("Contact")');
-
+ $currencies = Currency::getAll('id');
$opportunities = array();
for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++)
{
$opportunity = new Opportunity();
$opportunity->contacts->add($demoDataHelper->getRandomByModelName('Contact'));
- $opportunity->account = $opportunity->contacts[0]->account;
- $opportunity->owner = $opportunity->contacts[0]->owner;
- $currencyValue = new CurrencyValue();
- $currencyValue->currency = $demoDataHelper->getRandomByModelName('Currency');
- $opportunity->amount = $currencyValue;
+ $opportunity->account = $opportunity->contacts[0]->account;
+ $opportunity->owner = $opportunity->contacts[0]->owner;
+ $currencyValue = new CurrencyValue();
+ $currencyValue->currency = $currencies[array_rand($currencies)];
+ $opportunity->amount = $currencyValue;
$this->populateModel($opportunity);
$saved = $opportunity->save();
assert('$saved');
- $opportunities[] = $opportunity->id;
+ $opportunities[] = $opportunity->id;
}
$demoDataHelper->setRangeByModelName('Opportunity', $opportunities[0], $opportunities[count($opportunities)-1]);
}
@@ -48,9 +48,6 @@ public function makeAll(& $demoDataHelper)
$currency->rateToBase = .75;
$saved = $currency->save();
assert('$saved');
-
- $currencies = Currency::getAll('id');
- $demoDataHelper->setRangeByModelName('Currency', $currencies[0]->id, $currencies[count($currencies)-1]->id);
}
public function populateModel(& $model)

0 comments on commit ac1337a

Please sign in to comment.