Ejemplo n.º 1
0
    def test_get_members_of_user(self, mock_get_members):
        members = Members(config=TestConfig)

        mock_get_members.return_value = [{
            'membername': 'm1',
            'username': '******'
        }, {
            'membername': 'm3',
            'username': '******'
        }, {
            'membername': 'm2',
            'username': '******'
        }]
        self.assertEqual(['m1', 'm2', 'm3'], members.get_members_of_user('u1'))

        mock_get_members.return_value = [{
            'membername': 'm5',
            'username': '******'
        }, {
            'membername': 'm4',
            'username': '******'
        }]
        self.assertEqual(['m4', 'm5'], members.get_members_of_user('u2'))

        mock_get_members.return_value = []
        self.assertEqual([], members.get_members_of_user('u3'))
Ejemplo n.º 2
0
def delete_member(member):
    fds = FDs()
    if fds.fds_exists_for_member(member=member,
                                 for_user=current_user.username):
        flash(
            f'Member( {member} ) has first name / joint name in some FDs, first delete the FDs to delete this member.'
        )
        return redirect(url_for('allMembers'))

    members = Members()
    members.delete(member=member, for_user=current_user.username)
    flash(f'Deleted member( {member} ) successfully !!')
    return redirect(url_for('allMembers'))
Ejemplo n.º 3
0
def allMembers():
    members = Members()

    form = MemberForm()
    if form.validate_on_submit():
        members.add(member=form.membername.data,
                    for_user=current_user.username)
        flash('Member {} saved successfully !!'.format(form.membername.data))
        return redirect(url_for('allMembers'))

    members_for_user = members.get_members_of_user(user=current_user.username)
    return render_template('members/allMembers.html',
                           title='Members',
                           form=form,
                           members=members_for_user)
Ejemplo n.º 4
0
def report_15g():
    members = Members()

    if request.method == 'GET':
        return render_template('report15g/report15g.html',
                               title='15G Report',
                               members=members.get_members_of_user(
                                   current_user.username))

    if request.method == 'POST':
        fy_start, fy_end = get_financial_year()
        return render_template(
            'report15g/report15g.html',
            title='15G Report',
            members=members.get_members_of_user(current_user.username),
            report=(generate_15g_report(for_member=(request.form['member']),
                                        for_user=current_user.username)),
            member=request.form['member'],
            fy=f'{fy_start} - {fy_end}')
Ejemplo n.º 5
0
    def test_get_all_members_is_sorted(self, mock_exists):
        members = Members(config=TestConfig)

        mock_exists.return_value = True if {
            'membername': 'm1',
            'username': '******'
        } in self.mock_members else False
        self.assertTrue(members.exists(member='m1', for_user='******'))

        mock_exists.return_value = True if {
            'membername': 'm2',
            'username': '******'
        } in self.mock_members else False
        self.assertTrue(members.exists(member='m2', for_user='******'))

        mock_exists.return_value = True if {
            'membername': 'm3',
            'username': '******'
        } in self.mock_members else False
        self.assertTrue(members.exists(member='m3', for_user='******'))

        mock_exists.return_value = True if {
            'membername': 'm4',
            'username': '******'
        } in self.mock_members else False
        self.assertFalse(members.exists(member='m4', for_user='******'))
Ejemplo n.º 6
0
def fd():
    fds = FDs()
    banks = Banks()
    members = Members()
    bank_branches = banks.get_all_bank_branch_names(
        for_user=current_user.username)
    form = FDForm(
        banks.get_all_bank_branch_names(for_user=current_user.username),
        members.get_members_of_user(user=current_user.username))

    if form.validate_on_submit():
        fd = {
            'bank_name': form.bank_name.data,
            'bank_branch': form.bank_branch.data,
            'first_name': form.first_name.data,
            'joint_name': form.joint_name.data,
            'mode': form.mode.data,
            'type': form.type.data,
            'interest_account': form.interest_account.data,
            'fd_number': form.fd_number.data,
            'start_date': form.start_date.data,
            'end_date': form.end_date.data,
            'period': form.period.data,
            'roi': form.roi.data,
            'principal_amount': form.principal_amount.data,
            'maturity_amount': form.maturity_amount.data
        }
        fds.add(fd=fd, for_user=current_user.username)
        flash('New FD added successfully !!')
        return redirect(url_for('fd'))

    all_fds = fds.get_all_fds(current_user.username)
    append_serial_number(all_fds)
    return render_template('fd/fd.html',
                           title='Fixed Deposits',
                           form=form,
                           fds=all_fds,
                           branches=bank_branches,
                           total_fds=len(all_fds))
Ejemplo n.º 7
0
 def test_delete_member(self, mock_delete):
     members = Members(config=TestConfig)
     members.delete(member='m1', for_user='******')
     mock_delete.assert_called_with(member='m1', for_user='******')
Ejemplo n.º 8
0
 def test_add_member(self, mock_add):
     members = Members(config=TestConfig)
     members.add(member='m1', for_user='******')
     mock_add.assert_called_with('m1', 'u1')
Ejemplo n.º 9
0
 def validate_membername(self, membername):
     if Members().exists(member=membername.data,
                         for_user=current_user.username
                         ):  # Validate member name is unique
         raise ValidationError(
             'Member already exists, use a different name.')