public function testCreatePartialPayouts() { $user = new User(); $referralUserLevel1 = new User(); $referralUserLevel2 = new User(); $referralUserLevel3 = new User(); // Setup referral hierarchy $user->setReferrer($referralUserLevel1); $referralUserLevel1->setReferrer($referralUserLevel2); $referralUserLevel2->setReferrer($referralUserLevel3); // Setup the account $account = new Account(); $account->setUser($user); $account->setPayoutPercentage(0.9); $account->setBroker(new Broker()); // Setup payment $payment = new Payment(); $payment->setAccount($account); $payment->setAmount(100); $this->paymentManager->createPartialPayouts($payment); $this->assertEquals(90, $user->getTotalPartialPayoutAmount()); $this->assertEquals(9, $referralUserLevel1->getTotalPartialPayoutAmount()); $this->assertEquals(5, $referralUserLevel2->getTotalPartialPayoutAmount()); $this->assertEquals(1, $referralUserLevel3->getTotalPartialPayoutAmount()); }
public function createAccount(Account $account) { $account->setPayoutPercentage($account->getBroker()->getBasePercentage()); $accountEvent = $this->createAccountEvent($account); $this->eventDispatcher->dispatch(AccountEvents::ACCOUNT_CREATED, $accountEvent); $this->em->persist($account); }
protected function createAccountForm(User $user, Broker $broker, BrokerAccountType $brokerAccountType = null) { $account = new Account(); $account->setUser($user); $account->setBroker($broker); if (!$brokerAccountType) { $brokerAccountType = $broker->getAccountTypes()->first(); } $account->setBrokerAccountType($brokerAccountType); return $this->createForm(new AccountFormType(), $account, array('broker' => $broker)); }
protected function createAccountCreatedEmailMessage(Account $account) { $broker = $account->getBroker(); $user = $account->getUser(); $email = $broker && $broker->getAccountConfirmationEmail() ? $broker->getAccountConfirmationEmail() : '*****@*****.**'; $subjectLine = 'Please Verify Account'; $template = 'Account:Verification\\broker'; $data = array('user' => $user, 'account' => $account, 'broker' => $broker); $message = $this->emailMessageManager->createEmailMessage($subjectLine, $template, $data); $message->setEmail($email); $message->setReplyTo('*****@*****.**'); return $message; }
public function setAccount(Account $account) { $this->account = $account; $this->setBroker($account->getBroker()); }