diff --git a/dopt.DeltaBarth.Tests/PluginTest.cs b/dopt.DeltaBarth.Tests/PluginTest.cs index 614e7ce..7d0acaa 100644 --- a/dopt.DeltaBarth.Tests/PluginTest.cs +++ b/dopt.DeltaBarth.Tests/PluginTest.cs @@ -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 comp_id = new List { 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 comp_id = new List { 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 comp_id = new List { 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"); - } } } diff --git a/dopt.DeltaBarth/Plugin.cs b/dopt.DeltaBarth/Plugin.cs index 42682a5..5d7ea1e 100644 --- a/dopt.DeltaBarth/Plugin.cs +++ b/dopt.DeltaBarth/Plugin.cs @@ -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. /// - /// optional: Firmen-ID, für die die Pipeline ausgeführt werden soll. + /// 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 /// 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. /// Umsatzprognose inkl. Status-Objekt zur Nachvollziehbarkeit etwaig aufgetretener Fehler. /// - public DataObjects.UmsatzPrognoseAusgabe Umsatzprognose(int? firmaId, DateTime? analyseBeginn) + public DataObjects.UmsatzPrognoseAusgabe Umsatzprognose(List? 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(pyJson) ?? throw new PythonParsingException("Could not correctly parse object from Python"); return parsed; diff --git a/dopt.DeltaBarth/dopt.DeltaBarth.csproj b/dopt.DeltaBarth/dopt.DeltaBarth.csproj index d7dab4e..26208a2 100644 --- a/dopt.DeltaBarth/dopt.DeltaBarth.csproj +++ b/dopt.DeltaBarth/dopt.DeltaBarth.csproj @@ -6,12 +6,12 @@ enable x64 x64 - 0.4.0-alpha1 + 0.4.0 True - +