package ana

import (
	"testing"

	"gogs.inhome.blapointe.com/ana-ledger/src/ledger"
)

func TestNormalize(t *testing.T) {
	deltas := ledger.Deltas{
		ledger.Delta{Date: "2024-12-04", Value: 100, Name: "Bel:Withdrawal"},
		ledger.Delta{Date: "2024-12-06", Value: 100, Name: "Bel:Withdrawal"},
	}

	normalizer := NewNormalizer().
		With("^Bel:", "2024-12-05", 190_000).
		With("^Bel:", "2018-02-16", 86_000)

	normalized := normalizer.Normalize(deltas)
	for i, delta := range normalized {
		t.Logf("[%d] %+v", i, delta)
	}

	if normalized[0].Value != 100/float64(86_000) {
		t.Errorf("earliest transaction didnt use earliest salary")
	}
	if normalized[1].Value != 100/float64(190_000) {
		t.Errorf("latest transaction didnt use latest salary")
	}
}
