-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathincome_statements_test.go
133 lines (127 loc) · 6.96 KB
/
income_statements_test.go
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
package alphavantage
import (
"testing"
"github.com/AMekss/assert"
)
func TestToIncomeStatements(t *testing.T) {
var buf = `
{
"symbol": "IBM",
"annualReports": [
{
"fiscalDateEnding": "2020-12-31",
"reportedCurrency": "USD",
"grossProfit": "35575000000",
"totalRevenue": "73620000000",
"costOfRevenue": "38046000000",
"costofGoodsAndServicesSold": "439000000",
"operatingIncome": "4609000000",
"sellingGeneralAndAdministrative": "23082000000",
"researchAndDevelopment": "6333000000",
"operatingExpenses": "30966000000",
"investmentIncomeNet": "None",
"netInterestIncome": "-1288000000",
"interestIncome": "105000000",
"interestExpense": "1288000000",
"nonInterestIncome": "None",
"otherNonOperatingIncome": "-861000000",
"depreciation": "4227000000",
"depreciationAndAmortization": "2468000000",
"incomeBeforeTax": "4726000000",
"incomeTaxExpense": "-864000000",
"interestAndDebtExpense": "1288000000",
"netIncomeFromContinuingOperations": "5501000000",
"comprehensiveIncomeNetOfTax": "4850000000",
"ebit": "6014000000",
"ebitda": "8482000000",
"netIncome": "5590000000"
}
],
"quarterlyReports": [
{
"fiscalDateEnding": "2021-06-30",
"reportedCurrency": "USD",
"grossProfit": "9004000000",
"totalRevenue": "18745000000",
"costOfRevenue": "9741000000",
"costofGoodsAndServicesSold": "103000000",
"operatingIncome": "2304000000",
"sellingGeneralAndAdministrative": "5334000000",
"researchAndDevelopment": "1657000000",
"operatingExpenses": "6700000000",
"investmentIncomeNet": "None",
"netInterestIncome": "-281000000",
"interestIncome": "11000000",
"interestExpense": "281000000",
"nonInterestIncome": "None",
"otherNonOperatingIncome": "-315000000",
"depreciation": "1050000000",
"depreciationAndAmortization": "630000000",
"incomeBeforeTax": "1552000000",
"incomeTaxExpense": "227000000",
"interestAndDebtExpense": "281000000",
"netIncomeFromContinuingOperations": "1325000000",
"comprehensiveIncomeNetOfTax": "1930000000",
"ebit": "1833000000",
"ebitda": "2463000000",
"netIncome": "1325000000"
}
]
}
`
incomeStatements, err := toIncomeStatements([]byte(buf))
assert.NoError(t.Fatalf, err)
assert.EqualStrings(t, "IBM", incomeStatements.Symbol)
assert.EqualStrings(t, "2020-12-31", incomeStatements.AnnualReports[0].FiscalDateEnding)
assert.EqualStrings(t, "USD", incomeStatements.AnnualReports[0].ReportedCurrency)
assert.EqualInt(t, 35575000000, int(incomeStatements.AnnualReports[0].GrossProfit))
assert.EqualInt(t, 73620000000, int(incomeStatements.AnnualReports[0].TotalRevenue))
assert.EqualInt(t, 38046000000, int(incomeStatements.AnnualReports[0].CostOfRevenue))
assert.EqualInt(t, 439000000, int(incomeStatements.AnnualReports[0].CostOfGoodsAndServicesSold))
assert.EqualInt(t, 4609000000, int(incomeStatements.AnnualReports[0].OperatingIncome))
assert.EqualInt(t, 23082000000, int(incomeStatements.AnnualReports[0].SellingGeneralAndAdministrative))
assert.EqualInt(t, 6333000000, int(incomeStatements.AnnualReports[0].ResearchAndDevelopment))
assert.EqualInt(t, 30966000000, int(incomeStatements.AnnualReports[0].OperatingExpenses))
assert.EqualInt(t, 0, int(incomeStatements.AnnualReports[0].InvestmentIncomeNet))
assert.EqualInt(t, -1288000000, int(incomeStatements.AnnualReports[0].NetInterestIncome))
assert.EqualInt(t, 105000000, int(incomeStatements.AnnualReports[0].InterestIncome))
assert.EqualInt(t, 1288000000, int(incomeStatements.AnnualReports[0].InterestExpense))
assert.EqualInt(t, 0, int(incomeStatements.AnnualReports[0].NonInterestIncome))
assert.EqualInt(t, -861000000, int(incomeStatements.AnnualReports[0].OtherNonOperatingIncome))
assert.EqualInt(t, 4227000000, int(incomeStatements.AnnualReports[0].Depreciation))
assert.EqualInt(t, 2468000000, int(incomeStatements.AnnualReports[0].DepreciationAndAmortization))
assert.EqualInt(t, 4726000000, int(incomeStatements.AnnualReports[0].IncomeBeforeTax))
assert.EqualInt(t, -864000000, int(incomeStatements.AnnualReports[0].IncomeTaxExpense))
assert.EqualInt(t, 1288000000, int(incomeStatements.AnnualReports[0].InterestAndDebtExpense))
assert.EqualInt(t, 5501000000, int(incomeStatements.AnnualReports[0].NetIncomeFromContinuingOperations))
assert.EqualInt(t, 4850000000, int(incomeStatements.AnnualReports[0].ComprehensiveIncomeNetOfTax))
assert.EqualInt(t, 6014000000, int(incomeStatements.AnnualReports[0].Ebit))
assert.EqualInt(t, 8482000000, int(incomeStatements.AnnualReports[0].Ebitda))
assert.EqualInt(t, 5590000000, int(incomeStatements.AnnualReports[0].NetIncome))
assert.EqualStrings(t, "2021-06-30", incomeStatements.QuarterlyReports[0].FiscalDateEnding)
assert.EqualStrings(t, "USD", incomeStatements.QuarterlyReports[0].ReportedCurrency)
assert.EqualInt(t, 9004000000, int(incomeStatements.QuarterlyReports[0].GrossProfit))
assert.EqualInt(t, 18745000000, int(incomeStatements.QuarterlyReports[0].TotalRevenue))
assert.EqualInt(t, 9741000000, int(incomeStatements.QuarterlyReports[0].CostOfRevenue))
assert.EqualInt(t, 103000000, int(incomeStatements.QuarterlyReports[0].CostOfGoodsAndServicesSold))
assert.EqualInt(t, 2304000000, int(incomeStatements.QuarterlyReports[0].OperatingIncome))
assert.EqualInt(t, 5334000000, int(incomeStatements.QuarterlyReports[0].SellingGeneralAndAdministrative))
assert.EqualInt(t, 1657000000, int(incomeStatements.QuarterlyReports[0].ResearchAndDevelopment))
assert.EqualInt(t, 6700000000, int(incomeStatements.QuarterlyReports[0].OperatingExpenses))
assert.EqualInt(t, 0, int(incomeStatements.QuarterlyReports[0].InvestmentIncomeNet))
assert.EqualInt(t, -281000000, int(incomeStatements.QuarterlyReports[0].NetInterestIncome))
assert.EqualInt(t, 11000000, int(incomeStatements.QuarterlyReports[0].InterestIncome))
assert.EqualInt(t, 281000000, int(incomeStatements.QuarterlyReports[0].InterestExpense))
assert.EqualInt(t, 0, int(incomeStatements.QuarterlyReports[0].NonInterestIncome))
assert.EqualInt(t, -315000000, int(incomeStatements.QuarterlyReports[0].OtherNonOperatingIncome))
assert.EqualInt(t, 1050000000, int(incomeStatements.QuarterlyReports[0].Depreciation))
assert.EqualInt(t, 630000000, int(incomeStatements.QuarterlyReports[0].DepreciationAndAmortization))
assert.EqualInt(t, 1552000000, int(incomeStatements.QuarterlyReports[0].IncomeBeforeTax))
assert.EqualInt(t, 227000000, int(incomeStatements.QuarterlyReports[0].IncomeTaxExpense))
assert.EqualInt(t, 281000000, int(incomeStatements.QuarterlyReports[0].InterestAndDebtExpense))
assert.EqualInt(t, 1325000000, int(incomeStatements.QuarterlyReports[0].NetIncomeFromContinuingOperations))
assert.EqualInt(t, 1930000000, int(incomeStatements.QuarterlyReports[0].ComprehensiveIncomeNetOfTax))
assert.EqualInt(t, 1833000000, int(incomeStatements.QuarterlyReports[0].Ebit))
assert.EqualInt(t, 2463000000, int(incomeStatements.QuarterlyReports[0].Ebitda))
assert.EqualInt(t, 1325000000, int(incomeStatements.QuarterlyReports[0].NetIncome))
}