~whereswaldon/ledger

9cdfd1ab43fb24cec816e024ba524f0580b841fd — Chris Howey 1 year, 7 months ago 768f50e
fix: skip printing of empty ranges

Fixes #37
2 files changed, 10 insertions(+), 1 deletions(-)

M ledger/cmd/printBalance.go
M ledger/cmd/printRegister.go
M ledger/cmd/printBalance.go => ledger/cmd/printBalance.go +6 -1
@@ 26,13 26,18 @@ var balanceCmd = &cobra.Command{
			lperiod := ledger.Period(period)
			rtrans := ledger.TransactionsByPeriod(generalLedger, lperiod)
			for rIdx, rt := range rtrans {
				balances := ledger.GetBalances(rt.Transactions, args)
				if len(balances) < 1 {
					continue
				}

				if rIdx > 0 {
					fmt.Println("")
					fmt.Println(strings.Repeat("=", columnWidth))
				}
				fmt.Println(rt.Start.Format(transactionDateFormat), "-", rt.End.Format(transactionDateFormat))
				fmt.Println(strings.Repeat("=", columnWidth))
				PrintBalances(ledger.GetBalances(rt.Transactions, args), showEmptyAccounts, transactionDepth, columnWidth)
				PrintBalances(balances, showEmptyAccounts, transactionDepth, columnWidth)
			}
		}
	},

M ledger/cmd/printRegister.go => ledger/cmd/printRegister.go +4 -0
@@ 26,6 26,10 @@ var registerCmd = &cobra.Command{
			lperiod := ledger.Period(period)
			rtrans := ledger.TransactionsByPeriod(generalLedger, lperiod)
			for rIdx, rt := range rtrans {
				if len(rt.Transactions) < 1 {
					continue
				}

				if rIdx > 0 {
					fmt.Println(strings.Repeat("=", columnWidth))
				}