add selection with multiple company IDs for forecast pipeline, closes #14

This commit is contained in:
Florian Förster 2025-04-30 16:26:35 +02:00
parent 725e323f98
commit c34ed58fc0
3 changed files with 25 additions and 25 deletions

View File

@ -173,16 +173,31 @@ namespace dopt.DeltaBarth.Tests
}
[TestMethod]
[TestCategory("ActiveAPI")]
public void Umsatzprognose_WithCompanyIdWithDate_Test()
{
var test = new TPlugin();
string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant;
test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant);
var date = new DateTime(2023, 8, 15, 12, 45, 30);
List<int> comp_id = new List<int> { 1027, 5661, 1024 };
var res = test.Umsatzprognose(comp_id, date);
PrettyPrint(res);
Assert.AreEqual(4, res.status.code);
Assert.AreEqual((int)StatusCodes.DatensatzZuWenigeMonatsdatenpunkte, res.status.code);
test.Dispose();
}
[TestMethod]
[TestCategory("ActiveAPI")]
public void Umsatzprognose_WithCompanyIdWithoutDate_Test()
{
var test = new TPlugin();
string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant;
test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant);
var comp_id = 1024;
List<int> comp_id = new List<int> { 5661 };
var res = test.Umsatzprognose(comp_id, null);
PrettyPrint(res);
Assert.AreEqual(0, res.status.code);
Assert.AreEqual((int)StatusCodes.Erfolg, res.status.code);
Assert.AreEqual(4, res.status.code);
Assert.AreEqual((int)StatusCodes.DatensatzZuWenigeMonatsdatenpunkte, res.status.code);
test.Dispose();
}
[TestMethod]
@ -191,7 +206,7 @@ namespace dopt.DeltaBarth.Tests
var test = new TPlugin();
string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant;
test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant);
var comp_id = 1024;
List<int> comp_id = new List<int> { 5661 };
var res = test.Umsatzprognose(comp_id, null);
PrettyPrint(res);
Assert.AreEqual(1, res.status.code);
@ -232,7 +247,7 @@ namespace dopt.DeltaBarth.Tests
var test = new TPlugin();
string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant;
test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant);
var date = new DateTime(2015, 1, 1, 12, 45, 30);
var date = new DateTime(2021, 1, 1, 12, 45, 30);
var res = test.Umsatzprognose(null, date);
PrettyPrint(res);
Assert.AreEqual(0, res.status.code);
@ -252,20 +267,5 @@ namespace dopt.DeltaBarth.Tests
Assert.AreEqual((int)StatusCodes.VerbindungTimeout, res.status.code);
test.Dispose();
}
[TestMethod]
public void Umsatzprognose_WithoutCompanyIdWithValidDate_Test_DoubleDispose()
{
var test = new TPlugin();
string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant;
test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant);
var date = new DateTime(2015, 1, 1, 12, 45, 30);
var res = test.Umsatzprognose(null, date);
PrettyPrint(res);
Assert.AreEqual(1, res.status.code);
Assert.AreEqual((int)StatusCodes.VerbindungTimeout, res.status.code);
test.Dispose();
test.Dispose();
Console.WriteLine("After double dispose");
}
}
}

View File

@ -160,20 +160,20 @@ namespace dopt.DeltaBarth
/// Es werden API-Abrufe durchgeführt und somit auch Live-Daten genutzt.
/// Hierfür muss sichergestellt sein, dass der API-Server erreichbar und abrufbereit ist.
/// </summary>
/// <param name="firmaId">optional: Firmen-ID, für die die Pipeline ausgeführt werden soll.
/// <param name="firmaIds">optional: Liste von Firmen-IDs, für die die Pipeline ausgeführt werden soll.
/// Wird der Parameter nicht zur Verfügung gestellt, werden alle Firmen bzw. Kunden abgerufen</param>
/// <param name="analyseBeginn">optional: Start-Datum, ab dem die Daten für die Erstellung des Prognosemodells genutzt werden.
/// Daten, die weiter in der Vergangenheit liegen, werden nicht berücksichtigt.
/// Wird der Parameter nicht zur Verfügung gestellt, wird die gesamte Historie genutzt.</param>
/// <returns cref="DataObjects.UmsatzPrognoseAusgabe">Umsatzprognose inkl. Status-Objekt zur Nachvollziehbarkeit etwaig aufgetretener Fehler.</returns>
/// <exception cref="PythonParsingException"></exception>
public DataObjects.UmsatzPrognoseAusgabe Umsatzprognose(int? firmaId, DateTime? analyseBeginn)
public DataObjects.UmsatzPrognoseAusgabe Umsatzprognose(List<int>? firmaIds, DateTime? analyseBeginn)
{
AssertNotDisposed();
string pyJson;
using (Py.GIL())
{
pyJson = pyModPipeline.pipeline_sales_forecast(firmaId, analyseBeginn);
pyJson = pyModPipeline.pipeline_sales_forecast(firmaIds, analyseBeginn);
}
var parsed = JsonSerializer.Deserialize<DataObjects.UmsatzPrognoseAusgabe>(pyJson) ?? throw new PythonParsingException("Could not correctly parse object from Python");
return parsed;

View File

@ -6,12 +6,12 @@
<Nullable>enable</Nullable>
<PlatformTarget>x64</PlatformTarget>
<Platforms>x64</Platforms>
<Version>0.4.0-alpha1</Version>
<Version>0.4.0</Version>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="dopt.SharpPython" Version="0.4.2-alpha3" />
<PackageReference Include="dopt.SharpPython" Version="0.4.2" />
</ItemGroup>
</Project>