Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for commodities fx #5

Open
jbrodriguez opened this issue May 28, 2022 · 0 comments
Open

support for commodities fx #5

jbrodriguez opened this issue May 28, 2022 · 0 comments

Comments

@jbrodriguez
Copy link

this lib (and specifically the ledger-go tool) fails on this ledger file

;; Opening balances
2018/01/01 opening balances
  assets:savings:bank    $1234.56
  assets:crypto:bitcoin      BTC0.789
  equity:opening balances

the reason is there are 2 commodities and this line makes it fail

https://github.com/abourget/ledger/blob/master/journal/transaction.go#L47

func (tx *Transaction) ImplicitAmount() *Amount {
	var amount *Amount
	for _, n := range tx.Node.Postings {
		if n.Amount != nil {
			a := nodeToAmount(n.Amount)
			if amount != nil {
				if amount.Commodity != a.Commodity {
					return nil
				}
				amount.Quantity.Add(amount.Quantity, a.Quantity)
			} else {
				amount = a
			}
		}
	}

	amount.Quantity.Neg(amount.Quantity)
	return amount
}

is this a correct assessment or am i missing something ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant