public function testGetInstance()
 {
     $mapper = OrgCustomerMapper::getInstance();
     $this->assertNotNull($mapper);
     $this->assertInstanceOf('\\Application\\Model\\Mapper\\Organization\\OrgCustomerMapper', $mapper);
     $this->assertSame($this->_mapper, $mapper);
 }
Пример #2
0
 /**
  * @param  string                      $id
  * @return \Application\Model\SimModel
  */
 public function load($id, $org = null, $idType = 'Id')
 {
     $mapper = $this->getMapper();
     $idType = ucfirst(strtolower($idType));
     $sim = $mapper->{'findOneBy' . $idType}($id);
     if (is_null($sim)) {
         return null;
     }
     //retrieve the restriction:
     $resMapper = \Application\Model\Mapper\RestrictionMapper::getInstance();
     $restrictions = $resMapper->findOneBySubscriptionId($sim->getId());
     if (!is_null($restrictions)) {
         $sim->setRestrictions($restrictions);
     }
     //retrive the customer supplservices
     if ($sim->getCustomer()) {
         $orgMapper = \Application\Model\Mapper\Organization\OrgCustomerMapper::getInstance();
         $customer = $orgMapper->findOneById($sim->getCustomer()->getId());
         $supplServicesMapper = \Application\Model\Mapper\SupplServicesMapper::getInstance();
         if ($customer->getSupplementaryServicesId()) {
             $supplServices = $supplServicesMapper->findOneById($customer->getSupplementaryServicesId());
             if (!is_null($supplServices)) {
                 $supplServices->setTariffs(array());
                 $sim->setCustomerSupplServices($supplServices);
             }
         }
     }
     // Grow the model with additional data
     try {
         $mapper->getConsumption($sim);
     } catch (\Exception $e) {
         \App::log()->warn($e);
     }
     try {
         $mapper->getLifeCycle($sim);
     } catch (\Exception $e) {
         \App::log()->warn($e);
     }
     try {
         $mapper->getPresenceDetails($sim);
     } catch (\Exception $e) {
         \App::log()->warn($e);
     }
     try {
         $mapper->getLocationDetails($sim);
     } catch (\Exception $e) {
         \App::log()->warn($e);
     }
     try {
         $mapper->getTimeAndConsumptionVoucher($sim);
     } catch (\Exception $e) {
         \App::log()->warn($e);
     }
     return $sim;
 }
Пример #3
0
 protected function _mapEricssonModelToModel(array $data)
 {
     \App_Util_Array::changePropertyName($data, 'customer', 'customerData');
     $data = parent::_mapEricssonModelToModel($data);
     \App_Util_Array::changePropertyName($data, 'customerData.fiscalNumber', 'customerData.defaultBillingAccount.fiscalNumber');
     if (isset($data['customerData'])) {
         $data['customer'] = OrgCustomerMapper::getInstance()->mapToModel($data['customerData']);
         unset($data['customerData']);
     }
     if (isset($data['serviceProviderData'])) {
         $data['serviceProvider'] = OrgServiceProviderMapper::getInstance()->mapToModel($data['serviceProviderData']);
         unset($data['serviceProviderData']);
     }
     if (isset($data['billingAccountData'])) {
         $data['billingAccountName'] = $data['billingAccountData']['name'];
         if (isset($data['billingAccountData']['region'])) {
             $data['billingAccountRegion'] = $data['billingAccountData']['region'];
         }
         unset($data['billingAccountData']);
     }
     \App_Util_Array::changePropertyName($data, 'prebillBillingcycle', 'billingCycle');
     if (isset($data['billingCycle'])) {
         foreach ($data['billingCycle'] as &$bc) {
             $this->_mapReference($bc, 'billingAccount');
         }
     }
     $this->_mapReference($data, 'billingAccount');
     if (isset($data['datesData'])) {
         $data += $data['datesData'];
         unset($data['datesData']);
     }
     \App_Util_Array::changePropertiesNames($data, array('totalChargeData' => 'totalCharge', 'totalCharge.adjusts.adjustList' => 'totalCharge.adjusts', 'adjusts.adjustList' => 'adjusts', 'serviceGlobalCharges.basicServicesCustomerCharges' => 'serviceGlobalCharges.basicServices', 'serviceGlobalCharges.basicServices.commercialGroupData' => 'serviceGlobalCharges.basicServices.commercialGroup', 'serviceGlobalCharges.supplementaryServicesCustomerCharges' => 'serviceGlobalCharges.supplServices', 'subscriptionsChargesSummary.basicServices.commercialGroupData' => 'subscriptionsChargesSummary.basicServices.commercialGroup', 'subscriptionsChargesSummary.supplementaryServices' => 'subscriptionsChargesSummary.supplServices'));
     if (isset($data['serviceGlobalCharges']) && isset($data['serviceGlobalCharges']['basicServices']) && isset($data['serviceGlobalCharges']['basicServices']['commercialGroup'])) {
         foreach ($data['serviceGlobalCharges']['basicServices']['commercialGroup'] as &$item) {
             $this->_mapReference($item, 'aggregator');
         }
     }
     if (isset($data['subscriptionsChargesSummary']) && isset($data['subscriptionsChargesSummary']['basicServices']) && isset($data['subscriptionsChargesSummary']['basicServices']['commercialGroup'])) {
         foreach ($data['subscriptionsChargesSummary']['basicServices']['commercialGroup'] as &$item) {
             \App_Util_Array::changePropertiesNames($item, array('oneTimeFee.lifecycleStateChangeEvent' => 'oneTimeFee.lifecycleStatusChangeEvent', 'monthlyFee.activeStateRecurrentFee' => 'monthlyFee.activeStatusRecurrentFee', 'monthlyFee.deactivatedStateRecurrentFee' => 'monthlyFee.deactivatedStatusRecurrentFee', 'monthlyFee.activationReadyRecurrentFee' => 'monthlyFee.activationReadyStatusRecurrentFee', 'monthlyFee.activationPendingRecurrentFee' => 'monthlyFee.activationPendingStatusRecurrentFee'));
             $this->_mapReference($item, 'aggregator');
         }
     }
     if (!isset($data["published"])) {
         $data["published"] = isset($data["issuedDate"]) && $data["issuedDate"];
     }
     $customerDiscounts = \App_Util_Array::getItem($data, 'totalCharge.discounts.customer');
     if (empty($customerDiscounts)) {
         \App_Util_Array::unsetItem($data, 'totalCharge.discounts.customer');
     }
     return $data;
 }
Пример #4
0
 protected function _mapSubscriptionBaseTarget($data)
 {
     switch ($data['type']) {
         case Target\SubscriptionBaseTarget\OrgType::MASTER:
             $mapper = \Application\Model\Mapper\Organization\OrgMasterMapper::getInstance();
             break;
         case Target\SubscriptionBaseTarget\OrgType::SERVICE_PROVIDER:
             $mapper = \Application\Model\Mapper\Organization\OrgServiceProviderMapper::getInstance();
             break;
         case Target\SubscriptionBaseTarget\OrgType::CUSTOMER:
             $mapper = \Application\Model\Mapper\Organization\OrgCustomerMapper::getInstance();
             break;
         default:
             return array();
     }
     return array('organization' => $mapper::buildOrgId($data['id']));
 }
 public function setVoucherOnlyDiscounts($id, $discounts)
 {
     if ($id instanceof ServicePackModel) {
         $id = $id->getId();
     }
     $this->getCache()->remove($id);
     $data = array();
     foreach ($discounts as $discount) {
         $orgId = $discount->getCustomerId();
         Organization\OrgCustomerMapper::getInstance()->getCache()->remove($orgId);
         $data[] = $this->_mapModelDiscountToEricsson($discount->exportData());
     }
     return $this->_setVoucherOnlyDiscountsEricsson($id, $data);
 }