leekchan / accounting Goto Github PK
View Code? Open in Web Editor NEWmoney and currency formatting for golang
License: MIT License
money and currency formatting for golang
License: MIT License
Hi.
It seems the package github.com/cockroachdb/apd
was update yesterday and I am getting this.
github.com/leekchan/accounting
../../leekchan/accounting/formatnumber.go:79: d.ToStandard undefined (type *apd.Decimal has no field or method ToStandard)
../../leekchan/accounting/formatnumber.go:139: d.ToStandard undefined (type *apd.Decimal has no field or method ToStandard)
@leekchan Can you fix the problem?
Error:
leekchan/accounting/formatnumber.go:90: constant -9223372036854775808 overflows int
Won't compile for 32-bit architectures (main target is ARMv7)
When I try to execute the command
"go get github.com/leekchan/accounting"
I receive the error
"go: github.com/leekchan/[email protected]: reading github.com/leekchan/accounting/go.mod at revision v1.0.0: unknown revision v1.0.0"
Line 49 in 17a4ce5
some ComSymbol values have trailing whitespaces
if accounting.Thousand == "" {
accounting.Thousand = ","
}
Surely this is a big use case?
When I use INR(₹) to print the number, it is printing incorrectly
Expected:
100000.00--->1,00,000
1000000.00--->10,00,000
10000000.00---->1,00,00,000
Actual:
100000.00--->100,000
1000000.00--->1,000,000
10000000.00---->10,000,000
sample code
https://play.golang.org/p/KJgby1U9gZH
Can this be fixed?
would you be able to comment on the differences ?
i want to use this with a golang i18n library to round out the i18n support. "round out", get it hehe - sorry
I found that this project already supports Go modules. But sadly, the tags doesn't follow Semantic Versioning, which means that all tags of this project will be ignored by Go modules and replaced by pseudo-versions, go get acts weirdly when tags are not in that form. It would be great to have the tagged release be named in the format vX.X.X format so that go mod can read it.
$ go get github.com/leekchan/[email protected]
go get github.com/leekchan/[email protected]: no matching versions for query "v0.3"
$ go get github.com/leekchan/accounting
go: downloading github.com/leekchan/accounting v0.0.0-20191218023648-17a4ce5f94d4
go: github.com/leekchan/accounting upgrade => v0.0.0-20191218023648-17a4ce5f94d4
github.com/leekchan/accounting v0.0.0-20191218023648-17a4ce5f94d4
Else the mod file shows something like github.com/leekchan/accounting v0.0.0-20191218023648-17a4ce5f94d4
which is not very readable and difficult to upgrade. It’s hard to verify which version is in use. This is not conducive to version control
So, I propose this project to follow Semantic Versioning in future versions. For example, v1.0.1
, v2.0.0
, v3.1.0-alpha
, v3.1.0-beta.2
etc.
Negative numbers should print like -$3,575.95
but they currently print like $-3,575.95
.
@leekchan friend.
Hey please take a look at this line
Line 189 in 17a4ce5
I think Viet nam Dong has fraction length of 0, not 2 as in your code
reference: https://developer.cybersource.com/library/documentation/sbc/quickref/currencies.pdf
Thank you!
I can't choose if i want it without round.
In french Canadian, currency is at the end.
Is that possible ?
1234.56 should be 1 234,56 $
I found the parameter format for this.
Are there any plans to support generics?
Rewriting with generics could largely reduce the risk of exposing runtime panics and converting them into compile-time errors.
For example:
func (accounting *Accounting) FormatMoney(value interface{}) string
The FormatMoney
function takes in any
type and does type a check only at runtime.
Happy to help with the refactor if it sounds like a good idea.
Hi, thanks for a great library!
I'm working on a system that's dealing with both fiat currencies and a couple of cryptocurrencies and I thought I could easily build a Locale
object to describe common crypto formats (all decimal places, symbol after the number, etc)
I have this:
var cryptos = map[string]accounting.Locale{
"USDC": {
Name: "USD Coin",
FractionLength: 11,
ThouSep: ",",
DecSep: ".",
SpaceSep: " ",
UTFSymbol: "",
HTMLSymbol: "",
ComSymbol: "USDC",
Pre: false,
},
}
But then I realised, the actual formatting API doesn't accept some of these parameters, most importantly Pre
which I wanted to use to place the symbol after the value, which seems to be the consensus around crypto currency value formatting:
123.435 USDC
For example.
It seems this could be implemented in the formatMoneyString
function if Accounting
had a Pre
field.
Though, it also begs the question, why not just embed Locale
into Accounting
?
Anyway, would be happy to submit a PR for formatMoneyString
!
I'm getting this error when trying to build (go 1.6 - GOOS=linux GOARCH=386 go build):
github.com/leekchan/accounting
../../../.gvm/pkgsets/go1.6/global/src/github.com/leekchan/accounting/formatnumber.go:90: constant -9223372036854775808 overflows int
Any advice?
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.