Skip to content

Commit

Permalink
adjust dates
Browse files Browse the repository at this point in the history
  • Loading branch information
ananthakumaran committed Feb 11, 2024
1 parent c1c0f38 commit 62401a4
Show file tree
Hide file tree
Showing 29 changed files with 1,089 additions and 1,129 deletions.
4 changes: 2 additions & 2 deletions internal/query/posting.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (q *Query) All() []posting.Posting {
var postings []posting.Posting

q.context = q.context.Where("forecast = ?", q.includeForecast)
result := q.context.Order("date " + q.order + ", amount desc").Find(&postings)
result := q.context.Order("date " + q.order + ", amount desc, account asc").Find(&postings)
if result.Error != nil {
log.Fatal(result.Error)
}
Expand All @@ -140,7 +140,7 @@ func (q *Query) All() []posting.Posting {
func (q *Query) First() *posting.Posting {
var posting posting.Posting
q.context = q.context.Where("forecast = ?", q.includeForecast)
result := q.context.Order("date " + q.order + ", amount desc").First(&posting)
result := q.context.Order("date " + q.order + ", amount desc, account asc").First(&posting)

if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
Expand Down
37 changes: 6 additions & 31 deletions tests/fixture/inr-beancount/allocation.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,7 @@
"Assets:Checking": {
"date": "2022-01-08T00:00:00Z",
"account": "Assets:Checking",
"market_amount": 1974.6829928704
},
"Assets:Equity:AAPL": {
"date": "2022-01-08T00:00:00Z",
"account": "Assets:Equity:AAPL",
"market_amount": 10000
"market_amount": 11974.6829928704
},
"Assets:Equity:ABNB": {
"date": "2022-01-08T00:00:00Z",
Expand All @@ -127,17 +122,12 @@
"Assets:Checking": {
"date": "2022-01-09T00:00:00Z",
"account": "Assets:Checking",
"market_amount": 11097.2625128704
},
"Assets:Dollar": {
"date": "2022-01-09T00:00:00Z",
"account": "Assets:Dollar",
"market_amount": 804.42048
"market_amount": 1974.6829928704
},
"Assets:Equity:AAPL": {
"date": "2022-01-09T00:00:00Z",
"account": "Assets:Equity:AAPL",
"market_amount": 0
"market_amount": 10000
},
"Assets:Equity:ABNB": {
"date": "2022-01-09T00:00:00Z",
Expand All @@ -154,17 +144,7 @@
"Assets:Checking": {
"date": "2022-01-10T00:00:00Z",
"account": "Assets:Checking",
"market_amount": 11097.22810619763
},
"Assets:Coinbase:BTC": {
"date": "2022-01-10T00:00:00Z",
"account": "Assets:Coinbase:BTC",
"market_amount": 0
},
"Assets:Dollar": {
"date": "2022-01-10T00:00:00Z",
"account": "Assets:Dollar",
"market_amount": 804.42048
"market_amount": 12001.6829928704
},
"Assets:Equity:AAPL": {
"date": "2022-01-10T00:00:00Z",
Expand All @@ -186,12 +166,7 @@
"Assets:Checking": {
"date": "2022-01-11T00:00:00Z",
"account": "Assets:Checking",
"market_amount": 11097.22810619763
},
"Assets:Coinbase:BTC": {
"date": "2022-01-11T00:00:00Z",
"account": "Assets:Coinbase:BTC",
"market_amount": 0
"market_amount": 11097.2625128704
},
"Assets:Dollar": {
"date": "2022-01-11T00:00:00Z",
Expand Down Expand Up @@ -762,7 +737,7 @@
"Assets:Checking": {
"date": "2022-01-29T00:00:00Z",
"account": "Assets:Checking",
"market_amount": 11097.22810619763
"market_amount": 12169.22810619763
},
"Assets:Coinbase:BTC": {
"date": "2022-01-29T00:00:00Z",
Expand Down
4 changes: 2 additions & 2 deletions tests/fixture/inr-beancount/assets_balance.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"marketAmount": 102155.81133819763,
"balanceUnits": 0,
"latestPrice": 0,
"xirr": 12.15,
"xirr": 12.14,
"gainAmount": 13414.62810619763,
"absoluteReturn": 0.1358193262974935
},
Expand All @@ -18,7 +18,7 @@
"marketAmount": 13169.22810619763,
"balanceUnits": 0,
"latestPrice": 0,
"xirr": 44.43,
"xirr": 44.27,
"gainAmount": 13169.22810619763,
"absoluteReturn": 0
},
Expand Down
Loading

0 comments on commit 62401a4

Please sign in to comment.