예제 #1
0
 /**
  * @todo: Fix this so it's not messing around with arrays.
  *
  * @param unknown_type $schemeNumber
  * @param unknown_type $emailAddresses
  */
 public function setEmailAddresses($schemeNumber, $emailAddresses)
 {
     // First of all check to make sure this is a valid agent schemeNumber
     $agent = new Datasource_Core_Agents();
     $agentSelect = $agent->getBySchemeNumber($schemeNumber);
     $agentRow = $agent->fetchRow($agentSelect);
     if (!$agentRow) {
         return false;
     }
     // There is no 'replace' functionality in zend as it is, sadly, mysql specific
     // so we have to do a delete then an insert
     // First build a select object to get all email addresses for the specified agent
     $where = $this->quoteInto('scheme_number = ?', $schemeNumber);
     // Then delete them
     if (!$this->delete($where)) {
         //return false;
     }
     // Now build the insert array
     foreach ($emailAddresses as $emailAddress) {
         $tempEmailAddress = '';
         $tempCategoryId = '';
         if (is_array($emailAddress)) {
             $tempEmailAddress = $emailAddress['emailAddress'];
             $tempCategoryId = $emailAddress['categoryID'];
         } else {
             if (is_object($emailAddress)) {
                 $tempEmailAddress = $emailAddress->emailAddress;
                 $tempCategoryId = $emailAddress->categoryID;
             } else {
                 Application_Core_Logger::log("Datatype unknown when changing email address for agent {$schemeNumber}.", 'error');
                 return false;
             }
         }
         if ($tempEmailAddress != '') {
             $data = array('scheme_number' => $schemeNumber, 'email_address' => $tempEmailAddress, 'category_id' => $tempCategoryId);
             if (!$this->insert($data)) {
                 // Failed insertion
                 Application_Core_Logger::log("Can't insert e-mail address in table {$this->_name} (scheme_number = {$schemeNumber})", 'error');
                 return false;
             }
         }
     }
     return true;
 }
예제 #2
0
 /**
  * Saves the disbursement info to the relevant table 
  *
  * @param String policy, double $amount, int $months, String $paymethod, date $paymentdate, double $fee, int $csuID
  *
  * @return 
  *
  * 
  */
 public function processDisbursement($policynumber, $amount, $months, $paymethod, $paymentdate = null, $fee = null, $csuid = 0, $transactionType = 'payment')
 {
     if (is_null($paymentdate)) {
         $paymentdate = date("Y-m-d");
     }
     /**
      * prepair data to build transactions
      */
     $this->_policynumber = $policynumber;
     $this->_amount = $amount;
     $this->_months = $months;
     $policyDisb = new Datasource_Insurance_LegacyPolicies();
     $policy = $policyDisb->getByPolicyNumber($policynumber);
     $this->_policyname = $policy->policyName;
     $customerDisb = new Datasource_Core_LegacyCustomers();
     $customer = $customerDisb->getCustomer($policy->refNo);
     $scheduleDisb = new Datasource_Insurance_Schedules();
     $schedule = $scheduleDisb->retrieveByPolicyNumber($policynumber);
     $agentDisb = new Datasource_Core_Agents();
     $agentS = $agentDisb->getBySchemeNumber($policy->agentSchemeNumber);
     $agent = $agentDisb->fetchrow($agentS);
     $termDisb = new Datasource_Insurance_Policy_Term();
     $term = $termDisb->getPolicyTerm($policynumber, $policy->startDate);
     $this->_startdate = $policy->startDate;
     $transdata = array();
     $transdata['paymentrefno'] = $schedule->paymentRefNo;
     $transdata['policynumber'] = $policynumber;
     $transdata['paymentdate'] = $paymentdate;
     $transdata['amount'] = $amount;
     $transdata['handlingcharge'] = isset($fee) ? $fee : $schedule->ddFee;
     $transdata['csuid'] = $csuid;
     $transdata['months'] = $months;
     $transdata['paymethod'] = $paymethod;
     $transdata['whitelabelID'] = $agent['twolettercode'];
     $transdata['agentschemeno'] = $policy->agentSchemeNumber;
     $transdata['premier'] = ucfirst($agent['premier']);
     $transdata['salesman'] = $agent['salesman'];
     $transdata['riskarea'] = $policy->riskArea;
     $transdata['riskareab'] = $policy->riskAreaB;
     $transdata['isNewBusiness'] = $term['term'] == 1 ? 'yes' : 'no';
     $transdata['isPaidnet'] = $policy->paidNet;
     $transdata['policyTermID'] = $term['id'];
     $transdata['policyname'] = $policy->policyName;
     $transdata['type'] = $transactionType;
     $this->_transID = $this->_newtransaction->saveDetails($transdata);
     $transdata['trans_id'] = $this->_transID;
     $this->_termid = $transdata['policyTermID'];
     /*
      Create transaction record for MI
     */
     $transupportdata = array();
     $this->_transIDDW = $this->_transaction->saveDetails($transdata);
     $transupportdata['trans_id'] = $this->_transIDDW;
     $transupportdata['customerTitle'] = $customer->getTitle();
     $transupportdata['customerFirstName'] = $customer->getFirstName();
     $transupportdata['customerLastName'] = $customer->getLastName();
     $transupportdata['riskAddress1'] = $policy->propertyAddress1;
     $transupportdata['riskAddress2'] = $policy->propertyAddress2;
     $transupportdata['riskAddress3'] = $policy->propertyAddress3;
     $transupportdata['riskPostcode'] = $policy->propertyPostcode;
     $transupportdata['policytype'] = $policy->policyType;
     $transupportdata['payby'] = $policy->payBy;
     $transupportdata['policyLength'] = $policy->policyLength;
     $this->_transactionSupport->saveDetails($transupportdata);
     $this->_ptranID = $this->_paymentTransaction->saveDetails($transdata);
     $this->_getMult($policy);
     /*
      calculate for disbursement
     */
     $this->_calculateGrossprem($policy);
     $this->_calculateAgentComm($policy, $agent, $term['term']);
     $policyOptionsArray = explode("|", $policy->policyOptions);
     $es = array(4, 28, 29, 30);
     foreach ($policyOptionsArray as $key => $value) {
         $this->_initialise();
         $option = new Datasource_Insurance_Policy_Options($policy->policyType);
         $this->_optionID = $option->fetchOptionsByName($value);
         $this->_sumInsOption = $policyDisb->getPolicyOptionMatch($policy->policyOptions, $value, $policy->amountsCovered);
         if ($this->_sumInsOption > 0 || in_array($this->_optionID, $es)) {
             $this->_premOption = $policyDisb->getPolicyOptionMatch($policy->policyOptions, $value, $policy->optionPremiums) * $this->_mult;
             $this->_discOption = $policyDisb->getPolicyOptionMatch($policy->policyOptions, $value, $policy->optionDiscounts);
             $this->_calculateAgentCommOption();
             $this->_calculateTax();
             $this->_calculateNet($policy, $value);
             $this->_storeOptionDisbursement();
         }
         $this->_policynetprem += $this->_netOption;
         $this->_policyIPT += $this->_iptOption;
         if ($value == "contentstp") {
             $this->_disTcontents = $this->_netOption;
             $this->_iptTcontents = $this->_iptOption;
             $this->_premTcontents = $this->_premOption;
             $this->_sumTcontents = $this->_sumInsOption;
         } elseif ($value == "pedalcyclesp") {
             $this->_disTpedel = $this->_netOption;
             $this->_iptTpedel = $this->_iptOption;
             $this->_premTpedel = $this->_premOption;
             $this->_sumTpedel = $this->_sumInsOption;
         } elseif ($value == "possessionsp" || $value == "specpossessionsp") {
             $this->_disTposs += $this->_netOption;
             $this->_iptTposs += $this->_iptOption;
             $this->_premTposs += $this->_premOption;
             $this->_sumTposs += $this->_sumInsOption;
         } elseif ($value == "buildingsp" || $value == "buildingslflood") {
             $this->_disLbuilding += $this->_netOption;
             $this->_iptLbuilding += $this->_iptOption;
             $this->_premLbuilding += $this->_premOption;
             $this->_sumLbuilding = $this->_sumInsOption;
         } elseif ($value == "buildingsAccidentalDamagep") {
             $this->_disLBA = $this->_netOption;
             $this->_iptLBA = $this->_iptOption;
             $this->_premLBA = $this->_premOption;
             $this->_sumLBA = $this->_sumInsOption;
         } elseif ($value == "limitedcontentsp") {
             $this->_disLcontents = $this->_netOption;
             $this->_iptLcontents = $this->_iptOption;
             $this->_premLcontents = $this->_premOption;
             $this->_sumLcontents = $this->_sumInsOption;
         } elseif ($value == "contentslp" || $value == "contentslflood") {
             $this->_disLcontents += $this->_netOption;
             $this->_iptLcontents += $this->_iptOption;
             $this->_premLcontents += $this->_premOption;
             $this->_sumLcontents = $this->_sumInsOption;
         } elseif ($value == "contentslAccidentalDamagep") {
             $this->_disLCA = $this->_netOption;
             $this->_iptLCA = $this->_iptOption;
             $this->_premLCA = $this->_premOption;
             $this->_sumLCA = $this->_sumInsOption;
         } elseif ($value == "emergencyassistance" || $value == "emergencyassistancestandalone") {
             $this->_disES += $this->_netOption;
             $this->_iptES += $this->_iptOption;
             $this->_premES += $this->_premOption;
             $this->_sumES = $this->_sumInsOption;
         } elseif ($value == "emergencyassistancebahbuildings" || $value == "emergencyassistancebahstandalone") {
             $this->_disEB += $this->_netOption;
             $this->_iptEB += $this->_iptOption;
             $this->_premEB += $this->_premOption;
             $this->_sumEB = $this->_sumInsOption;
         }
         //Zend_Debug::dump($this);
     }
     $this->_grosspremium = round($this->_policypremium + $this->_policyIPT, 2);
     $this->_calCulateBalance();
     if ($this->_policyname == "tenantsp") {
         $this->_newtransaction->updateNewTranForTenant($this);
         $this->_transaction->updateTranForTenant($this);
     }
     if ($this->_policyname == "landlordsp") {
         $this->_newtransaction->updateTranForLandlord($this);
         $this->_transaction->updateTranForLandlord($this);
     }
     $this->_paymentTransaction->updatePaymentTransaction($this);
     /*
      * TODO reverse or refund disbursement
      */
     if ($amount < 0) {
     }
 }