/** * Converts quote to policy */ public function changeQuoteToPolicy($quoteNumber, $policyNumber = null) { //If policyNumber is empty then assume the QHLI should be replaced with PHLI. if (empty($policyNumber)) { $policyNumber = preg_replace('/^Q/', 'P', $quoteNumber); } //Create a policy object from the data passed in. $quoteDatasource = new Datasource_Insurance_LegacyQuotes(); $quote = $quoteDatasource->getByPolicyNumber($quoteNumber); $quote->policyNumber = $policyNumber; $quote->status = "Policy"; if ($this->getPayFrequency() == "ANNUALLY") { $quote->payBy = "Annually"; } if ($this->getPayMethod() == "DD") { $quote->payMethod = "DirectDebit"; } elseif ($this->getPayMethod() == "CC") { $quote->payMethod = "CreditCard"; } //Set the issueDate and timecompleted fields (which oddly record the same value but //in different formats). $issueDate = Zend_Date::now(); $quote->issueDate = $issueDate->toString(Zend_Date::ISO_8601); $quote->timeCompleted = $issueDate->toString(Zend_Date::TIMESTAMP); $quote->payStatus = "UpToDate"; // Update the optionpremiums field in the database /* if($quote->payBy=="Annually") { $optionPremiums = explode('|',$quote->optionPremiums); for($i=0;$i<count($optionPremiums);$i++){ $optionPremiums[$i] = round($optionPremiums[$i]*$quote->policyLength,2); } $optionPremiums = implode('|', $optionPremiums); $quote->optionPremiums = $optionPremiums; }*/ //Write the policy to the datasource $policyDatasource = new Datasource_Insurance_LandlordsPlus_Policies(); $policyDatasource->save($quote); //Delete the legacy quote. $quoteDatasource->remove(array(Manager_Insurance_TenantsContentsPlus_Quote::POLICY_NUMBER => $quoteNumber)); // And finally - remove the new quote as well $this->delete(); }
/** * Description given in the IChangeable interface. */ public function changeQuoteToPolicy($quoteNumber, $policyNumber = null) { //If policyNumber is empty then assume the QHLI should be replaced with PHLI. if (empty($policyNumber)) { $policyNumber = preg_replace('/^Q/', 'P', $quoteNumber); } //Create a policy object from the data passed in. $quoteDatasource = new Datasource_Insurance_LegacyQuotes(); $quote = $quoteDatasource->getByPolicyNumber($quoteNumber); $quote->policyNumber = $policyNumber; $quote->status = "Policy"; //Set the issueDate and timecompleted fields (which oddly record the same value but //in different formats). $issueDate = Zend_Date::now(); $quote->issueDate = $issueDate->toString(Zend_Date::ISO_8601); $quote->timeCompleted = $issueDate->toString(Zend_Date::TIMESTAMP); // Update the optionpremiums field in the database if ($quote->payBy == "Annually") { $optionPremiums = explode('|', $quote->optionPremiums); $optionPremiums[0] = round($optionPremiums[0] * $quote->policyLength, 2); $optionPremiums[1] = round($optionPremiums[1] * $quote->policyLength, 2); $optionPremiums[2] = round($optionPremiums[2] * $quote->policyLength, 2); $optionPremiums[3] = round($optionPremiums[3] * $quote->policyLength, 2); $optionPremiums = implode('|', $optionPremiums); $quote->optionPremiums = $optionPremiums; } //Write the policy to the datasource $policyDatasource = new Datasource_Insurance_TenantsContentsPlus_Policies(); $policyDatasource->save($quote); //Finally, delete the quote. $quoteDatasource->remove(array(Manager_Insurance_TenantsContentsPlus_Quote::POLICY_NUMBER => $quoteNumber)); }