コード例 #1
0
 /**
  * @return Response
  */
 public function createAction()
 {
     /** @var User $ria */
     $ria = $this->getUser();
     $em = $this->container->get('doctrine.orm.entity_manager');
     $riaCompanyInfo = $em->getRepository('WealthbotRiaBundle:RiaCompanyInformation')->findOneBy(array('ria_user_id' => $ria->getId()));
     if ($riaCompanyInfo->getPortfolioProcessing() == RiaCompanyInformation::PORTFOLIO_PROCESSING_STRAIGHT_THROUGH && $ria->getBillingSpecs()->count() > 0) {
         return new Response(array('error' => 'can\'t add more than one for straight portfolio processing'), 400);
     }
     $billingSpec = new BillingSpec();
     //Need to separate fields in subform
     $formType = new BillingSpecFormType();
     $data = $this->getRequest()->get($formType->getName());
     $billingSpec->setType($data['type']);
     $form = $this->createForm($formType, $billingSpec);
     $form->bind($this->getRequest());
     if ($form->isValid()) {
         if ($riaCompanyInfo->getPortfolioProcessing() == RiaCompanyInformation::PORTFOLIO_PROCESSING_STRAIGHT_THROUGH) {
             $billingSpec->setMaster(true);
         }
         $em = $this->getDoctrine()->getManager();
         $billingSpec->setOwner($this->getUser());
         $em->persist($billingSpec);
         $em->flush();
         return new Response();
     } else {
         $errors = new FormErrorBag($form);
         return new Response($errors->toJson(), 400);
     }
 }
コード例 #2
0
ファイル: FeeManagerTest.php プロジェクト: junjinZ/wealthbot
 protected function getRiaUser()
 {
     $ria = new User();
     $adminBillingSpec = new BillingSpec();
     $adminBillingSpec->setName('Admin Billing Spec for RIA TEST');
     $adminBillingSpec->addAppointedUser($ria);
     $adminBillingSpec->setFees($this->returnAdminFees());
     $adminBillingSpec->setMaster(true);
     $adminBillingSpec->setType(BillingSpec::TYPE_TIER);
     $adminBillingSpec->setMinimalFee(0);
     $ria->setAppointedBillingSpec($adminBillingSpec);
     return $ria;
 }
コード例 #3
0
 protected function createAdminBillingSpec($name)
 {
     $fee = new Fee();
     $fee->setFeeWithoutRetirement(500);
     $spec = new BillingSpec();
     $spec->setMaster(true);
     $spec->setMinimalFee(300);
     $spec->setName($name);
     $spec->setOwner(null);
     $spec->setType(BillingSpec::TYPE_FLAT);
     $spec->setFees(array($fee));
     $fee->setBillingSpec($spec);
     $this->em->persist($spec);
     $this->em->persist($fee);
     return $spec;
 }
コード例 #4
0
 function load(ObjectManager $manager)
 {
     /** @var User $riaUser */
     $riaUser = $this->getReference('user-ria');
     $billingSpec = new BillingSpec();
     $billingSpec->setMaster(1);
     $billingSpec->setName('Flat spec');
     $billingSpec->setOwner($riaUser);
     $billingSpec->setType(BillingSpec::TYPE_FLAT);
     $billingSpec->setMinimalFee(35);
     $manager->persist($billingSpec);
     $this->setReference('ria-flat-spec', $billingSpec);
     $billingSpec = new BillingSpec();
     $billingSpec->setMaster(0);
     $billingSpec->setName('Tier spec');
     $billingSpec->setType(BillingSpec::TYPE_TIER);
     $billingSpec->setOwner($riaUser);
     $billingSpec->setMinimalFee(20);
     $manager->persist($billingSpec);
     $this->setReference('ria-tier-spec', $billingSpec);
     $weboUserRia = $this->getReference('user-wealthbot-io-ria');
     $billingSpec = new BillingSpec();
     $billingSpec->setMaster(false);
     $billingSpec->setName('Webo Flat Spec');
     $billingSpec->setType(BillingSpec::TYPE_FLAT);
     $billingSpec->setOwner($weboUserRia);
     $billingSpec->setMinimalFee(10);
     $manager->persist($billingSpec);
     $this->setReference('wealthbot-ria-flat-spec', $billingSpec);
     $billingSpec = new BillingSpec();
     $billingSpec->setMaster(true);
     $billingSpec->setName('Webo Tier Spec');
     $billingSpec->setType(BillingSpec::TYPE_TIER);
     $billingSpec->setOwner($weboUserRia);
     $billingSpec->setMinimalFee(20);
     $manager->persist($billingSpec);
     $this->setReference('wealthbot-ria-tier-spec', $billingSpec);
     $manager->flush();
     /** @var User $client */
     $client = $this->getReference('clientN1');
     $client->setAppointedBillingSpec($billingSpec);
     /** @var User $client */
     $client = $this->getReference('clientN2');
     $client->setAppointedBillingSpec($this->getReference('wealthbot-ria-flat-spec'));
     /** @var User $client */
     $client = $this->getReference('clientN3');
     $client->setAppointedBillingSpec($this->getReference('wealthbot-ria-tier-spec'));
     /** @var User $client */
     $client = $this->getReference('clientN4');
     $client->setAppointedBillingSpec($this->getReference('wealthbot-ria-tier-spec'));
     $manager->flush();
 }
コード例 #5
0
 /**
  * Create default Admin Spec for RIA
  *
  * @param User $ria
  * @return BillingSpec
  */
 public function initDefaultAdminSpec(User $ria)
 {
     $billingSpec = new BillingSpec();
     $billingSpec->setType(BillingSpec::TYPE_TIER);
     $billingSpec->setName('Admin spec for ' . $ria->getRiaCompanyInformation()->getName());
     $billingSpec->addAppointedUser($ria);
     $billingSpec->setMinimalFee(0.0);
     return $billingSpec;
 }
コード例 #6
0
ファイル: LoadAdminData.php プロジェクト: junjinZ/wealthbot
 private function createAdminFees(ObjectManager $manager, User $adminUser)
 {
     $fees = array(array('fee_with_retirement' => 0.004, 'fee_without_retirement' => 0.0025, 'tier_top' => Fee::INFINITY));
     $adminBillingSpec = new BillingSpec();
     $adminBillingSpec->setName('Admin Billing Spec for new RIA');
     $adminBillingSpec->setMinimalFee(0);
     $adminBillingSpec->setType(BillingSpec::TYPE_TIER);
     $adminBillingSpec->setMaster(true);
     $adminBillingSpec->setOwner(null);
     foreach ($fees as $feeRow) {
         $fee = new Fee();
         $fee->setFeeWithRetirement($feeRow['fee_with_retirement']);
         $fee->setFeeWithoutRetirement($feeRow['fee_without_retirement']);
         $fee->setTierTop($feeRow['tier_top']);
         $adminBillingSpec->addFee($fee);
     }
     $manager->persist($adminBillingSpec);
 }