Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Belegabruf: Abruf einer Prozentkondition #56

Open
Christian-Sachse opened this issue Jun 5, 2024 · 2 comments
Open

Belegabruf: Abruf einer Prozentkondition #56

Christian-Sachse opened this issue Jun 5, 2024 · 2 comments

Comments

@Christian-Sachse
Copy link

Hallo zusammen,

macht man einen Teilabruf eines Belegs mit einer Prozentkondition (also Bezug zu andern Positionen) wird diese Position im Quellbeleg als vollständig abgerufen ausgegeben.

Getestet habe ich es mit BONUS-5 aus den Beispieldaten. Ruft man diese Position mit ab passiert folgendes:

  • Bezieht sich die Kondition auf Zeilen, die mit dabei sind funktioniert es wie erwartet
  • Bezieht sich die Kondition auf Zeilen, die gar nicht mit abgerufen werden, passiert nichts. Sie fehlt im Zielbeleg. Das ist sehr gut und erspart mir viel Prüfarbeit ;) ich gebe sie einfach mit an, die Ab macht den Rest. Echt super!
  • ABER: In jedem Fall ist im Quellbeleg danach der StatusContinuation = CompleteyContinued, was ja nicht stimmt. Nun würde, wenn man "stumpf" darauf prüft diese Kondition niemals mehr angewendet werden, was ja auch nicht richtig ist.

Könnt ihr das mal prüfen? Ich habe es im Einkauf bei BE->WE getestet.
Ich habe hier über xtend.Lager Wareneingänge zu erfassen. Manche Kunden nutzen aber Rabatte (Prozent) oder Zuschläge (Kupfer und Teuerung und so'n Zeug) und ich tue mich schwer diese Belege sauber zu bearbeiten (siehe auch Einleitungs- und Abruftexte :P )

Bei Fragen gern melden.

Viele Grüße
Christian

@aronkankel
Copy link
Contributor

aronkankel commented Jun 13, 2024

Hallo @Christian-Sachse ,

ich kann das nicht so einfach nachvollziehen. Bei mir bleibt die Prozentkondition als "nicht abgerufen" im Ursprungsbeleg bestehen.

Hier mein Test:

    [Test]
    public void TestTeilabrufMitProzentkondition()
    {
        int? bestellungId = null;

        // Bestellung mit
        // 1. Artikel   DBER1
        // 2. Kondition BONUS-5 mit Bezug auf DBER1
        // 3. Artikel   DPRG1

        var bestellung = new PurchaseDocumentModel(
            documentType: "BE",
            supplierNumber: 70001,
            documentDate: DateTime.Today,
            lineItems: new List<LineItemModel>());

        // 1. Artikel   DBER1
        bestellung.LineItems.Add(new LineItemModel(
            lineItemType: LineItemModel.LineItemTypeEnum.Product,
            key: 1,  // Key für Konditionsbezug
            productLineItemData: new ProductLineItemModel(
                productNumber: "DBER1",
                quantity: 1
                )
            ));

        // 2. Kondition BONUS-5 mit Bezug auf DBER1
        bestellung.LineItems.Add(new LineItemModel(
            lineItemType: LineItemModel.LineItemTypeEnum.Condition,
            conditionLineItemData: new ConditionLineItemModel(
                condition: "BONUS-5",
                referringTo: new List<int> { 1 }
                )
            ));

        // 3. Artikel   DPRG1
        bestellung.LineItems.Add(new LineItemModel(
            lineItemType: LineItemModel.LineItemTypeEnum.Product,
            productLineItemData: new ProductLineItemModel(
                productNumber: "DPRG1",
                quantity: 1
                )
            ));

        try
        {
            // Bestellung anlegen
            var responsePostBestellung = _einkaufsbelegApi.V1PurchaseDocumentsPostWithHttpInfo(
                bestellung, xHSDoInsertIntroductionLineItem: false);

            responsePostBestellung.StatusCode.Should().Be(HttpStatusCode.Created);
            bestellungId = ApiConverter.GetIdFromHeaderLocation(responsePostBestellung);

            // Bestellung auslesen
            var responseGetBestellung = _einkaufsbelegApi.V1PurchaseDocumentsPurchaseDocumentIdGetWithHttpInfo(
                bestellungId.Value);

            responseGetBestellung.StatusCode.Should().Be(HttpStatusCode.OK);
            responseGetBestellung.Data.Should().NotBeNull();
            responseGetBestellung.Data.LineItems.Should().NotBeNull();
            responseGetBestellung.Data.LineItems.Count.Should().Be(3);

            // Teilabruf der Position 3 (ohne Konditionsbezug)
            var processData = new ProcessDataModel(
                targetDocument: new TargetDocumentDataModel(
                    documentType: "WE",
                    documentDate: DateTime.Today,
                    lineItems: new List<TargetLineItemModel>()
                    {
                        new TargetLineItemModel(
                            new List<SourceLineItemDataModel>()
                            {
                                new SourceLineItemDataModel(
                                    id: responseGetBestellung.Data.LineItems.Last().Id.Value,
                                    sourceDocumentId: bestellungId.Value,
                                    doProcess: true,
                                    doRemain: false                                        
                                    )
                            }
                            )
                    }),
                sourceDocuments: new List<SourceDocumentDataModel>()
                {
                    new SourceDocumentDataModel(
                        id: bestellungId.Value)
                }
                );

            var responsePostProcess = _einkaufsbelegApi.V1PurchaseDocumentsProcessPostWithHttpInfo(
                processData);

            responsePostProcess.StatusCode.Should().Be(HttpStatusCode.Created);

            // Bestellung erneut auslesen
            responseGetBestellung = _einkaufsbelegApi.V1PurchaseDocumentsPurchaseDocumentIdGetWithHttpInfo(
                bestellungId.Value);

            responseGetBestellung.StatusCode.Should().Be(HttpStatusCode.OK);
            responseGetBestellung.Data.Should().NotBeNull();
            responseGetBestellung.Data.LineItems.Should().NotBeNull();
            responseGetBestellung.Data.LineItems.Count.Should().Be(3);

            responseGetBestellung.Data.LineItems[0].StatusContinuation.Should().Be(LineItemModel.StatusContinuationEnum.NotContinued);
            responseGetBestellung.Data.LineItems[1].StatusContinuation.Should().Be(LineItemModel.StatusContinuationEnum.NotContinued);
            responseGetBestellung.Data.LineItems[2].StatusContinuation.Should().Be(LineItemModel.StatusContinuationEnum.CompletelyContinued);
        }
        catch (ApiException e)
        {
            Console.WriteLine(e);
            Assert.Fail(e.Message);
        }
    }

Kannst du mir noch genauer schildern, welche Daten du postest und wie der Ursprungsbeleg aussieht?

@Christian-Sachse
Copy link
Author

Sorry jetzt erst gesehen. ich teste bei mir nochmal und melde mich.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants