def showAccountsTable(client): total = ClientAccount.getTotalScoreByClient(client=client) context = { 'client': client, 'total': total, 'show_action_btn': True, } return render_to_string('client/profile_accounts_list.html', context)
def showAccountsTable(request): # Get the user object client = request.user if (client is None) or (not client.hasRole('ROLE_CLIENT')): return JsonResponse({ 'status': 'error', 'message': 'Client does not exist.', }) total = ClientAccount.getTotalScoreByClient(client=client) print(total) context = { 'client': client, 'total': total, 'show_action_btn': True, } return render(request, 'client/profile_accounts_list.html', context)
def checkAccountsSum(request): if (not request.is_ajax()): raise Http404() # Get the user object client = request.user ria = client.profile.ria_user riaMinAssetSize = ria.riacompanyinformation.min_asset_size total = ClientAccount.getTotalScoreByClient(client=client) if riaMinAssetSize > total['value']: message = 'You must invest at least $' + '{0:.2f}'.format( riaMinAssetSize) + ' with us.' return JsonResponse({ 'status': 'error', 'message': message, }) return JsonResponse({ 'status': 'success', })
def index(request): print("-----http-----",request.__dict__) clientPortfolioManager = ClientPortfolioManager() # Get the user object email = Email.objects.last().email client = get_object_or_404(User, email=email) ria = client.profile.ria_user # Get client's portfolio clientPortfolio = clientPortfolioManager.getCurrentPortfolio(client=client) if clientPortfolio is None: clientPortfolio = clientPortfolioManager.getActivePortfolio(client=client) if clientPortfolio is None: raise Http404() companyInformation = ria.riacompanyinformation portfolio = clientPortfolio.portfolio isQualified = manageQualified( session=request.session, companyInformation=companyInformation, isQualified=request.GET.get('is_qualified') ) isFinal = False # If client has final portfolio if clientPortfolio.isAdvisorApproved(): isFinal = True if client.profile.registration_step < 4: profile = client.profile profile.registration_step = 4 profile.save() elif clientPortfolio.isProposed(): existWorkflow = None # Skip implementing workflow at this moment portfolioInformationManager = PortfolioInformationManager() clientAccounts = ClientAccount.objects.filter(client=client) retirementAccounts = ClientAccount.objects.filter(client=client, groupType__group__name=AccountGroup.GROUP_EMPLOYER_RETIREMENT) form = PortfolioForm() # Skip document at this moment documents = { 'ria_investment_management_agreement': '#', } portfolio_information = portfolioInformationManager.getPortfolioInformation(user=client, model=portfolio, isQualified=isQualified) client.appointedBillingSpec.calcFeeTier() data = { 'is_final': isFinal, 'client': client, 'client_accounts': clientAccounts, 'total': ClientAccount.getTotalScoreByClient(client=client), 'ria_company_information': companyInformation, 'has_retirement_account': True if retirementAccounts.exists() else False, 'portfolio_information': portfolio_information, 'show_sas_cash': containsSasCash(clientAccounts), 'is_use_qualified_models': companyInformation.is_use_qualified_models, 'form': form, 'signing_date': datetime.now(), 'documents': documents, 'action': 'client_portfolio', } return render(request, 'client/portfolio_index.html', data)
def suggestedPortfolio(request, client_id, client_view=0): clientPortfolioManager = ClientPortfolioManager() # Get the ria and client objects ria = request.user client = get_object_or_404(User, pk=client_id) clientPortfolio = clientPortfolioManager.getActivePortfolio(client=client) if clientPortfolio is None: raise Http404("This client does not have suggested portfolio.") # Skip implementing mailer at this moment portfolio = clientPortfolio.portfolio if request.method == 'POST': settingsForm = SuggestedPortfolioForm(request.POST, instance=client.profile, clientPortfolio=clientPortfolio) if settingsForm.is_valid(): portfolio = settingsForm.save(commit=False) else: settingsForm = SuggestedPortfolioForm(instance=client.profile, clientPortfolio=clientPortfolio) companyInformation = ria.riacompanyinformation isUseQualified = companyInformation.isUseQualifiedModels() isQualified = False if isUseQualified: # Skip implementing isQualified setting logic at this moment pass form = RiaClientAccountForm(client=client) clientAccounts = ClientAccount.findConsolidatedAccountsByClient( client=client) portfolioInformationManager = PortfolioInformationManager() portfolio_information = portfolioInformationManager.getPortfolioInformation( user=client, model=portfolio, isQualified=isQualified) client.appointedBillingSpec.calcFeeTier() if bool(client_view): parent_template = 'ria/clear_layout.html' else: parent_template = 'ria/dashboard_index.html' context = { 'is_client_view': bool(client_view), 'user': ria, 'form': form, 'total': ClientAccount.getTotalScoreByClient(client=client), 'client': client, 'client_accounts': clientAccounts, 'settings_form': settingsForm, 'client_answers': ClientQuestionnaireAnswer.objects.filter(client=client), 'has_retirement_account': ClientAccount.hasRetirementAccount(client=client), 'ria_company_information': ria.riacompanyinformation, 'client_has_final_portfolio': clientPortfolio.isAdvisorApproved(), 'portfolio_information': portfolio_information, 'is_use_qualified_models': isUseQualified, 'action': 'ria_suggested_portfolio', 'billing_spec': client.appointedBillingSpec, 'parent_template': parent_template, } return render(request, 'ria/prospects_suggested_portfolio.html', context)