diff --git a/index.html b/index.html
index 779fc75..e264d43 100644
--- a/index.html
+++ b/index.html
@@ -27,6 +27,8 @@
+
+
diff --git a/package.json b/package.json
index eff0aad..ebe8f2e 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
"compile": "gulp uglify",
"gulp-pre-commit": "gulp pre-commit",
"postinstall": "npm run compile && gulp clean-post-install",
- "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+https://debo.suite.repo/modulos-npm/foca-directivas.git git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git git+https://debo.suite.repo/modulos-npm/foca-modal-flete git+https://debo.suite.repo/modulos-npm/foca-modal.git git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git"
+ "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+https://debo.suite.repo/modulos-npm/foca-directivas.git git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git git+https://debo.suite.repo/modulos-npm/foca-modal-flete git+https://debo.suite.repo/modulos-npm/foca-modal.git git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git"
},
"pre-commit": [
"gulp-pre-commit"
@@ -35,8 +35,10 @@
"foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git",
"foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git",
"foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos",
+ "foca-modal-cotizacion": "git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git",
"foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git",
"foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete",
+ "foca-modal-moneda": "git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git",
"foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git",
"foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git",
"foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git",
diff --git a/src/js/app.js b/src/js/app.js
index d21a96c..b95430f 100644
--- a/src/js/app.js
+++ b/src/js/app.js
@@ -10,5 +10,7 @@ angular.module('focaCrearNotaPedido', [
'focaDirectivas',
'focaModal',
'focaModalDomicilio',
- 'angular-ladda'
+ 'angular-ladda',
+ 'focaModalMoneda',
+ 'focaModalCotizacion'
]);
diff --git a/src/js/controller.js b/src/js/controller.js
index 9096916..9bc5de5 100644
--- a/src/js/controller.js
+++ b/src/js/controller.js
@@ -25,14 +25,38 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
maxDate: new Date(),
minDate: new Date(2010, 0, 1)
};
+ $scope.crearObjetoNotaPedido = function() {
+ $scope.notaPedido = {
+ vendedor: {},
+ cliente: {},
+ proveedor: {},
+ domicilio: {dom: ''},
+ moneda: {},
+ cotizacion: {}
+ };
+ };
- $scope.notaPedido = {
- vendedor: {},
- cliente: {},
- domicilio: {dom: ''},
- moneda: {detalle: ''}
+ //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
+ $scope.obtenerMonedaPorDefecto = function() {
+ crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) {
+ monedaPorDefecto = {
+ id: res.data[0].ID,
+ detalle: res.data[0].DETALLE,
+ simbolo: res.data[0].SIMBOLO,
+ cotizaciones: res.data[0].cotizaciones
+ };
+ addCabecera('Moneda:', monedaPorDefecto.detalle);
+ addCabecera('Fecha cotizacion:',
+ new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString());
+ addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION);
+ $scope.notaPedido.moneda = monedaPorDefecto;
+ $scope.notaPedido.cotizacion.id = monedaPorDefecto.cotizaciones[0].ID;
+ });
};
+ var monedaPorDefecto;
+ $scope.crearObjetoNotaPedido();
+ $scope.obtenerMonedaPorDefecto();
$scope.cabecera = [];
$scope.showCabecera = true;
@@ -42,24 +66,27 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
$scope.articulosTabla = [];
$scope.idLista = undefined;
- var notaPedidoTemp = crearNotaPedidoService.getNotaPedido();
+ //La pantalla solo se usa para cargar pedidos
+ //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido();
+
crearNotaPedidoService.getPrecioCondicion().then(
function(res) {
$scope.precioCondiciones = res.data;
}
);
- if (notaPedidoTemp !== undefined) {
- notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga);
- $scope.notaPedido = notaPedidoTemp;
- $scope.notaPedido.flete = ($scope.notaPedido.flete).toString();
- $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString();
- $scope.idLista = $scope.notaPedido.precioCondicion;
- crearNotaPedidoService
- .getArticulosByIdNotaPedido($scope.notaPedido.id).then(
- function(res) {
- $scope.articulosTabla = res.data;
- }
- );
+ //La pantalla solo se usa para cargar pedidos
+ // if (notaPedidoTemp !== undefined) {
+ // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga);
+ // $scope.notaPedido = notaPedidoTemp;
+ // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString();
+ // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString();
+ // $scope.idLista = $scope.notaPedido.precioCondicion;
+ // crearNotaPedidoService
+ // .getArticulosByIdNotaPedido($scope.notaPedido.id).then(
+ // function(res) {
+ // $scope.articulosTabla = res.data;
+ // }
+ // );
//TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO
//(NO REQUERIDO EN ESTA VERSION)
// crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then(
@@ -67,12 +94,12 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
// $scope.notaPedido.domicilio = res.data;
// }
// );
- } else {
- $scope.notaPedido.fechaCarga = new Date();
- $scope.notaPedido.bomba = '0';
- $scope.notaPedido.flete = '0';
- $scope.idLista = undefined;
- }
+ // } else {
+ // $scope.notaPedido.fechaCarga = new Date();
+ // $scope.notaPedido.bomba = '0';
+ // $scope.notaPedido.flete = '0';
+ // $scope.idLista = undefined;
+ // }
//TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO
// $scope.addNewDom = function() {
// $scope.notaPedido.domicilio.push({ 'id': 0 });
@@ -86,39 +113,55 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
// ), 1);
// }
// };
+
$scope.crearNotaPedido = function() {
- if($scope.articulosTabla.length === 0) {
+ if(!$scope.notaPedido.vendedor.codigo) {
+ focaModalService.alert('Ingrese Vendedor');
+ return;
+ } else if(!$scope.notaPedido.cliente.id) {
+ focaModalService.alert('Ingrese Cliente');
+ return;
+ } else if(!$scope.notaPedido.proveedor.codigo) {
+ focaModalService.alert('Ingrese Proveedor');
+ return;
+ } else if(!$scope.notaPedido.moneda.id) {
+ focaModalService.alert('Ingrese Moneda');
+ return;
+ } else if(!$scope.notaPedido.cotizacion.id) {
+ focaModalService.alert('Ingrese Cotización');
+ return;
+ } else if(!$scope.plazosPagos) {
+ focaModalService.alert('Ingrese Precios y Condiciones');
+ return;
+ } else if(!$scope.notaPedido.flete) {
+ focaModalService.alert('Ingrese Flete');
+ return;
+ } else if(!$scope.notaPedido.domicilio.id) {
+ focaModalService.aler('Ingrese Domicilio');
+ return;
+ } else if($scope.articulosTabla.length === 0) {
focaModalService.alert('Debe cargar almenos un articulo');
return;
}
- if($scope.notaPedido.domicilio.id === undefined) {
- $scope.notaPedido.domicilio.id = 0;
- }
var date = new Date();
var notaPedido = {
id: 0,
fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000))
.toISOString().slice(0, 19).replace('T', ' '),
- vendedor: $scope.notaPedido.vendedor.nombre,
+ idVendedor: $scope.notaPedido.vendedor.codigo,
idCliente: $scope.notaPedido.cliente.id,
- domicilio: $scope.notaPedido.domicilio,
- bomba: $scope.notaPedido.bomba,
- flete: $scope.notaPedido.flete,
+ idProveedor: $scope.notaPedido.proveedor.codigo,
+ idDomicilio: $scope.notaPedido.domicilio.id,
+ idCotizacion: $scope.notaPedido.cotizacion.id,
+ flete: parseInt($scope.notaPedido.flete),
+ fob: parseInt($scope.notaPedido.fob),
+ bomba: parseInt($scope.notaPedido.bomba),
+ kilometros: $scope.notaPedido.kilometros,
total: $scope.getTotal()
};
crearNotaPedidoService.crearNotaPedido(notaPedido).then(
function(data) {
- if($scope.notaPedido.flete === 1) {
- var flete = {
- idNotaPedido: data.data.id,
- idTransportista: $scope.notaPedido.fleteId,
- idChofer: $scope.notaPedido.chofer.id,
- idVehiculo: $scope.notaPedido.vehiculo.id,
- kilometros: $scope.notaPedido.kilometros,
- costoKilometro: $scope.notaPedido.costoUnitarioKmFlete
- };
- crearNotaPedidoService.crearFlete(flete);
- }
+
var articulosNotaPedido = $scope.articulosTabla;
for(var i = 0; i < articulosNotaPedido.length; i++) {
delete articulosNotaPedido[i].editCantidad;
@@ -136,7 +179,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
crearNotaPedidoService.crearPlazosParaNotaPedido(json);
}
focaModalService.alert('Nota pedido creada');
- $scope.limpiarPantalla();
+ $scope.obtenerMonedaPorDefecto();
+ $scope.crearObjetoNotaPedido();
+ $scope.cabecera = [];
+ $scope.articulosTabla = [];
}
);
};
@@ -192,7 +238,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
modalInstance.result.then(
function(vendedor) {
addCabecera('Vendedor:', vendedor.NomVen);
- $scope.notaPedido.vendedor.nombre = vendedor.NomVen;
+ $scope.notaPedido.vendedor.codigo = vendedor.CodVen;
}, function() {
}
@@ -210,7 +256,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
);
modalInstance.result.then(
function(proveedor) {
- $scope.notaPedido.proveedor = proveedor.NOM;
+ $scope.notaPedido.proveedor.codigo = proveedor.COD;
addCabecera('Proveedor:', proveedor.NOM);
}, function() {
@@ -219,6 +265,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
};
$scope.seleccionarCliente = function() {
+
var modalInstance = $uibModal.open(
{
ariaLabelledBy: 'Busqueda de Cliente',
@@ -229,8 +276,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
);
modalInstance.result.then(
function(cliente) {
- $scope.notaPedido.cliente.nombre = cliente.nom;
- $scope.notaPedido.cliente.id = cliente.cod;
crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then(
function(data) {
if(data.data.length === 0){
@@ -239,37 +284,38 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
.then(
function() {
$scope.seleccionarCliente();
- $scope.notaPedido.cliente = {nombre: ''};
}
);
return;
}
- var modalInstanceDomicilio = $uibModal.open(
- {
- ariaLabelledBy: 'Busqueda de Domicilios',
- templateUrl: 'modal-domicilio.html',
- controller: 'focaModalDomicilioController',
- resolve: { idCliente: function() { return cliente.cod; }},
- size: 'lg',
- backdrop: 'static',
- }
- );
- modalInstanceDomicilio.result.then(
- function(domicilio) {
- focaModalService.alert('Domicilio elegido' + domicilio.dom);
- }, function() {
- $scope.notaPedido.cliente.nombre = '';
- $scope.notaPedido.cliente.id = '';
- removeCabecera('Cliente:');
- $scope.seleccionarCliente();
- return;
- }
- );
+ $scope.abrirModalDomicilios(cliente);
}
);
- addCabecera('Cliente:', cliente.nom);
}, function() {
+
+ }
+ );
+ };
+ $scope.abrirModalDomicilios = function(cliente) {
+ var modalInstanceDomicilio = $uibModal.open(
+ {
+ ariaLabelledBy: 'Busqueda de Domicilios',
+ templateUrl: 'modal-domicilio.html',
+ controller: 'focaModalDomicilioController',
+ resolve: { idCliente: function() { return cliente.cod; }},
+ size: 'lg',
+ }
+ );
+ modalInstanceDomicilio.result.then(
+ function(domicilio) {
+ $scope.notaPedido.domicilio.id = domicilio.id;
+ $scope.notaPedido.cliente.id = cliente.cod;
+ addCabecera('Cliente:', cliente.nom);
+ addCabecera('Domicilio:', domicilio.dom);
+ }, function() {
+ $scope.seleccionarCliente();
+ return;
}
);
};
@@ -291,7 +337,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
for (var i = 0; i < arrayTempArticulos.length; i++) {
total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
}
- return total.toFixed(2);
+ return parseFloat(total.toFixed(2));
};
$scope.getSubTotal = function() {
@@ -358,11 +404,12 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
modalInstance.result.then(
function(datos) {
$scope.notaPedido.flete = datos.flete;
+ $scope.notaPedido.fob = datos.FOB;
$scope.notaPedido.bomba = datos.bomba;
$scope.notaPedido.kilometros = datos.kilometros;
addCabecera('Flete:', datos.flete);
- if(datos.flete === 'si') {
+ if(datos.flete === '1') {
addCabecera('Bomba:', datos.bomba);
addCabecera('Kilometros:', datos.kilometros);
} else {
@@ -386,37 +433,36 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
);
modalInstance.result.then(
function(moneda) {
- $scope.notaPedido.moneda = {
- id: moneda.ID,
- detalle: moneda.DETALLE,
- simbolo: moneda.SIMBOLO
- };
- addCabecera('Moneda:', moneda.DETALLE);
- $scope.abrirModalCotizacion(moneda.ID);
+ $scope.abrirModalCotizacion(moneda);
}, function() {
}
);
};
- $scope.abrirModalCotizacion = function(idMoneda) {
+ $scope.abrirModalCotizacion = function(moneda) {
var modalInstance = $uibModal.open(
{
ariaLabelledBy: 'Busqueda de Cotización',
templateUrl: 'modal-cotizacion.html',
controller: 'focaModalCotizacionController',
size: 'lg',
- resolve: {idMoneda: function() {return idMoneda;}}
+ resolve: {idMoneda: function() {return moneda.ID;}}
}
);
modalInstance.result.then(
function(cotizacion) {
+ $scope.notaPedido.moneda = {
+ id: moneda.ID,
+ detalle: moneda.DETALLE,
+ simbolo: moneda.SIMBOLO
+ };
$scope.notaPedido.cotizacion = {
id: cotizacion.ID,
cotizacion: cotizacion.COTIZACION
};
-
+ addCabecera('Moneda:', moneda.DETALLE);
addCabecera(
'Fecha cotizacion:',
$filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
diff --git a/src/js/service.js b/src/js/service.js
index 427f087..cd79b16 100644
--- a/src/js/service.js
+++ b/src/js/service.js
@@ -45,6 +45,9 @@ angular.module('focaCrearNotaPedido')
},
crearPlazosParaNotaPedido: function(plazos) {
return $http.post(route + '/plazo-pago/nota-pedido', plazos);
+ },
+ getCotizacionByIdMoneda: function(id) {
+ return $http.get(route + '/moneda/' + id);
}
};
}]);