Skip to content
Open
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
6 changes: 5 additions & 1 deletion app/scripts/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ angular.module('contractualClienteApp')
var id_token = window.localStorage.getItem('id_token').split('.');
var payload = JSON.parse(atob(id_token[1]));
var tipo = payload.documento_compuesto.split(payload.documento)
terceroCrudRequest.get("datos_identificacion?limit=-1&fields=TerceroId&query=TipoDocumentoId__CodigoAbreviacion%3A"+ tipo[0] +"%2CNumero%3A" + payload.documento)
terceroCrudRequest.get("datos_identificacion",{
limit:"-1",
fields:"TerceroId",
query:"Activo:true,TipoDocumentoId__CodigoAbreviacion:"+ tipo[0] +",Numero:" + payload.documento
})
.then(function(res){
window.localStorage.setItem("idTercero", res.data[0].TerceroId.Id);
})
Expand Down
71 changes: 62 additions & 9 deletions app/scripts/controllers/necesidad/necesidades.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Controller of the contractualClienteApp
*/
angular.module('contractualClienteApp')
.controller('NecesidadesCtrl', function ($scope, planCuentasMidRequest, agoraRequest, parametrosRequest,catalogoRequest, necesidadService, $translate, $window,$http, $mdDialog, gridApiService, necesidadesCrudRequest) {
.controller('NecesidadesCtrl', function ($scope, planCuentasMidRequest, agoraRequest, parametrosRequest,catalogoRequest, necesidadService, $translate, $window,$http, $mdDialog, gridApiService, necesidadesCrudRequest, terceroMidRequest, coreAmazonRequest) {
var self = this;
self.offset = 0;
self.rechazada = false;
Expand Down Expand Up @@ -232,19 +232,72 @@ angular.module('contractualClienteApp')
self.cargarDatosNecesidades = function (offset, query) {
if (query === undefined) { query = []; }
query = typeof (query) === "string" ? [query] : query;
query.push("EstadoNecesidad.Nombre__not_in:Borrador");

var req = necesidadesCrudRequest.get('necesidad', $.param({
limit: self.gridOptions.paginationPageSize,
offset: offset,
sortby: "Id",
order: "desc"
//query.push("EstadoNecesidad.Nombre__not_in:Borrador");
var req;
req = necesidadesCrudRequest.get('necesidad', $.param({
query: query,
limit: self.gridOptions.paginationPageSize,
offset: offset,
sortby: "Id",
order: "desc"
}, true));
req.then(gridApiService.paginationFunc(self.gridOptions, offset));
return req;
};

self.cargarDatosNecesidades(self.offset, self.query);
terceroMidRequest
.get("propiedad/dependencia/" + window.localStorage.getItem("idTercero"))
.then(function (Dependencias) {
//trae lista dependencias
if (Dependencias.data !== null) {
self.dependencia_soli_data = Dependencias.data;
} else {
swal({
title: "Sin dependencias",
type: "error",
text: "No tiene dependencias relacionadas",
showCloseButton: true,
confirmButtonText: $translate.instant("CERRAR"),
});
}
coreAmazonRequest
.get("ordenador_gasto",
$.param({
limit: -1,
sortby: "Cargo",
order: "asc",
}))
.then(function (response) {
self.ordenador_gasto_data = response.data;
self.cargarQuery(self.ordenador_gasto_data);
self.cargarDatosNecesidades(self.offset, self.query);
})
.catch(function (err) {
console.info(err);
});
});

self.cargarQuery = function(infoDep) {
var RolOrdenadorGastoDep;
self.dependencia_soli_data.forEach(function(depen){
RolOrdenadorGastoDep = infoDep
.filter(function(rolf){
return rolf.DependenciaId === depen.Id;
})
.map(function(rol){
return rol.DependenciaId;
})
.join("|")
});
if(RolOrdenadorGastoDep){
self.query = "DependenciaNecesidadId__RolOrdenadorGasto__in:" + RolOrdenadorGastoDep;
} else {
const deps = self.dependencia_soli_data.map(function(dep){
return dep.Id;
}).join("|");
self.query = "DependenciaNecesidadId__DependenciaSolicitante__in:" + deps;
}
}

self.transformIvaData = function(data) { // Transformar datos de IVA
if (data) {
Expand Down
18 changes: 17 additions & 1 deletion app/scripts/controllers/necesidad/pdfnecesidad.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,29 @@
* Controller of the contractualClienteApp
*/
angular.module('contractualClienteApp')
.controller('PdfnecesidadCtrl', function (pdfMakerNecesidadesService, $scope, $routeParams, necesidadService) {
.controller('PdfnecesidadCtrl', function (pdfMakerNecesidadesService, $scope, $routeParams, necesidadService,catalogoRequest) {
var self = this;
$scope.IdNecesidad = $routeParams.IdNecesidad;

self.generarNecesidad = function (IdNecesidad) {
necesidadService.getFullNecesidad(IdNecesidad).then(function (trNecesidad) {
trNecesidad=trNecesidad.data.Body;
if (trNecesidad.ProductosCatalogoNecesidad && trNecesidad.ProductosCatalogoNecesidad !== null) {
trNecesidad.ProductosCatalogoNecesidad.forEach(function(prod) {
prod.valorIvaUnd=0;
prod.ElementoNombre="";
prod.ValorTotal=0;
catalogoRequest.get('elemento', $.param({
query: "Id:"+prod.CatalogoId,
fields: 'Id,Nombre',
limit: -1,
sortby: "Nombre",
order: "asc",
})).then(function (response) {
prod.ElementoNombre = response.data[0].Nombre;
});
})
}
$scope.trNecesidad = trNecesidad;
pdfMakerNecesidadesService.docDefinition(trNecesidad).then(function (docDefinition) {
var a = pdfMake.createPdf(docDefinition);
Expand Down
8 changes: 8 additions & 0 deletions app/scripts/controllers/necesidad/solicitud_necesidad.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,8 @@ angular
self.jefe_solicitante = JD.Persona;
self.Necesidad.DependenciaNecesidadId.JefeDepSolicitanteId =
JD.JefeDependencia.Id;
self.Necesidad.DependenciaNecesidadId.DependenciaSolicitante =
self.dependencia_solicitante;
// self.dependencia_solicitante.JefeDependenciaSolicitante = JD.JefeDependencia.Id; OLD
})
.catch(function (err) { })
Expand All @@ -550,6 +552,8 @@ angular
self.jefe_destino = JD.Persona;
self.Necesidad.DependenciaNecesidadId.JefeDepDestinoId =
JD.JefeDependencia.Id;
self.Necesidad.DependenciaNecesidadId.DependenciaDestino =
self.dependencia_destino;
})
.catch(function (err) { })
: _;
Expand All @@ -568,6 +572,8 @@ angular
self.supervisor = JD.Persona;
self.Necesidad.DependenciaNecesidadId.SupervisorId =
JD.JefeDependencia.Id;
self.Necesidad.DependenciaNecesidadId.DependenciaSupervisor =
self.dependencia_supervisor;
})
.catch(function (err) { })
: _;
Expand All @@ -586,6 +592,8 @@ angular
self.ordenador_gasto = JD.Persona;
self.Necesidad.DependenciaNecesidadId.OrdenadorGastoId =
parseInt(JD.JefeDependencia.Id, 10);
self.Necesidad.DependenciaNecesidadId.RolOrdenadorGasto =
self.rol_ordenador_gasto;
})
.catch(function (err) { })
: _;
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/services/tercero_crud_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ angular.module('terceroCrudService',[])
if (params === undefined) {
return $http.get(path + tabla, [{ timeout: cancelSearch.promise }, token_service.setting_bearer.headers]);
} else {
return $http.get(path + tabla + "/?" + params, [{ timeout: cancelSearch.promise }, token_service.setting_bearer.headers]);
return $http.get(path + tabla, { timeout: cancelSearch.promise, params: params }/*[, token_service.setting_bearer.headers]*/);
}
},
post: function(tabla, elemento) {
Expand All @@ -36,4 +36,4 @@ angular.module('terceroCrudService',[])
return cancelSearch.resolve('search aborted');
}
};
});
});
64 changes: 42 additions & 22 deletions app/scripts/services/utils/pdf_maker_necesidades.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ angular.module('contractualClienteApp')
if(trNecesidad.Necesidad.TipoFinanciacionNecesidadId.CodigoAbreviacion === "I") {
for(var i = 0; i < r.Metas.length; i++) {
for(var j = 0; j < r.Metas[i].Actividades.length ; j++) {
for(var k = 0; k < r.Metas[i].Actividades[2].FuentesActividad.length ; k++) {
for(var k = 0; k < r.Metas[i].Actividades[j].FuentesActividad.length ; k++) {
valorRubroNecesidad = valorRubroNecesidad + r.Metas[i].Actividades[j].FuentesActividad[k].MontoParcial;
}
}
}
}else{
for(var i = 0; i < r.Fuentes.length; i++) {
valorRubroNecesidad = valorRubroNecesidad + r.Fuentes[3].MontoParcial;
valorRubroNecesidad = valorRubroNecesidad + r.Fuentes[i].MontoParcial;
}
}
r.InfoRubro.ValorNecesidad = valorRubroNecesidad;
Expand Down Expand Up @@ -90,9 +90,27 @@ angular.module('contractualClienteApp')

var dependenciaDestino = dependenciaData.filter(function (d) { return d.Id === jefeDependenciaDestino.JefeDependencia.DependenciaId })[0]
var dependenciaSolicitante = dependenciaData.filter(function (d) { return d.Id === jefeDependenciaSolicitante.JefeDependencia.DependenciaId })[0]
var perfil;
var perfil, compraBool = false, compraString = "";

if(trNecesidad.Necesidad && trNecesidad.Necesidad.TipoContratoNecesidadId && trNecesidad.Necesidad.TipoContratoNecesidadId.Nombre){
if(trNecesidad.Necesidad.TipoContratoNecesidadId.Nombre == "Compra"){
perfil = {
ValorParametro: trNecesidad.Necesidad.TipoContratoNecesidadId.Nombre
};
compraString = trNecesidad.Necesidad.TipoContratoNecesidadId.Nombre;
compraBool = true;
}
}

if(trNecesidad.DetalleServicioNecesidad && trNecesidad.DetalleServicioNecesidad.TipoServicioId){
perfil = trNecesidad.DetalleServicioNecesidad ? TiposServicios.find(function(element){return element.ID == trNecesidad.DetalleServicioNecesidad.TipoServicioId}): {ValorParametro: ""};
perfil = trNecesidad.DetalleServicioNecesidad ? TiposServicios.find(function(element){
return element.ID == trNecesidad.DetalleServicioNecesidad.TipoServicioId
}): {
ValorParametro: ""
};
if(compraBool){
perfil.ValorParametro = perfil.ValorParametro + " y " +compraString;
}
}else if(trNecesidad.DetallePrestacionServicioNecesidad && trNecesidad.DetallePrestacionServicioNecesidad.PerfilId){
perfil = trNecesidad.DetallePrestacionServicioNecesidad ? perfil_data.filter(function (d) {
return d.Id === trNecesidad.DetallePrestacionServicioNecesidad.PerfilId
Expand Down Expand Up @@ -165,26 +183,28 @@ angular.module('contractualClienteApp')
[{ alignment: "justify", text: trNecesidad.Necesidad.Justificacion.toUpperCase() }],
[{ style: "title2", text: "ESPECIFICACIONES TÉCNICAS: Si la compra o el servicio contempla especificaciones del orden técnico descríbalas." }],
[
{
table: {
headerRows: 1,
widths: ["auto", "*", "auto", "auto"],
body: [
["Descripción", "", "Cantidad", "Unidad"],
[
["Cod. 1", "Especificación:"],
[{text: perfil.ValorParametro ?
perfil.ValorParametro : perfil.DESCRIPCION ? perfil.DESCRIPCION:"", bold: true}, "Actividades:",
{
text: trNecesidad.ActividadEspecificaNecesidad ?
trNecesidad.ActividadEspecificaNecesidad.map(function (ae, i) { return (i + 1).toString() + '. ' + ae.Descripcion + '.'}).join('\n \n') : "Ninguna", alignment: "justify"
}],
{ text: 1, alignment: 'center' },
""
]
{
table: {
headerRows: 1,
widths: ["auto", "*", "auto", "auto"],
body: [
["Descripción", "", "Cantidad", "Unidad"],
[
["Cod. 1", "Especificación:"],
[{text: perfil.ValorParametro ?
perfil.ValorParametro : perfil.DESCRIPCION ? perfil.DESCRIPCION : "", bold: true}, compraBool ? "Productos" : "Actividades:",
{
text: compraBool ? trNecesidad.ProductosCatalogoNecesidad.map(function (prod, j){ return (j + 1).toString() + '. ' + prod.ElementoNombre + '.'}).join('\n \n')
:
trNecesidad.ActividadEspecificaNecesidad ?
trNecesidad.ActividadEspecificaNecesidad.map(function (ae, i) { return (i + 1).toString() + '. ' + ae.Descripcion + '.'}).join('\n \n') : "Ninguna", alignment: "justify"
}],
[{ text: compraBool ? trNecesidad.ProductosCatalogoNecesidad.map(function (prod){ return "\n \n" + prod.Cantidad}).join('\n \n') : 1, alignment: 'center' }],
""
]
}
]
}
}
],
[{ style: "title1", text: "Información del contacto".toUpperCase() }],
[[
Expand Down