Releases: leekchan/accounting
Releases · leekchan/accounting
v0.3.1
v0.3
accounting v0.3 includes many contributions. Thank you to all who have contributed in this great work! 🙇
🌟 What's New in accounting v0.3
- #7 Support github.com/cockroachdb/apd for BigDecimal numbers (by @tamalsaha)
- #10 Add support for github.com/shopspring/decimal Add support for github.com/shopspring/decimal (by @Dexus)
- #11 Add Function DefaultAccounting and NewAccounting (by @Dexus)
- #13 Go modules (by @akkumar)
- #14 Use formattedNumber to format zero (by @bykof)
- #15 Locale Info and UnformatNumber (by @djackreuter)
v0.2
v0.1
big.Float support has been added
ac = accounting.Accounting{Symbol: "$", Precision: 2}
fmt.Println(ac.FormatMoneyBigFloat(big.NewFloat(123456789.213123))) // "$123,456,789.21"
fmt.Println(ac.FormatMoneyBigFloat(big.NewFloat(12345678))) // "$12,345,678.00"
ac = accounting.Accounting{Symbol: "€", Precision: 2, Thousand: ".", Decimal: ","}
fmt.Println(ac.FormatMoneyBigFloat(big.NewFloat(4999.99))) // "€4.999,99"
fmt.Println(ac.FormatMoneyBigFloat(big.NewFloat(-4999.99))) // "€-4.999,99"
ac = accounting.Accounting{Symbol: "£ ", Precision: 0}
fmt.Println(ac.FormatMoneyBigFloat(big.NewFloat(-500000))) // "£ -500,000"
ac = accounting.Accounting{Symbol: "GBP", Precision: 0,
Format: "%s %v", FormatNegative: "%s (%v)", FormatZero: "%s --"}
fmt.Println(ac.FormatMoneyBigFloat(big.NewFloat(1000000))) // "GBP 1,000,000"
fmt.Println(ac.FormatMoneyBigFloat(big.NewFloat(-5000))) // "GBP (5,000)"
fmt.Println(ac.FormatMoneyBigFloat(big.NewFloat(0))) // "GBP --"