Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions helpers/ajustesHelper/ajustes.acta.helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,24 @@ func fillElementos(elsOrg []*models.DetalleElemento_) (completos []*models.Detal

}

func generarNuevosActa(nuevos []*models.DetalleElemento_) (actualizados []*models.Elemento, outputError map[string]interface{}) {
func generarNuevosActa(nuevos []*models.DetalleElemento_, originales []*models.Elemento) (actualizados []*models.Elemento, outputError map[string]interface{}) {

funcion := "generarNuevosActa"
defer errorCtrl.ErrorControlFunction(funcion+" - Unhandled Error!", "500")

outputError = utilsHelper.FillStruct(nuevos, &actualizados)
if outputError = utilsHelper.FillStruct(nuevos, &actualizados); outputError != nil {
return
}

// El PUT a acta_recibido_crud reemplaza la fila completa; se preservan las
// fechas del elemento original para no violar el not-null de fecha_creacion.
for _, el := range actualizados {
if idx := findElementoInArrayE(originales, el.Id); idx > -1 {
el.FechaCreacion = originales[idx].FechaCreacion
el.FechaModificacion = originales[idx].FechaModificacion
}
}

return

}
Expand Down
2 changes: 1 addition & 1 deletion helpers/ajustesHelper/ajustes.auto.helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func GenerarAjusteAutomatico(elementos []*models.DetalleElemento_) (resultado *m
}

if len(updateSg)+len(updateVls)+len(updateMsc) > 0 {
if nuevos, err := generarNuevosActa(append(updateSg, (append(updateVls, updateMsc...))...)); err != nil {
if nuevos, err := generarNuevosActa(append(updateSg, (append(updateVls, updateMsc...))...), orgiginalesActa); err != nil {
return nil, err
} else {
nuevosActa = nuevos
Expand Down
2 changes: 1 addition & 1 deletion helpers/ajustesHelper/ajustes.movimientos.helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func generarMovimientoAjuste(sg, vls, msc, mp []*models.DetalleElemento_, movCon
movimiento.FormatoTipoMovimientoId = fm[0]
}

if sm, err := movimientosArka.GetAllEstadoMovimiento(url.QueryEscape("Ajuste Aprobado")); err != nil {
if sm, err := movimientosArka.GetAllEstadoMovimiento("query=Nombre:" + url.QueryEscape("Ajuste Aprobado")); err != nil {
return nil, nil, err
} else {
movimiento.EstadoMovimientoId = sm[0]
Expand Down
25 changes: 0 additions & 25 deletions helpers/crud/consecutivos/Post.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"

"github.com/beego/beego/v2/core/logs"
beego "github.com/beego/beego/v2/server/web"
"github.com/udistrital/arka_mid/models"
"github.com/udistrital/arka_mid/utils_oas/errorCtrl"
Expand All @@ -23,14 +22,12 @@ func Post(consecutivo interface{}) (outputError map[string]interface{}) {
response := new(models.RespuestaAPI1Interface)

if err := request.SendJson(urlcrud, "POST", response, consecutivo); err != nil {
logs.Error(urlcrud + ", " + err.Error())
eval := ` - request.SendJson(urlcrud, "POST", response, consecutivo)`
return errorCtrl.Error(funcion+eval, err, "502")
}

if !response.Success {
err := fmt.Errorf("%v", response.Message)
logs.Error(err)
eval := ` - request.SendJson(urlcrud, "POST", response, consecutivo)`
return errorCtrl.Error(funcion+eval, err, "502")
}
Expand All @@ -56,28 +53,6 @@ func Post(consecutivo interface{}) (outputError map[string]interface{}) {
err := fmt.Errorf("response.Data llegó como arreglo vacío")
return errorCtrl.Error(funcion+" - response.Data vacío", err, "502")
}

// intentar encontrar el consecutivo correcto si el payload es *models.Consecutivo
if cons, ok := consecutivo.(*models.Consecutivo); ok {
for _, item := range data {
tmp := models.Consecutivo{}
raw, err := json.Marshal(item)
if err != nil {
continue
}
if err := json.Unmarshal(raw, &tmp); err != nil {
continue
}

if tmp.ContextoId == cons.ContextoId &&
tmp.Year == cons.Year &&
tmp.Descripcion == cons.Descripcion {
return fill(item, consecutivo)
}
}
}

// fallback: usar el último elemento
return fill(data[len(data)-1], consecutivo)

default:
Expand Down
78 changes: 39 additions & 39 deletions swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1211,44 +1211,6 @@
}
}
},
"/salida/{id}/anular": {
"put": {
"tags": [
"salida"
],
"description": "Anula una salida aprobada, registra un movimiento de reversión contable y restablece la entrada padre cuando corresponda.",
"operationId": "SalidaController.PutAnular",
"parameters": [
{
"in": "path",
"name": "id",
"description": "Id de la salida a anular",
"required": true,
"type": "integer",
"format": "int64"
},
{
"in": "body",
"name": "body",
"description": "Observación de la anulación",
"schema": {
"$ref": "#/definitions/models.AnulacionSalidaRequest"
}
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/models.ResultadoAnulacionSalida"
}
},
"400": {
"description": "the request contains incorrect syntax"
}
}
}
},
"/inmuebles/": {
"get": {
"tags": [
Expand Down Expand Up @@ -1792,6 +1754,44 @@
}
}
},
"/salida/{id}/anular": {
"put": {
"tags": [
"salida"
],
"description": "Anula una salida aprobada, registra un movimiento de reversión contable y restablece la entrada padre cuando corresponda.",
"operationId": "SalidaController.PutAnular",
"parameters": [
{
"in": "path",
"name": "id",
"description": "Id de la salida a anular",
"required": true,
"type": "integer",
"format": "int64"
},
{
"in": "body",
"name": "body",
"description": "Observación de la anulación",
"schema": {
"$ref": "#/definitions/models.AnulacionSalidaRequest"
}
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/models.ResultadoAnulacionSalida"
}
},
"400": {
"description": "the request contains incorrect syntax"
}
}
}
},
"/terceros/{id}": {
"get": {
"tags": [
Expand Down Expand Up @@ -4796,4 +4796,4 @@
"description": "ReportesController operations for reportes\n"
}
]
}
}
6 changes: 5 additions & 1 deletion utils_oas/errorCtrl/errorCtrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import (
func ErrorControlController(c web.Controller, controller string) {
if err := recover(); err != nil {
logs.Error(err)
localError := err.(map[string]interface{})
localError, ok := err.(map[string]interface{})
if !ok {
c.Abort(strconv.Itoa(http.StatusInternalServerError))
return
}
Comment on lines +15 to +19
appName, _ := web.AppConfig.String("appname")
c.Data["mesaage"] = (appName + "/" + controller + "/" + (localError["funcion"]).(string))
c.Data["data"] = normalizeErrorValue(localError["err"])
Comment on lines 20 to 22
Expand Down