1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-10-30 07:40:05 -04:00
This commit is contained in:
Aaron Lindsay 2017-11-25 21:01:48 -05:00
parent 9cd2724416
commit d9ecaa530b
4 changed files with 43 additions and 43 deletions

View File

@ -20,8 +20,8 @@ func TestLuaAccounts(t *testing.T) {
accountids.Sort() accountids.Sort()
equalityString := "" equalityString := ""
for i, _ := range accountids { for i := range accountids {
for j, _ := range accountids { for j := range accountids {
if i == j { if i == j {
equalityString += "true" equalityString += "true"
} else { } else {

View File

@ -34,8 +34,8 @@ func TestLuaSecurities(t *testing.T) {
securityids.Sort() securityids.Sort()
equalityString := "" equalityString := ""
for i, _ := range securityids { for i := range securityids {
for j, _ := range securityids { for j := range securityids {
if i == j { if i == j {
equalityString += "true" equalityString += "true"
} else { } else {

View File

@ -155,14 +155,14 @@ func (t *TestData) Teardown() error {
var data = []TestData{ var data = []TestData{
{ {
users: []User{ users: []User{
User{ {
DefaultCurrency: 840, // USD DefaultCurrency: 840, // USD
Name: "John Smith", Name: "John Smith",
Username: "jsmith", Username: "jsmith",
Password: "hunter2", Password: "hunter2",
Email: "jsmith@example.com", Email: "jsmith@example.com",
}, },
User{ {
DefaultCurrency: 978, // Euro DefaultCurrency: 978, // Euro
Name: "Billy Bob", Name: "Billy Bob",
Username: "bbob6", Username: "bbob6",
@ -171,7 +171,7 @@ var data = []TestData{
}, },
}, },
securities: []handlers.Security{ securities: []handlers.Security{
handlers.Security{ {
UserId: 0, UserId: 0,
Name: "USD", Name: "USD",
Description: "US Dollar", Description: "US Dollar",
@ -180,7 +180,7 @@ var data = []TestData{
Type: handlers.Currency, Type: handlers.Currency,
AlternateId: "840", AlternateId: "840",
}, },
handlers.Security{ {
UserId: 0, UserId: 0,
Name: "SPY", Name: "SPY",
Description: "SPDR S&P 500 ETF Trust", Description: "SPDR S&P 500 ETF Trust",
@ -189,7 +189,7 @@ var data = []TestData{
Type: handlers.Stock, Type: handlers.Stock,
AlternateId: "78462F103", AlternateId: "78462F103",
}, },
handlers.Security{ {
UserId: 1, UserId: 1,
Name: "EUR", Name: "EUR",
Description: "Euro", Description: "Euro",
@ -198,7 +198,7 @@ var data = []TestData{
Type: handlers.Currency, Type: handlers.Currency,
AlternateId: "978", AlternateId: "978",
}, },
handlers.Security{ {
UserId: 0, UserId: 0,
Name: "EUR", Name: "EUR",
Description: "Euro", Description: "Euro",
@ -209,35 +209,35 @@ var data = []TestData{
}, },
}, },
prices: []handlers.Price{ prices: []handlers.Price{
handlers.Price{ {
SecurityId: 1, SecurityId: 1,
CurrencyId: 0, CurrencyId: 0,
Date: time.Date(2017, time.January, 2, 21, 0, 0, 0, time.UTC), Date: time.Date(2017, time.January, 2, 21, 0, 0, 0, time.UTC),
Value: "225.24", Value: "225.24",
RemoteId: "12387-129831-1238", RemoteId: "12387-129831-1238",
}, },
handlers.Price{ {
SecurityId: 1, SecurityId: 1,
CurrencyId: 0, CurrencyId: 0,
Date: time.Date(2017, time.January, 3, 21, 0, 0, 0, time.UTC), Date: time.Date(2017, time.January, 3, 21, 0, 0, 0, time.UTC),
Value: "226.58", Value: "226.58",
RemoteId: "12387-129831-1239", RemoteId: "12387-129831-1239",
}, },
handlers.Price{ {
SecurityId: 1, SecurityId: 1,
CurrencyId: 0, CurrencyId: 0,
Date: time.Date(2017, time.January, 4, 21, 0, 0, 0, time.UTC), Date: time.Date(2017, time.January, 4, 21, 0, 0, 0, time.UTC),
Value: "226.40", Value: "226.40",
RemoteId: "12387-129831-1240", RemoteId: "12387-129831-1240",
}, },
handlers.Price{ {
SecurityId: 1, SecurityId: 1,
CurrencyId: 0, CurrencyId: 0,
Date: time.Date(2017, time.January, 5, 21, 0, 0, 0, time.UTC), Date: time.Date(2017, time.January, 5, 21, 0, 0, 0, time.UTC),
Value: "227.21", Value: "227.21",
RemoteId: "12387-129831-1241", RemoteId: "12387-129831-1241",
}, },
handlers.Price{ {
SecurityId: 0, SecurityId: 0,
CurrencyId: 3, CurrencyId: 3,
Date: time.Date(2017, time.November, 16, 18, 49, 53, 0, time.UTC), Date: time.Date(2017, time.November, 16, 18, 49, 53, 0, time.UTC),
@ -246,49 +246,49 @@ var data = []TestData{
}, },
}, },
accounts: []handlers.Account{ accounts: []handlers.Account{
handlers.Account{ {
UserId: 0, UserId: 0,
SecurityId: 0, SecurityId: 0,
ParentAccountId: -1, ParentAccountId: -1,
Type: handlers.Asset, Type: handlers.Asset,
Name: "Assets", Name: "Assets",
}, },
handlers.Account{ {
UserId: 0, UserId: 0,
SecurityId: 0, SecurityId: 0,
ParentAccountId: 0, ParentAccountId: 0,
Type: handlers.Asset, Type: handlers.Asset,
Name: "Credit Union Checking", Name: "Credit Union Checking",
}, },
handlers.Account{ {
UserId: 0, UserId: 0,
SecurityId: 0, SecurityId: 0,
ParentAccountId: -1, ParentAccountId: -1,
Type: handlers.Expense, Type: handlers.Expense,
Name: "Expenses", Name: "Expenses",
}, },
handlers.Account{ {
UserId: 0, UserId: 0,
SecurityId: 0, SecurityId: 0,
ParentAccountId: 2, ParentAccountId: 2,
Type: handlers.Expense, Type: handlers.Expense,
Name: "Groceries", Name: "Groceries",
}, },
handlers.Account{ {
UserId: 0, UserId: 0,
SecurityId: 0, SecurityId: 0,
ParentAccountId: 2, ParentAccountId: 2,
Type: handlers.Expense, Type: handlers.Expense,
Name: "Cable", Name: "Cable",
}, },
handlers.Account{ {
UserId: 1, UserId: 1,
SecurityId: 2, SecurityId: 2,
ParentAccountId: -1, ParentAccountId: -1,
Type: handlers.Asset, Type: handlers.Asset,
Name: "Assets", Name: "Assets",
}, },
handlers.Account{ {
UserId: 1, UserId: 1,
SecurityId: 2, SecurityId: 2,
ParentAccountId: -1, ParentAccountId: -1,
@ -297,18 +297,18 @@ var data = []TestData{
}, },
}, },
transactions: []handlers.Transaction{ transactions: []handlers.Transaction{
handlers.Transaction{ {
UserId: 0, UserId: 0,
Description: "weekly groceries", Description: "weekly groceries",
Date: time.Date(2017, time.October, 15, 1, 16, 59, 0, time.UTC), Date: time.Date(2017, time.October, 15, 1, 16, 59, 0, time.UTC),
Splits: []*handlers.Split{ Splits: []*handlers.Split{
&handlers.Split{ {
Status: handlers.Reconciled, Status: handlers.Reconciled,
AccountId: 1, AccountId: 1,
SecurityId: -1, SecurityId: -1,
Amount: "-5.6", Amount: "-5.6",
}, },
&handlers.Split{ {
Status: handlers.Reconciled, Status: handlers.Reconciled,
AccountId: 3, AccountId: 3,
SecurityId: -1, SecurityId: -1,
@ -316,18 +316,18 @@ var data = []TestData{
}, },
}, },
}, },
handlers.Transaction{ {
UserId: 0, UserId: 0,
Description: "weekly groceries", Description: "weekly groceries",
Date: time.Date(2017, time.October, 31, 19, 10, 14, 0, time.UTC), Date: time.Date(2017, time.October, 31, 19, 10, 14, 0, time.UTC),
Splits: []*handlers.Split{ Splits: []*handlers.Split{
&handlers.Split{ {
Status: handlers.Reconciled, Status: handlers.Reconciled,
AccountId: 1, AccountId: 1,
SecurityId: -1, SecurityId: -1,
Amount: "-81.59", Amount: "-81.59",
}, },
&handlers.Split{ {
Status: handlers.Reconciled, Status: handlers.Reconciled,
AccountId: 3, AccountId: 3,
SecurityId: -1, SecurityId: -1,
@ -335,18 +335,18 @@ var data = []TestData{
}, },
}, },
}, },
handlers.Transaction{ {
UserId: 0, UserId: 0,
Description: "Cable", Description: "Cable",
Date: time.Date(2017, time.September, 2, 0, 00, 00, 0, time.UTC), Date: time.Date(2017, time.September, 2, 0, 00, 00, 0, time.UTC),
Splits: []*handlers.Split{ Splits: []*handlers.Split{
&handlers.Split{ {
Status: handlers.Reconciled, Status: handlers.Reconciled,
AccountId: 1, AccountId: 1,
SecurityId: -1, SecurityId: -1,
Amount: "-39.99", Amount: "-39.99",
}, },
&handlers.Split{ {
Status: handlers.Entered, Status: handlers.Entered,
AccountId: 4, AccountId: 4,
SecurityId: -1, SecurityId: -1,
@ -354,18 +354,18 @@ var data = []TestData{
}, },
}, },
}, },
handlers.Transaction{ {
UserId: 1, UserId: 1,
Description: "Gas", Description: "Gas",
Date: time.Date(2017, time.November, 1, 13, 19, 50, 0, time.UTC), Date: time.Date(2017, time.November, 1, 13, 19, 50, 0, time.UTC),
Splits: []*handlers.Split{ Splits: []*handlers.Split{
&handlers.Split{ {
Status: handlers.Reconciled, Status: handlers.Reconciled,
AccountId: 5, AccountId: 5,
SecurityId: -1, SecurityId: -1,
Amount: "-24.56", Amount: "-24.56",
}, },
&handlers.Split{ {
Status: handlers.Entered, Status: handlers.Entered,
AccountId: 6, AccountId: 6,
SecurityId: -1, SecurityId: -1,
@ -375,7 +375,7 @@ var data = []TestData{
}, },
}, },
reports: []handlers.Report{ reports: []handlers.Report{
handlers.Report{ {
UserId: 0, UserId: 0,
Name: "This Year's Monthly Expenses", Name: "This Year's Monthly Expenses",
Lua: ` Lua: `
@ -433,30 +433,30 @@ end`,
}, },
}, },
tabulations: []handlers.Tabulation{ tabulations: []handlers.Tabulation{
handlers.Tabulation{ {
ReportId: 0, ReportId: 0,
Title: "2017 Monthly Expenses", Title: "2017 Monthly Expenses",
Subtitle: "This is my subtitle", Subtitle: "This is my subtitle",
Units: "USD", Units: "USD",
Labels: []string{"2017-01-01", "2017-02-01", "2017-03-01", "2017-04-01", "2017-05-01", "2017-06-01", "2017-07-01", "2017-08-01", "2017-09-01", "2017-10-01", "2017-11-01", "2017-12-01"}, Labels: []string{"2017-01-01", "2017-02-01", "2017-03-01", "2017-04-01", "2017-05-01", "2017-06-01", "2017-07-01", "2017-08-01", "2017-09-01", "2017-10-01", "2017-11-01", "2017-12-01"},
Series: map[string]*handlers.Series{ Series: map[string]*handlers.Series{
"Assets": &handlers.Series{ "Assets": {
Values: []float64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, Values: []float64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
Series: map[string]*handlers.Series{ Series: map[string]*handlers.Series{
"Credit Union Checking": &handlers.Series{ "Credit Union Checking": {
Values: []float64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, Values: []float64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
Series: map[string]*handlers.Series{}, Series: map[string]*handlers.Series{},
}, },
}, },
}, },
"Expenses": &handlers.Series{ "Expenses": {
Values: []float64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, Values: []float64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
Series: map[string]*handlers.Series{ Series: map[string]*handlers.Series{
"Groceries": &handlers.Series{ "Groceries": {
Values: []float64{0, 0, 0, 0, 0, 0, 0, 0, 0, 87.19, 0, 0}, Values: []float64{0, 0, 0, 0, 0, 0, 0, 0, 0, 87.19, 0, 0},
Series: map[string]*handlers.Series{}, Series: map[string]*handlers.Series{},
}, },
"Cable": &handlers.Series{ "Cable": {
Values: []float64{0, 0, 0, 0, 0, 0, 0, 0, 39.99, 0, 0, 0}, Values: []float64{0, 0, 0, 0, 0, 0, 0, 0, 39.99, 0, 0, 0},
Series: map[string]*handlers.Series{}, Series: map[string]*handlers.Series{},
}, },

View File

@ -182,13 +182,13 @@ func TestCreateTransaction(t *testing.T) {
Description: "Imbalanced", Description: "Imbalanced",
Date: time.Date(2017, time.September, 1, 0, 00, 00, 0, time.UTC), Date: time.Date(2017, time.September, 1, 0, 00, 00, 0, time.UTC),
Splits: []*handlers.Split{ Splits: []*handlers.Split{
&handlers.Split{ {
Status: handlers.Reconciled, Status: handlers.Reconciled,
AccountId: d.accounts[1].AccountId, AccountId: d.accounts[1].AccountId,
SecurityId: -1, SecurityId: -1,
Amount: "-39.98", Amount: "-39.98",
}, },
&handlers.Split{ {
Status: handlers.Entered, Status: handlers.Entered,
AccountId: d.accounts[4].AccountId, AccountId: d.accounts[4].AccountId,
SecurityId: -1, SecurityId: -1,