mv /ana, /ledger to /src/
This commit is contained in:
38
src/ledger/delta.go
Normal file
38
src/ledger/delta.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package ledger
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Currency string
|
||||
|
||||
const (
|
||||
USD = Currency("$")
|
||||
)
|
||||
|
||||
type Delta struct {
|
||||
Date string
|
||||
Name string
|
||||
Value float64
|
||||
Currency Currency
|
||||
Description string
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func newDelta(d, desc, name string, v float64, c string, isSet bool) Delta {
|
||||
return Delta{
|
||||
Date: d,
|
||||
Name: name,
|
||||
Value: v,
|
||||
Currency: Currency(c),
|
||||
Description: desc,
|
||||
isSet: isSet,
|
||||
}
|
||||
}
|
||||
|
||||
func (delta Delta) Debug() string {
|
||||
return fmt.Sprintf("{@%s %s:\"%s\" %s%.2f %s}", delta.Date, delta.Name, delta.Description, func() string {
|
||||
if !delta.isSet {
|
||||
return ""
|
||||
}
|
||||
return "= "
|
||||
}(), delta.Value, delta.Currency)
|
||||
}
|
||||
Reference in New Issue
Block a user