From a65cd4d90a2b9355036888de83e94a34d7e3b3cf Mon Sep 17 00:00:00 2001 From: George Date: Mon, 19 Oct 2026 16:52:23 -0500 Subject: [PATCH] Version 2.1.13.0: cabecera de la NC en un solo metodo (CabeceraNotaCredito.Completar) Co-Authored-By: Claude Sonnet 5.5 --- CLAUDE.md | 7 ++- .../Net.Business.Services.csproj | 2 +- .../CreditNotes/CabeceraNotaCredito.cs | 53 +++++++++++++++++++ Net.Data/WMS/Picking/PickingRepository.cs | 47 +++------------- Net.Data/WMS/Recibo/ReciboRepository.cs | 25 ++------- 5 files changed, 70 insertions(+), 64 deletions(-) create mode 100644 Net.Data/ServicesLayer/CreditNotes/CabeceraNotaCredito.cs diff --git a/CLAUDE.md b/CLAUDE.md index 7a193a5..14dded6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,7 +10,7 @@ comprimido (versión antigua)**. ## Versión y control de versiones -- **Versión actual: 2.1.12.0** (rama `limpieza-2.1.8.0`; `main` = 2.1.7.0) (`Net.Business.Services.csproj`: `Version`, +- **Versión actual: 2.1.13.0** (rama `limpieza-2.1.8.0`; `main` = 2.1.7.0) (`Net.Business.Services.csproj`: `Version`, `AssemblyVersion`, `FileVersion`). Cada versión tiene su commit; al publicar se sube la versión (ver `publicar.ps1`). - **Git**: rama `main`, remoto `origin` = @@ -140,6 +140,11 @@ transferencias siempre, sin depender de `Notificacion`. Detalle y tabla en (rama "Privado"), `Program.cs` (`CreateHostBuilder` viejo), `ConnectionServiceLayer` (líneas de header/éxito y un `if` de `NoContent` vacío), `CreditNotesRepository`, `ReciboRepository`, `InventarioRepository`, `ConnectionSQL`, `DBParameter` y `BE_BusinessPartners` (ya no queda código comentado). Sigue pendiente `PatchAsyncSBA` y la redundancia de serie/cabecera de la NC. +- **v2.1.13.0 — cabecera única de la NC** (sin cambios de comportamiento): la serie (`BC10` si el tipo del + documento origen es `03`, si no `FC10`), el correlativo (`HelperCorrelativo`) y los ~15 campos de la cabecera de + la NC estaban copiados en Picking DESPACHO, Picking PICKING (estado 13) y Recibo Devolución; ahora están en + `Net.Data/ServicesLayer/CreditNotes/CabeceraNotaCredito.Completar` (con comentarios de la regla de la 2.1.7.0). + Cada llamador pasa los datos de su origen (factura o, en Recibo sin factura, la solicitud de devolución). - Sin probar contra SAP: confirmar con la factura 292410 que SAP devuelve `BaseType`/`BaseEntry` en las líneas y `BatchNumbers` en las de la Entrega. diff --git a/Net.Business.Services/Net.Business.Services.csproj b/Net.Business.Services/Net.Business.Services.csproj index 1c63200..3ee87a5 100644 --- a/Net.Business.Services/Net.Business.Services.csproj +++ b/Net.Business.Services/Net.Business.Services.csproj @@ -3,7 +3,7 @@ netcoreapp3.1 ITCA_API_SAP_WMS - 2.1.12.0 + 2.1.13.0 2.1.12.0 2.1.12.0 24763424-3300-4c85-87e3-503f8fdebd14 diff --git a/Net.Data/ServicesLayer/CreditNotes/CabeceraNotaCredito.cs b/Net.Data/ServicesLayer/CreditNotes/CabeceraNotaCredito.cs new file mode 100644 index 0000000..306cb0f --- /dev/null +++ b/Net.Data/ServicesLayer/CreditNotes/CabeceraNotaCredito.cs @@ -0,0 +1,53 @@ +using Net.Business.Entities.ServicesLayer.CreditNotes; +using Net.Data.HelperData.Correlativo; +using System; + +namespace Net.Data.ServicesLayer.CreditNotes +{ + // Cabecera de la nota de credito (Picking DESPACHO, Picking PICKING estado 13 y Recibo Devolucion). + // Antes la serie, el correlativo y estos campos estaban copiados 3 veces. + public static class CabeceraNotaCredito + { + // Completa la cabecera de la NC con los datos del documento origen (la factura o, en Recibo sin factura, + // la solicitud de devolucion). Las lineas las arma cada llamador. + // tipoOrigen/serieOrigen/correlativoOrigen: U_SYP_MDTD / U_SYP_MDSD / U_SYP_MDCD del documento origen. + public static void Completar(BE_CreditNotesNotes nc, string docCurrency, string cardCode, string cardName, string paymentGroupCode, + string tipoOrigen, string serieOrigen, string correlativoOrigen, DateTime fechaOrigen, string motivo, string tipoMotivo) + { + // v2.1.7.0: la serie sale del TIPO del documento origen (03 = boleta -> BC10, otro -> FC10), no de su serie. + // En Recibo se comparaba la serie origen (p. ej. B005) con "03" y siempre salia FC10. + // Pendiente: validar con contabilidad la serie de boletas. + string serie = SerieNotaCredito(tipoOrigen); + + // El correlativo sale de @SYP_NUMDOC (HelperCorrelativo) + string correlativo = HelperCorrelativo.Get(serie); + + nc.DocCurrency = docCurrency; + nc.CardCode = cardCode; + nc.CardName = cardName; + nc.PaymentGroupCode = paymentGroupCode; + nc.DocDate = DateTime.Now; + nc.DocDueDate = DateTime.Now; + + // Documento origen (el que se devuelve) + nc.U_SYP_MDTO = tipoOrigen; + nc.U_SYP_MDCO = correlativoOrigen; + nc.U_SYP_MDSO = serieOrigen; + nc.U_SYP_FECHAREF = fechaOrigen.ToString("yyyy-MM-dd"); + + nc.U_SYP_MOTNC = motivo; + nc.U_SYP_TPONC = tipoMotivo; + + // La NC misma: tipo 07, con la serie y el correlativo elegidos arriba + nc.U_SYP_MDTD = "07"; + nc.U_SYP_MDSD = serie; + nc.U_SYP_MDCD = correlativo; + nc.NumAtCard = "07-" + serie + "-" + correlativo; + } + + public static string SerieNotaCredito(string tipoOrigen) + { + return tipoOrigen == "03" ? "BC10" : "FC10"; + } + } +} diff --git a/Net.Data/WMS/Picking/PickingRepository.cs b/Net.Data/WMS/Picking/PickingRepository.cs index ad451a3..a6de160 100644 --- a/Net.Data/WMS/Picking/PickingRepository.cs +++ b/Net.Data/WMS/Picking/PickingRepository.cs @@ -15,7 +15,6 @@ using Net.Business.Entities.WMS.ProcesoPicking; using Net.Connection; using Net.Connection.ServiceLayer; using Net.CrossCotting; -using Net.Data.HelperData.Correlativo; using Net.Data.HelperData.HelperProcesoPermitido; using Net.Data.HelperData.Stock; using Net.Data.ServicesLayer; @@ -171,26 +170,9 @@ namespace Net.Data.WMS.Picking } } - // Serie de la NC segun el TIPO de documento de la factura (U_SYP_MDTD): 03 = boleta -> BC10, otro -> FC10. - // El correlativo sale de @SYP_NUMDOC (HelperCorrelativo) - string Serie = _invoices.U_SYP_MDTD == "03" ? "BC10" : "FC10"; - string Correlativo = HelperCorrelativo.Get(Serie); - creditNotesNotes.DocCurrency = _invoices.DocCurrency; - creditNotesNotes.CardCode = _invoices.CardCode; - creditNotesNotes.CardName = _invoices.CardName; - creditNotesNotes.PaymentGroupCode = _invoices.PaymentGroupCode; - creditNotesNotes.DocDate = DateTime.Now; - creditNotesNotes.DocDueDate = DateTime.Now; - creditNotesNotes.U_SYP_MDTO = _invoices.U_SYP_MDTD; - creditNotesNotes.U_SYP_MDCO = _invoices.U_SYP_MDCD; - creditNotesNotes.U_SYP_MDSO = _invoices.U_SYP_MDSD; - creditNotesNotes.U_SYP_MOTNC = DescripcionMotivo; - creditNotesNotes.U_SYP_TPONC = MotivoNotaCredito; - creditNotesNotes.U_SYP_MDCD = Correlativo; - creditNotesNotes.U_SYP_MDSD = Serie; - creditNotesNotes.U_SYP_MDTD = "07"; - creditNotesNotes.U_SYP_FECHAREF = _invoices.DocDate.ToString("yyyy-MM-dd"); - creditNotesNotes.NumAtCard = ("07-" + Serie + "-" + Correlativo); + // Cabecera de la NC (serie BC10/FC10 por tipo de la factura, correlativo, documento origen) + CabeceraNotaCredito.Completar(creditNotesNotes, _invoices.DocCurrency, _invoices.CardCode, _invoices.CardName, _invoices.PaymentGroupCode, + _invoices.U_SYP_MDTD, _invoices.U_SYP_MDSD, _invoices.U_SYP_MDCD, _invoices.DocDate, DescripcionMotivo, MotivoNotaCredito); entidad.Detalle.ForEach(x => { @@ -437,26 +419,9 @@ namespace Net.Data.WMS.Picking } } - // Serie segun el tipo de documento de la factura (03 = boleta -> BC10, otro -> FC10) - string Serie = _invoices.U_SYP_MDTD == "03" ? "BC10" : "FC10"; - string Correlativo = HelperCorrelativo.Get(Serie); - - creditNotesNotes.DocCurrency = _invoices.DocCurrency; - creditNotesNotes.CardCode = _invoices.CardCode; - creditNotesNotes.CardName = _invoices.CardName; - creditNotesNotes.PaymentGroupCode = _invoices.PaymentGroupCode; - creditNotesNotes.DocDate = DateTime.Now; - creditNotesNotes.DocDueDate = DateTime.Now; - creditNotesNotes.U_SYP_MDTO = _invoices.U_SYP_MDTD; - creditNotesNotes.U_SYP_MDCO = _invoices.U_SYP_MDCD; - creditNotesNotes.U_SYP_MDSO = _invoices.U_SYP_MDSD; - creditNotesNotes.U_SYP_MOTNC = DescripcionMotivo; - creditNotesNotes.U_SYP_TPONC = MotivoNotaCredito; - creditNotesNotes.U_SYP_MDCD = Correlativo; - creditNotesNotes.U_SYP_MDSD = Serie; - creditNotesNotes.U_SYP_MDTD = "07"; - creditNotesNotes.U_SYP_FECHAREF = _invoices.DocDate.ToString("yyyy-MM-dd"); - creditNotesNotes.NumAtCard = ("07-" + Serie+ "-" + Correlativo); + // Cabecera de la NC (serie BC10/FC10 por tipo de la factura, correlativo, documento origen) + CabeceraNotaCredito.Completar(creditNotesNotes, _invoices.DocCurrency, _invoices.CardCode, _invoices.CardName, _invoices.PaymentGroupCode, + _invoices.U_SYP_MDTD, _invoices.U_SYP_MDSD, _invoices.U_SYP_MDCD, _invoices.DocDate, DescripcionMotivo, MotivoNotaCredito); entidad.Detalle.ForEach(x => { diff --git a/Net.Data/WMS/Recibo/ReciboRepository.cs b/Net.Data/WMS/Recibo/ReciboRepository.cs index c5490b7..c15bb40 100644 --- a/Net.Data/WMS/Recibo/ReciboRepository.cs +++ b/Net.Data/WMS/Recibo/ReciboRepository.cs @@ -13,7 +13,6 @@ using Net.Business.Entities.ServicesLayer.StockTransfer; using Net.Business.Entities.WMS.Recibo; using Net.Connection; using Net.CrossCotting; -using Net.Data.HelperData.Correlativo; using Net.Data.HelperData.Stock; using Net.Data.ServicesLayer; using Net.Data.ServicesLayer.CreditNotes; @@ -402,26 +401,10 @@ namespace Net.Data.WMS.Recibo } #endregion - // Serie segun el TIPO de documento origen (03 = boleta), no segun su serie - // El correlativo sale de @SYP_NUMDOC (HelperCorrelativo) - string Serie = U_SYP_MDTO == "03" ? "BC10" : "FC10"; - string Correlativo = HelperCorrelativo.Get(Serie); - creditNotesNotes.DocCurrency = returnRequest.DocCurrency; - creditNotesNotes.CardCode = returnRequest.CardCode; - creditNotesNotes.CardName = returnRequest.CardName; - creditNotesNotes.PaymentGroupCode = returnRequest.PaymentGroupCode; - creditNotesNotes.DocDate = DateTime.Now; - creditNotesNotes.DocDueDate = DateTime.Now; - creditNotesNotes.NumAtCard = ("07-" + Serie +"-" + Correlativo); - creditNotesNotes.U_SYP_MDTO = U_SYP_MDTO; - creditNotesNotes.U_SYP_MDCO = U_SYP_MDCO; - creditNotesNotes.U_SYP_MDSO = U_SYP_MDSO; - creditNotesNotes.U_SYP_MOTNC = returnRequest.U_SYP_MOTNC; - creditNotesNotes.U_SYP_TPONC = returnRequest.U_SYP_TPONC; - creditNotesNotes.U_SYP_MDCD = Correlativo; - creditNotesNotes.U_SYP_MDSD = Serie; - creditNotesNotes.U_SYP_MDTD = "07"; - creditNotesNotes.U_SYP_FECHAREF = DocDate.ToString("yyyy-MM-dd"); + // Cabecera de la NC: serie BC10/FC10 por el TIPO del documento origen (v2.1.7.0), correlativo y documento origen. + // El origen es la factura de la solicitud de devolucion o, si no hay, la propia solicitud + CabeceraNotaCredito.Completar(creditNotesNotes, returnRequest.DocCurrency, returnRequest.CardCode, returnRequest.CardName, returnRequest.PaymentGroupCode, + U_SYP_MDTO, U_SYP_MDSO, U_SYP_MDCO, DocDate, returnRequest.U_SYP_MOTNC, returnRequest.U_SYP_TPONC); entidad.Detalle.ForEach(x => { var Item = returnRequest.DocumentLines.ToList().FirstOrDefault(t => t.LineNum == x.Item);