accept --cpi=FILE --cpiy=YEAR to translate money to target year
All checks were successful
cicd / ci (push) Successful in 1m30s
All checks were successful
cicd / ci (push) Successful in 1m30s
This commit is contained in:
@@ -68,15 +68,15 @@ func (n Normalizer) Normalize(deltas ledger.Deltas) ledger.Deltas {
|
||||
}
|
||||
|
||||
func (n Normalizer) NormalizeDelta(delta ledger.Delta) ledger.Delta {
|
||||
delta.Value /= n.NormalizeFactor(delta)
|
||||
delta.Value /= n.NormalizeFactor(delta.Name, delta.Date)
|
||||
return delta
|
||||
}
|
||||
|
||||
func (n Normalizer) NormalizeFactor(delta ledger.Delta) float64 {
|
||||
func (n Normalizer) NormalizeFactor(name, date string) float64 {
|
||||
for pattern := range n.m {
|
||||
if regexp.MustCompile(pattern).MatchString(delta.Name) {
|
||||
if regexp.MustCompile(pattern).MatchString(name) {
|
||||
for _, normalize := range n.m[pattern] {
|
||||
if normalize.startDate < delta.Date {
|
||||
if normalize.startDate < date {
|
||||
return normalize.factor
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user