Exemplo n.º 1
0
    def setUp(self):
        for atid, _ in constants.ACCOUNT_TYPES:
            AccountTypeRiskProfileGroupFactory.create(account_type=atid)
        self.today = today = date(2016, 5, 1)
        self.older_fiscal_year = FiscalYearFactory.create()
        self.older_fiscal_year2 = FiscalYearFactory.create()
        self.current_fiscal_year = FiscalYearFactory.create(
            year=today.year,
            begin_date=datetime(year=today.year, month=1, day=1),
            end_date=datetime(year=today.year, month=12, day=31))
        self.firm = FirmFactory.create()
        self.firm.fiscal_years.add(self.older_fiscal_year)
        self.firm.fiscal_years.add(self.older_fiscal_year2)
        self.firm.fiscal_years.add(self.current_fiscal_year)
        # add an advisor for the firm
        self.advisor = AdvisorFactory.create(firm=self.firm)
        # add a client account for the firm
        self.betasmartz_client = ClientFactory.create(advisor=self.advisor)
        self.client_account = ClientAccountFactory.create(
            primary_owner=self.betasmartz_client)
        # add some goals
        self.goal1 = GoalFactory.create(account=self.client_account)
        self.goal2 = GoalFactory.create(account=self.client_account)
        # add some transaction fees associated with the goals
        # there are two fees here, one for the from_goal1, and one for the to_goal2
        self.fee1 = TransactionFactory.create(
            reason=Transaction.REASON_FEE,
            status=Transaction.STATUS_EXECUTED,
            from_goal=self.goal1,
            to_goal=self.goal2,
            amount=500,
            executed=today - relativedelta(months=1))

        # add new advisor to firm
        # add new clientacounts for advisor and fees
        self.advisor2 = AdvisorFactory.create(firm=self.firm)
        self.betasmartz_client2 = ClientFactory.create(advisor=self.advisor2)
        self.client_account2 = ClientAccountFactory.create(
            primary_owner=self.betasmartz_client2)
        self.goal3 = GoalFactory.create(account=self.client_account2)
        # add some more fees
        self.fee2 = TransactionFactory.create(
            reason=Transaction.REASON_FEE,
            status=Transaction.STATUS_EXECUTED,
            to_goal=self.goal3,
            amount=800,
            executed=self.older_fiscal_year.begin_date +
            relativedelta(months=1))
Exemplo n.º 2
0
    def test_get_firm_analytics_worth_and_risk_filter(self):
        # /firm/analytics?worth=affluent&risk=0&risk=20&advisor=&client=
        url = reverse('firm:analytics') + '?worth=affluent&risk=0&risk=20&advisor=&client='
        rep = AuthorisedRepresentativeFactory.create(firm=self.firm)
        advisor = AdvisorFactory.create(firm=self.firm)
        aclient = ClientFactory.create(advisor=advisor)
        aaccount = ClientAccountFactory.create(primary_owner=aclient)
        goal = GoalFactory.create(account=aaccount)

        self.client.login(username=rep.user.email, password='******')
        response = self.client.get(url)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
Exemplo n.º 3
0
 def test_security_statement(self):
     advisor = AdvisorFactory.create()
     advisor.country = 'US'
     advisor.save()
     test_security_statement_data = {'some': 'data'}
     advisor.regional_data = {
         'ssn': '555-55-5555',
         'social_security_statement': 'https://some.url/on/softlayer/cloud/storage',
         'social_security_statement_data': test_security_statement_data,
     }
     advisor.clean()
     self.assertEqual(advisor.regional_data.get('social_security_statement'), 'https://some.url/on/softlayer/cloud/storage')
     self.assertEqual(advisor.regional_data.get('social_security_statement_data'), test_security_statement_data)
Exemplo n.º 4
0
 def test_tax_transcript(self):
     advisor = AdvisorFactory.create()
     advisor.country = 'US'
     advisor.save()
     test_transcript_data = {'some': 'data'}
     advisor.regional_data = {
         'politically_exposed': True,
         'ssn': '555-55-5555',
         'tax_transcript': 'https://some.url/on/softlayer/cloud/storage',
         'tax_transcript_data': test_transcript_data,
     }
     advisor.clean()
     self.assertEqual(advisor.regional_data.get('tax_transcript'), 'https://some.url/on/softlayer/cloud/storage')
     self.assertEqual(advisor.regional_data.get('tax_transcript_data'), test_transcript_data)
    def setUp(self):
        self.support_group = GroupFactory(name=GROUP_SUPPORT_STAFF)
        self.account = ClientAccountFactory.create()

        self.advisor = self.account.primary_owner.advisor
        self.firm = self.advisor.firm
        self.advisor2 = AdvisorFactory.create(firm=self.firm)
        self.betasmartz_client2 = ClientFactory.create(advisor=self.advisor2)
        self.account2 = ClientAccountFactory.create(
            primary_owner=self.betasmartz_client2)
        self.account_group = AccountGroupFactory.create(advisor=self.advisor)
        self.account_group2 = AccountGroupFactory.create(advisor=self.advisor2)
        self.account.account_group = self.account_group
        self.account.save()
        self.account2.account_group = self.account_group2
        self.account2.save()
        self.rep = AuthorisedRepresentativeFactory.create(firm=self.firm)
Exemplo n.º 6
0
    def test_update_risk_profile_responses(self):
        url = reverse('api:v1:client-risk-profile-responses',
                      args=[self.betasmartz_client.id])
        self.client.force_authenticate(self.user)
        risk_profile_response = RiskProfileAnswerFactory.create()
        data = [risk_profile_response.id]
        response = self.client.put(url, data)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data, data)

        other_advisor = AdvisorFactory.create()
        self.client.force_authenticate(other_advisor.user)
        response = self.client.put(url, data)
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

        other_client = ClientFactory.create()
        self.client.force_authenticate(other_client.user)
        response = self.client.put(url, data)
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Exemplo n.º 7
0
    def test_create_client_with_advisor(self):
        """
        Test advisor is ignored, as advisor comes from invite.
        """
        # We need an accepted invitation to be able to create a client
        usr = UserFactory.create()
        invite = EmailInviteFactory.create(user=usr,
                                           status=EmailInvite.STATUS_ACCEPTED)

        url = reverse('api:v1:client-list')
        advisor = AdvisorFactory.create()
        regional_data = {
            'ssn': '555-55-5555',
            'politically_exposed': True,
        }
        data = {
            "advisor_agreement": True,
            "betasmartz_agreement": True,
            "date_of_birth": date(2016, 9, 21),
            "employment_status": EMPLOYMENT_STATUS_FULL_TIME,
            "gender": GENDER_MALE,
            "income": 1234,
            "phone_num": "+1-234-234-2342",
            "residential_address": {
                "address": "123 My Street\nSome City",
                "post_code": "112233",
                "region": {
                    "name": "New South Wales",
                    "country": "AU",
                    "code": "NSW",
                }
            },
            "advisor": advisor.id,
            'regional_data': regional_data,
        }
        self.client.force_authenticate(usr)
        response = self.client.post(url, data)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertNotEqual(invite.advisor.id, advisor.id)
        self.assertEqual(response.data['advisor']['id'], invite.advisor.id)
Exemplo n.º 8
0
 def test_security_statement(self):
     advisor = AdvisorFactory.create()
     advisor.country = 'US'
     advisor.save()
     test_security_statement_data = {'some': 'data'}
     advisor.regional_data = {
         'politically_exposed':
         True,
         'ssn':
         '555-55-5555',
         'social_security_statement':
         'https://some.url/on/softlayer/cloud/storage',
         'social_security_statement_data':
         json.dumps(test_security_statement_data),
     }
     advisor.clean()
     self.assertEqual(
         advisor.regional_data.get('social_security_statement'),
         'https://some.url/on/softlayer/cloud/storage')
     self.assertEqual(
         json.loads(
             advisor.regional_data.get('social_security_statement_data')),
         test_security_statement_data)