reinstate profit loss overview

This commit is contained in:
2026-06-01 13:13:40 +07:00
parent dc13bb5f93
commit 47fa21d739
10 changed files with 541 additions and 25 deletions
@@ -154,6 +154,16 @@ func TestAnalyticsServiceGetProfitLossAnalyticsValidation(t *testing.T) {
},
wantErr: "date_from cannot be after date_to",
},
{
name: "invalid group_by",
req: &models.ProfitLossAnalyticsRequest{
OrganizationID: uuid.New(),
DateFrom: now,
DateTo: now,
GroupBy: "quarter",
},
wantErr: "invalid group_by value: quarter",
},
}
for _, tt := range tests {
@@ -166,3 +176,17 @@ func TestAnalyticsServiceGetProfitLossAnalyticsValidation(t *testing.T) {
})
}
}
func TestAnalyticsServiceGetProfitLossAnalyticsAllowsEmptyGroupBy(t *testing.T) {
service := NewAnalyticsServiceImpl(analyticsProcessorStub{})
now := time.Date(2026, 5, 1, 0, 0, 0, 0, time.UTC)
resp, err := service.GetProfitLossAnalytics(context.Background(), &models.ProfitLossAnalyticsRequest{
OrganizationID: uuid.New(),
DateFrom: now,
DateTo: now,
})
require.NoError(t, err)
require.Nil(t, resp)
}