Skip to content
This repository was archived by the owner on Feb 21, 2023. It is now read-only.

Commit e44f985

Browse files
committed
Configure IPCA + Selic annual tax rate.
1 parent f59e35a commit e44f985

File tree

1 file changed

+63
-30
lines changed

1 file changed

+63
-30
lines changed
Lines changed: 63 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,68 @@
1-
using System;
2-
using System.Text.Json.Serialization;
3-
4-
namespace FinancialManager.Data.Models;
1+
namespace FinancialManager.Data.Models;
52

63
public class InvestmentOption
74
{
8-
public int Code { get; init; }
9-
public string Logo { get; init; } = string.Empty;
10-
public int ResponsibleCode { get; init; }
11-
public int StockCode { get; init; }
12-
public string StockDescription { get; init; } = string.Empty;
13-
public int StockFcCode { get; init; }
14-
public string Responsible { get; init; } = string.Empty;
15-
public double TaxRate { get; init; }
16-
public string Index { get; init; } = string.Empty;
17-
public double Percentage { get; init; }
18-
public int Deadline { get; init; }
19-
public string ExpireDate { get; init; } = string.Empty;
20-
public double Minimum { get; init; }
21-
public double Pu { get; init; }
22-
public string StockIssueType { get; init; } = string.Empty;
23-
public string Remuneration { get; init; } = string.Empty;
24-
public string Liquidity { get; init; } = string.Empty;
25-
public string Ir { get; init; } = string.Empty;
26-
public string Aba { get; init; } = string.Empty;
27-
public int Suitability { get; init; }
28-
public string Secured { get; init; } = string.Empty;
29-
public string Qualified { get; init; } = string.Empty;
30-
public string Rating { get; init; } = string.Empty;
31-
public double Bond { get; init; }
32-
public bool Selected { get; init; }
33-
public double SelicRate { get; set; }
5+
public int Code { get; init; }
6+
public string Logo { get; init; } = string.Empty;
7+
public int ResponsibleCode { get; init; }
8+
public int StockCode { get; init; }
9+
public string StockDescription { get; init; } = string.Empty;
10+
public int StockFcCode { get; init; }
11+
public string Responsible { get; init; } = string.Empty;
12+
public double TaxRate { get; init; }
13+
public string Index { get; init; } = string.Empty;
14+
public double Percentage { get; init; }
15+
public int Deadline { get; init; }
16+
public string ExpireDate { get; init; } = string.Empty;
17+
public double Minimum { get; init; }
18+
public double Pu { get; init; }
19+
public string StockIssueType { get; init; } = string.Empty;
20+
public string Remuneration { get; init; } = string.Empty;
21+
public string Liquidity { get; init; } = string.Empty;
22+
public string Ir { get; init; } = string.Empty;
23+
public string Aba { get; init; } = string.Empty;
24+
public int Suitability { get; init; }
25+
public string Secured { get; init; } = string.Empty;
26+
public string Qualified { get; init; } = string.Empty;
27+
public string Rating { get; init; } = string.Empty;
28+
public double Bond { get; init; }
29+
public bool Selected { get; init; }
30+
public double SelicRate { get; set; }
3431
public double IpcaRate { get; set; }
32+
public double AnnualTaxRate => this.Index switch
33+
{
34+
"IPC-A" => ((Math.Pow(1 + (this.IpcaRate / 100d), 1 * 12d) - 1) * 100) + this.TaxRate,
35+
"CDI" => this.Percentage * this.SelicRate / 100,
36+
"PRE" => this.TaxRate,
37+
_ => this.TaxRate
38+
};
39+
40+
public double MonthTaxRate => (Math.Pow(1 + (this.AnnualTaxRate / 100d), 1 / 12d) - 1) * 100;
41+
public double DayTaxRate => (Math.Pow(1 + (this.MonthTaxRate / 100d), 1 / 30d) - 1) * 100;
42+
public double IrTaxeRate => this.GetIrTaxeRate(this.Deadline);
43+
44+
double GetIrTaxeRate(int deadLine)
45+
{
46+
if (deadLine <= 180)
47+
{
48+
return 22.50;
49+
}
50+
else if (deadLine > 180 && deadLine <= 365)
51+
{
52+
return 20;
53+
}
54+
else if (deadLine > 365 && deadLine <= 720)
55+
{
56+
return 17.50;
57+
}
58+
else if (deadLine > 720)
59+
{
60+
return 15;
61+
}
62+
else
63+
{
64+
return 22.50;
65+
}
66+
}
3567
}
68+

0 commit comments

Comments
 (0)