bgmulinari / B1SLayer

A lightweight SAP Business One Service Layer client for .NET
MIT License
136 stars 47 forks source link

Different totals from the order to the invoice #67

Open halflores opened 5 months ago

halflores commented 5 months ago

Hi, @bgmulinari Why do I get different totals from the order to the invoice? My input: image

            #region CREAR OFERTA DE VENTA, modelo a tomar
            var ofertaVenta = new
            {
                CardCode = oferta.CardCode,
                DocDueDate = oferta.DocDueDate,
                DocumentLines = oferta.DocumentLines
                                 .Select(x => new
                                 {
                                     ItemCode = x.ItemCode,
                                     Quantity = x.Quantity,
                                     WarehouseCode = x.WhsCode,
                                     LineNum = x.LineNum,
                                     UoMEntry = x.UoMEntry
                                 }).ToList()
            };

            var objQuotations = new SLBatchRequest(
                HttpMethod.Post,
                "Quotations",
                ofertaVenta,
                1); // Content-ID for this entity
            #endregion

            #region CREAR ORDER VENTA, modelo a tomar
            var orderVenta = new
            {
                CardCode = order.CardCode,
                DocDueDate = order.DocDueDate,
                PaymentGroupCode = order.PaymentGroupCode,
                DocumentLines = order.DocumentLines
                                 .Select(x => new
                                 {
                                     BaseEntry = x.BaseEntry,
                                     BaseLine = x.BaseLine,
                                     BaseType = x.BaseType,
                                     WarehouseCode = x.WhsCode
                                 }).ToList()
            };

            var objOrders = new SLBatchRequest(
                HttpMethod.Post,
                "Orders",
                orderVenta,
                2);
            #endregion

            #region CREAR FACTURA VENTA, modelo a tomar
            var invoiceVenta = new
            {
                CardCode = invoice.CardCode,
                DocDueDate = invoice.DocDueDate,
                PaymentGroupCode = invoice.PaymentGroupCode,
                Indicator = 4,
                Series = 142,
                ReserveInvoice = "tYES",
                DocType = "dDocument_Items",
                DocumentLines = invoice.DocumentLines
                                 .Select(x => new
                                 {
                                     BaseEntry = x.BaseEntry,
                                     BaseLine = x.BaseLine,
                                     BaseType = x.BaseType,
                                     TaxCode = x.TaxCode,
                                     WarehouseCode = x.WhsCode
                                 }).ToList()
            };

            var objInvoice = new SLBatchRequest(
                HttpMethod.Post,
                "Invoices",
                invoiceVenta,
                3);
            #endregion

            Tuple<HttpResponseMessage[], string> results = await _slConnections[login.SLConexion].PostBatchAsync(objQuotations, objOrders, objInvoice);

image

bgmulinari commented 5 months ago

Hi, @halflores.

It's hard to know the cause of your issue without comparing the created documents in detail.

In any case, I don't believe this issue is related to B1SLayer. Try reproducing the issue by sending the requests through Postman.

halflores commented 5 months ago

Hi, @bgmulinari Thanks in advance, I made the corrections and the calculations of the amounts vary due to taxes. So, making some adjustments, the following happens: When the documents (sales quote, sales order and invoice) are created in PostBach, the amounts are recalculated. When I create the individual documents the amounts are maintained. This is the result of sending in PostBach

image

Individually sent like this image

Maybe you know how the map relation of individual documents could be done?

bgmulinari commented 5 months ago

Hi, @halflores.

The relation between documents is defined in the document lines by the fields BaseType, BaseEntry and BaseLine.

halflores commented 5 months ago

Hi @bgmulinari It is absolutely understandable, as you can see in the first image. But when I use this way it recalculates the amount per line. Do you know how I can prevent it from being recalculated and keep it as if it were an individual document?