12
12
13
13
alias Transactions.Repo ;
14
14
alias Transactions.Accounts.User ;
15
+ alias Transactions.Operations.Type ;
16
+ alias Transactions.Operations.Operation ;
15
17
18
+ Repo . delete_all Operation
16
19
Repo . delete_all User
20
+ Repo . delete_all Type
17
21
18
- Repo . insert! ( % User { age: 25 , email: "[email protected] " , first_name: "James" , last_name: "Bond" } ) ;
19
- Repo . insert! ( % User { age: 36 , email: "[email protected] " , first_name: "Yurii" , last_name: "Bodarev" } ) ;
20
- Repo . insert! ( % User { age: 30 , email: "[email protected] " , first_name: "Ivan" , last_name: "Zushko" } ) ;
21
- Repo . insert! ( % User { age: 66 , email: "[email protected] " , first_name: "Deleted" , last_name: "User" , is_deleted: true } ) ;
22
+ # Users
23
+ user_james = Repo . insert! ( % User { age: 25 , email: "[email protected] " , first_name: "James" , last_name: "Bond" } )
24
+ user_yurii = Repo . insert! ( % User { age: 36 , email: "[email protected] " , first_name: "Yurii" , last_name: "Bodarev" } )
25
+ user_ivan = Repo . insert! ( % User { age: 30 , email: "[email protected] " , first_name: "Ivan" , last_name: "Zushko" } )
26
+ Repo . insert! ( % User { age: 66 , email: "[email protected] " , first_name: "Deleted" , last_name: "User" , is_deleted: true } )
27
+
28
+ # Operation types
29
+ debit_operation_type = Repo . insert! ( % Type { type: "debit" , description: "remove an amount of money from a users's account" } )
30
+ credit_operation_type = Repo . insert! ( % Type { type: "credit" , description: "add an amount of money to a users's account" } )
31
+
32
+
33
+ # Operations
34
+ % Operation { amount: 10.0 , description: "Enumeration" , user: user_james , type: credit_operation_type }
35
+ |> Repo . insert!
36
+
37
+ % Operation { amount: - 5.0 , description: "Amazon sale" , user: user_james , type: debit_operation_type }
38
+ |> Repo . insert!
0 commit comments