Commit 715e7ebc852e874ee7f9f7b0baeea2c9eca268cb
1 parent
edc2dc474c
Exists in
master
and in
1 other branch
cargar nota de pedido
Showing
4 changed files
with
84 additions
and
22 deletions
Show diff stats
index.html
| 1 | <html ng-app="focaCrearRemito"> | 1 | <html ng-app="focaCrearRemito"> |
| 2 | <head> | 2 | <head> |
| 3 | <meta charset="UTF-8"/> | 3 | <meta charset="UTF-8"/> |
| 4 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | 4 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
| 5 | 5 | ||
| 6 | <!--CSS--> | 6 | <!--CSS--> |
| 7 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> | 7 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> |
| 8 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/> | 8 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/> |
| 9 | <link href="node_modules/ladda/dist/ladda-themeless.min.css" rel="stylesheet"> | 9 | <link href="node_modules/ladda/dist/ladda-themeless.min.css" rel="stylesheet"> |
| 10 | 10 | ||
| 11 | <!--VENDOR JS--> | 11 | <!--VENDOR JS--> |
| 12 | <script src="node_modules/jquery/dist/jquery.min.js"></script> | 12 | <script src="node_modules/jquery/dist/jquery.min.js"></script> |
| 13 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> | 13 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> |
| 14 | <script src="node_modules/angular/angular.min.js"></script> | 14 | <script src="node_modules/angular/angular.min.js"></script> |
| 15 | <script src="node_modules/angular-route/angular-route.min.js"></script> | 15 | <script src="node_modules/angular-route/angular-route.min.js"></script> |
| 16 | <script src="node_modules/angular-cookies/angular-cookies.min.js"></script> | 16 | <script src="node_modules/angular-cookies/angular-cookies.min.js"></script> |
| 17 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> | 17 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> |
| 18 | <script src="node_modules/ladda/dist/spin.min.js"></script> | 18 | <script src="node_modules/ladda/dist/spin.min.js"></script> |
| 19 | <script src="node_modules/ladda/dist/ladda.min.js"></script> | 19 | <script src="node_modules/ladda/dist/ladda.min.js"></script> |
| 20 | <script src="node_modules/angular-ladda/dist/angular-ladda.min.js"></script> | 20 | <script src="node_modules/angular-ladda/dist/angular-ladda.min.js"></script> |
| 21 | <script src="vendor/cordovaGeolocationModule.min.js"></script> | 21 | <script src="vendor/cordovaGeolocationModule.min.js"></script> |
| 22 | 22 | ||
| 23 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> | 23 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> |
| 24 | <script src="node_modules/foca-modal-vendedores/dist/foca-modal-vendedores.min.js"></script> | 24 | <script src="node_modules/foca-modal-vendedores/dist/foca-modal-vendedores.min.js"></script> |
| 25 | <script src="node_modules/foca-modal-busqueda-productos/dist/foca-busqueda-productos.min.js"></script> | 25 | <script src="node_modules/foca-modal-busqueda-productos/dist/foca-busqueda-productos.min.js"></script> |
| 26 | <script src="node_modules/foca-modal-proveedor/dist/foca-modal-proveedor.min.js"></script> | 26 | <script src="node_modules/foca-modal-proveedor/dist/foca-modal-proveedor.min.js"></script> |
| 27 | <script src="node_modules/foca-busqueda-cliente/dist/foca-busqueda-cliente.min.js"></script> | 27 | <script src="node_modules/foca-busqueda-cliente/dist/foca-busqueda-cliente.min.js"></script> |
| 28 | <script src="node_modules/foca-modal-precio-condiciones/dist/foca-modal-precio-condiciones.min.js"></script> | 28 | <script src="node_modules/foca-modal-precio-condiciones/dist/foca-modal-precio-condiciones.min.js"></script> |
| 29 | <script src="node_modules/foca-modal-flete/dist/foca-modal-flete.min.js"></script> | 29 | <script src="node_modules/foca-modal-flete/dist/foca-modal-flete.min.js"></script> |
| 30 | <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> | 30 | <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> |
| 31 | <script src="node_modules/foca-modal-domicilio/dist/foca-modal-domicilios.min.js"></script> | 31 | <script src="node_modules/foca-modal-domicilio/dist/foca-modal-domicilios.min.js"></script> |
| 32 | <script src="./node_modules/foca-configuracion/dist/foca-configuracion.min.js"></script> | 32 | <script src="./node_modules/foca-configuracion/dist/foca-configuracion.min.js"></script> |
| 33 | <script src="node_modules/foca-modal-moneda/dist/foca-modal-moneda.min.js"></script> | 33 | <script src="node_modules/foca-modal-moneda/dist/foca-modal-moneda.min.js"></script> |
| 34 | <script src="node_modules/foca-modal-cotizacion/dist/foca-modal-cotizacion.min.js"></script> | 34 | <script src="node_modules/foca-modal-cotizacion/dist/foca-modal-cotizacion.min.js"></script> |
| 35 | <script src="node_modules/foca-seguimiento/dist/foca-seguimiento.min.js"></script> | 35 | <script src="node_modules/foca-seguimiento/dist/foca-seguimiento.min.js"></script> |
| 36 | <script src="../foca-modal-nota-pedido/dist/foca-modal-nota-pedido.min.js"></script> | ||
| 36 | 37 | ||
| 37 | <script src="src/js/app.js"></script> | 38 | <script src="src/js/app.js"></script> |
| 38 | <script src="src/js/controller.js"></script> | 39 | <script src="src/js/controller.js"></script> |
| 39 | <script src="src/js/service.js"></script> | 40 | <script src="src/js/service.js"></script> |
| 40 | <script src="src/js/businessService.js"></script> | 41 | <script src="src/js/businessService.js"></script> |
| 41 | <script src="src/js/route.js"></script> | 42 | <script src="src/js/route.js"></script> |
| 42 | 43 | ||
| 43 | <script src="src/etc/develop.js"></script> | 44 | <script src="src/etc/develop.js"></script> |
| 44 | </head> | 45 | </head> |
| 45 | <body> | 46 | <body> |
| 46 | <div ng-view class="container-fluid"></div> | 47 | <div ng-view class="container-fluid"></div> |
| 47 | </body> | 48 | </body> |
| 48 | </html> | 49 | </html> |
| 49 | 50 |
package.json
| 1 | { | 1 | { |
| 2 | "name": "foca-crear-remito", | 2 | "name": "foca-crear-remito", |
| 3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
| 4 | "description": "Listado y ABM nota de remitos", | 4 | "description": "Listado y ABM nota de remitos", |
| 5 | "main": "index.js", | 5 | "main": "index.js", |
| 6 | "scripts": { | 6 | "scripts": { |
| 7 | "test": "echo \"Error: no test specified\" && exit 1", | 7 | "test": "echo \"Error: no test specified\" && exit 1", |
| 8 | "compile": "gulp uglify", | 8 | "compile": "gulp uglify", |
| 9 | "gulp-pre-commit": "gulp pre-commit", | 9 | "gulp-pre-commit": "gulp pre-commit", |
| 10 | "postinstall": "npm run compile && gulp clean-post-install", | 10 | "postinstall": "npm run compile && gulp clean-post-install", |
| 11 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route angular-cookies 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-seguimiento.git git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git git+https://debo.suite.repo/modulos-npm/foca-configuracion.git" | 11 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route angular-cookies 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-seguimiento.git git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git git+https://debo.suite.repo/modulos-npm/foca-configuracion.git" |
| 12 | }, | 12 | }, |
| 13 | "pre-commit": [ | 13 | "pre-commit": [ |
| 14 | "gulp-pre-commit" | 14 | "gulp-pre-commit" |
| 15 | ], | 15 | ], |
| 16 | "repository": { | 16 | "repository": { |
| 17 | "type": "git", | 17 | "type": "git", |
| 18 | "url": "https://debo.suite.repo/modulos-npm/foca-crear-remito.git" | 18 | "url": "https://debo.suite.repo/modulos-npm/foca-crear-remito.git" |
| 19 | }, | 19 | }, |
| 20 | "author": "Foca Software", | 20 | "author": "Foca Software", |
| 21 | "license": "ISC", | 21 | "license": "ISC", |
| 22 | "peerDependencies": { | 22 | "peerDependencies": { |
| 23 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", | 23 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", |
| 24 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", | 24 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", |
| 25 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", | 25 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", |
| 26 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", | 26 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", |
| 27 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", | 27 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", |
| 28 | "foca-seguimiento": "git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git" | 28 | "foca-seguimiento": "git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git" |
| 29 | }, | 29 | }, |
| 30 | "devDependencies": { | 30 | "devDependencies": { |
| 31 | "angular": "^1.7.5", | 31 | "angular": "^1.7.5", |
| 32 | "angular-cookies": "^1.7.5", | ||
| 32 | "angular-ladda": "^0.4.3", | 33 | "angular-ladda": "^0.4.3", |
| 33 | "angular-route": "^1.7.5", | 34 | "angular-route": "^1.7.5", |
| 34 | "bootstrap": "^4.1.3", | 35 | "bootstrap": "^4.1.3", |
| 35 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", | 36 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", |
| 37 | "foca-configuracion": "git+https://debo.suite.repo/modulos-npm/foca-configuracion.git", | ||
| 36 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", | 38 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", |
| 37 | "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", | 39 | "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", |
| 38 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", | 40 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", |
| 39 | "foca-modal-cotizacion": "git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git", | 41 | "foca-modal-cotizacion": "git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git", |
| 40 | "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", | 42 | "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", |
| 41 | "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete", | 43 | "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete", |
| 42 | "foca-modal-moneda": "git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git", | 44 | "foca-modal-moneda": "git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git", |
| 43 | "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", | 45 | "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", |
| 44 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", | 46 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", |
| 45 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", | 47 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", |
| 46 | "foca-seguimiento": "git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git", | 48 | "foca-seguimiento": "git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git", |
| 47 | "font-awesome": "^4.7.0", | 49 | "font-awesome": "^4.7.0", |
| 48 | "gulp": "^3.9.1", | 50 | "gulp": "^3.9.1", |
| 49 | "gulp-angular-templatecache": "^2.2.2", | 51 | "gulp-angular-templatecache": "^2.2.5", |
| 50 | "gulp-clean": "^0.4.0", | 52 | "gulp-clean": "^0.4.0", |
| 51 | "gulp-concat": "^2.6.1", | 53 | "gulp-concat": "^2.6.1", |
| 52 | "gulp-connect": "^5.6.1", | 54 | "gulp-connect": "^5.6.1", |
| 53 | "gulp-htmlmin": "^5.0.1", | 55 | "gulp-htmlmin": "^5.0.1", |
| 54 | "gulp-jshint": "^2.1.0", | 56 | "gulp-jshint": "^2.1.0", |
| 55 | "gulp-rename": "^1.4.0", | 57 | "gulp-rename": "^1.4.0", |
| 56 | "gulp-replace": "^1.0.0", | 58 | "gulp-replace": "^1.0.0", |
| 57 | "gulp-sequence": "^1.0.0", | 59 | "gulp-sequence": "^1.0.0", |
| 58 | "gulp-uglify": "^3.0.1", | 60 | "gulp-uglify": "^3.0.1", |
| 59 | "gulp-uglify-es": "^1.0.4", | 61 | "gulp-uglify-es": "^1.0.4", |
| 60 | "jasmine-core": "^3.3.0", | 62 | "jasmine-core": "^3.3.0", |
| 61 | "jquery": "^3.3.1", | 63 | "jquery": "^3.3.1", |
| 62 | "jshint": "^2.9.6", | 64 | "jshint": "^2.9.6", |
| 63 | "ladda": "1.0.6", | 65 | "ladda": "1.0.6", |
| 64 | "pre-commit": "^1.2.2", | 66 | "pre-commit": "^1.2.2", |
| 65 | "pump": "^3.0.0", | 67 | "pump": "^3.0.0", |
| 66 | "ui-bootstrap4": "^3.0.5", | 68 | "ui-bootstrap4": "^3.0.5" |
| 67 | "angular-cookies": "^1.7.5", | ||
| 68 | "foca-configuracion": "git+https://debo.suite.repo/modulos-npm/foca-configuracion.git" | ||
| 69 | } | 69 | } |
src/js/app.js
| 1 | angular.module('focaCrearRemito', [ | 1 | angular.module('focaCrearRemito', [ |
| 2 | 'ngRoute', | 2 | 'ngRoute', |
| 3 | 'ngCookies', | 3 | 'ngCookies', |
| 4 | 'ui.bootstrap', | 4 | 'ui.bootstrap', |
| 5 | 'focaModalVendedores', | 5 | 'focaModalVendedores', |
| 6 | 'focaBusquedaProductos', | 6 | 'focaBusquedaProductos', |
| 7 | 'focaModalProveedor', | 7 | 'focaModalProveedor', |
| 8 | 'focaBusquedaCliente', | 8 | 'focaBusquedaCliente', |
| 9 | 'focaModalPrecioCondicion', | 9 | 'focaModalPrecioCondicion', |
| 10 | 'focaModalFlete', | 10 | 'focaModalFlete', |
| 11 | 'focaDirectivas', | 11 | 'focaDirectivas', |
| 12 | 'focaModal', | 12 | 'focaModal', |
| 13 | 'focaModalDomicilio', | 13 | 'focaModalDomicilio', |
| 14 | 'focaModalMoneda', | 14 | 'focaModalMoneda', |
| 15 | 'focaModalCotizacion', | 15 | 'focaModalCotizacion', |
| 16 | 'focaConfiguracion', | 16 | 'focaConfiguracion', |
| 17 | 'angular-ladda' | 17 | 'angular-ladda', |
| 18 | 'focaModalNotaPedido' | ||
| 18 | ]); | 19 | ]); |
| 19 | 20 |
src/js/controller.js
| 1 | angular.module('focaCrearRemito') .controller('remitoController', | 1 | angular.module('focaCrearRemito') .controller('remitoController', |
| 2 | [ | 2 | [ |
| 3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', |
| 4 | 'focaModalService', 'remitoBusinessService', | 4 | 'focaModalService', 'remitoBusinessService', |
| 5 | function( | 5 | function( |
| 6 | $scope, $uibModal, $location, $filter, crearRemitoService, focaModalService, | 6 | $scope, $uibModal, $location, $filter, crearRemitoService, focaModalService, |
| 7 | remitoBusinessService | 7 | remitoBusinessService |
| 8 | ) { | 8 | ) { |
| 9 | $scope.botonera = [ | 9 | $scope.botonera = [ |
| 10 | {texto: 'Nota Pedido', accion: function() {$scope.seleccionarNotaPedido();}}, | 10 | {texto: 'Nota Pedido', accion: function() {$scope.seleccionarNotaPedido();}}, |
| 11 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, | 11 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, |
| 12 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | 12 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
| 13 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, | 13 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, |
| 14 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | 14 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, |
| 15 | { | 15 | { |
| 16 | texto: 'Precios y condiciones', | 16 | texto: 'Precios y condiciones', |
| 17 | accion: function() {$scope.abrirModalListaPrecio();}}, | 17 | accion: function() {$scope.abrirModalListaPrecio();}}, |
| 18 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | 18 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, |
| 19 | {texto: '', accion: function() {}} | 19 | {texto: '', accion: function() {}} |
| 20 | ]; | 20 | ]; |
| 21 | $scope.datepickerAbierto = false; | 21 | $scope.datepickerAbierto = false; |
| 22 | 22 | ||
| 23 | $scope.show = false; | 23 | $scope.show = false; |
| 24 | $scope.cargando = true; | 24 | $scope.cargando = true; |
| 25 | $scope.dateOptions = { | 25 | $scope.dateOptions = { |
| 26 | maxDate: new Date(), | 26 | maxDate: new Date(), |
| 27 | minDate: new Date(2010, 0, 1) | 27 | minDate: new Date(2010, 0, 1) |
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | $scope.remito = { | 30 | $scope.remito = { |
| 31 | vendedor: {}, | 31 | vendedor: {}, |
| 32 | cliente: {}, | 32 | cliente: {}, |
| 33 | proveedor: {}, | 33 | proveedor: {}, |
| 34 | domicilio: {dom: ''}, | 34 | domicilio: {dom: ''}, |
| 35 | moneda: {}, | 35 | moneda: {}, |
| 36 | cotizacion: {} | 36 | cotizacion: {} |
| 37 | }; | 37 | }; |
| 38 | var monedaPorDefecto; | 38 | var monedaPorDefecto; |
| 39 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 39 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
| 40 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { | 40 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { |
| 41 | monedaPorDefecto = { | 41 | monedaPorDefecto = { |
| 42 | id: res.data[0].ID, | 42 | id: res.data[0].ID, |
| 43 | detalle: res.data[0].DETALLE, | 43 | detalle: res.data[0].DETALLE, |
| 44 | simbolo: res.data[0].SIMBOLO, | 44 | simbolo: res.data[0].SIMBOLO, |
| 45 | cotizaciones: res.data[0].cotizaciones | 45 | cotizaciones: res.data[0].cotizaciones |
| 46 | }; | 46 | }; |
| 47 | addCabecera('Moneda:', monedaPorDefecto.detalle); | 47 | addCabecera('Moneda:', monedaPorDefecto.detalle); |
| 48 | addCabecera('Fecha cotizacion:', | 48 | addCabecera('Fecha cotizacion:', |
| 49 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | 49 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); |
| 50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); | 50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); |
| 51 | $scope.remito.moneda = monedaPorDefecto; | 51 | $scope.remito.moneda = monedaPorDefecto; |
| 52 | $scope.remito.cotizacion = monedaPorDefecto.cotizaciones[0]; | 52 | $scope.remito.cotizacion = monedaPorDefecto.cotizaciones[0]; |
| 53 | }); | 53 | }); |
| 54 | 54 | ||
| 55 | $scope.cabecera = []; | 55 | $scope.cabecera = []; |
| 56 | $scope.showCabecera = true; | 56 | $scope.showCabecera = true; |
| 57 | 57 | ||
| 58 | $scope.now = new Date(); | 58 | $scope.now = new Date(); |
| 59 | $scope.puntoVenta = Math.round(Math.random() * 10000); | 59 | $scope.puntoVenta = Math.round(Math.random() * 10000); |
| 60 | $scope.comprobante = Math.round(Math.random() * 1000000); | 60 | $scope.comprobante = Math.round(Math.random() * 1000000); |
| 61 | 61 | ||
| 62 | $scope.articulosTabla = []; | 62 | $scope.articulosTabla = []; |
| 63 | $scope.idLista = undefined; | 63 | $scope.idLista = undefined; |
| 64 | //La pantalla solo se usa para cargar remitos | 64 | //La pantalla solo se usa para cargar remitos |
| 65 | //var remitoTemp = crearRemitoService.getRemito(); | 65 | //var remitoTemp = crearRemitoService.getRemito(); |
| 66 | 66 | ||
| 67 | crearRemitoService.getPrecioCondicion().then( | 67 | crearRemitoService.getPrecioCondicion().then( |
| 68 | function(res) { | 68 | function(res) { |
| 69 | $scope.precioCondiciones = res.data; | 69 | $scope.precioCondiciones = res.data; |
| 70 | } | 70 | } |
| 71 | ); | 71 | ); |
| 72 | 72 | ||
| 73 | crearRemitoService.getNumeroRemito().then( | 73 | crearRemitoService.getNumeroRemito().then( |
| 74 | function(res) { | 74 | function(res) { |
| 75 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 75 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
| 76 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); | 76 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); |
| 77 | }, | 77 | }, |
| 78 | function(err) { | 78 | function(err) { |
| 79 | focaModalService.alert('La terminal no esta configurada correctamente'); | 79 | focaModalService.alert('La terminal no esta configurada correctamente'); |
| 80 | console.info(err); | 80 | console.info(err); |
| 81 | } | 81 | } |
| 82 | ); | 82 | ); |
| 83 | 83 | ||
| 84 | $scope.seleccionarNotaPedido = function() { | 84 | $scope.seleccionarNotaPedido = function() { |
| 85 | var modalInstance = $uibModal.open( | 85 | var modalInstance = $uibModal.open( |
| 86 | { | 86 | { |
| 87 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 87 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
| 88 | templateUrl: 'foca-modal-nota-pedido.html', | 88 | templateUrl: 'foca-modal-nota-pedido.html', |
| 89 | controller: 'focaModalNotaPedidoController', | 89 | controller: 'focaModalNotaPedidoController', |
| 90 | resolve: { | 90 | resolve: { |
| 91 | parametroNotaPedido: { | 91 | parametroNotaPedido: { |
| 92 | idLista: $scope.idLista, | 92 | idLista: $scope.idLista, |
| 93 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 93 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
| 94 | simbolo: $scope.remito.moneda.simbolo | 94 | simbolo: $scope.remito.moneda.simbolo |
| 95 | } | 95 | } |
| 96 | }, | 96 | }, |
| 97 | size: 'lg' | 97 | size: 'lg' |
| 98 | } | 98 | } |
| 99 | ); | 99 | ); |
| 100 | modalInstance.result.then( | 100 | modalInstance.result.then( |
| 101 | function(producto) { | 101 | function(notaPedido) { |
| 102 | var newArt = | 102 | //añado cabeceras |
| 103 | { | 103 | removeCabecera('Moneda:'); |
| 104 | id: 0, | 104 | removeCabecera('Fecha cotizacion:'); |
| 105 | codigo: producto.codigo, | 105 | removeCabecera('Cotizacion:'); |
| 106 | sector: producto.sector, | 106 | var cabeceras = [ |
| 107 | sectorCodigo: producto.sector + '-' + producto.codigo, | 107 | { |
| 108 | descripcion: producto.descripcion, | 108 | label: 'Moneda', |
| 109 | item: $scope.articulosTabla.length + 1, | 109 | valor: notaPedido.cotizacion[0].moneda[0].DETALLE |
| 110 | nombre: producto.descripcion, | 110 | }, |
| 111 | precio: parseFloat(producto.precio.toFixed(4)), | 111 | { |
| 112 | costoUnitario: producto.costo, | 112 | label: 'Fecha cotizacion', |
| 113 | editCantidad: false, | 113 | valor: $filter('date')(notaPedido.cotizacion[0].FECHA, |
| 114 | editPrecio: false | 114 | 'dd/MM/yyyy') |
| 115 | }; | 115 | }, |
| 116 | $scope.articuloACargar = newArt; | 116 | { |
| 117 | $scope.cargando = false; | 117 | label: 'Cotizacion', |
| 118 | valor: notaPedido.cotizacion[0].VENDEDOR | ||
| 119 | }, | ||
| 120 | { | ||
| 121 | label: 'Cliente:', | ||
| 122 | valor: notaPedido.cliente[0].NOM | ||
| 123 | }, | ||
| 124 | { | ||
| 125 | label: 'Vendedor:', | ||
| 126 | valor: notaPedido.vendedor[0].NomVen | ||
| 127 | }, | ||
| 128 | { | ||
| 129 | label: 'Proveedor:', | ||
| 130 | valor: notaPedido.proveedor[0].NOM | ||
| 131 | }, | ||
| 132 | { | ||
| 133 | label: 'Flete:', | ||
| 134 | valor: notaPedido.flete === 1 ? 'Si' : 'No' | ||
| 135 | }, | ||
| 136 | { | ||
| 137 | label: 'FOB:', | ||
| 138 | valor: notaPedido.fob === 1 ? 'Si' : 'No' | ||
| 139 | }, | ||
| 140 | { | ||
| 141 | label: 'Precio condicion:', | ||
| 142 | valor: valorPrecioCondicion() | ||
| 143 | } | ||
| 144 | ]; | ||
| 145 | //TO DO CUANDO MOSTRAR PLAZOS | ||
| 146 | function valorPrecioCondicion() { | ||
| 147 | if(notaPedido.idPrecioCondicion > 0) { | ||
| 148 | return notaPedido.precioCondicion[0].nombre; | ||
| 149 | } else { | ||
| 150 | return 'Ingreso Manual'; | ||
| 151 | } | ||
| 152 | |||
| 153 | } | ||
| 154 | |||
| 155 | if(notaPedido.flete === 1) { | ||
| 156 | var cabeceraBomba = { | ||
| 157 | label: 'Bomba', | ||
| 158 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | ||
| 159 | }; | ||
| 160 | if(notaPedido.kilometros){ | ||
| 161 | var cabeceraKilometros = { | ||
| 162 | label: 'Kilometros', | ||
| 163 | valor: notaPedido.kilometros | ||
| 164 | }; | ||
| 165 | cabeceras.push(cabeceraKilometros); | ||
| 166 | } | ||
| 167 | cabeceras.push(cabeceraBomba); | ||
| 168 | } | ||
| 169 | $scope.articulosTabla = notaPedido.articulosNotaPedido; | ||
| 170 | $scope.remito = notaPedido; | ||
| 171 | addArrayCabecera(cabeceras); | ||
| 172 | |||
| 118 | }, function() { | 173 | }, function() { |
| 119 | // funcion ejecutada cuando se cancela el modal | 174 | // funcion ejecutada cuando se cancela el modal |
| 120 | } | 175 | } |
| 121 | ); | 176 | ); |
| 122 | }; | 177 | }; |
| 123 | 178 | ||
| 124 | $scope.seleccionarRemito = function() { | 179 | $scope.seleccionarRemito = function() { |
| 125 | var modalInstance = $uibModal.open( | 180 | var modalInstance = $uibModal.open( |
| 126 | { | 181 | { |
| 127 | ariaLabelledBy: 'Busqueda de Remito', | 182 | ariaLabelledBy: 'Busqueda de Remito', |
| 128 | templateUrl: 'foca-modal-remito.html', | 183 | templateUrl: 'foca-modal-remito.html', |
| 129 | controller: 'focaModalRemitoController', | 184 | controller: 'focaModalRemitoController', |
| 130 | resolve: { | 185 | resolve: { |
| 131 | parametroRemito: { | 186 | parametroRemito: { |
| 132 | idLista: $scope.idLista, | 187 | idLista: $scope.idLista, |
| 133 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 188 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
| 134 | simbolo: $scope.remito.moneda.simbolo | 189 | simbolo: $scope.remito.moneda.simbolo |
| 135 | } | 190 | } |
| 136 | }, | 191 | }, |
| 137 | size: 'lg' | 192 | size: 'lg' |
| 138 | } | 193 | } |
| 139 | ); | 194 | ); |
| 140 | modalInstance.result.then( | 195 | modalInstance.result.then( |
| 141 | function(producto) { | 196 | function(producto) { |
| 142 | var newArt = | 197 | var newArt = |
| 143 | { | 198 | { |
| 144 | id: 0, | 199 | id: 0, |
| 145 | codigo: producto.codigo, | 200 | codigo: producto.codigo, |
| 146 | sector: producto.sector, | 201 | sector: producto.sector, |
| 147 | sectorCodigo: producto.sector + '-' + producto.codigo, | 202 | sectorCodigo: producto.sector + '-' + producto.codigo, |
| 148 | descripcion: producto.descripcion, | 203 | descripcion: producto.descripcion, |
| 149 | item: $scope.articulosTabla.length + 1, | 204 | item: $scope.articulosTabla.length + 1, |
| 150 | nombre: producto.descripcion, | 205 | nombre: producto.descripcion, |
| 151 | precio: parseFloat(producto.precio.toFixed(4)), | 206 | precio: parseFloat(producto.precio.toFixed(4)), |
| 152 | costoUnitario: producto.costo, | 207 | costoUnitario: producto.costo, |
| 153 | editCantidad: false, | 208 | editCantidad: false, |
| 154 | editPrecio: false | 209 | editPrecio: false |
| 155 | }; | 210 | }; |
| 156 | $scope.articuloACargar = newArt; | 211 | $scope.articuloACargar = newArt; |
| 157 | $scope.cargando = false; | 212 | $scope.cargando = false; |
| 158 | }, function() { | 213 | }, function() { |
| 159 | // funcion ejecutada cuando se cancela el modal | 214 | // funcion ejecutada cuando se cancela el modal |
| 160 | } | 215 | } |
| 161 | ); | 216 | ); |
| 162 | }; | 217 | }; |
| 163 | 218 | ||
| 164 | //La pantalla solo se usa para cargar remitos | 219 | //La pantalla solo se usa para cargar remitos |
| 165 | // if (remitoTemp !== undefined) { | 220 | // if (remitoTemp !== undefined) { |
| 166 | // remitoTemp.fechaCarga = new Date(remitoTemp.fechaCarga); | 221 | // remitoTemp.fechaCarga = new Date(remitoTemp.fechaCarga); |
| 167 | // $scope.remito = remitoTemp; | 222 | // $scope.remito = remitoTemp; |
| 168 | // $scope.remito.flete = ($scope.remito.flete).toString(); | 223 | // $scope.remito.flete = ($scope.remito.flete).toString(); |
| 169 | // $scope.remito.bomba = ($scope.remito.bomba).toString(); | 224 | // $scope.remito.bomba = ($scope.remito.bomba).toString(); |
| 170 | // $scope.idLista = $scope.remito.precioCondicion; | 225 | // $scope.idLista = $scope.remito.precioCondicion; |
| 171 | // crearRemitoService | 226 | // crearRemitoService |
| 172 | // .getArticulosByIdRemito($scope.remito.id).then( | 227 | // .getArticulosByIdRemito($scope.remito.id).then( |
| 173 | // function(res) { | 228 | // function(res) { |
| 174 | // $scope.articulosTabla = res.data; | 229 | // $scope.articulosTabla = res.data; |
| 175 | // } | 230 | // } |
| 176 | // ); | 231 | // ); |
| 177 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR REMITO | 232 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR REMITO |
| 178 | //(NO REQUERIDO EN ESTA VERSION) | 233 | //(NO REQUERIDO EN ESTA VERSION) |
| 179 | // crearRemitoService.getDomiciliosByIdRemito($scope.remito.id).then( | 234 | // crearRemitoService.getDomiciliosByIdRemito($scope.remito.id).then( |
| 180 | // function(res) { | 235 | // function(res) { |
| 181 | // $scope.remito.domicilio = res.data; | 236 | // $scope.remito.domicilio = res.data; |
| 182 | // } | 237 | // } |
| 183 | // ); | 238 | // ); |
| 184 | // } else { | 239 | // } else { |
| 185 | // $scope.remito.fechaCarga = new Date(); | 240 | // $scope.remito.fechaCarga = new Date(); |
| 186 | // $scope.remito.bomba = '0'; | 241 | // $scope.remito.bomba = '0'; |
| 187 | // $scope.remito.flete = '0'; | 242 | // $scope.remito.flete = '0'; |
| 188 | // $scope.idLista = undefined; | 243 | // $scope.idLista = undefined; |
| 189 | // } | 244 | // } |
| 190 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 245 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
| 191 | // $scope.addNewDom = function() { | 246 | // $scope.addNewDom = function() { |
| 192 | // $scope.remito.domicilio.push({ 'id': 0 }); | 247 | // $scope.remito.domicilio.push({ 'id': 0 }); |
| 193 | // }; | 248 | // }; |
| 194 | // $scope.removeNewChoice = function(choice) { | 249 | // $scope.removeNewChoice = function(choice) { |
| 195 | // if ($scope.remito.domicilio.length > 1) { | 250 | // if ($scope.remito.domicilio.length > 1) { |
| 196 | // $scope.remito.domicilio.splice($scope.remito.domicilio.findIndex( | 251 | // $scope.remito.domicilio.splice($scope.remito.domicilio.findIndex( |
| 197 | // function(c) { | 252 | // function(c) { |
| 198 | // return c.$$hashKey === choice.$$hashKey; | 253 | // return c.$$hashKey === choice.$$hashKey; |
| 199 | // } | 254 | // } |
| 200 | // ), 1); | 255 | // ), 1); |
| 201 | // } | 256 | // } |
| 202 | // }; | 257 | // }; |
| 203 | 258 | ||
| 204 | $scope.crearRemito = function() { | 259 | $scope.crearRemito = function() { |
| 205 | if(!$scope.remito.vendedor.codigo) { | 260 | if(!$scope.remito.vendedor.codigo) { |
| 206 | focaModalService.alert('Ingrese Vendedor'); | 261 | focaModalService.alert('Ingrese Vendedor'); |
| 207 | return; | 262 | return; |
| 208 | } else if(!$scope.remito.cliente.cod) { | 263 | } else if(!$scope.remito.cliente.cod) { |
| 209 | focaModalService.alert('Ingrese Cliente'); | 264 | focaModalService.alert('Ingrese Cliente'); |
| 210 | return; | 265 | return; |
| 211 | } else if(!$scope.remito.proveedor.codigo) { | 266 | } else if(!$scope.remito.proveedor.codigo) { |
| 212 | focaModalService.alert('Ingrese Proveedor'); | 267 | focaModalService.alert('Ingrese Proveedor'); |
| 213 | return; | 268 | return; |
| 214 | } else if(!$scope.remito.moneda.id) { | 269 | } else if(!$scope.remito.moneda.id) { |
| 215 | focaModalService.alert('Ingrese Moneda'); | 270 | focaModalService.alert('Ingrese Moneda'); |
| 216 | return; | 271 | return; |
| 217 | } else if(!$scope.remito.cotizacion.ID) { | 272 | } else if(!$scope.remito.cotizacion.ID) { |
| 218 | focaModalService.alert('Ingrese Cotización'); | 273 | focaModalService.alert('Ingrese Cotización'); |
| 219 | return; | 274 | return; |
| 220 | } else if(!$scope.plazosPagos) { | 275 | } else if(!$scope.plazosPagos) { |
| 221 | focaModalService.alert('Ingrese Precios y Condiciones'); | 276 | focaModalService.alert('Ingrese Precios y Condiciones'); |
| 222 | return; | 277 | return; |
| 223 | } else if( | 278 | } else if( |
| 224 | $scope.remito.flete === undefined || $scope.remito.flete === null) | 279 | $scope.remito.flete === undefined || $scope.remito.flete === null) |
| 225 | { | 280 | { |
| 226 | focaModalService.alert('Ingrese Flete'); | 281 | focaModalService.alert('Ingrese Flete'); |
| 227 | return; | 282 | return; |
| 228 | } else if(!$scope.remito.domicilio.id) { | 283 | } else if(!$scope.remito.domicilio.id) { |
| 229 | focaModalService.alert('Ingrese Domicilio'); | 284 | focaModalService.alert('Ingrese Domicilio'); |
| 230 | return; | 285 | return; |
| 231 | } else if($scope.articulosTabla.length === 0) { | 286 | } else if($scope.articulosTabla.length === 0) { |
| 232 | focaModalService.alert('Debe cargar al menos un articulo'); | 287 | focaModalService.alert('Debe cargar al menos un articulo'); |
| 233 | return; | 288 | return; |
| 234 | } | 289 | } |
| 235 | var date = new Date(); | 290 | var date = new Date(); |
| 236 | var remito = { | 291 | var remito = { |
| 237 | id: 0, | 292 | id: 0, |
| 238 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 293 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
| 239 | .toISOString().slice(0, 19).replace('T', ' '), | 294 | .toISOString().slice(0, 19).replace('T', ' '), |
| 240 | idVendedor: $scope.remito.vendedor.codigo, | 295 | idVendedor: $scope.remito.vendedor.codigo, |
| 241 | idCliente: $scope.remito.cliente.cod, | 296 | idCliente: $scope.remito.cliente.cod, |
| 242 | nombreCliente: $scope.remito.cliente.nom, | 297 | nombreCliente: $scope.remito.cliente.nom, |
| 243 | cuitCliente: $scope.remito.cliente.cuit, | 298 | cuitCliente: $scope.remito.cliente.cuit, |
| 244 | idProveedor: $scope.remito.proveedor.codigo, | 299 | idProveedor: $scope.remito.proveedor.codigo, |
| 245 | idDomicilio: $scope.remito.domicilio.id, | 300 | idDomicilio: $scope.remito.domicilio.id, |
| 246 | idCotizacion: $scope.remito.cotizacion.ID, | 301 | idCotizacion: $scope.remito.cotizacion.ID, |
| 247 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 302 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
| 248 | flete: $scope.remito.flete, | 303 | flete: $scope.remito.flete, |
| 249 | fob: $scope.remito.fob, | 304 | fob: $scope.remito.fob, |
| 250 | bomba: $scope.remito.bomba, | 305 | bomba: $scope.remito.bomba, |
| 251 | kilometros: $scope.remito.kilometros, | 306 | kilometros: $scope.remito.kilometros, |
| 252 | estado: 0, | 307 | estado: 0, |
| 253 | total: $scope.getTotal() | 308 | total: $scope.getTotal() |
| 254 | }; | 309 | }; |
| 255 | crearRemitoService.crearRemito(remito).then( | 310 | crearRemitoService.crearRemito(remito).then( |
| 256 | function(data) { | 311 | function(data) { |
| 257 | remitoBusinessService.addArticulos($scope.articulosTabla, | 312 | remitoBusinessService.addArticulos($scope.articulosTabla, |
| 258 | data.data.id, $scope.remito.cotizacion.COTIZACION); | 313 | data.data.id, $scope.remito.cotizacion.COTIZACION); |
| 259 | var plazos = $scope.plazosPagos; | 314 | var plazos = $scope.plazosPagos; |
| 260 | for(var j = 0; j < plazos.length; j++) { | 315 | for(var j = 0; j < plazos.length; j++) { |
| 261 | var json = { | 316 | var json = { |
| 262 | idRemito: data.data.id, | 317 | idRemito: data.data.id, |
| 263 | dias: plazos[j].dias | 318 | dias: plazos[j].dias |
| 264 | }; | 319 | }; |
| 265 | crearRemitoService.crearPlazosParaRemito(json); | 320 | crearRemitoService.crearPlazosParaRemito(json); |
| 266 | } | 321 | } |
| 267 | remitoBusinessService.addEstado(data.data.id, | 322 | remitoBusinessService.addEstado(data.data.id, |
| 268 | $scope.remito.vendedor.codigo); | 323 | $scope.remito.vendedor.codigo); |
| 269 | 324 | ||
| 270 | focaModalService.alert('Nota remito creada'); | 325 | focaModalService.alert('Nota remito creada'); |
| 271 | $scope.cabecera = []; | 326 | $scope.cabecera = []; |
| 272 | addCabecera('Moneda:', $scope.remito.moneda.detalle); | 327 | addCabecera('Moneda:', $scope.remito.moneda.detalle); |
| 273 | addCabecera( | 328 | addCabecera( |
| 274 | 'Fecha cotizacion:', | 329 | 'Fecha cotizacion:', |
| 275 | $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') | 330 | $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') |
| 276 | ); | 331 | ); |
| 277 | addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); | 332 | addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); |
| 278 | $scope.remito.vendedor = {}; | 333 | $scope.remito.vendedor = {}; |
| 279 | $scope.remito.cliente = {}; | 334 | $scope.remito.cliente = {}; |
| 280 | $scope.remito.proveedor = {}; | 335 | $scope.remito.proveedor = {}; |
| 281 | $scope.remito.domicilio = {}; | 336 | $scope.remito.domicilio = {}; |
| 282 | $scope.remito.flete = null; | 337 | $scope.remito.flete = null; |
| 283 | $scope.remito.fob = null; | 338 | $scope.remito.fob = null; |
| 284 | $scope.remito.bomba = null; | 339 | $scope.remito.bomba = null; |
| 285 | $scope.remito.kilometros = null; | 340 | $scope.remito.kilometros = null; |
| 286 | $scope.articulosTabla = []; | 341 | $scope.articulosTabla = []; |
| 287 | } | 342 | } |
| 288 | ); | 343 | ); |
| 289 | }; | 344 | }; |
| 290 | 345 | ||
| 291 | $scope.seleccionarArticulo = function() { | 346 | $scope.seleccionarArticulo = function() { |
| 292 | if ($scope.idLista === undefined) { | 347 | if ($scope.idLista === undefined) { |
| 293 | focaModalService.alert( | 348 | focaModalService.alert( |
| 294 | 'Primero seleccione una lista de precio y condicion'); | 349 | 'Primero seleccione una lista de precio y condicion'); |
| 295 | return; | 350 | return; |
| 296 | } | 351 | } |
| 297 | var modalInstance = $uibModal.open( | 352 | var modalInstance = $uibModal.open( |
| 298 | { | 353 | { |
| 299 | ariaLabelledBy: 'Busqueda de Productos', | 354 | ariaLabelledBy: 'Busqueda de Productos', |
| 300 | templateUrl: 'modal-busqueda-productos.html', | 355 | templateUrl: 'modal-busqueda-productos.html', |
| 301 | controller: 'modalBusquedaProductosCtrl', | 356 | controller: 'modalBusquedaProductosCtrl', |
| 302 | resolve: { | 357 | resolve: { |
| 303 | parametroProducto: { | 358 | parametroProducto: { |
| 304 | idLista: $scope.idLista, | 359 | idLista: $scope.idLista, |
| 305 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 360 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
| 306 | simbolo: $scope.remito.moneda.simbolo | 361 | simbolo: $scope.remito.moneda.simbolo |
| 307 | } | 362 | } |
| 308 | }, | 363 | }, |
| 309 | size: 'lg' | 364 | size: 'lg' |
| 310 | } | 365 | } |
| 311 | ); | 366 | ); |
| 312 | modalInstance.result.then( | 367 | modalInstance.result.then( |
| 313 | function(producto) { | 368 | function(producto) { |
| 314 | var newArt = | 369 | var newArt = |
| 315 | { | 370 | { |
| 316 | id: 0, | 371 | id: 0, |
| 317 | codigo: producto.codigo, | 372 | codigo: producto.codigo, |
| 318 | sector: producto.sector, | 373 | sector: producto.sector, |
| 319 | sectorCodigo: producto.sector + '-' + producto.codigo, | 374 | sectorCodigo: producto.sector + '-' + producto.codigo, |
| 320 | descripcion: producto.descripcion, | 375 | descripcion: producto.descripcion, |
| 321 | item: $scope.articulosTabla.length + 1, | 376 | item: $scope.articulosTabla.length + 1, |
| 322 | nombre: producto.descripcion, | 377 | nombre: producto.descripcion, |
| 323 | precio: parseFloat(producto.precio.toFixed(4)), | 378 | precio: parseFloat(producto.precio.toFixed(4)), |
| 324 | costoUnitario: producto.costo, | 379 | costoUnitario: producto.costo, |
| 325 | editCantidad: false, | 380 | editCantidad: false, |
| 326 | editPrecio: false | 381 | editPrecio: false |
| 327 | }; | 382 | }; |
| 328 | $scope.articuloACargar = newArt; | 383 | $scope.articuloACargar = newArt; |
| 329 | $scope.cargando = false; | 384 | $scope.cargando = false; |
| 330 | }, function() { | 385 | }, function() { |
| 331 | // funcion ejecutada cuando se cancela el modal | 386 | // funcion ejecutada cuando se cancela el modal |
| 332 | } | 387 | } |
| 333 | ); | 388 | ); |
| 334 | }; | 389 | }; |
| 335 | 390 | ||
| 336 | $scope.seleccionarVendedor = function() { | 391 | $scope.seleccionarVendedor = function() { |
| 337 | var modalInstance = $uibModal.open( | 392 | var modalInstance = $uibModal.open( |
| 338 | { | 393 | { |
| 339 | ariaLabelledBy: 'Busqueda de Vendedores', | 394 | ariaLabelledBy: 'Busqueda de Vendedores', |
| 340 | templateUrl: 'modal-vendedores.html', | 395 | templateUrl: 'modal-vendedores.html', |
| 341 | controller: 'modalVendedoresCtrl', | 396 | controller: 'modalVendedoresCtrl', |
| 342 | size: 'lg' | 397 | size: 'lg' |
| 343 | } | 398 | } |
| 344 | ); | 399 | ); |
| 345 | modalInstance.result.then( | 400 | modalInstance.result.then( |
| 346 | function(vendedor) { | 401 | function(vendedor) { |
| 347 | addCabecera('Vendedor:', vendedor.NomVen); | 402 | addCabecera('Vendedor:', vendedor.NomVen); |
| 348 | $scope.remito.vendedor.codigo = vendedor.CodVen; | 403 | $scope.remito.vendedor.codigo = vendedor.CodVen; |
| 349 | }, function() { | 404 | }, function() { |
| 350 | 405 | ||
| 351 | } | 406 | } |
| 352 | ); | 407 | ); |
| 353 | }; | 408 | }; |
| 354 | 409 | ||
| 355 | $scope.seleccionarProveedor = function() { | 410 | $scope.seleccionarProveedor = function() { |
| 356 | var modalInstance = $uibModal.open( | 411 | var modalInstance = $uibModal.open( |
| 357 | { | 412 | { |
| 358 | ariaLabelledBy: 'Busqueda de Proveedor', | 413 | ariaLabelledBy: 'Busqueda de Proveedor', |
| 359 | templateUrl: 'modal-proveedor.html', | 414 | templateUrl: 'modal-proveedor.html', |
| 360 | controller: 'focaModalProveedorCtrl', | 415 | controller: 'focaModalProveedorCtrl', |
| 361 | size: 'lg' | 416 | size: 'lg' |
| 362 | } | 417 | } |
| 363 | ); | 418 | ); |
| 364 | modalInstance.result.then( | 419 | modalInstance.result.then( |
| 365 | function(proveedor) { | 420 | function(proveedor) { |
| 366 | $scope.remito.proveedor.codigo = proveedor.COD; | 421 | $scope.remito.proveedor.codigo = proveedor.COD; |
| 367 | addCabecera('Proveedor:', proveedor.NOM); | 422 | addCabecera('Proveedor:', proveedor.NOM); |
| 368 | }, function() { | 423 | }, function() { |
| 369 | 424 | ||
| 370 | } | 425 | } |
| 371 | ); | 426 | ); |
| 372 | }; | 427 | }; |
| 373 | 428 | ||
| 374 | $scope.seleccionarCliente = function() { | 429 | $scope.seleccionarCliente = function() { |
| 375 | 430 | ||
| 376 | var modalInstance = $uibModal.open( | 431 | var modalInstance = $uibModal.open( |
| 377 | { | 432 | { |
| 378 | ariaLabelledBy: 'Busqueda de Cliente', | 433 | ariaLabelledBy: 'Busqueda de Cliente', |
| 379 | templateUrl: 'foca-busqueda-cliente-modal.html', | 434 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 380 | controller: 'focaBusquedaClienteModalController', | 435 | controller: 'focaBusquedaClienteModalController', |
| 381 | size: 'lg' | 436 | size: 'lg' |
| 382 | } | 437 | } |
| 383 | ); | 438 | ); |
| 384 | modalInstance.result.then( | 439 | modalInstance.result.then( |
| 385 | function(cliente) { | 440 | function(cliente) { |
| 386 | $scope.abrirModalDomicilios(cliente); | 441 | $scope.abrirModalDomicilios(cliente); |
| 387 | }, function() { | 442 | }, function() { |
| 388 | 443 | ||
| 389 | } | 444 | } |
| 390 | ); | 445 | ); |
| 391 | }; | 446 | }; |
| 392 | 447 | ||
| 393 | $scope.abrirModalDomicilios = function(cliente) { | 448 | $scope.abrirModalDomicilios = function(cliente) { |
| 394 | var modalInstanceDomicilio = $uibModal.open( | 449 | var modalInstanceDomicilio = $uibModal.open( |
| 395 | { | 450 | { |
| 396 | ariaLabelledBy: 'Busqueda de Domicilios', | 451 | ariaLabelledBy: 'Busqueda de Domicilios', |
| 397 | templateUrl: 'modal-domicilio.html', | 452 | templateUrl: 'modal-domicilio.html', |
| 398 | controller: 'focaModalDomicilioController', | 453 | controller: 'focaModalDomicilioController', |
| 399 | resolve: { idCliente: function() { return cliente.cod; }}, | 454 | resolve: { idCliente: function() { return cliente.cod; }}, |
| 400 | size: 'lg', | 455 | size: 'lg', |
| 401 | } | 456 | } |
| 402 | ); | 457 | ); |
| 403 | modalInstanceDomicilio.result.then( | 458 | modalInstanceDomicilio.result.then( |
| 404 | function(domicilio) { | 459 | function(domicilio) { |
| 405 | $scope.remito.domicilio.id = domicilio.nivel2; | 460 | $scope.remito.domicilio.id = domicilio.nivel2; |
| 406 | $scope.remito.cliente = cliente; | 461 | $scope.remito.cliente = cliente; |
| 407 | 462 | ||
| 408 | addCabecera('Cliente:', cliente.nom); | 463 | addCabecera('Cliente:', cliente.nom); |
| 409 | addCabecera('Domicilio:', domicilio.dom); | 464 | addCabecera('Domicilio:', domicilio.dom); |
| 410 | }, function() { | 465 | }, function() { |
| 411 | $scope.seleccionarCliente(); | 466 | $scope.seleccionarCliente(); |
| 412 | return; | 467 | return; |
| 413 | } | 468 | } |
| 414 | ); | 469 | ); |
| 415 | }; | 470 | }; |
| 416 | 471 | ||
| 417 | $scope.mostrarFichaCliente = function() { | 472 | $scope.mostrarFichaCliente = function() { |
| 418 | $uibModal.open( | 473 | $uibModal.open( |
| 419 | { | 474 | { |
| 420 | ariaLabelledBy: 'Datos del Cliente', | 475 | ariaLabelledBy: 'Datos del Cliente', |
| 421 | templateUrl: 'foca-crear-remito-ficha-cliente.html', | 476 | templateUrl: 'foca-crear-remito-ficha-cliente.html', |
| 422 | controller: 'focaCrearRemitoFichaClienteController', | 477 | controller: 'focaCrearRemitoFichaClienteController', |
| 423 | size: 'lg' | 478 | size: 'lg' |
| 424 | } | 479 | } |
| 425 | ); | 480 | ); |
| 426 | }; | 481 | }; |
| 427 | 482 | ||
| 428 | $scope.getTotal = function() { | 483 | $scope.getTotal = function() { |
| 429 | var total = 0; | 484 | var total = 0; |
| 430 | var arrayTempArticulos = $scope.articulosTabla; | 485 | var arrayTempArticulos = $scope.articulosTabla; |
| 431 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 486 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
| 432 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 487 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 433 | } | 488 | } |
| 434 | return parseFloat(total.toFixed(2)); | 489 | return parseFloat(total.toFixed(2)); |
| 435 | }; | 490 | }; |
| 436 | 491 | ||
| 437 | $scope.getSubTotal = function() { | 492 | $scope.getSubTotal = function() { |
| 438 | if($scope.articuloACargar) { | 493 | if($scope.articuloACargar) { |
| 439 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 494 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 440 | } | 495 | } |
| 441 | }; | 496 | }; |
| 442 | 497 | ||
| 443 | $scope.abrirModalListaPrecio = function() { | 498 | $scope.abrirModalListaPrecio = function() { |
| 444 | var modalInstance = $uibModal.open( | 499 | var modalInstance = $uibModal.open( |
| 445 | { | 500 | { |
| 446 | ariaLabelledBy: 'Busqueda de Precio Condición', | 501 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 447 | templateUrl: 'modal-precio-condicion.html', | 502 | templateUrl: 'modal-precio-condicion.html', |
| 448 | controller: 'focaModalPrecioCondicionController', | 503 | controller: 'focaModalPrecioCondicionController', |
| 449 | size: 'lg' | 504 | size: 'lg' |
| 450 | } | 505 | } |
| 451 | ); | 506 | ); |
| 452 | modalInstance.result.then( | 507 | modalInstance.result.then( |
| 453 | function(precioCondicion) { | 508 | function(precioCondicion) { |
| 454 | var cabecera = ''; | 509 | var cabecera = ''; |
| 455 | var plazosConcat = ''; | 510 | var plazosConcat = ''; |
| 456 | if(!Array.isArray(precioCondicion)) { | 511 | if(!Array.isArray(precioCondicion)) { |
| 457 | $scope.plazosPagos = precioCondicion.plazoPago; | 512 | $scope.plazosPagos = precioCondicion.plazoPago; |
| 458 | $scope.idLista = precioCondicion.idListaPrecio; | 513 | $scope.idLista = precioCondicion.idListaPrecio; |
| 459 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 514 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
| 460 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 515 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
| 461 | } | 516 | } |
| 462 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 517 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
| 463 | } else { //Cuando se ingresan los plazos manualmente | 518 | } else { //Cuando se ingresan los plazos manualmente |
| 464 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 519 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
| 465 | $scope.plazosPagos = precioCondicion; | 520 | $scope.plazosPagos = precioCondicion; |
| 466 | for(var j = 0; j < precioCondicion.length; j++) { | 521 | for(var j = 0; j < precioCondicion.length; j++) { |
| 467 | plazosConcat += precioCondicion[j].dias + ' '; | 522 | plazosConcat += precioCondicion[j].dias + ' '; |
| 468 | } | 523 | } |
| 469 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 524 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
| 470 | } | 525 | } |
| 471 | $scope.articulosTabla = []; | 526 | $scope.articulosTabla = []; |
| 472 | addCabecera('Precios y condiciones:', cabecera); | 527 | addCabecera('Precios y condiciones:', cabecera); |
| 473 | }, function() { | 528 | }, function() { |
| 474 | 529 | ||
| 475 | } | 530 | } |
| 476 | ); | 531 | ); |
| 477 | }; | 532 | }; |
| 478 | 533 | ||
| 479 | $scope.abrirModalFlete = function() { | 534 | $scope.abrirModalFlete = function() { |
| 480 | var modalInstance = $uibModal.open( | 535 | var modalInstance = $uibModal.open( |
| 481 | { | 536 | { |
| 482 | ariaLabelledBy: 'Busqueda de Flete', | 537 | ariaLabelledBy: 'Busqueda de Flete', |
| 483 | templateUrl: 'modal-flete.html', | 538 | templateUrl: 'modal-flete.html', |
| 484 | controller: 'focaModalFleteController', | 539 | controller: 'focaModalFleteController', |
| 485 | size: 'lg', | 540 | size: 'lg', |
| 486 | resolve: { | 541 | resolve: { |
| 487 | parametrosFlete: | 542 | parametrosFlete: |
| 488 | function() { | 543 | function() { |
| 489 | return { | 544 | return { |
| 490 | flete: $scope.remito.flete ? '1' : | 545 | flete: $scope.remito.flete ? '1' : |
| 491 | ($scope.remito.fob ? 'FOB' : | 546 | ($scope.remito.fob ? 'FOB' : |
| 492 | ($scope.remito.flete === undefined ? null : '0')), | 547 | ($scope.remito.flete === undefined ? null : '0')), |
| 493 | bomba: $scope.remito.bomba ? '1' : | 548 | bomba: $scope.remito.bomba ? '1' : |
| 494 | ($scope.remito.bomba === undefined ? null : '0'), | 549 | ($scope.remito.bomba === undefined ? null : '0'), |
| 495 | kilometros: $scope.remito.kilometros | 550 | kilometros: $scope.remito.kilometros |
| 496 | }; | 551 | }; |
| 497 | } | 552 | } |
| 498 | } | 553 | } |
| 499 | } | 554 | } |
| 500 | ); | 555 | ); |
| 501 | modalInstance.result.then( | 556 | modalInstance.result.then( |
| 502 | function(datos) { | 557 | function(datos) { |
| 503 | $scope.remito.flete = datos.flete; | 558 | $scope.remito.flete = datos.flete; |
| 504 | $scope.remito.fob = datos.FOB; | 559 | $scope.remito.fob = datos.FOB; |
| 505 | $scope.remito.bomba = datos.bomba; | 560 | $scope.remito.bomba = datos.bomba; |
| 506 | $scope.remito.kilometros = datos.kilometros; | 561 | $scope.remito.kilometros = datos.kilometros; |
| 507 | 562 | ||
| 508 | addCabecera('Flete:', datos.flete ? 'Si' : | 563 | addCabecera('Flete:', datos.flete ? 'Si' : |
| 509 | ($scope.remito.fob ? 'FOB' : 'No')); | 564 | ($scope.remito.fob ? 'FOB' : 'No')); |
| 510 | if(datos.flete) { | 565 | if(datos.flete) { |
| 511 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | 566 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); |
| 512 | addCabecera('Kilometros:', datos.kilometros); | 567 | addCabecera('Kilometros:', datos.kilometros); |
| 513 | } else { | 568 | } else { |
| 514 | removeCabecera('Bomba:'); | 569 | removeCabecera('Bomba:'); |
| 515 | removeCabecera('Kilometros:'); | 570 | removeCabecera('Kilometros:'); |
| 516 | $scope.remito.fob = false; | 571 | $scope.remito.fob = false; |
| 517 | $scope.remito.bomba = false; | 572 | $scope.remito.bomba = false; |
| 518 | $scope.remito.kilometros = null; | 573 | $scope.remito.kilometros = null; |
| 519 | } | 574 | } |
| 520 | }, function() { | 575 | }, function() { |
| 521 | 576 | ||
| 522 | } | 577 | } |
| 523 | ); | 578 | ); |
| 524 | }; | 579 | }; |
| 525 | 580 | ||
| 526 | $scope.abrirModalMoneda = function() { | 581 | $scope.abrirModalMoneda = function() { |
| 527 | var modalInstance = $uibModal.open( | 582 | var modalInstance = $uibModal.open( |
| 528 | { | 583 | { |
| 529 | ariaLabelledBy: 'Busqueda de Moneda', | 584 | ariaLabelledBy: 'Busqueda de Moneda', |
| 530 | templateUrl: 'modal-moneda.html', | 585 | templateUrl: 'modal-moneda.html', |
| 531 | controller: 'focaModalMonedaController', | 586 | controller: 'focaModalMonedaController', |
| 532 | size: 'lg' | 587 | size: 'lg' |
| 533 | } | 588 | } |
| 534 | ); | 589 | ); |
| 535 | modalInstance.result.then( | 590 | modalInstance.result.then( |
| 536 | function(moneda) { | 591 | function(moneda) { |
| 537 | $scope.abrirModalCotizacion(moneda); | 592 | $scope.abrirModalCotizacion(moneda); |
| 538 | }, function() { | 593 | }, function() { |
| 539 | 594 | ||
| 540 | } | 595 | } |
| 541 | ); | 596 | ); |
| 542 | }; | 597 | }; |
| 543 | 598 | ||
| 544 | $scope.abrirModalCotizacion = function(moneda) { | 599 | $scope.abrirModalCotizacion = function(moneda) { |
| 545 | var modalInstance = $uibModal.open( | 600 | var modalInstance = $uibModal.open( |
| 546 | { | 601 | { |
| 547 | ariaLabelledBy: 'Busqueda de Cotización', | 602 | ariaLabelledBy: 'Busqueda de Cotización', |
| 548 | templateUrl: 'modal-cotizacion.html', | 603 | templateUrl: 'modal-cotizacion.html', |
| 549 | controller: 'focaModalCotizacionController', | 604 | controller: 'focaModalCotizacionController', |
| 550 | size: 'lg', | 605 | size: 'lg', |
| 551 | resolve: {idMoneda: function() {return moneda.ID;}} | 606 | resolve: {idMoneda: function() {return moneda.ID;}} |
| 552 | } | 607 | } |
| 553 | ); | 608 | ); |
| 554 | modalInstance.result.then( | 609 | modalInstance.result.then( |
| 555 | function(cotizacion) { | 610 | function(cotizacion) { |
| 556 | var articulosTablaTemp = $scope.articulosTabla; | 611 | var articulosTablaTemp = $scope.articulosTabla; |
| 557 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 612 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
| 558 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 613 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
| 559 | $scope.remito.cotizacion.COTIZACION; | 614 | $scope.remito.cotizacion.COTIZACION; |
| 560 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 615 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
| 561 | cotizacion.COTIZACION; | 616 | cotizacion.COTIZACION; |
| 562 | } | 617 | } |
| 563 | $scope.articulosTabla = articulosTablaTemp; | 618 | $scope.articulosTabla = articulosTablaTemp; |
| 564 | $scope.remito.moneda = { | 619 | $scope.remito.moneda = { |
| 565 | id: moneda.ID, | 620 | id: moneda.ID, |
| 566 | detalle: moneda.DETALLE, | 621 | detalle: moneda.DETALLE, |
| 567 | simbolo: moneda.SIMBOLO | 622 | simbolo: moneda.SIMBOLO |
| 568 | }; | 623 | }; |
| 569 | $scope.remito.cotizacion = { | 624 | $scope.remito.cotizacion = { |
| 570 | ID: cotizacion.ID, | 625 | ID: cotizacion.ID, |
| 571 | COTIZACION: cotizacion.COTIZACION, | 626 | COTIZACION: cotizacion.COTIZACION, |
| 572 | FECHA: cotizacion.FECHA | 627 | FECHA: cotizacion.FECHA |
| 573 | }; | 628 | }; |
| 574 | addCabecera('Moneda:', moneda.DETALLE); | 629 | addCabecera('Moneda:', moneda.DETALLE); |
| 575 | addCabecera( | 630 | addCabecera( |
| 576 | 'Fecha cotizacion:', | 631 | 'Fecha cotizacion:', |
| 577 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 632 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
| 578 | ); | 633 | ); |
| 579 | addCabecera('Cotizacion:', cotizacion.COTIZACION); | 634 | addCabecera('Cotizacion:', cotizacion.COTIZACION); |
| 580 | }, function() { | 635 | }, function() { |
| 581 | 636 | ||
| 582 | } | 637 | } |
| 583 | ); | 638 | ); |
| 584 | }; | 639 | }; |
| 585 | 640 | ||
| 586 | $scope.agregarATabla = function(key) { | 641 | $scope.agregarATabla = function(key) { |
| 587 | if(key === 13) { | 642 | if(key === 13) { |
| 588 | if($scope.articuloACargar.cantidad === undefined || | 643 | if($scope.articuloACargar.cantidad === undefined || |
| 589 | $scope.articuloACargar.cantidad === 0 || | 644 | $scope.articuloACargar.cantidad === 0 || |
| 590 | $scope.articuloACargar.cantidad === null ) { | 645 | $scope.articuloACargar.cantidad === null ) { |
| 591 | focaModalService.alert('El valor debe ser al menos 1'); | 646 | focaModalService.alert('El valor debe ser al menos 1'); |
| 592 | return; | 647 | return; |
| 593 | } | 648 | } |
| 594 | delete $scope.articuloACargar.sectorCodigo; | 649 | delete $scope.articuloACargar.sectorCodigo; |
| 595 | $scope.articulosTabla.push($scope.articuloACargar); | 650 | $scope.articulosTabla.push($scope.articuloACargar); |
| 596 | $scope.cargando = true; | 651 | $scope.cargando = true; |
| 597 | } | 652 | } |
| 598 | }; | 653 | }; |
| 599 | 654 | ||
| 600 | $scope.quitarArticulo = function(key) { | 655 | $scope.quitarArticulo = function(key) { |
| 601 | $scope.articulosTabla.splice(key, 1); | 656 | $scope.articulosTabla.splice(key, 1); |
| 602 | }; | 657 | }; |
| 603 | 658 | ||
| 604 | $scope.editarArticulo = function(key, articulo) { | 659 | $scope.editarArticulo = function(key, articulo) { |
| 605 | if(key === 13) { | 660 | if(key === 13) { |
| 606 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 661 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
| 607 | articulo.cantidad === undefined) { | 662 | articulo.cantidad === undefined) { |
| 608 | focaModalService.alert('El valor debe ser al menos 1'); | 663 | focaModalService.alert('El valor debe ser al menos 1'); |
| 609 | return; | 664 | return; |
| 610 | } | 665 | } |
| 611 | articulo.editCantidad = false; | 666 | articulo.editCantidad = false; |
| 612 | articulo.editPrecio = false; | 667 | articulo.editPrecio = false; |
| 613 | } | 668 | } |
| 614 | }; | 669 | }; |
| 615 | 670 | ||
| 616 | $scope.cambioEdit = function(articulo, propiedad) { | 671 | $scope.cambioEdit = function(articulo, propiedad) { |
| 617 | if(propiedad === 'cantidad') { | 672 | if(propiedad === 'cantidad') { |
| 618 | articulo.editCantidad = true; | 673 | articulo.editCantidad = true; |
| 619 | } else if(propiedad === 'precio') { | 674 | } else if(propiedad === 'precio') { |
| 620 | articulo.editPrecio = true; | 675 | articulo.editPrecio = true; |
| 621 | } | 676 | } |
| 622 | }; | 677 | }; |
| 623 | 678 | ||
| 624 | $scope.limpiarFlete = function() { | 679 | $scope.limpiarFlete = function() { |
| 625 | $scope.remito.fleteNombre = ''; | 680 | $scope.remito.fleteNombre = ''; |
| 626 | $scope.remito.chofer = ''; | 681 | $scope.remito.chofer = ''; |
| 627 | $scope.remito.vehiculo = ''; | 682 | $scope.remito.vehiculo = ''; |
| 628 | $scope.remito.kilometros = ''; | 683 | $scope.remito.kilometros = ''; |
| 629 | $scope.remito.costoUnitarioKmFlete = ''; | 684 | $scope.remito.costoUnitarioKmFlete = ''; |
| 630 | $scope.choferes = ''; | 685 | $scope.choferes = ''; |
| 631 | $scope.vehiculos = ''; | 686 | $scope.vehiculos = ''; |
| 632 | }; | 687 | }; |
| 633 | 688 | ||
| 634 | $scope.limpiarPantalla = function() { | 689 | $scope.limpiarPantalla = function() { |
| 635 | $scope.limpiarFlete(); | 690 | $scope.limpiarFlete(); |
| 636 | $scope.remito.flete = '0'; | 691 | $scope.remito.flete = '0'; |
| 637 | $scope.remito.bomba = '0'; | 692 | $scope.remito.bomba = '0'; |
| 638 | $scope.remito.precioCondicion = ''; | 693 | $scope.remito.precioCondicion = ''; |
| 639 | $scope.articulosTabla = []; | 694 | $scope.articulosTabla = []; |
| 640 | $scope.remito.vendedor.nombre = ''; | 695 | $scope.remito.vendedor.nombre = ''; |
| 641 | $scope.remito.cliente = {nombre: ''}; | 696 | $scope.remito.cliente = {nombre: ''}; |
| 642 | $scope.remito.domicilio = {dom: ''}; | 697 | $scope.remito.domicilio = {dom: ''}; |
| 643 | $scope.domiciliosCliente = []; | 698 | $scope.domiciliosCliente = []; |
| 644 | }; | 699 | }; |
| 645 | 700 | ||
| 646 | $scope.resetFilter = function() { | 701 | $scope.resetFilter = function() { |
| 647 | $scope.articuloACargar = {}; | 702 | $scope.articuloACargar = {}; |
| 648 | $scope.cargando = true; | 703 | $scope.cargando = true; |
| 649 | }; | 704 | }; |
| 650 | 705 | ||
| 651 | $scope.selectFocus = function($event) { | 706 | $scope.selectFocus = function($event) { |
| 652 | $event.target.select(); | 707 | $event.target.select(); |
| 653 | }; | 708 | }; |
| 654 | 709 | ||
| 655 | $scope.salir = function() { | 710 | $scope.salir = function() { |
| 656 | $location.path('/'); | 711 | $location.path('/'); |
| 657 | }; | 712 | }; |
| 713 | function addArrayCabecera(array) { | ||
| 714 | for(var i = 0; i < array.length; i++) { | ||
| 715 | addCabecera(array[i].label, array[i].valor); | ||
| 716 | } | ||
| 717 | } | ||
| 658 | 718 | ||
| 659 | function addCabecera(label, valor) { | 719 | function addCabecera(label, valor) { |
| 660 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 720 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
| 661 | if(propiedad.length === 1) { | 721 | if(propiedad.length === 1) { |
| 662 | propiedad[0].valor = valor; | 722 | propiedad[0].valor = valor; |
| 663 | } else { | 723 | } else { |
| 664 | $scope.cabecera.push({label: label, valor: valor}); | 724 | $scope.cabecera.push({label: label, valor: valor}); |
| 665 | } | 725 | } |
| 666 | } | 726 | } |
| 667 | 727 | ||
| 668 | function removeCabecera(label) { | 728 | function removeCabecera(label) { |
| 669 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 729 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
| 670 | if(propiedad.length === 1) { | 730 | if(propiedad.length === 1) { |
| 671 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 731 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
| 672 | } | 732 | } |
| 673 | } | 733 | } |
| 674 | 734 | ||
| 675 | function rellenar(relleno, longitud) { | 735 | function rellenar(relleno, longitud) { |
| 676 | relleno = '' + relleno; | 736 | relleno = '' + relleno; |
| 677 | while (relleno.length < longitud) { | 737 | while (relleno.length < longitud) { |
| 678 | relleno = '0' + relleno; | 738 | relleno = '0' + relleno; |
| 679 | } | 739 | } |
| 680 | 740 | ||
| 681 | return relleno; | 741 | return relleno; |
| 682 | } | 742 | } |
| 683 | } | 743 | } |
| 684 | ] | 744 | ] |
| 685 | ) | 745 | ) |
| 686 | .controller('remitoListaCtrl', [ | 746 | .controller('remitoListaCtrl', [ |
| 687 | '$scope', | 747 | '$scope', |
| 688 | 'crearRemitoService', | 748 | 'crearRemitoService', |
| 689 | '$location', | 749 | '$location', |
| 690 | function($scope, crearRemitoService, $location) { | 750 | function($scope, crearRemitoService, $location) { |
| 691 | crearRemitoService.obtenerRemito().then(function(datos) { | 751 | crearRemitoService.obtenerRemito().then(function(datos) { |
| 692 | $scope.remitos = datos.data; | 752 | $scope.remitos = datos.data; |
| 693 | }); | 753 | }); |
| 694 | $scope.editar = function(remito) { | 754 | $scope.editar = function(remito) { |
| 695 | crearRemitoService.setRemito(remito); | 755 | crearRemitoService.setRemito(remito); |
| 696 | $location.path('/venta-nota-remito/abm/'); | 756 | $location.path('/venta-nota-remito/abm/'); |
| 697 | }; | 757 | }; |
| 698 | $scope.crearRemito = function() { | 758 | $scope.crearRemito = function() { |
| 699 | crearRemitoService.clearRemito(); | 759 | crearRemitoService.clearRemito(); |
| 700 | $location.path('/venta-nota-remito/abm/'); | 760 | $location.path('/venta-nota-remito/abm/'); |
| 701 | }; | 761 | }; |
| 702 | } | 762 | } |
| 703 | ]) | 763 | ]) |
| 704 | .controller('focaCrearRemitoFichaClienteController', [ | 764 | .controller('focaCrearRemitoFichaClienteController', [ |
| 705 | '$scope', | 765 | '$scope', |
| 706 | 'crearRemitoService', | 766 | 'crearRemitoService', |
| 707 | '$location', | 767 | '$location', |
| 708 | function($scope, crearRemitoService, $location) { | 768 | function($scope, crearRemitoService, $location) { |
| 709 | crearRemitoService.obtenerRemito().then(function(datos) { | 769 | crearRemitoService.obtenerRemito().then(function(datos) { |
| 710 | $scope.remitos = datos.data; | 770 | $scope.remitos = datos.data; |
| 711 | }); | 771 | }); |
| 712 | $scope.editar = function(remito) { | 772 | $scope.editar = function(remito) { |
| 713 | crearRemitoService.setRemito(remito); | 773 | crearRemitoService.setRemito(remito); |
| 714 | $location.path('/venta-nota-remito/abm/'); | 774 | $location.path('/venta-nota-remito/abm/'); |
| 715 | }; | 775 | }; |
| 716 | $scope.crearRemito = function() { | 776 | $scope.crearRemito = function() { |
| 717 | crearRemitoService.clearRemito(); | 777 | crearRemitoService.clearRemito(); |
| 718 | $location.path('/venta-nota-remito/abm/'); | 778 | $location.path('/venta-nota-remito/abm/'); |
| 719 | }; | 779 | }; |
| 720 | } | 780 | } |
| 721 | ]); | 781 | ]); |
| 722 | 782 |