update due date and range date

This commit is contained in:
2026-05-29 18:24:14 +07:00
parent d26f5c5354
commit dc13bb5f93
23 changed files with 640 additions and 84 deletions
@@ -119,3 +119,50 @@ func TestAnalyticsServiceGetPurchasingAnalyticsAllowsEmptyGroupBy(t *testing.T)
require.NoError(t, err)
require.NotNil(t, resp)
}
func TestAnalyticsServiceGetProfitLossAnalyticsValidation(t *testing.T) {
service := NewAnalyticsServiceImpl(analyticsProcessorStub{})
now := time.Date(2026, 5, 1, 0, 0, 0, 0, time.UTC)
tests := []struct {
name string
req *models.ProfitLossAnalyticsRequest
wantErr string
}{
{
name: "missing date_from",
req: &models.ProfitLossAnalyticsRequest{
OrganizationID: uuid.New(),
DateTo: now,
},
wantErr: "date_from is required",
},
{
name: "missing date_to",
req: &models.ProfitLossAnalyticsRequest{
OrganizationID: uuid.New(),
DateFrom: now,
},
wantErr: "date_to is required",
},
{
name: "reversed dates",
req: &models.ProfitLossAnalyticsRequest{
OrganizationID: uuid.New(),
DateFrom: now.AddDate(0, 0, 1),
DateTo: now,
},
wantErr: "date_from cannot be after date_to",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
resp, err := service.GetProfitLossAnalytics(context.Background(), tt.req)
require.Nil(t, resp)
require.Error(t, err)
require.Contains(t, err.Error(), tt.wantErr)
})
}
}