B1SLayer icon indicating copy to clipboard operation
B1SLayer copied to clipboard

Different totals from the order to the invoice

Open halflores opened this issue 10 months ago • 4 comments

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

halflores avatar Apr 10 '24 17:04 halflores

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.

bgmulinari avatar Apr 10 '24 18:04 bgmulinari

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?

halflores avatar Apr 25 '24 16:04 halflores

Hi, @halflores.

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

bgmulinari avatar Apr 26 '24 13:04 bgmulinari

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?

halflores avatar Apr 26 '24 13:04 halflores