feat: add percentage loyalti setting mode

This commit is contained in:
efrilm
2026-10-02 14:19:12 +07:00
parent d3e3ea6b08
commit b372821b23
13 changed files with 193 additions and 36 deletions
+8
View File
@@ -14,6 +14,14 @@ func TestLoyaltyCashbackPercent(t *testing.T) {
assert.Equal(t, 0.0, LoyaltyCashbackPercent(1, 1, 0))
}
func TestLoyaltyEarnSettings_CashbackPercent(t *testing.T) {
s := LoyaltyEarnSettings{EarnMode: "PER_AMOUNT", EarnPerAmount: 100, EarnValue: 1, EarnPercent: 2.5}
assert.Equal(t, 1.0, s.CashbackPercent(1))
s.EarnMode = "PERCENTAGE"
assert.Equal(t, 2.5, s.CashbackPercent(1))
assert.Equal(t, 250.0, s.CashbackPercent(100), "each point earned is worth point_value rupiah")
}
func TestNewLoyaltySettingsImpact(t *testing.T) {
before := OrganizationLoyaltySettings{PointValue: 1, Exchange: LoyaltyExchangeSettings{CoinAmount: 1, PointAmount: 1}}
after := OrganizationLoyaltySettings{PointValue: 100, Exchange: LoyaltyExchangeSettings{CoinAmount: 10, PointAmount: 1}}