0
1
00:00:00,221 --> 00:00:03,361
Alright so let's continue and
let's work on the transfer
1

2
00:00:03,361 --> 00:00:08,241
money to another account. So
basically we want to create a
2

3
00:00:08,241 --> 00:00:12,241
function that will receive an
account. And we want to be able
3

4
00:00:12,241 --> 00:00:16,001
to make a deposit on this
account. So that shouldn't be
4

5
00:00:16,001 --> 00:00:19,281
too complicated. We're going to
create a new function that is
5

6
00:00:19,281 --> 00:00:24,161
going to be transfer money.
And we're going to send an
6

7
00:00:24,161 --> 00:00:28,721
amount of money so it's going
to be an amount number and we
7

8
00:00:28,721 --> 00:00:34,841
want to target an account. So
this will be a bank account. So
8

9
00:00:34,841 --> 00:00:40,121
I forgot here to say that it
returns a number and so
9

10
00:00:40,121 --> 00:00:44,281
transfer money is not going to
return anything. So transfer
10

11
00:00:44,281 --> 00:00:46,921
money well we just need to make
sure that we have enough money
11

12
00:00:46,921 --> 00:00:50,441
before sending it to the
account. But fortunately the
12

13
00:00:50,441 --> 00:00:53,641
withdraw is already doing
this check. So maybe what we
13

14
00:00:53,641 --> 00:01:02,301
can just do is a widthdraw of
this amount on our own account
14

15
00:01:02,301 --> 00:01:08,201
and right after that we can
just do a deposit of this
15

16
00:01:08,201 --> 00:01:11,481
amount on the other account.
And if for some reason I don't
16

17
00:01:11,481 --> 00:01:14,761
have enough money this is going
to throw an error and since I'm
17

18
00:01:14,761 --> 00:01:17,881
not catching it this is going
to crash and we won't go to the
18

19
00:01:17,881 --> 00:01:21,481
deposit. So technically we're
good with the transfer money to
19

20
00:01:21,481 --> 00:01:24,121
another account and we have
checked that the minimum
20

21
00:01:24,121 --> 00:01:28,281
balance is enough before doing
a withdraw or a transfer so
21

22
00:01:28,281 --> 00:01:33,161
that's perfect. Now let's work
on the mensual interest. So
22

23
00:01:33,161 --> 00:01:37,321
first we have to store
somewhere the percentage of
23

24
00:01:37,321 --> 00:01:40,921
menstrual interest. So we are
going to receive that from the
24

25
00:01:40,921 --> 00:01:46,521
constructor so let's do this so
we can go at the top here and
25

26
00:01:46,521 --> 00:01:52,601
we can create another private
interestRate that is going
26

27
00:01:52,601 --> 00:01:56,521
to be a number and I will have
an interest ceiling that will
27

28
00:01:56,521 --> 00:02:00,041
be the maximum amount the
interest rate is going to be
28

29
00:02:00,041 --> 00:02:08,361
calculated on, so interest
ceiling. And I'm going to
29

30
00:02:08,361 --> 00:02:11,481
receive that from my
constructor so interest rate
30

31
00:02:11,481 --> 00:02:16,121
and interest ceiling and these
are going to be numbers okay
31

32
00:02:16,121 --> 00:02:21,161
and I'm going to receive that
so interest rate
32

33
00:02:24,221 --> 00:02:28,881
and interest ceiling. So
basically we just want to have
33

34
00:02:28,881 --> 00:02:31,921
a function that would be in
charge of returning what should
34

35
00:02:31,921 --> 00:02:36,721
be the mensual interest. So
I'm going to create another
35

36
00:02:36,721 --> 00:02:41,321
function here. And I'm going to
call it get mensual
36

37
00:02:41,321 --> 00:02:49,361
interests. So this is going to
return a number and technically
37

38
00:02:49,361 --> 00:02:52,401
it doesn't need any parameters
because it's going to use only
38

39
00:02:52,401 --> 00:02:57,361
what's inside our class. So the
balance, the interest rate and
39

40
00:02:57,361 --> 00:03:04,001
the interest setting. So first
we have to check if the balance
40

41
00:03:04,001 --> 00:03:09,441
is above the limit the interest
ceiling limit so if this
41

42
00:03:09,441 --> 00:03:17,041
balance is greater than this
interest ceiling then we're
42

43
00:03:17,041 --> 00:03:20,001
going to calculate the interest
rate on the maximum on the
43

44
00:03:20,001 --> 00:03:24,501
ceiling so we're going to
return this dot interest
44

45
00:03:24,501 --> 00:03:30,581
ceiling multiply by this.interest rate 
otherwise we're
45

46
00:03:30,581 --> 00:03:33,861
under the interest ceiling so
we're going to return this dot
46

47
00:03:33,861 --> 00:03:41,141
balance multiply by this
interest rate and we're good so
47

48
00:03:41,141 --> 00:03:45,301
technically now as you can see
an account expect both interest
48

49
00:03:45,301 --> 00:03:49,621
rate and interest ceiling so
for example here I could set it
49

50
00:03:49,621 --> 00:03:58,521
to one percent and the ceiling
to 50000 like this, and technically
50

51
00:03:58,521 --> 00:04:06,081
we should be able to calculate
I'm going to do that after now
51

52
00:04:06,081 --> 00:04:10,361
technically so I'm going to
open my console and I'm just to
52

53
00:04:10,361 --> 00:04:16,521
console log account one. get
mensual interest and let's
53

54
00:04:16,521 --> 00:04:24,961
see Zero. Oh right because I
don't have anymore money so I'm
54

55
00:04:24,961 --> 00:04:30,681
just going to remove all of
that for now So it should be
55

56
00:04:30,681 --> 00:04:39,321
calculated on 40000 and 1% of
40000 is 400. That is true. So
56

57
00:04:39,321 --> 00:04:41,961
it seems that the mensual
interest function is working.
57

58
00:04:41,961 --> 00:04:48,761
We're good. So technically this
and this are good. And we have
58

59
00:04:48,761 --> 00:04:54,501
even done the interest ceiling.
Okay so in the next video we're
59

60
00:04:54,501 --> 00:04:56,661
going to work on the favorites.
So let's do that in the next
60

61
00:04:56,661 --> 00:04:59,061
one.
