chore: replace int amount_cents for string storage and decimal pkg
This commit is contained in:
parent
13774eec7d
commit
c8a1eb5b7a
45 changed files with 706 additions and 587 deletions
17
internal/model/money.go
Normal file
17
internal/model/money.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
// FormatMoney formats a decimal as a dollar string like "$12.50"
|
||||
func FormatMoney(d decimal.Decimal) string {
|
||||
return fmt.Sprintf("$%s", d.StringFixed(2))
|
||||
}
|
||||
|
||||
// FormatDecimal formats a decimal for form input values like "12.50"
|
||||
func FormatDecimal(d decimal.Decimal) string {
|
||||
return d.StringFixed(2)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue