bueno es parte del plan de implementacion para el caso de uso de gestion

de stock
This commit is contained in:
fede committed 2026-11-16 08:37:34 -03:00
1 parent 24e746b1b7
commit 6ed8805e21
40 files changed
+2748 -31

No files matched your search

@@ -0,0 +1,32 @@
package factura
import (
"errors"
"net/http"
"strconv"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
r "repuestera_back/repositorios"
)
func ObtenerFactura(c *gin.Context) {
id, err := strconv.ParseUint(c.Param("id"), 10, 64)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "id inválido"})
return
}
factura, err := r.ObtenerRepositorios(c).Factura.ObtenerConRelaciones(uint(id))
if errors.Is(err, gorm.ErrRecordNotFound) {
c.JSON(http.StatusNotFound, gin.H{"error": "factura no encontrada"})
return
}
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, factura)
}