-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.java
More file actions
executable file
·152 lines (128 loc) · 4.26 KB
/
User.java
File metadata and controls
executable file
·152 lines (128 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class User {
private String name;
private Investment investAccount;
private ArrayList<Investment> investments = new ArrayList<>();
private double annualSalary;
private double buyingPrice;
private double sellingPrice;
private int years;
private boolean resident;
private double actualCGTProfit;
Map<String, Object> cgtDetailsMap = new HashMap<>();
// Constructor
public User() {
// Assign initial values
investAccount = new Investment();
name = "";
annualSalary = 0;
buyingPrice = 0;
sellingPrice = 0;
years = 0;
resident = true;
}
public String getName() {
// Get user name
return (name);
}
public boolean getRecidencyStatus() {
// Get user's residency status
return (resident);
}
public double getBuyingPrice() {
// Get user's crypto buying price
return (buyingPrice);
}
// Get user's crypto selling price
public double getSellingPrice() {
// Get user's crypto selling price
return (sellingPrice);
}
public double getAnnualSalary() {
// Get user's annual salary
return (annualSalary);
}
public ArrayList<Investment> getInvestments() {
// Get all investments
return (investments);
}
// Get Capital Gain Tax Details
public Map<String, Object> getCgtDetailsMap() {
return cgtDetailsMap;
}
public void setCgtDetailsMap(Map<String, Object> cgtDetailsMap) {
// Set Capital Gain Tax Details
this.cgtDetailsMap = cgtDetailsMap;
}
public void setName(String inputName) {
// Set user's name
name = inputName;
}
public void setInvestments(ArrayList<Investment> investments) {
// Set all investments
this.investments = investments;
}
public void setInvestment(double amt1, double amt2, double amt3, int sel) {
// Set each investment
// initialize investment class object
investAccount = new Investment();
// Call public method from Investment class and set investment information to the obejct
investAccount.setAllDeposits(amt1, amt2, amt3);
investAccount.setcoinSelection(sel);
// Add each object to a Object ArrayList
investments.add(investAccount);
}
public void setUserDetails(String newName, double newAnnualSalary,
double newBuyingPrice, double newSellingPrice,
int newYears, boolean newResident) {
// Assign values
name = newName;
annualSalary = newAnnualSalary;
buyingPrice = newBuyingPrice;
sellingPrice = newSellingPrice;
years = newYears;
resident = newResident;
}
public void mCalculateCGT() {
double CGTTaxableProfit = (sellingPrice - buyingPrice) / years;
double annualIncome = annualSalary + CGTTaxableProfit;
double taxRate = 0;
// Check resident status and assign tax rate according to annual income
if (resident) {
if (annualIncome <= 18200)
taxRate = 0;
else if (annualIncome <= 45000)
taxRate = 0.19;
else if (annualIncome <= 120000)
taxRate = 0.325;
else if (annualIncome <= 180000)
taxRate = 0.37;
else
taxRate = 0.45;
} else {
if (annualIncome <= 120000)
taxRate = 0.325;
else if (annualIncome <= 180000)
taxRate = 0.37;
else
taxRate = 0.45;
}
// Calculate CGT
double CGTtax = taxRate * CGTTaxableProfit;
// Calculate actual profit
actualCGTProfit = CGTTaxableProfit - CGTtax;
// Put data into map
cgtDetailsMap.put("taxRate", taxRate);
cgtDetailsMap.put("CGTtax", CGTtax);
cgtDetailsMap.put("actualCGTProfit", actualCGTProfit);
cgtDetailsMap.put("remainingActualCGTProfit", actualCGTProfit);
}
public void mShowCryptoTable() {
investAccount.mShowCryptoTable();
}
public void mCalculateCrypto() {
investAccount.mCalculateCrypto();
}
}