Commit 59fd4f02c7cfb4955341eea9f8631ced8f073e8e
Exists in
develop
Merge branch 'develop' of git.focasoftware.com:lsuarez/foca-crear-remito into develop
actualizar rama
Showing
3 changed files
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-domicilio.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="node_modules/foca-modal-nota-pedido/dist/foca-modal-nota-pedido.min.js"></script> | 36 | <script src="node_modules/foca-modal-nota-pedido/dist/foca-modal-nota-pedido.min.js"></script> |
| 37 | <script src="node_modules/foca-botonera-facturador/dist/foca-botonera-facturador.min.js"></script> | 37 | <script src="node_modules/foca-botonera-facturador/dist/foca-botonera-facturador.min.js"></script> |
| 38 | 38 | ||
| 39 | <script src="src/js/app.js"></script> | 39 | <script src="src/js/app.js"></script> |
| 40 | <script src="src/js/controller.js"></script> | 40 | <script src="src/js/controller.js"></script> |
| 41 | <script src="src/js/service.js"></script> | 41 | <script src="src/js/service.js"></script> |
| 42 | <script src="src/js/businessService.js"></script> | 42 | <script src="src/js/businessService.js"></script> |
| 43 | <script src="src/js/route.js"></script> | 43 | <script src="src/js/route.js"></script> |
| 44 | 44 | ||
| 45 | <script src="src/etc/develop.js"></script> | 45 | <script src="src/etc/develop.js"></script> |
| 46 | </head> | 46 | </head> |
| 47 | <body> | 47 | <body> |
| 48 | <div ng-view class="container-fluid"></div> | 48 | <div ng-view class="container-fluid"></div> |
| 49 | </body> | 49 | </body> |
| 50 | </html> | 50 | </html> |
| 51 | 51 |
package.json
| 1 | { | 1 | { |
| 2 | "name": "foca-crear-remito", | 2 | "name": "foca-crear-remito", |
| 3 | "version": "0.0.1", | 3 | "version": "v0.1.1B", |
| 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 | "refresh": "gulp uglify && cp tmp/foca-crear-remito.js ../wrapper-demo/node_modules/foca-crear-remito/dist/foca-crear-remito.min.js", | 7 | "refresh": "gulp uglify && cp tmp/foca-crear-remito.js ../wrapper-demo/node_modules/foca-crear-remito/dist/foca-crear-remito.min.js", |
| 8 | "test": "test.html", | 8 | "test": "test.html", |
| 9 | "compile": "gulp uglify", | 9 | "compile": "gulp uglify", |
| 10 | "gulp-pre-commit": "gulp pre-commit", | 10 | "gulp-pre-commit": "gulp pre-commit", |
| 11 | "postinstall": "npm run compile && gulp clean-post-install", | 11 | "postinstall": "npm run compile && gulp clean-post-install", |
| 12 | "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+ssh://git@debonline.dyndns.org:npm/foca-directivas.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-vendedores.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-proveedor.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-busqueda-productos.git git+ssh://git@debonline.dyndns.org:npm/foca-busqueda-cliente.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-precio-condiciones.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-flete.git git+ssh://git@debonline.dyndns.org:npm/foca-modal.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-domicilio.git git+ssh://git@debonline.dyndns.org:npm/foca-seguimiento.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-moneda.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-cotizacion.git git+ssh://git@debonline.dyndns.org:npm/foca-configuracion.git" | 12 | "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+ssh://git@debonline.dyndns.org:npm/foca-directivas.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-vendedores.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-proveedor.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-busqueda-productos.git git+ssh://git@debonline.dyndns.org:npm/foca-busqueda-cliente.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-precio-condiciones.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-flete.git git+ssh://git@debonline.dyndns.org:npm/foca-modal.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-domicilio.git git+ssh://git@debonline.dyndns.org:npm/foca-seguimiento.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-moneda.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-cotizacion.git git+ssh://git@debonline.dyndns.org:npm/foca-configuracion.git" |
| 13 | }, | 13 | }, |
| 14 | "pre-commit": [ | 14 | "pre-commit": [ |
| 15 | "gulp-pre-commit" | 15 | "gulp-pre-commit" |
| 16 | ], | 16 | ], |
| 17 | "repository": { | 17 | "repository": { |
| 18 | "type": "git", | 18 | "type": "git", |
| 19 | "url": "https://debo.suite.repo/modulos-npm/foca-crear-remito.git" | 19 | "url": "https://debo.suite.repo/modulos-npm/foca-crear-remito.git" |
| 20 | }, | 20 | }, |
| 21 | "author": "Foca Software", | 21 | "author": "Foca Software", |
| 22 | "license": "ISC", | 22 | "license": "ISC", |
| 23 | "peerDependencies": { | 23 | "peerDependencies": { |
| 24 | "foca-busqueda-cliente": "git+ssh://git@debonline.dyndns.org:npm/foca-busqueda-cliente.git", | 24 | "foca-busqueda-cliente": "git+ssh://git@debonline.dyndns.org:npm/foca-busqueda-cliente.git", |
| 25 | "foca-directivas": "git+ssh://git@debonline.dyndns.org:npm/foca-directivas.git", | 25 | "foca-directivas": "git+ssh://git@debonline.dyndns.org:npm/foca-directivas.git", |
| 26 | "foca-modal-busqueda-productos": "git+ssh://git@debonline.dyndns.org:npm/foca-modal-busqueda-productos.git", | 26 | "foca-modal-busqueda-productos": "git+ssh://git@debonline.dyndns.org:npm/foca-modal-busqueda-productos.git", |
| 27 | "foca-modal-proveedor": "git+ssh://git@debonline.dyndns.org:npm/foca-modal-proveedor.git", | 27 | "foca-modal-proveedor": "git+ssh://git@debonline.dyndns.org:npm/foca-modal-proveedor.git", |
| 28 | "foca-modal-vendedores": "git+ssh://git@debonline.dyndns.org:npm/foca-modal-vendedores.git", | 28 | "foca-modal-vendedores": "git+ssh://git@debonline.dyndns.org:npm/foca-modal-vendedores.git", |
| 29 | "foca-seguimiento": "git+ssh://git@debonline.dyndns.org:npm/foca-seguimiento.git" | 29 | "foca-seguimiento": "git+ssh://git@debonline.dyndns.org:npm/foca-seguimiento.git" |
| 30 | }, | 30 | }, |
| 31 | "devDependencies": { | 31 | "devDependencies": { |
| 32 | "angular": "^1.7.5", | 32 | "angular": "^1.7.5", |
| 33 | "angular-cookies": "^1.7.5", | 33 | "angular-cookies": "^1.7.5", |
| 34 | "angular-ladda": "^0.4.3", | 34 | "angular-ladda": "^0.4.3", |
| 35 | "angular-mocks": "^1.7.7", | 35 | "angular-mocks": "^1.7.7", |
| 36 | "angular-route": "^1.7.5", | 36 | "angular-route": "^1.7.5", |
| 37 | "bootstrap": "^4.1.3", | 37 | "bootstrap": "^4.1.3", |
| 38 | "foca-botonera-facturador": "git+ssh://git@debonline.dyndns.org:npm/foca-botonera-facturador.git", | 38 | "foca-botonera-facturador": "git+ssh://git@debonline.dyndns.org:npm/foca-botonera-facturador.git", |
| 39 | "foca-busqueda-cliente": "git+ssh://git@debonline.dyndns.org:npm/foca-busqueda-cliente.git", | 39 | "foca-busqueda-cliente": "git+ssh://git@debonline.dyndns.org:npm/foca-busqueda-cliente.git", |
| 40 | "foca-configuracion": "git+ssh://git@debonline.dyndns.org:npm/foca-configuracion.git", | 40 | "foca-configuracion": "git+ssh://git@debonline.dyndns.org:npm/foca-configuracion.git", |
| 41 | "foca-directivas": "git+ssh://git@debonline.dyndns.org:npm/foca-directivas.git", | 41 | "foca-directivas": "git+ssh://git@debonline.dyndns.org:npm/foca-directivas.git", |
| 42 | "foca-modal": "git+ssh://git@debonline.dyndns.org:npm/foca-modal.git", | 42 | "foca-modal": "git+ssh://git@debonline.dyndns.org:npm/foca-modal.git", |
| 43 | "foca-modal-busqueda-productos": "git+ssh://git@debonline.dyndns.org:npm/foca-modal-busqueda-productos.git", | 43 | "foca-modal-busqueda-productos": "git+ssh://git@debonline.dyndns.org:npm/foca-modal-busqueda-productos.git", |
| 44 | "foca-modal-cotizacion": "git+ssh://git@debonline.dyndns.org:npm/foca-modal-cotizacion.git", | 44 | "foca-modal-cotizacion": "git+ssh://git@debonline.dyndns.org:npm/foca-modal-cotizacion.git", |
| 45 | "foca-modal-domicilio": "git+ssh://git@debonline.dyndns.org:npm/foca-modal-domicilio.git", | 45 | "foca-modal-domicilio": "git+ssh://git@debonline.dyndns.org:npm/foca-modal-domicilio.git", |
| 46 | "foca-modal-flete": "git+ssh://git@debonline.dyndns.org:npm/foca-modal-flete.git", | 46 | "foca-modal-flete": "git+ssh://git@debonline.dyndns.org:npm/foca-modal-flete.git", |
| 47 | "foca-modal-precio-condiciones": "git+ssh://git@debonline.dyndns.org:npm/foca-modal-precio-condiciones.git", | 47 | "foca-modal-precio-condiciones": "git+ssh://git@debonline.dyndns.org:npm/foca-modal-precio-condiciones.git", |
| 48 | "foca-seguimiento": "git+ssh://git@debonline.dyndns.org:npm/foca-seguimiento.git", | 48 | "foca-seguimiento": "git+ssh://git@debonline.dyndns.org:npm/foca-seguimiento.git", |
| 49 | "font-awesome": "^4.7.0", | 49 | "font-awesome": "^4.7.0", |
| 50 | "gulp": "^3.9.1", | 50 | "gulp": "^3.9.1", |
| 51 | "gulp-angular-templatecache": "^2.2.5", | 51 | "gulp-angular-templatecache": "^2.2.5", |
| 52 | "gulp-clean": "^0.4.0", | 52 | "gulp-clean": "^0.4.0", |
| 53 | "gulp-concat": "^2.6.1", | 53 | "gulp-concat": "^2.6.1", |
| 54 | "gulp-connect": "^5.6.1", | 54 | "gulp-connect": "^5.6.1", |
| 55 | "gulp-htmlmin": "^5.0.1", | 55 | "gulp-htmlmin": "^5.0.1", |
| 56 | "gulp-jshint": "^2.1.0", | 56 | "gulp-jshint": "^2.1.0", |
| 57 | "gulp-rename": "^1.4.0", | 57 | "gulp-rename": "^1.4.0", |
| 58 | "gulp-replace": "^1.0.0", | 58 | "gulp-replace": "^1.0.0", |
| 59 | "gulp-sequence": "^1.0.0", | 59 | "gulp-sequence": "^1.0.0", |
| 60 | "gulp-uglify": "^3.0.1", | 60 | "gulp-uglify": "^3.0.1", |
| 61 | "gulp-uglify-es": "^1.0.4", | 61 | "gulp-uglify-es": "^1.0.4", |
| 62 | "jasmine-core": "^3.3.0", | 62 | "jasmine-core": "^3.3.0", |
| 63 | "jquery": "^3.3.1", | 63 | "jquery": "^3.3.1", |
| 64 | "jshint": "^2.10.2", | 64 | "jshint": "^2.10.2", |
| 65 | "ladda": "1.0.6", | 65 | "ladda": "1.0.6", |
| 66 | "pre-commit": "^1.2.2", | 66 | "pre-commit": "^1.2.2", |
| 67 | "pump": "^3.0.0", | 67 | "pump": "^3.0.0", |
| 68 | "ui-bootstrap4": "^3.0.5" | 68 | "ui-bootstrap4": "^3.0.5" |
| 69 | } | 69 | } |
| 70 | } | 70 | } |
src/js/controller.js
| 1 | angular.module('focaCrearRemito').controller('remitoController', | 1 | angular.module('focaCrearRemito').controller('remitoController', |
| 2 | [ | 2 | [ |
| 3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout', |
| 4 | 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', | 4 | 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', |
| 5 | '$localStorage', | 5 | '$localStorage', |
| 6 | function ( | 6 | function ( |
| 7 | $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService, | 7 | $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService, |
| 8 | remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) { | 8 | remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) { |
| 9 | config(); | 9 | config(); |
| 10 | 10 | ||
| 11 | var cotizacionPArgentino = {}; | 11 | var cotizacionPArgentino = {}; |
| 12 | 12 | ||
| 13 | function config() { | 13 | function config() { |
| 14 | $scope.tmpCantidad = Number; | 14 | $scope.tmpCantidad = Number; |
| 15 | $scope.tmpPrecio = Number; | 15 | $scope.tmpPrecio = Number; |
| 16 | $scope.botonera = crearRemitoService.getBotonera(); | 16 | $scope.botonera = crearRemitoService.getBotonera(); |
| 17 | $scope.isNumber = angular.isNumber; | 17 | $scope.isNumber = angular.isNumber; |
| 18 | $scope.datepickerAbierto = false; | 18 | $scope.datepickerAbierto = false; |
| 19 | $scope.show = false; | 19 | $scope.show = false; |
| 20 | $scope.cargando = true; | 20 | $scope.cargando = true; |
| 21 | $scope.now = new Date(); | 21 | $scope.now = new Date(); |
| 22 | $scope.puntoVenta = rellenar(0, 4); | 22 | $scope.puntoVenta = rellenar(0, 4); |
| 23 | $scope.comprobante = rellenar(0, 8); | 23 | $scope.comprobante = rellenar(0, 8); |
| 24 | $scope.dateOptions = { | 24 | $scope.dateOptions = { |
| 25 | maxDate: new Date(), | 25 | maxDate: new Date(), |
| 26 | minDate: new Date(2010, 0, 1) | 26 | minDate: new Date(2010, 0, 1) |
| 27 | }; | 27 | }; |
| 28 | $scope.cabeceras = []; | 28 | $scope.cabeceras = []; |
| 29 | crearRemitoService.getParametros().then(function (res) { | 29 | crearRemitoService.getParametros().then(function (res) { |
| 30 | var parametros = JSON.parse(res.data[0].jsonText); | 30 | var parametros = JSON.parse(res.data[0].jsonText); |
| 31 | if ($localStorage.remito) { | 31 | if ($localStorage.remito) { |
| 32 | $timeout(function () { getLSRemito(); }); | 32 | $timeout(function () { getLSRemito(); }); |
| 33 | } else { | 33 | } else { |
| 34 | for (var property in parametros) { | 34 | for (var property in parametros) { |
| 35 | $scope.remito[property] = parametros[property]; | 35 | $scope.remito[property] = parametros[property]; |
| 36 | $scope.inicial[property] = parametros[property]; | 36 | $scope.inicial[property] = parametros[property]; |
| 37 | } | 37 | } |
| 38 | setearRemito($scope.remito); | 38 | setearRemito($scope.remito); |
| 39 | } | 39 | } |
| 40 | }); | 40 | }); |
| 41 | 41 | ||
| 42 | //SETEO BOTONERA LATERAL | 42 | //SETEO BOTONERA LATERAL |
| 43 | $timeout(function () { | 43 | $timeout(function () { |
| 44 | focaBotoneraLateralService.showSalir(false); | 44 | focaBotoneraLateralService.showSalir(false); |
| 45 | focaBotoneraLateralService.showPausar(true); | 45 | focaBotoneraLateralService.showPausar(true); |
| 46 | focaBotoneraLateralService.showGuardar(true, $scope.crearRemito); | 46 | focaBotoneraLateralService.showGuardar(true, $scope.crearRemito); |
| 47 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 47 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
| 48 | }); | 48 | }); |
| 49 | 49 | ||
| 50 | init(); | 50 | init(); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | function init() { | 53 | function init() { |
| 54 | $scope.$broadcast('cleanCabecera'); | 54 | $scope.$broadcast('cleanCabecera'); |
| 55 | $scope.remito = { | 55 | $scope.remito = { |
| 56 | id: 0, | 56 | id: 0, |
| 57 | estado: 0, | 57 | estado: 0, |
| 58 | // vendedor: {}, | 58 | // vendedor: {}, |
| 59 | cliente: {}, | 59 | cliente: {}, |
| 60 | proveedor: {}, | 60 | proveedor: {}, |
| 61 | domicilio: { dom: '' }, | 61 | domicilio: { dom: '' }, |
| 62 | moneda: {}, | 62 | moneda: {}, |
| 63 | cotizacion: $scope.cotizacionPorDefecto || {}, | 63 | cotizacion: $scope.cotizacionPorDefecto || {}, |
| 64 | articulosRemito: [], | 64 | articulosRemito: [], |
| 65 | remitoPuntoDescarga: [] | 65 | remitoPuntoDescarga: [] |
| 66 | }; | 66 | }; |
| 67 | $scope.notaPedido = { | 67 | $scope.notaPedido = { |
| 68 | id: 0 | 68 | id: 0 |
| 69 | }; | 69 | }; |
| 70 | 70 | ||
| 71 | $scope.remito.articulosRemito = []; | 71 | $scope.remito.articulosRemito = []; |
| 72 | $scope.idLista = undefined; | 72 | $scope.idLista = undefined; |
| 73 | 73 | ||
| 74 | crearRemitoService.getNumeroRemito().then( | 74 | crearRemitoService.getNumeroRemito().then( |
| 75 | function (res) { | 75 | function (res) { |
| 76 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 76 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
| 77 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); | 77 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); |
| 78 | }, | 78 | }, |
| 79 | function (err) { | 79 | function (err) { |
| 80 | focaModalService.alert('La terminal no esta configurada correctamente'); | 80 | focaModalService.alert('La terminal no esta configurada correctamente'); |
| 81 | console.info(err); | 81 | console.info(err); |
| 82 | } | 82 | } |
| 83 | ); | 83 | ); |
| 84 | 84 | ||
| 85 | $scope.inicial = angular.copy($scope.remito); | 85 | $scope.inicial = angular.copy($scope.remito); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | $scope.$watch('remito', function (newValue) { | 88 | $scope.$watch('remito', function (newValue) { |
| 89 | focaBotoneraLateralService.setPausarData({ | 89 | focaBotoneraLateralService.setPausarData({ |
| 90 | label: 'remito', | 90 | label: 'remito', |
| 91 | val: newValue | 91 | val: newValue |
| 92 | }); | 92 | }); |
| 93 | focaBotoneraLateralService.setRutasPausadas({ | 93 | focaBotoneraLateralService.setRutasPausadas({ |
| 94 | label: 'rutas', | 94 | label: 'rutas', |
| 95 | val: 'venta-remito/crear' | 95 | val: 'venta-remito/crear' |
| 96 | }); | 96 | }); |
| 97 | }, true); | 97 | }, true); |
| 98 | 98 | ||
| 99 | $scope.seleccionarNotaPedido = function () { | 99 | $scope.seleccionarNotaPedido = function () { |
| 100 | if ($scope.remitoIsDirty) { | 100 | if ($scope.remitoIsDirty) { |
| 101 | focaModalService.confirm('¿Desea continuar? Se perderan los cambios') | 101 | focaModalService.confirm('¿Desea continuar? Se perderan los cambios') |
| 102 | .then(function () { | 102 | .then(function () { |
| 103 | $scope.getNotaPedidoModal(); | 103 | $scope.getNotaPedidoModal(); |
| 104 | }); | 104 | }); |
| 105 | } else { | 105 | } else { |
| 106 | $scope.getNotaPedidoModal(); | 106 | $scope.getNotaPedidoModal(); |
| 107 | } | 107 | } |
| 108 | }; | 108 | }; |
| 109 | 109 | ||
| 110 | $scope.getNotaPedidoModal = function () { | 110 | $scope.getNotaPedidoModal = function () { |
| 111 | if (!varlidarRemitoFacturado()) return; | 111 | if (!varlidarRemitoFacturado()) return; |
| 112 | if (!varlidarRemitoAbierto()) return; | 112 | if (!varlidarRemitoAbierto()) return; |
| 113 | var modalInstance = $uibModal.open( | 113 | var modalInstance = $uibModal.open( |
| 114 | { | 114 | { |
| 115 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 115 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
| 116 | templateUrl: 'foca-modal-nota-pedido.html', | 116 | templateUrl: 'foca-modal-nota-pedido.html', |
| 117 | controller: 'focaModalNotaPedidoController', | 117 | controller: 'focaModalNotaPedidoController', |
| 118 | size: 'lg', | 118 | size: 'lg', |
| 119 | resolve: { | 119 | resolve: { |
| 120 | usadoPor: function () { return 'remito'; }, | 120 | usadoPor: function () { return 'remito'; }, |
| 121 | idVendedor: function () { return null; } | 121 | idVendedor: function () { return null; } |
| 122 | } | 122 | } |
| 123 | } | 123 | } |
| 124 | ); | 124 | ); |
| 125 | modalInstance.result.then( | 125 | modalInstance.result.then( |
| 126 | function (notaPedido) { | 126 | function (notaPedido) { |
| 127 | //añado cabeceras | 127 | //añado cabeceras |
| 128 | $scope.remitoIsDirty = true; | 128 | $scope.remitoIsDirty = true; |
| 129 | $scope.notaPedido = notaPedido; | 129 | $scope.notaPedido = notaPedido; |
| 130 | $scope.remito.cliente = notaPedido.cliente; | 130 | $scope.remito.cliente = notaPedido.cliente; |
| 131 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 131 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
| 132 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 132 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
| 133 | var puntosDescarga = []; | 133 | var puntosDescarga = []; |
| 134 | notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedido) { | 134 | notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedido) { |
| 135 | puntosDescarga.push(notaPedido.puntoDescarga); | 135 | puntosDescarga.push(notaPedido.puntoDescarga); |
| 136 | }); | 136 | }); |
| 137 | $scope.cabeceras = [ | 137 | $scope.cabeceras = [ |
| 138 | { | 138 | { |
| 139 | label: 'Cliente:', | 139 | label: 'Cliente:', |
| 140 | valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + | 140 | valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + |
| 141 | ' - ' + notaPedido.cliente.NOM | 141 | ' - ' + notaPedido.cliente.NOM |
| 142 | }, | 142 | }, |
| 143 | { | 143 | { |
| 144 | label: 'Domicilio:', | 144 | label: 'Domicilio:', |
| 145 | valor: notaPedido.domicilioStamp | 145 | valor: notaPedido.domicilioStamp |
| 146 | }, | 146 | }, |
| 147 | // { | 147 | // { |
| 148 | // label: 'Vendedor:', | 148 | // label: 'Vendedor:', |
| 149 | // valor: $filter('rellenarDigitos')( | 149 | // valor: $filter('rellenarDigitos')( |
| 150 | // notaPedido.vendedor.NUM, 3 | 150 | // notaPedido.vendedor.NUM, 3 |
| 151 | // ) + ' - ' + notaPedido.vendedor.NOM | 151 | // ) + ' - ' + notaPedido.vendedor.NOM |
| 152 | // }, | 152 | // }, |
| 153 | 153 | ||
| 154 | { | 154 | { |
| 155 | label: 'Proveedor:', | 155 | label: 'Proveedor:', |
| 156 | valor: $filter('rellenarDigitos') | 156 | valor: $filter('rellenarDigitos') |
| 157 | (notaPedido.proveedor.COD, 5) + ' - ' + | 157 | (notaPedido.proveedor.COD, 5) + ' - ' + |
| 158 | notaPedido.proveedor.NOM | 158 | notaPedido.proveedor.NOM |
| 159 | }, | 159 | }, |
| 160 | 160 | ||
| 161 | { | 161 | { |
| 162 | label: 'Flete:', | 162 | label: 'Flete:', |
| 163 | valor: notaPedido.fob === 1 ? 'FOB' : ( | 163 | valor: notaPedido.fob === 1 ? 'FOB' : ( |
| 164 | notaPedido.flete === 1 ? 'Si' : 'No') | 164 | notaPedido.flete === 1 ? 'Si' : 'No') |
| 165 | }, | 165 | }, |
| 166 | { | 166 | { |
| 167 | label: 'Puntos de descarga: ', | 167 | label: 'Puntos de descarga: ', |
| 168 | valor: $filter('rellenarDigitos')( | 168 | valor: $filter('rellenarDigitos')( |
| 169 | getCabeceraPuntoDescarga(puntosDescarga)) | 169 | getCabeceraPuntoDescarga(puntosDescarga)) |
| 170 | } | 170 | } |
| 171 | ]; | 171 | ]; |
| 172 | actualizarCabeceraMoneda(notaPedido.cotizacion); | 172 | actualizarCabeceraMoneda(notaPedido.cotizacion); |
| 173 | valorPrecioCondicion(); | 173 | valorPrecioCondicion(); |
| 174 | // Seteo checked en cabeceras | 174 | // Seteo checked en cabeceras |
| 175 | $filter('filter')($scope.botonera, | 175 | $filter('filter')($scope.botonera, |
| 176 | { label: 'Cliente' })[0].checked = true; | 176 | { label: 'Cliente' })[0].checked = true; |
| 177 | $filter('filter')($scope.botonera, | 177 | $filter('filter')($scope.botonera, |
| 178 | { label: 'Proveedor' })[0].checked = true; | 178 | { label: 'Proveedor' })[0].checked = true; |
| 179 | $filter('filter')($scope.botonera, | 179 | $filter('filter')($scope.botonera, |
| 180 | { label: 'Moneda' })[0].checked = true; | 180 | { label: 'Moneda' })[0].checked = true; |
| 181 | $filter('filter')($scope.botonera, | 181 | $filter('filter')($scope.botonera, |
| 182 | { label: 'Nota pedido' })[0].checked = true; | 182 | { label: 'Nota pedido' })[0].checked = true; |
| 183 | $filter('filter')($scope.botonera, | 183 | $filter('filter')($scope.botonera, |
| 184 | { label: 'Precios y condiciones' })[0].checked = true; | 184 | { label: 'Precios y condiciones' })[0].checked = true; |
| 185 | $filter('filter')($scope.botonera, | 185 | $filter('filter')($scope.botonera, |
| 186 | { label: 'Domicilio de Entrega' })[0].checked = true; | 186 | { label: 'Domicilio de Entrega' })[0].checked = true; |
| 187 | 187 | ||
| 188 | if (notaPedido.observaciones) { | 188 | if (notaPedido.observaciones) { |
| 189 | $filter('filter')($scope.botonera, | 189 | $filter('filter')($scope.botonera, |
| 190 | { label: 'Observaciones' })[0].checked = true; | 190 | { label: 'Observaciones' })[0].checked = true; |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | function valorPrecioCondicion() { | 193 | function valorPrecioCondicion() { |
| 194 | if (parseInt(notaPedido.idListaPrecio) > 0) { | 194 | if (parseInt(notaPedido.idListaPrecio) > 0) { |
| 195 | crearRemitoService | 195 | crearRemitoService |
| 196 | .getListaPrecioById(parseInt(notaPedido.idListaPrecio)) | 196 | .getListaPrecioById(parseInt(notaPedido.idListaPrecio)) |
| 197 | .then(function (res) { | 197 | .then(function (res) { |
| 198 | $scope.cabeceras.push({ | 198 | $scope.cabeceras.push({ |
| 199 | label: 'Precios y Condiciones:', | 199 | label: 'Precios y Condiciones:', |
| 200 | valor: | 200 | valor: |
| 201 | parseInt(res.data[0].ID) + ' - ' + | 201 | parseInt(res.data[0].ID) + ' - ' + |
| 202 | res.data[0].DES + ' ' + | 202 | res.data[0].DES + ' ' + |
| 203 | remitoBusinessService | 203 | remitoBusinessService |
| 204 | .plazoToString(notaPedido.notaPedidoPlazo) | 204 | .plazoToString(notaPedido.notaPedidoPlazo) |
| 205 | }); | 205 | }); |
| 206 | addArrayCabecera($scope.cabeceras); | 206 | addArrayCabecera($scope.cabeceras); |
| 207 | }); | 207 | }); |
| 208 | } | 208 | } |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | if (notaPedido.flete === 1) { | 211 | if (notaPedido.flete === 1) { |
| 212 | var cabeceraBomba = { | 212 | var cabeceraBomba = { |
| 213 | label: 'Bomba:', | 213 | label: 'Bomba:', |
| 214 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 214 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
| 215 | }; | 215 | }; |
| 216 | if (notaPedido.kilometros) { | 216 | if (notaPedido.kilometros) { |
| 217 | var cabeceraKilometros = { | 217 | var cabeceraKilometros = { |
| 218 | label: 'Kilometros:', | 218 | label: 'Kilometros:', |
| 219 | valor: notaPedido.kilometros | 219 | valor: notaPedido.kilometros |
| 220 | }; | 220 | }; |
| 221 | $scope.cabeceras.push(cabeceraKilometros); | 221 | $scope.cabeceras.push(cabeceraKilometros); |
| 222 | } | 222 | } |
| 223 | $scope.cabeceras.push(cabeceraBomba); | 223 | $scope.cabeceras.push(cabeceraBomba); |
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | $scope.remito = angular.copy(notaPedido); | 226 | $scope.remito = angular.copy(notaPedido); |
| 227 | $scope.remito.id = 0; | 227 | $scope.remito.id = 0; |
| 228 | $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; | 228 | $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; |
| 229 | $scope.remito.remitoPuntoDescarga = notaPedido.notaPedidoPuntoDescarga; | 229 | $scope.remito.remitoPuntoDescarga = notaPedido.notaPedidoPuntoDescarga; |
| 230 | 230 | ||
| 231 | notaPedido.articulosNotaPedido.forEach(function (articulo) { | 231 | notaPedido.articulosNotaPedido.forEach(function (articulo) { |
| 232 | articulo.id = 0; | 232 | articulo.id = 0; |
| 233 | articulo.idRemito = 0; | 233 | articulo.idRemito = 0; |
| 234 | articulo.precio = | 234 | articulo.precio = |
| 235 | (articulo.precio / notaPedido.cotizacion.VENDEDOR).toFixed(4); | 235 | (articulo.precio / notaPedido.cotizacion.VENDEDOR).toFixed(4); |
| 236 | }); | 236 | }); |
| 237 | 237 | ||
| 238 | $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; | 238 | $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; |
| 239 | 239 | ||
| 240 | if (notaPedido.idPrecioCondicion > 0) { | 240 | if (notaPedido.idPrecioCondicion > 0) { |
| 241 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | 241 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; |
| 242 | } else { | 242 | } else { |
| 243 | $scope.idLista = -1; | 243 | $scope.idLista = -1; |
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | enableObservaciones(notaPedido.observaciones ? true : false); | 246 | enableObservaciones(notaPedido.observaciones ? true : false); |
| 247 | addArrayCabecera($scope.cabeceras); | 247 | addArrayCabecera($scope.cabeceras); |
| 248 | 248 | ||
| 249 | }, function () { | 249 | }, function () { |
| 250 | // funcion ejecutada cuando se cancela el modal | 250 | // funcion ejecutada cuando se cancela el modal |
| 251 | } | 251 | } |
| 252 | ); | 252 | ); |
| 253 | }; | 253 | }; |
| 254 | 254 | ||
| 255 | $scope.seleccionarRemito = function () { | 255 | $scope.seleccionarRemito = function () { |
| 256 | if ($scope.remitoIsDirty) { | 256 | if ($scope.remitoIsDirty) { |
| 257 | focaModalService.confirm('¿Desea continuar? Se perderan los cambios') | 257 | focaModalService.confirm('¿Desea continuar? Se perderan los cambios') |
| 258 | .then(function () { | 258 | .then(function () { |
| 259 | $scope.getRemitoModal(); | 259 | $scope.getRemitoModal(); |
| 260 | }); | 260 | }); |
| 261 | } else { | 261 | } else { |
| 262 | $scope.getRemitoModal(); | 262 | $scope.getRemitoModal(); |
| 263 | } | 263 | } |
| 264 | }; | 264 | }; |
| 265 | $scope.getRemitoModal = function () { | 265 | $scope.getRemitoModal = function () { |
| 266 | var modalInstance = $uibModal.open( | 266 | var modalInstance = $uibModal.open( |
| 267 | { | 267 | { |
| 268 | ariaLabelledBy: 'Busqueda de Remito', | 268 | ariaLabelledBy: 'Busqueda de Remito', |
| 269 | templateUrl: 'foca-modal-remito.html', | 269 | templateUrl: 'foca-modal-remito.html', |
| 270 | controller: 'focaModalRemitoController', | 270 | controller: 'focaModalRemitoController', |
| 271 | size: 'lg', | 271 | size: 'lg', |
| 272 | resolve: { usadoPor: function () { return 'remito'; } } | 272 | resolve: { usadoPor: function () { return 'remito'; } } |
| 273 | } | 273 | } |
| 274 | ); | 274 | ); |
| 275 | modalInstance.result.then(function (remito) { | 275 | modalInstance.result.then(function (remito) { |
| 276 | 276 | ||
| 277 | remito.articulosRemito.forEach(function (articulo) { | 277 | remito.articulosRemito.forEach(function (articulo) { |
| 278 | articulo.precio = | 278 | articulo.precio = |
| 279 | (articulo.precio / remito.cotizacion.VENDEDOR).toFixed(4); | 279 | (articulo.precio / remito.cotizacion.VENDEDOR).toFixed(4); |
| 280 | }); | 280 | }); |
| 281 | 281 | ||
| 282 | setearRemito(remito); | 282 | setearRemito(remito); |
| 283 | 283 | ||
| 284 | }, function () { | 284 | }, function () { |
| 285 | // funcion ejecutada cuando se cancela el modal | 285 | // funcion ejecutada cuando se cancela el modal |
| 286 | } | 286 | } |
| 287 | ); | 287 | ); |
| 288 | }; | 288 | }; |
| 289 | //validacion por domicilio y por plazo pago | 289 | //validacion por domicilio y por plazo pago |
| 290 | $scope.crearRemito = function () { | 290 | $scope.crearRemito = function () { |
| 291 | 291 | ||
| 292 | if (!remitoBusinessService.validarRemito($scope.remito, $scope.articulosFiltro())) { | 292 | if (!remitoBusinessService.validarRemito($scope.remito, $scope.articulosFiltro())) { |
| 293 | return; | 293 | return; |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | focaBotoneraLateralService.startGuardar(); | 296 | focaBotoneraLateralService.startGuardar(); |
| 297 | $scope.saveLoading = true; | 297 | $scope.saveLoading = true; |
| 298 | var rutaJson = JSON.parse($localStorage.rutas); | 298 | if ($localStorage.rutas) { |
| 299 | removeItemFromArr(rutaJson, 'venta-remito/crear'); | 299 | var rutaJson = JSON.parse($localStorage.rutas); |
| 300 | $localStorage.rutas = JSON.stringify(rutaJson); | 300 | removeItemFromArr(rutaJson, 'venta-remito/crear'); |
| 301 | $localStorage.rutas = JSON.stringify(rutaJson); | ||
| 302 | } | ||
| 301 | 303 | ||
| 302 | var save = { | 304 | var save = { |
| 303 | remito: { | 305 | remito: { |
| 304 | id: $scope.remito.id, | 306 | id: $scope.remito.id, |
| 305 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | 307 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), |
| 306 | idCliente: $scope.remito.cliente.COD, | 308 | idCliente: $scope.remito.cliente.COD, |
| 307 | nombreCliente: $scope.remito.cliente.NOM, | 309 | nombreCliente: $scope.remito.cliente.NOM, |
| 308 | cuitCliente: $scope.remito.cliente.CUIT, | 310 | cuitCliente: $scope.remito.cliente.CUIT, |
| 309 | total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR, | 311 | total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR, |
| 310 | numeroNotaPedido: $scope.remito.numeroNotaPedido, | 312 | numeroNotaPedido: $scope.remito.numeroNotaPedido, |
| 311 | idVendedor: parseInt($scope.remito.cliente.VEN), | 313 | idVendedor: parseInt($scope.remito.cliente.VEN), |
| 312 | idProveedor: $scope.remito.proveedor.COD, | 314 | idProveedor: $scope.remito.proveedor.COD, |
| 313 | idDomicilio: $scope.remito.idDomicilio || $scope.remito.domicilio.id, | 315 | idDomicilio: $scope.remito.idDomicilio || $scope.remito.domicilio.id, |
| 314 | idCotizacion: $scope.remito.cotizacion.ID, | 316 | idCotizacion: $scope.remito.cotizacion.ID, |
| 315 | idListaPrecio: $scope.idLista, | 317 | idListaPrecio: $scope.idLista, |
| 316 | flete: $scope.remito.flete, | 318 | flete: $scope.remito.flete, |
| 317 | fob: $scope.remito.fob, | 319 | fob: $scope.remito.fob, |
| 318 | bomba: $scope.remito.bomba, | 320 | bomba: $scope.remito.bomba, |
| 319 | kilometros: $scope.remito.kilometros, | 321 | kilometros: $scope.remito.kilometros, |
| 320 | domicilioStamp: $scope.remito.domicilioStamp, | 322 | domicilioStamp: $scope.remito.domicilioStamp, |
| 321 | observaciones: $scope.remito.observaciones, | 323 | observaciones: $scope.remito.observaciones, |
| 322 | numeroRemito: parseInt($scope.comprobante), | 324 | numeroRemito: parseInt($scope.comprobante), |
| 323 | sucursal: parseInt($scope.puntoVenta), | 325 | sucursal: parseInt($scope.puntoVenta), |
| 324 | responsabilidadIvaCliente: $scope.remito.cliente.IVA, | 326 | responsabilidadIvaCliente: $scope.remito.cliente.IVA, |
| 325 | descuento: 0,//TODO, | 327 | descuento: 0,//TODO, |
| 326 | importeNeto: getImporte('netoUnitario'), | 328 | importeNeto: getImporte('netoUnitario'), |
| 327 | importeExento: getImporte('exentoUnitario'), | 329 | importeExento: getImporte('exentoUnitario'), |
| 328 | importeIva: getImporte('ivaUnitario'), | 330 | importeIva: getImporte('ivaUnitario'), |
| 329 | importeIvaServicios: 0,//TODO | 331 | importeIvaServicios: 0,//TODO |
| 330 | importeImpuestoInterno: getImporte('impuestoInternoUnitario'), | 332 | importeImpuestoInterno: getImporte('impuestoInternoUnitario'), |
| 331 | importeImpuestoInterno1: getImporte('impuestoInterno1Unitario'), | 333 | importeImpuestoInterno1: getImporte('impuestoInterno1Unitario'), |
| 332 | importeImpuestoInterno2: getImporte('impuestoInterno2Unitario'), | 334 | importeImpuestoInterno2: getImporte('impuestoInterno2Unitario'), |
| 333 | percepcion: 0,//TODO | 335 | percepcion: 0,//TODO |
| 334 | percepcionIva: 0,//TODO | 336 | percepcionIva: 0,//TODO |
| 335 | redondeo: 0,//TODO | 337 | redondeo: 0,//TODO |
| 336 | anulado: false, | 338 | anulado: false, |
| 337 | planilla: $filter('date')($scope.now, 'ddMMyyyy'), | 339 | planilla: $filter('date')($scope.now, 'ddMMyyyy'), |
| 338 | lugar: parseInt($scope.puntoVenta), | 340 | lugar: parseInt($scope.puntoVenta), |
| 339 | cuentaMadre: 0,//TODO | 341 | cuentaMadre: 0,//TODO |
| 340 | cuentaContable: 0,//TODO | 342 | cuentaContable: 0,//TODO |
| 341 | asiento: 0,//TODO | 343 | asiento: 0,//TODO |
| 342 | e_hd: '',//TODO | 344 | e_hd: '',//TODO |
| 343 | c_hd: '', | 345 | c_hd: '', |
| 344 | numeroLiquidoProducto: 0,//TODO | 346 | numeroLiquidoProducto: 0,//TODO |
| 345 | estado: $scope.remito.estado, | 347 | estado: $scope.remito.estado, |
| 346 | destinoVenta: 0,//TODO | 348 | destinoVenta: 0,//TODO |
| 347 | operacionTipo: 0, //TODO | 349 | operacionTipo: 0, //TODO |
| 348 | }, | 350 | }, |
| 349 | notaPedido: $scope.notaPedido, | 351 | notaPedido: $scope.notaPedido, |
| 350 | articulos: remitoBusinessService.quitarCotizacion($scope.articulosFiltro(), | 352 | articulos: remitoBusinessService.quitarCotizacion($scope.articulosFiltro(), |
| 351 | $scope.remito.cotizacion.VENDEDOR), | 353 | $scope.remito.cotizacion.VENDEDOR), |
| 352 | puntosDescarga: remitoBusinessService.addPuntosDescarga( | 354 | puntosDescarga: remitoBusinessService.addPuntosDescarga( |
| 353 | $scope.remito.remitoPuntoDescarga), | 355 | $scope.remito.remitoPuntoDescarga), |
| 354 | plazos: $scope.remito.remitoPlazo | 356 | plazos: $scope.remito.remitoPlazo |
| 355 | }; | 357 | }; |
| 356 | crearRemitoService.crearRemito(save).then( | 358 | crearRemitoService.crearRemito(save).then( |
| 357 | function (data) { | 359 | function (data) { |
| 358 | 360 | ||
| 359 | focaBotoneraLateralService.endGuardar(true); | 361 | focaBotoneraLateralService.endGuardar(true); |
| 360 | $scope.saveLoading = false; | 362 | $scope.saveLoading = false; |
| 361 | 363 | ||
| 362 | if (data.status === 500) { | 364 | if (data.status === 500) { |
| 363 | focaModalService.alert(data.data); | 365 | focaModalService.alert(data.data); |
| 364 | return; | 366 | return; |
| 365 | } | 367 | } |
| 366 | 368 | ||
| 367 | abrirModalMail(data.data.id, | 369 | abrirModalMail(data.data.id, |
| 368 | $scope.remito.cliente, | 370 | $scope.remito.cliente, |
| 369 | $filter('comprobante')([ | 371 | $filter('comprobante')([ |
| 370 | $scope.puntoVenta, | 372 | $scope.puntoVenta, |
| 371 | data.data.numero | 373 | data.data.numero |
| 372 | ]) | 374 | ]) |
| 373 | ); | 375 | ); |
| 374 | 376 | ||
| 375 | config(); | 377 | config(); |
| 376 | 378 | ||
| 377 | }, function (error) { | 379 | }, function (error) { |
| 378 | focaModalService.alert(error.data || 'Hubo un error al crear el remito'); | 380 | focaModalService.alert(error.data || 'Hubo un error al crear el remito'); |
| 379 | focaBotoneraLateralService.endGuardar(); | 381 | focaBotoneraLateralService.endGuardar(); |
| 380 | $scope.saveLoading = false; | 382 | $scope.saveLoading = false; |
| 381 | console.info(error); | 383 | console.info(error); |
| 382 | } | 384 | } |
| 383 | ); | 385 | ); |
| 384 | }; | 386 | }; |
| 385 | 387 | ||
| 386 | $scope.seleccionarProductos = function () { | 388 | $scope.seleccionarProductos = function () { |
| 387 | if (!varlidarRemitoFacturado()) return; | 389 | if (!varlidarRemitoFacturado()) return; |
| 388 | if (!varlidarRemitoAbierto()) return; | 390 | if (!varlidarRemitoAbierto()) return; |
| 389 | if ($scope.notaPedido.id !== 0) { | 391 | if ($scope.notaPedido.id !== 0) { |
| 390 | $scope.idLista = parseInt($scope.notaPedido.idListaPrecio); | 392 | $scope.idLista = parseInt($scope.notaPedido.idListaPrecio); |
| 391 | } | 393 | } |
| 392 | if ($scope.idLista === undefined) { | 394 | if ($scope.idLista === undefined) { |
| 393 | focaModalService.alert( | 395 | focaModalService.alert( |
| 394 | 'Primero seleccione una lista de precio y condicion'); | 396 | 'Primero seleccione una lista de precio y condicion'); |
| 395 | return; | 397 | return; |
| 396 | } | 398 | } |
| 397 | var modalInstance = $uibModal.open( | 399 | var modalInstance = $uibModal.open( |
| 398 | { | 400 | { |
| 399 | ariaLabelledBy: 'Busqueda de Productos', | 401 | ariaLabelledBy: 'Busqueda de Productos', |
| 400 | templateUrl: 'modal-busqueda-productos.html', | 402 | templateUrl: 'modal-busqueda-productos.html', |
| 401 | controller: 'modalBusquedaProductosCtrl', | 403 | controller: 'modalBusquedaProductosCtrl', |
| 402 | resolve: { | 404 | resolve: { |
| 403 | parametroProducto: { | 405 | parametroProducto: { |
| 404 | idLista: $scope.idLista, | 406 | idLista: $scope.idLista, |
| 405 | cotizacion: $scope.remito.cotizacion.VENDEDOR, | 407 | cotizacion: $scope.remito.cotizacion.VENDEDOR, |
| 406 | simbolo: $scope.remito.cotizacion.moneda.SIMBOLO | 408 | simbolo: $scope.remito.cotizacion.moneda.SIMBOLO |
| 407 | } | 409 | } |
| 408 | }, | 410 | }, |
| 409 | size: 'lg' | 411 | size: 'lg' |
| 410 | } | 412 | } |
| 411 | ); | 413 | ); |
| 412 | modalInstance.result.then( | 414 | modalInstance.result.then( |
| 413 | function (producto) { | 415 | function (producto) { |
| 414 | var newArt = | 416 | var newArt = |
| 415 | { | 417 | { |
| 416 | id: 0, | 418 | id: 0, |
| 417 | idRemito: 0, | 419 | idRemito: 0, |
| 418 | codigo: producto.codigo, | 420 | codigo: producto.codigo, |
| 419 | sector: producto.sector, | 421 | sector: producto.sector, |
| 420 | sectorCodigo: producto.sector + '-' + producto.codigo, | 422 | sectorCodigo: producto.sector + '-' + producto.codigo, |
| 421 | descripcion: producto.descripcionLarga, | 423 | descripcion: producto.descripcionLarga, |
| 422 | item: $scope.remito.articulosRemito.length + 1, | 424 | item: $scope.remito.articulosRemito.length + 1, |
| 423 | nombre: producto.descripcion, | 425 | nombre: producto.descripcion, |
| 424 | precio: parseFloat(producto.precio.toFixed(4)), | 426 | precio: parseFloat(producto.precio.toFixed(4)), |
| 425 | costoUnitario: producto.costo, | 427 | costoUnitario: producto.costo, |
| 426 | editCantidad: false, | 428 | editCantidad: false, |
| 427 | editPrecio: false, | 429 | editPrecio: false, |
| 428 | rubro: producto.CodRub, | 430 | rubro: producto.CodRub, |
| 429 | ivaUnitario: producto.IMPIVA, | 431 | ivaUnitario: producto.IMPIVA, |
| 430 | impuestoInternoUnitario: producto.ImpInt, | 432 | impuestoInternoUnitario: producto.ImpInt, |
| 431 | impuestoInterno1Unitario: producto.ImpInt2, | 433 | impuestoInterno1Unitario: producto.ImpInt2, |
| 432 | impuestoInterno2Unitario: producto.ImpInt3, | 434 | impuestoInterno2Unitario: producto.ImpInt3, |
| 433 | precioLista: producto.precio, | 435 | precioLista: producto.precio, |
| 434 | combustible: 1, | 436 | combustible: 1, |
| 435 | facturado: 0, | 437 | facturado: 0, |
| 436 | idArticulo: producto.id, | 438 | idArticulo: producto.id, |
| 437 | tasaIva: producto.tasaIVA | 439 | tasaIva: producto.tasaIVA |
| 438 | }; | 440 | }; |
| 439 | 441 | ||
| 440 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : producto.neto; | 442 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : producto.neto; |
| 441 | newArt.netoUnitario = newArt.ivaUnitario ? producto.neto : 0; | 443 | newArt.netoUnitario = newArt.ivaUnitario ? producto.neto : 0; |
| 442 | 444 | ||
| 443 | $scope.articuloACargar = newArt; | 445 | $scope.articuloACargar = newArt; |
| 444 | $scope.cargando = false; | 446 | $scope.cargando = false; |
| 445 | }, function () { | 447 | }, function () { |
| 446 | // funcion ejecutada cuando se cancela el modal | 448 | // funcion ejecutada cuando se cancela el modal |
| 447 | } | 449 | } |
| 448 | ); | 450 | ); |
| 449 | }; | 451 | }; |
| 450 | 452 | ||
| 451 | $scope.seleccionarPuntosDeDescarga = function () { | 453 | $scope.seleccionarPuntosDeDescarga = function () { |
| 452 | if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { | 454 | if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { |
| 453 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 455 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
| 454 | return; | 456 | return; |
| 455 | } else { | 457 | } else { |
| 456 | var modalInstance = $uibModal.open( | 458 | var modalInstance = $uibModal.open( |
| 457 | { | 459 | { |
| 458 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', | 460 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
| 459 | templateUrl: 'modal-punto-descarga.html', | 461 | templateUrl: 'modal-punto-descarga.html', |
| 460 | controller: 'focaModalPuntoDescargaController', | 462 | controller: 'focaModalPuntoDescargaController', |
| 461 | size: 'lg', | 463 | size: 'lg', |
| 462 | resolve: { | 464 | resolve: { |
| 463 | filters: { | 465 | filters: { |
| 464 | idDomicilio: $scope.remito.domicilio.id, | 466 | idDomicilio: $scope.remito.domicilio.id, |
| 465 | idCliente: $scope.remito.cliente.COD, | 467 | idCliente: $scope.remito.cliente.COD, |
| 466 | articulos: $scope.remito.articulosRemito, | 468 | articulos: $scope.remito.articulosRemito, |
| 467 | puntosDescarga: $scope.remito.remitoPuntoDescarga, | 469 | puntosDescarga: $scope.remito.remitoPuntoDescarga, |
| 468 | domicilio: $scope.remito.domicilio | 470 | domicilio: $scope.remito.domicilio |
| 469 | } | 471 | } |
| 470 | } | 472 | } |
| 471 | } | 473 | } |
| 472 | ); | 474 | ); |
| 473 | modalInstance.result.then( | 475 | modalInstance.result.then( |
| 474 | function (puntosDescarga) { | 476 | function (puntosDescarga) { |
| 475 | 477 | ||
| 476 | puntosDescarga.forEach(function (punto) { | 478 | puntosDescarga.forEach(function (punto) { |
| 477 | $scope.remito.remitoPuntoDescarga.push( | 479 | $scope.remito.remitoPuntoDescarga.push( |
| 478 | { | 480 | { |
| 479 | puntoDescarga: punto | 481 | puntoDescarga: punto |
| 480 | } | 482 | } |
| 481 | ); | 483 | ); |
| 482 | }); | 484 | }); |
| 483 | 485 | ||
| 484 | $scope.$broadcast('addCabecera', { | 486 | $scope.$broadcast('addCabecera', { |
| 485 | label: 'Puntos de descarga:', | 487 | label: 'Puntos de descarga:', |
| 486 | valor: getCabeceraPuntoDescarga(puntosDescarga) | 488 | valor: getCabeceraPuntoDescarga(puntosDescarga) |
| 487 | }); | 489 | }); |
| 488 | }, function () { | 490 | }, function () { |
| 489 | $scope.abrirModalDomicilios($scope.cliente); | 491 | $scope.abrirModalDomicilios($scope.cliente); |
| 490 | } | 492 | } |
| 491 | ); | 493 | ); |
| 492 | } | 494 | } |
| 493 | }; | 495 | }; |
| 494 | 496 | ||
| 495 | $scope.seleccionarCliente = function () { | 497 | $scope.seleccionarCliente = function () { |
| 496 | if (!varlidarRemitoFacturado()) return; | 498 | if (!varlidarRemitoFacturado()) return; |
| 497 | if (!varlidarRemitoAbierto()) return; | 499 | if (!varlidarRemitoAbierto()) return; |
| 498 | var modalInstance = $uibModal.open( | 500 | var modalInstance = $uibModal.open( |
| 499 | { | 501 | { |
| 500 | ariaLabelledBy: 'Busqueda de Cliente', | 502 | ariaLabelledBy: 'Busqueda de Cliente', |
| 501 | templateUrl: 'foca-busqueda-cliente-modal.html', | 503 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 502 | controller: 'focaBusquedaClienteModalController', | 504 | controller: 'focaBusquedaClienteModalController', |
| 503 | resolve: { | 505 | resolve: { |
| 504 | parametros: function () { | 506 | parametros: function () { |
| 505 | return { | 507 | return { |
| 506 | // vendedor: $scope.idVendedor, | 508 | // vendedor: $scope.idVendedor, |
| 507 | cobrador: null, | 509 | cobrador: null, |
| 508 | searchText: $scope.cliente ? $scope.cliente.nom : '' | 510 | searchText: $scope.cliente ? $scope.cliente.nom : '' |
| 509 | }; | 511 | }; |
| 510 | }, | 512 | }, |
| 511 | }, | 513 | }, |
| 514 | backdrop: false, | ||
| 512 | size: 'lg' | 515 | size: 'lg' |
| 513 | } | 516 | } |
| 514 | ); | 517 | ); |
| 515 | modalInstance.result.then( | 518 | modalInstance.result.then( |
| 516 | function (cliente) { | 519 | function (cliente) { |
| 517 | 520 | ||
| 518 | if ($scope.remito.precioCondicion !== undefined) { | 521 | if ($scope.remito.precioCondicion !== undefined) { |
| 519 | focaModalService | 522 | focaModalService |
| 520 | .alert('Debe agregar lista de precio de cliente actual') | 523 | .alert('Debe agregar lista de precio de cliente actual') |
| 521 | .then(function () { | 524 | .then(function () { |
| 522 | $scope.remito.precioCondicion = undefined; | 525 | $scope.remito.precioCondicion = undefined; |
| 523 | $scope.$broadcast('removeCabecera', 'Precios y Condiciones:'); | 526 | $scope.$broadcast('removeCabecera', 'Precios y Condiciones:'); |
| 524 | $filter('filter')($scope.botonera, | 527 | $filter('filter')($scope.botonera, |
| 525 | { label: 'Precios y Condiciones' })[0].checked = false; | 528 | { label: 'Precios y Condiciones' })[0].checked = false; |
| 526 | }) | 529 | }) |
| 527 | .catch(function () { | 530 | .catch(function () { |
| 528 | }) | 531 | }) |
| 529 | } | 532 | } |
| 530 | 533 | ||
| 531 | // if (angular.equals({}, cliente.vendedor)) { | 534 | // if (angular.equals({}, cliente.vendedor)) { |
| 532 | 535 | ||
| 533 | // focaModalService | 536 | // focaModalService |
| 534 | // .alert('El cliente seleccionado no tiene tiene ' + | 537 | // .alert('El cliente seleccionado no tiene tiene ' + |
| 535 | // 'vendedor asignado.') | 538 | // 'vendedor asignado.') |
| 536 | // .then($scope.seleccionarCliente); | 539 | // .then($scope.seleccionarCliente); |
| 537 | 540 | ||
| 538 | // return; | 541 | // return; |
| 539 | // } | 542 | // } |
| 540 | 543 | ||
| 541 | $scope.cliente = cliente; | 544 | $scope.cliente = cliente; |
| 542 | $scope.abrirModalDomicilios(cliente); | 545 | $scope.abrirModalDomicilios(cliente); |
| 543 | }, function () { | 546 | }, function () { |
| 544 | } | 547 | } |
| 545 | ); | 548 | ); |
| 546 | }; | 549 | }; |
| 547 | 550 | ||
| 548 | $scope.seleccionarEliminarRemito = function () { | 551 | $scope.seleccionarEliminarRemito = function () { |
| 549 | focaModalService.confirm('¿Desea eliminar este remito?').then(function (data) { | 552 | focaModalService.confirm('¿Desea eliminar este remito?').then(function (data) { |
| 550 | if (data) { | 553 | if (data) { |
| 551 | $scope.remito.anulado = true; | 554 | $scope.remito.anulado = true; |
| 552 | delete $scope.remito.remitoPlazo; | 555 | delete $scope.remito.remitoPlazo; |
| 553 | // delete $scope.remito.vendedor; | 556 | // delete $scope.remito.vendedor; |
| 554 | delete $scope.remito.proveedor; | 557 | delete $scope.remito.proveedor; |
| 555 | delete $scope.remito.cliente; | 558 | delete $scope.remito.cliente; |
| 556 | delete $scope.remito.cotizacion; | 559 | delete $scope.remito.cotizacion; |
| 557 | delete $scope.remito.remitoPuntoDescarga; | 560 | delete $scope.remito.remitoPuntoDescarga; |
| 558 | delete $scope.remito.articulosRemito; | 561 | delete $scope.remito.articulosRemito; |
| 559 | delete $scope.remito.fechaRemito; | 562 | delete $scope.remito.fechaRemito; |
| 560 | crearRemitoService.eliminarRemito($scope.remito); | 563 | crearRemitoService.eliminarRemito($scope.remito); |
| 561 | } | 564 | } |
| 562 | config(); | 565 | config(); |
| 563 | }); | 566 | }); |
| 564 | }; | 567 | }; |
| 565 | 568 | ||
| 566 | $scope.seleccionarProveedor = function () { | 569 | $scope.seleccionarProveedor = function () { |
| 567 | if (!varlidarRemitoFacturado()) return; | 570 | if (!varlidarRemitoFacturado()) return; |
| 568 | if (!varlidarRemitoAbierto()) return; | 571 | if (!varlidarRemitoAbierto()) return; |
| 569 | var parametrosModal = { | 572 | var parametrosModal = { |
| 570 | titulo: 'Búsqueda de Proveedor', | 573 | titulo: 'Búsqueda de Proveedor', |
| 571 | query: '/proveedor', | 574 | query: '/proveedor', |
| 572 | columnas: [ | 575 | columnas: [ |
| 573 | { | 576 | { |
| 574 | nombre: 'Código', | 577 | nombre: 'Código', |
| 575 | propiedad: 'COD', | 578 | propiedad: 'COD', |
| 576 | filtro: { | 579 | filtro: { |
| 577 | nombre: 'rellenarDigitos', | 580 | nombre: 'rellenarDigitos', |
| 578 | parametro: 5 | 581 | parametro: 5 |
| 579 | } | 582 | } |
| 580 | }, | 583 | }, |
| 581 | { | 584 | { |
| 582 | nombre: 'Nombre', | 585 | nombre: 'Nombre', |
| 583 | propiedad: 'NOM' | 586 | propiedad: 'NOM' |
| 584 | }, | 587 | }, |
| 585 | { | 588 | { |
| 586 | nombre: 'CUIT', | 589 | nombre: 'CUIT', |
| 587 | propiedad: 'CUIT' | 590 | propiedad: 'CUIT' |
| 588 | } | 591 | } |
| 589 | ], | 592 | ], |
| 590 | tipo: 'POST', | 593 | tipo: 'POST', |
| 591 | json: { razonCuitCod: '' } | 594 | json: { razonCuitCod: '' } |
| 592 | }; | 595 | }; |
| 593 | focaModalService.modal(parametrosModal).then( | 596 | focaModalService.modal(parametrosModal).then( |
| 594 | function (proveedor) { | 597 | function (proveedor) { |
| 595 | $scope.seleccionarFlete(proveedor); | 598 | $scope.seleccionarFlete(proveedor); |
| 596 | }, function () { } | 599 | }, function () { } |
| 597 | ); | 600 | ); |
| 598 | }; | 601 | }; |
| 599 | 602 | ||
| 600 | $scope.seleccionarDomicilioDeEntrega = function () { | 603 | $scope.seleccionarDomicilioDeEntrega = function () { |
| 601 | if (!varlidarRemitoFacturado()) return; | 604 | if (!varlidarRemitoFacturado()) return; |
| 602 | if (!varlidarRemitoAbierto()) return; | 605 | if (!varlidarRemitoAbierto()) return; |
| 603 | if (!$scope.remito.cliente.COD && !$scope.cliente) { | 606 | if (!$scope.remito.cliente.COD && !$scope.cliente) { |
| 604 | focaModalService.alert('Seleccione un Cliente'); | 607 | focaModalService.alert('Seleccione un Cliente'); |
| 605 | return; | 608 | return; |
| 606 | } else { | 609 | } else { |
| 607 | $scope.abrirModalDomicilios($scope.remito.cliente.COD ? | 610 | $scope.abrirModalDomicilios($scope.remito.cliente.COD ? |
| 608 | $scope.remito.cliente.COD : $scope.cliente); | 611 | $scope.remito.cliente.COD : $scope.cliente); |
| 609 | } | 612 | } |
| 610 | }; | 613 | }; |
| 611 | 614 | ||
| 612 | $scope.abrirModalDomicilios = function (cliente) { | 615 | $scope.abrirModalDomicilios = function (cliente) { |
| 613 | var modalInstanceDomicilio = $uibModal.open( | 616 | var modalInstanceDomicilio = $uibModal.open( |
| 614 | { | 617 | { |
| 615 | ariaLabelledBy: 'Busqueda de Domicilios', | 618 | ariaLabelledBy: 'Busqueda de Domicilios', |
| 616 | templateUrl: 'modal-domicilio.html', | 619 | templateUrl: 'modal-domicilio.html', |
| 617 | controller: 'focaModalDomicilioController', | 620 | controller: 'focaModalDomicilioController', |
| 621 | backdrop: false, | ||
| 618 | size: 'lg', | 622 | size: 'lg', |
| 619 | resolve: { | 623 | resolve: { |
| 620 | idCliente: function () { | 624 | idCliente: function () { |
| 621 | return $scope.remito.cliente.COD ? $scope.remito.cliente.COD : | 625 | return $scope.remito.cliente.COD ? $scope.remito.cliente.COD : |
| 622 | cliente.COD; | 626 | cliente.COD; |
| 623 | }, | 627 | }, |
| 624 | esNuevo: function () { | 628 | esNuevo: function () { |
| 625 | return ($scope.remito.cliente.COD ? false : cliente.esNuevo); | 629 | return ($scope.remito.cliente.COD ? false : cliente.esNuevo); |
| 626 | } | 630 | } |
| 627 | } | 631 | } |
| 628 | } | 632 | } |
| 629 | ); | 633 | ); |
| 630 | modalInstanceDomicilio.result | 634 | modalInstanceDomicilio.result |
| 631 | .then(function (domicilio) { | 635 | .then(function (domicilio) { |
| 632 | $scope.remito.domicilio = domicilio; | 636 | $scope.remito.domicilio = domicilio; |
| 633 | $scope.remito.cliente = cliente; | 637 | $scope.remito.cliente = cliente; |
| 634 | // $scope.remito.vendedor = cliente.vendedor; | 638 | // $scope.remito.vendedor = cliente.vendedor; |
| 635 | 639 | ||
| 636 | var domicilioStamp = | 640 | var domicilioStamp = |
| 637 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 641 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
| 638 | domicilio.Localidad + ', ' + domicilio.Provincia; | 642 | domicilio.Localidad + ', ' + domicilio.Provincia; |
| 639 | 643 | ||
| 640 | $scope.remito.domicilioStamp = domicilioStamp; | 644 | $scope.remito.domicilioStamp = domicilioStamp; |
| 641 | 645 | ||
| 642 | // $scope.$broadcast('addCabecera', { | 646 | // $scope.$broadcast('addCabecera', { |
| 643 | // label: 'Vendedor:', | 647 | // label: 'Vendedor:', |
| 644 | // valor: $filter('rellenarDigitos')($scope.remito.vendedor | 648 | // valor: $filter('rellenarDigitos')($scope.remito.vendedor |
| 645 | // .NUM, 3) + ' - ' + $scope.remito.vendedor.NOM | 649 | // .NUM, 3) + ' - ' + $scope.remito.vendedor.NOM |
| 646 | // }); | 650 | // }); |
| 647 | $scope.$broadcast('addCabecera', { | 651 | $scope.$broadcast('addCabecera', { |
| 648 | label: 'Cliente:', | 652 | label: 'Cliente:', |
| 649 | valor: $filter('rellenarDigitos') | 653 | valor: $filter('rellenarDigitos') |
| 650 | ($scope.remito.cliente.COD, 3) + | 654 | ($scope.remito.cliente.COD, 3) + |
| 651 | ' - ' + $scope.remito.cliente.NOM | 655 | ' - ' + $scope.remito.cliente.NOM |
| 652 | }); | 656 | }); |
| 653 | $scope.$broadcast('addCabecera', { | 657 | $scope.$broadcast('addCabecera', { |
| 654 | label: 'Domicilio:', | 658 | label: 'Domicilio:', |
| 655 | valor: domicilioStamp | 659 | valor: domicilioStamp |
| 656 | }); | 660 | }); |
| 657 | 661 | ||
| 658 | if (domicilio.verPuntos) { | 662 | if (domicilio.verPuntos) { |
| 659 | delete $scope.remito.domicilio.verPuntos; | 663 | delete $scope.remito.domicilio.verPuntos; |
| 660 | $scope.seleccionarPuntosDeDescarga(); | 664 | $scope.seleccionarPuntosDeDescarga(); |
| 661 | } | 665 | } |
| 662 | 666 | ||
| 663 | $filter('filter')($scope.botonera, | 667 | $filter('filter')($scope.botonera, |
| 664 | { label: 'Cliente' })[0].checked = true; | 668 | { label: 'Cliente' })[0].checked = true; |
| 665 | $filter('filter')($scope.botonera, | 669 | $filter('filter')($scope.botonera, |
| 666 | { label: 'Domicilio de Entrega' })[0].checked = true; | 670 | { label: 'Domicilio de Entrega' })[0].checked = true; |
| 667 | 671 | ||
| 668 | }) | 672 | }) |
| 669 | .catch(function (e) { | 673 | .catch(function (e) { |
| 670 | console.info(e); | 674 | console.info(e); |
| 671 | $scope.seleccionarCliente(true); | 675 | $scope.seleccionarCliente(true); |
| 672 | return; | 676 | return; |
| 673 | }); | 677 | }); |
| 674 | }; | 678 | }; |
| 675 | 679 | ||
| 676 | $scope.getTotal = function () { | 680 | $scope.getTotal = function () { |
| 677 | var total = 0; | 681 | var total = 0; |
| 678 | var arrayTempArticulos = $scope.articulosFiltro(); | 682 | var arrayTempArticulos = $scope.articulosFiltro(); |
| 679 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 683 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
| 680 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 684 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 681 | } | 685 | } |
| 682 | return parseFloat(total.toFixed(2)); | 686 | return parseFloat(total.toFixed(2)); |
| 683 | }; | 687 | }; |
| 684 | 688 | ||
| 685 | $scope.getSubTotal = function () { | 689 | $scope.getSubTotal = function () { |
| 686 | if ($scope.articuloACargar) { | 690 | if ($scope.articuloACargar) { |
| 687 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 691 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 688 | } | 692 | } |
| 689 | }; | 693 | }; |
| 690 | 694 | ||
| 691 | $scope.seleccionarPreciosYCondiciones = function () { | 695 | $scope.seleccionarPreciosYCondiciones = function () { |
| 692 | if (!$scope.remito.cliente.COD) { | 696 | if (!$scope.remito.cliente.COD) { |
| 693 | focaModalService.alert('Primero seleccione un cliente'); | 697 | focaModalService.alert('Primero seleccione un cliente'); |
| 694 | return; | 698 | return; |
| 695 | } | 699 | } |
| 696 | if ($scope.remito.articulosRemito.length !== 0) { | 700 | if ($scope.remito.articulosRemito.length !== 0) { |
| 697 | if (varlidarRemitoFacturado() && varlidarRemitoAbierto()) { | 701 | if (varlidarRemitoFacturado() && varlidarRemitoAbierto()) { |
| 698 | abrirModal(); | 702 | abrirModal(); |
| 699 | } | 703 | } |
| 700 | } else { | 704 | } else { |
| 701 | abrirModal(); | 705 | abrirModal(); |
| 702 | } | 706 | } |
| 703 | 707 | ||
| 704 | function abrirModal() { | 708 | function abrirModal() { |
| 705 | var parametros = { | 709 | var parametros = { |
| 706 | idCliente: $scope.remito.cliente.COD, | 710 | idCliente: $scope.remito.cliente.COD, |
| 707 | idListaPrecio: $scope.remito.cliente.MOD | 711 | idListaPrecio: $scope.remito.cliente.MOD |
| 708 | }; | 712 | }; |
| 709 | var modalInstance = $uibModal.open( | 713 | var modalInstance = $uibModal.open( |
| 710 | { | 714 | { |
| 711 | ariaLabelledBy: 'Busqueda de Precio Condición', | 715 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 712 | templateUrl: 'modal-precio-condicion.html', | 716 | templateUrl: 'modal-precio-condicion.html', |
| 713 | controller: 'focaModalPrecioCondicionController', | 717 | controller: 'focaModalPrecioCondicionController', |
| 714 | size: 'lg', | 718 | size: 'lg', |
| 715 | resolve: { | 719 | resolve: { |
| 716 | parametros: function () { return parametros; } | 720 | parametros: function () { return parametros; } |
| 717 | } | 721 | } |
| 718 | } | 722 | } |
| 719 | ); | 723 | ); |
| 720 | modalInstance.result.then( | 724 | modalInstance.result.then( |
| 721 | function (precioCondicion) { | 725 | function (precioCondicion) { |
| 722 | var cabecera = ''; | 726 | var cabecera = ''; |
| 723 | var plazosConcat = ''; | 727 | var plazosConcat = ''; |
| 724 | if (!Array.isArray(precioCondicion)) { | 728 | if (!Array.isArray(precioCondicion)) { |
| 725 | $scope.remito.idPrecioCondicion = precioCondicion.listaPrecio.ID; | 729 | $scope.remito.idPrecioCondicion = precioCondicion.listaPrecio.ID; |
| 726 | $scope.remito.remitoPlazo = precioCondicion.plazoPago; | 730 | $scope.remito.remitoPlazo = precioCondicion.plazoPago; |
| 727 | $scope.idLista = parseInt(precioCondicion.listaPrecio.ID) ? | 731 | $scope.idLista = parseInt(precioCondicion.listaPrecio.ID) ? |
| 728 | parseInt(precioCondicion.listaPrecio.ID) : -1; | 732 | parseInt(precioCondicion.listaPrecio.ID) : -1; |
| 729 | $scope.remito.cliente.MOD = precioCondicion.listaPrecio.ID; | 733 | $scope.remito.cliente.MOD = precioCondicion.listaPrecio.ID; |
| 730 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | 734 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { |
| 731 | plazosConcat += precioCondicion.plazoPago[i].dias + ', '; | 735 | plazosConcat += precioCondicion.plazoPago[i].dias + ', '; |
| 732 | } | 736 | } |
| 733 | plazosConcat = plazosConcat.substring(0, plazosConcat.length - 2); | 737 | plazosConcat = plazosConcat.substring(0, plazosConcat.length - 2); |
| 734 | cabecera = $filter('rellenarDigitos') | 738 | cabecera = $filter('rellenarDigitos') |
| 735 | (parseInt(precioCondicion.listaPrecio.ID), 4) + | 739 | (parseInt(precioCondicion.listaPrecio.ID), 4) + |
| 736 | ' - ' + precioCondicion.listaPrecio.DES + ' ' + | 740 | ' - ' + precioCondicion.listaPrecio.DES + ' ' + |
| 737 | plazosConcat.trim(); | 741 | plazosConcat.trim(); |
| 738 | } else { //Cuando se ingresan los plazos manualmente | 742 | } else { //Cuando se ingresan los plazos manualmente |
| 739 | $scope.remito.idPrecioCondicion = 0; | 743 | $scope.remito.idPrecioCondicion = 0; |
| 740 | //-1, el modal productos busca todos los productos | 744 | //-1, el modal productos busca todos los productos |
| 741 | $scope.idLista = -1; | 745 | $scope.idLista = -1; |
| 742 | $scope.remito.remitoPlazo = precioCondicion; | 746 | $scope.remito.remitoPlazo = precioCondicion; |
| 743 | for (var j = 0; j < precioCondicion.length; j++) { | 747 | for (var j = 0; j < precioCondicion.length; j++) { |
| 744 | plazosConcat += precioCondicion[j].dias + ' '; | 748 | plazosConcat += precioCondicion[j].dias + ' '; |
| 745 | } | 749 | } |
| 746 | cabecera = plazosConcat.trim(); | 750 | cabecera = plazosConcat.trim(); |
| 747 | } | 751 | } |
| 748 | var cabecerasFilter = !$filter('filter')($scope.cabeceras, | 752 | var cabecerasFilter = !$filter('filter')($scope.cabeceras, |
| 749 | { label: 'Precios y Condiciones' }); | 753 | { label: 'Precios y Condiciones' }); |
| 750 | if (!cabecerasFilter) { | 754 | if (!cabecerasFilter) { |
| 751 | $scope.cabeceras.push({ | 755 | $scope.cabeceras.push({ |
| 752 | label: 'Precios y Condiciones:', | 756 | label: 'Precios y Condiciones:', |
| 753 | valor: parseInt(precioCondicion.listaPrecio.ID) + ' - ' + | 757 | valor: parseInt(precioCondicion.listaPrecio.ID) + ' - ' + |
| 754 | precioCondicion.listaPrecio.DES + ' ' + | 758 | precioCondicion.listaPrecio.DES + ' ' + |
| 755 | remitoBusinessService | 759 | remitoBusinessService |
| 756 | .plazoToString(precioCondicion.plazoPago) | 760 | .plazoToString(precioCondicion.plazoPago) |
| 757 | }); | 761 | }); |
| 758 | 762 | ||
| 759 | $scope.remito.idListaPrecio = parseInt( | 763 | $scope.remito.idListaPrecio = parseInt( |
| 760 | precioCondicion.listaPrecio.ID); | 764 | precioCondicion.listaPrecio.ID); |
| 761 | } | 765 | } |
| 762 | $filter('filter')($scope.cabeceras, | 766 | $filter('filter')($scope.cabeceras, |
| 763 | { label: 'Precios y Condiciones' })[0].valor = cabecera; | 767 | { label: 'Precios y Condiciones' })[0].valor = cabecera; |
| 764 | 768 | ||
| 765 | $scope.remito.precioCondicion = precioCondicion; | 769 | $scope.remito.precioCondicion = precioCondicion; |
| 766 | $filter('filter')($scope.botonera, | 770 | $filter('filter')($scope.botonera, |
| 767 | { label: 'Precios y Condiciones' })[0].checked = true; | 771 | { label: 'Precios y Condiciones' })[0].checked = true; |
| 768 | addArrayCabecera($scope.cabeceras); | 772 | addArrayCabecera($scope.cabeceras); |
| 769 | }, function () { | 773 | }, function () { |
| 770 | 774 | ||
| 771 | } | 775 | } |
| 772 | ); | 776 | ); |
| 773 | } | 777 | } |
| 774 | }; | 778 | }; |
| 775 | 779 | ||
| 776 | $scope.seleccionarFlete = function (proveedor) { | 780 | $scope.seleccionarFlete = function (proveedor) { |
| 777 | if (!varlidarRemitoFacturado()) return; | 781 | if (!varlidarRemitoFacturado()) return; |
| 778 | if (!varlidarRemitoAbierto()) return; | 782 | if (!varlidarRemitoAbierto()) return; |
| 779 | var modalInstance = $uibModal.open( | 783 | var modalInstance = $uibModal.open( |
| 780 | { | 784 | { |
| 781 | ariaLabelledBy: 'Busqueda de Flete', | 785 | ariaLabelledBy: 'Busqueda de Flete', |
| 782 | templateUrl: 'modal-flete.html', | 786 | templateUrl: 'modal-flete.html', |
| 783 | controller: 'focaModalFleteController', | 787 | controller: 'focaModalFleteController', |
| 784 | size: 'lg', | 788 | size: 'lg', |
| 785 | resolve: { | 789 | resolve: { |
| 786 | parametrosFlete: | 790 | parametrosFlete: |
| 787 | function () { | 791 | function () { |
| 788 | return { | 792 | return { |
| 789 | flete: $scope.remito.flete ? '1' : | 793 | flete: $scope.remito.flete ? '1' : |
| 790 | ($scope.remito.fob ? 'FOB' : | 794 | ($scope.remito.fob ? 'FOB' : |
| 791 | ($scope.remito.flete === undefined ? | 795 | ($scope.remito.flete === undefined ? |
| 792 | null : '0')), | 796 | null : '0')), |
| 793 | bomba: $scope.remito.bomba ? '1' : | 797 | bomba: $scope.remito.bomba ? '1' : |
| 794 | ($scope.remito.bomba === undefined ? | 798 | ($scope.remito.bomba === undefined ? |
| 795 | null : '0'), | 799 | null : '0'), |
| 796 | kilometros: $scope.remito.kilometros | 800 | kilometros: $scope.remito.kilometros |
| 797 | }; | 801 | }; |
| 798 | } | 802 | } |
| 799 | } | 803 | } |
| 800 | } | 804 | } |
| 801 | ); | 805 | ); |
| 802 | modalInstance.result.then( | 806 | modalInstance.result.then( |
| 803 | function (datos) { | 807 | function (datos) { |
| 804 | $scope.remitoIsDirty = true; | 808 | $scope.remitoIsDirty = true; |
| 805 | $scope.remito.proveedor = proveedor; | 809 | $scope.remito.proveedor = proveedor; |
| 806 | $scope.remito.idProveedor = proveedor.COD; | 810 | $scope.remito.idProveedor = proveedor.COD; |
| 807 | $scope.$broadcast('addCabecera', { | 811 | $scope.$broadcast('addCabecera', { |
| 808 | label: 'Proveedor:', | 812 | label: 'Proveedor:', |
| 809 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 813 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
| 810 | proveedor.NOM | 814 | proveedor.NOM |
| 811 | }); | 815 | }); |
| 812 | 816 | ||
| 813 | $scope.remito.flete = datos.flete; | 817 | $scope.remito.flete = datos.flete; |
| 814 | $scope.remito.fob = datos.FOB; | 818 | $scope.remito.fob = datos.FOB; |
| 815 | $scope.remito.bomba = datos.bomba; | 819 | $scope.remito.bomba = datos.bomba; |
| 816 | $scope.remito.kilometros = datos.kilometros; | 820 | $scope.remito.kilometros = datos.kilometros; |
| 817 | 821 | ||
| 818 | $scope.$broadcast('addCabecera', { | 822 | $scope.$broadcast('addCabecera', { |
| 819 | label: 'Flete:', | 823 | label: 'Flete:', |
| 820 | valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') | 824 | valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') |
| 821 | }); | 825 | }); |
| 822 | if (datos.flete) { | 826 | if (datos.flete) { |
| 823 | $scope.$broadcast('addCabecera', { | 827 | $scope.$broadcast('addCabecera', { |
| 824 | label: 'Bomba:', | 828 | label: 'Bomba:', |
| 825 | valor: datos.bomba ? 'Si' : 'No' | 829 | valor: datos.bomba ? 'Si' : 'No' |
| 826 | }); | 830 | }); |
| 827 | $scope.$broadcast('addCabecera', { | 831 | $scope.$broadcast('addCabecera', { |
| 828 | label: 'Kilometros:', | 832 | label: 'Kilometros:', |
| 829 | valor: datos.kilometros | 833 | valor: datos.kilometros |
| 830 | }); | 834 | }); |
| 831 | } else { | 835 | } else { |
| 832 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 836 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
| 833 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 837 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
| 834 | $scope.remito.bomba = false; | 838 | $scope.remito.bomba = false; |
| 835 | $scope.remito.kilometros = null; | 839 | $scope.remito.kilometros = null; |
| 836 | } | 840 | } |
| 837 | 841 | ||
| 838 | $filter('filter')($scope.botonera, | 842 | $filter('filter')($scope.botonera, |
| 839 | { label: 'Proveedor' })[0].checked = true; | 843 | { label: 'Proveedor' })[0].checked = true; |
| 840 | }, function () { | 844 | }, function () { |
| 841 | $scope.seleccionarTransportista(); | 845 | $scope.seleccionarTransportista(); |
| 842 | } | 846 | } |
| 843 | ); | 847 | ); |
| 844 | }; | 848 | }; |
| 845 | 849 | ||
| 846 | $scope.seleccionarMoneda = function () { | 850 | $scope.seleccionarMoneda = function () { |
| 847 | if (!varlidarRemitoFacturado()) return; | 851 | if (!varlidarRemitoFacturado()) return; |
| 848 | if (!varlidarRemitoAbierto()) return; | 852 | if (!varlidarRemitoAbierto()) return; |
| 849 | var parametrosModal = { | 853 | var parametrosModal = { |
| 850 | titulo: 'Búsqueda de monedas', | 854 | titulo: 'Búsqueda de monedas', |
| 851 | query: '/moneda', | 855 | query: '/moneda', |
| 852 | columnas: [ | 856 | columnas: [ |
| 853 | { | 857 | { |
| 854 | propiedad: 'DETALLE', | 858 | propiedad: 'DETALLE', |
| 855 | nombre: 'Nombre' | 859 | nombre: 'Nombre' |
| 856 | }, | 860 | }, |
| 857 | { | 861 | { |
| 858 | propiedad: 'SIMBOLO', | 862 | propiedad: 'SIMBOLO', |
| 859 | nombre: 'Símbolo' | 863 | nombre: 'Símbolo' |
| 860 | } | 864 | } |
| 861 | ], | 865 | ], |
| 862 | size: 'md' | 866 | size: 'md' |
| 863 | }; | 867 | }; |
| 864 | focaModalService.modal(parametrosModal).then( | 868 | focaModalService.modal(parametrosModal).then( |
| 865 | function (moneda) { | 869 | function (moneda) { |
| 866 | 870 | ||
| 867 | if (moneda.ID !== 1) { | 871 | if (moneda.ID !== 1) { |
| 868 | $scope.abrirModalCotizacion(moneda); | 872 | $scope.abrirModalCotizacion(moneda); |
| 869 | return; | 873 | return; |
| 870 | } | 874 | } |
| 871 | 875 | ||
| 872 | crearRemitoService.getCotizacionByIdMoneda(1) | 876 | crearRemitoService.getCotizacionByIdMoneda(1) |
| 873 | .then(function (res) { | 877 | .then(function (res) { |
| 874 | 878 | ||
| 875 | cotizacionPArgentino = res.data[0].cotizaciones[0]; | 879 | cotizacionPArgentino = res.data[0].cotizaciones[0]; |
| 876 | cotizacionPArgentino.moneda = moneda; | 880 | cotizacionPArgentino.moneda = moneda; |
| 877 | 881 | ||
| 878 | actualizarCabeceraMoneda(cotizacionPArgentino); | 882 | actualizarCabeceraMoneda(cotizacionPArgentino); |
| 879 | $filter('filter')($scope.botonera, | 883 | $filter('filter')($scope.botonera, |
| 880 | { label: 'Moneda' })[0].checked = true; | 884 | { label: 'Moneda' })[0].checked = true; |
| 881 | $scope.remito.cotizacion = cotizacionPArgentino; | 885 | $scope.remito.cotizacion = cotizacionPArgentino; |
| 882 | }); | 886 | }); |
| 883 | }, function () { | 887 | }, function () { |
| 884 | 888 | ||
| 885 | } | 889 | } |
| 886 | ); | 890 | ); |
| 887 | }; | 891 | }; |
| 888 | 892 | ||
| 889 | $scope.seleccionarObservaciones = function () { | 893 | $scope.seleccionarObservaciones = function () { |
| 890 | focaModalService | 894 | focaModalService |
| 891 | .prompt({ | 895 | .prompt({ |
| 892 | titulo: 'Observaciones', | 896 | titulo: 'Observaciones', |
| 893 | value: $scope.remito.observaciones, | 897 | value: $scope.remito.observaciones, |
| 894 | textarea: true, | 898 | textarea: true, |
| 895 | readonly: false | 899 | readonly: false |
| 896 | }) | 900 | }) |
| 897 | .then(function (observaciones) { | 901 | .then(function (observaciones) { |
| 898 | $scope.remito.observaciones = observaciones; | 902 | $scope.remito.observaciones = observaciones; |
| 899 | }); | 903 | }); |
| 900 | }; | 904 | }; |
| 901 | 905 | ||
| 902 | $scope.abrirModalCotizacion = function (moneda) { | 906 | $scope.abrirModalCotizacion = function (moneda) { |
| 903 | var modalInstance = $uibModal.open( | 907 | var modalInstance = $uibModal.open( |
| 904 | { | 908 | { |
| 905 | ariaLabelledBy: 'Busqueda de Cotización', | 909 | ariaLabelledBy: 'Busqueda de Cotización', |
| 906 | templateUrl: 'modal-cotizacion.html', | 910 | templateUrl: 'modal-cotizacion.html', |
| 907 | controller: 'focaModalCotizacionController', | 911 | controller: 'focaModalCotizacionController', |
| 908 | size: 'lg', | 912 | size: 'lg', |
| 909 | resolve: { idMoneda: function () { return moneda.ID; } } | 913 | resolve: { idMoneda: function () { return moneda.ID; } } |
| 910 | } | 914 | } |
| 911 | ); | 915 | ); |
| 912 | modalInstance.result.then( | 916 | modalInstance.result.then( |
| 913 | function (cotizacion) { | 917 | function (cotizacion) { |
| 914 | cotizacion.moneda = moneda; | 918 | cotizacion.moneda = moneda; |
| 915 | $scope.remitoIsDirty = true; | 919 | $scope.remitoIsDirty = true; |
| 916 | actualizarCabeceraMoneda(cotizacion); | 920 | actualizarCabeceraMoneda(cotizacion); |
| 917 | $filter('filter')($scope.botonera, | 921 | $filter('filter')($scope.botonera, |
| 918 | { label: 'Moneda' })[0].checked = true; | 922 | { label: 'Moneda' })[0].checked = true; |
| 919 | $scope.remito.cotizacion = cotizacion; | 923 | $scope.remito.cotizacion = cotizacion; |
| 920 | }, function () { | 924 | }, function () { |
| 921 | 925 | ||
| 922 | } | 926 | } |
| 923 | ); | 927 | ); |
| 924 | }; | 928 | }; |
| 925 | 929 | ||
| 926 | function actualizarCabeceraMoneda(cotizacion) { | 930 | function actualizarCabeceraMoneda(cotizacion) { |
| 927 | 931 | ||
| 928 | $scope.remito.articulosRemito.forEach(function (art) { | 932 | $scope.remito.articulosRemito.forEach(function (art) { |
| 929 | art.precio = (art.precio * $scope.remito.cotizacion.VENDEDOR).toFixed(4); | 933 | art.precio = (art.precio * $scope.remito.cotizacion.VENDEDOR).toFixed(4); |
| 930 | art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4); | 934 | art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4); |
| 931 | }); | 935 | }); |
| 932 | 936 | ||
| 933 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { | 937 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { |
| 934 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 938 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
| 935 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 939 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
| 936 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 940 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
| 937 | } else { | 941 | } else { |
| 938 | $scope.$broadcast('addCabecera', { | 942 | $scope.$broadcast('addCabecera', { |
| 939 | label: 'Moneda:', | 943 | label: 'Moneda:', |
| 940 | valor: cotizacion.moneda.DETALLE | 944 | valor: cotizacion.moneda.DETALLE |
| 941 | }); | 945 | }); |
| 942 | $scope.$broadcast('addCabecera', { | 946 | $scope.$broadcast('addCabecera', { |
| 943 | label: 'Fecha cotizacion:', | 947 | label: 'Fecha cotizacion:', |
| 944 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 948 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
| 945 | }); | 949 | }); |
| 946 | $scope.$broadcast('addCabecera', { | 950 | $scope.$broadcast('addCabecera', { |
| 947 | label: 'Cotizacion:', | 951 | label: 'Cotizacion:', |
| 948 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 952 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
| 949 | }); | 953 | }); |
| 950 | } | 954 | } |
| 951 | } | 955 | } |
| 952 | 956 | ||
| 953 | $scope.agregarATabla = function (key) { | 957 | $scope.agregarATabla = function (key) { |
| 954 | if (key === 13) { | 958 | if (key === 13) { |
| 955 | if (!$scope.articuloACargar.cantidad || !$scope.articuloACargar.precio) { | 959 | if (!$scope.articuloACargar.cantidad || !$scope.articuloACargar.precio) { |
| 956 | focaModalService.alert('El valor debe ser al menos 1'); | 960 | focaModalService.alert('El valor debe ser al menos 1'); |
| 957 | return; | 961 | return; |
| 958 | } | 962 | } |
| 959 | delete $scope.articuloACargar.sectorCodigo; | 963 | delete $scope.articuloACargar.sectorCodigo; |
| 960 | $scope.remito.articulosRemito.push($scope.articuloACargar); | 964 | $scope.remito.articulosRemito.push($scope.articuloACargar); |
| 961 | $scope.cargando = true; | 965 | $scope.cargando = true; |
| 962 | } | 966 | } |
| 963 | }; | 967 | }; |
| 964 | 968 | ||
| 965 | $scope.quitarArticulo = function (articulo) { | 969 | $scope.quitarArticulo = function (articulo) { |
| 966 | articulo.idRemito = -1; | 970 | articulo.idRemito = -1; |
| 967 | }; | 971 | }; |
| 968 | 972 | ||
| 969 | $scope.articulosFiltro = function () { | 973 | $scope.articulosFiltro = function () { |
| 970 | 974 | ||
| 971 | var result = $scope.remito.articulosRemito.filter(function (articulo) { | 975 | var result = $scope.remito.articulosRemito.filter(function (articulo) { |
| 972 | return articulo.idRemito >= 0; | 976 | return articulo.idRemito >= 0; |
| 973 | }); | 977 | }); |
| 974 | 978 | ||
| 975 | // Agrego checked en cabecera si hay datos | 979 | // Agrego checked en cabecera si hay datos |
| 976 | if (result.length) { | 980 | if (result.length) { |
| 977 | $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = true; | 981 | $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = true; |
| 978 | } else { | 982 | } else { |
| 979 | $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = false; | 983 | $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = false; |
| 980 | } | 984 | } |
| 981 | return result; | 985 | return result; |
| 982 | }; | 986 | }; |
| 983 | 987 | ||
| 984 | $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) { | 988 | $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) { |
| 985 | if (key === 13) { | 989 | if (key === 13) { |
| 986 | if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) { | 990 | if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) { |
| 987 | focaModalService.alert('Debes introducir algún valor'); | 991 | focaModalService.alert('Debes introducir algún valor'); |
| 988 | return; | 992 | return; |
| 989 | } else if (tmpCantidad === '0' || tmpPrecio === '0') { | 993 | } else if (tmpCantidad === '0' || tmpPrecio === '0') { |
| 990 | focaModalService.alert('Esta ingresando un producto con valor 0'); | 994 | focaModalService.alert('Esta ingresando un producto con valor 0'); |
| 991 | return; | 995 | return; |
| 992 | } else if (tmpCantidad < 0 || tmpPrecio < 0) { | 996 | } else if (tmpCantidad < 0 || tmpPrecio < 0) { |
| 993 | focaModalService.alert('Los valores no pueden ser negativos'); | 997 | focaModalService.alert('Los valores no pueden ser negativos'); |
| 994 | return; | 998 | return; |
| 995 | } else if (!Number.isInteger(tmpCantidad)) { | 999 | } else if (!Number.isInteger(tmpCantidad)) { |
| 996 | focaModalService.alert('Debes introducir un número entero'); | 1000 | focaModalService.alert('Debes introducir un número entero'); |
| 997 | return; | 1001 | return; |
| 998 | } else { | 1002 | } else { |
| 999 | articulo.cantidad = tmpCantidad; | 1003 | articulo.cantidad = tmpCantidad; |
| 1000 | articulo.precio = tmpPrecio; | 1004 | articulo.precio = tmpPrecio; |
| 1001 | $scope.getTotal(); | 1005 | $scope.getTotal(); |
| 1002 | articulo.editCantidad = articulo.editPrecio = false; | 1006 | articulo.editCantidad = articulo.editPrecio = false; |
| 1003 | } | 1007 | } |
| 1004 | } | 1008 | } |
| 1005 | }; | 1009 | }; |
| 1006 | 1010 | ||
| 1007 | $scope.cancelarEditar = function (articulo) { | 1011 | $scope.cancelarEditar = function (articulo) { |
| 1008 | $scope.tmpCantidad = articulo.cantidad; | 1012 | $scope.tmpCantidad = articulo.cantidad; |
| 1009 | $scope.tmpPrecio = articulo.precio; | 1013 | $scope.tmpPrecio = articulo.precio; |
| 1010 | articulo.editCantidad = articulo.editPrecio = false; | 1014 | articulo.editCantidad = articulo.editPrecio = false; |
| 1011 | }; | 1015 | }; |
| 1012 | 1016 | ||
| 1013 | $scope.cambioEdit = function (articulo, propiedad) { | 1017 | $scope.cambioEdit = function (articulo, propiedad) { |
| 1014 | if (propiedad === 'cantidad') { | 1018 | if (propiedad === 'cantidad') { |
| 1015 | articulo.editCantidad = true; | 1019 | articulo.editCantidad = true; |
| 1016 | } else if (propiedad === 'precio') { | 1020 | } else if (propiedad === 'precio') { |
| 1017 | articulo.editPrecio = true; | 1021 | articulo.editPrecio = true; |
| 1018 | } | 1022 | } |
| 1019 | }; | 1023 | }; |
| 1020 | 1024 | ||
| 1021 | $scope.resetFilter = function () { | 1025 | $scope.resetFilter = function () { |
| 1022 | $scope.articuloACargar = {}; | 1026 | $scope.articuloACargar = {}; |
| 1023 | $scope.cargando = true; | 1027 | $scope.cargando = true; |
| 1024 | }; | 1028 | }; |
| 1025 | //Recibe aviso si el teclado está en uso | 1029 | //Recibe aviso si el teclado está en uso |
| 1026 | $rootScope.$on('usarTeclado', function (event, data) { | 1030 | $rootScope.$on('usarTeclado', function (event, data) { |
| 1027 | if (data) { | 1031 | if (data) { |
| 1028 | $scope.mostrarTeclado = true; | 1032 | $scope.mostrarTeclado = true; |
| 1029 | return; | 1033 | return; |
| 1030 | } | 1034 | } |
| 1031 | $scope.mostrarTeclado = false; | 1035 | $scope.mostrarTeclado = false; |
| 1032 | }); | 1036 | }); |
| 1033 | 1037 | ||
| 1034 | $scope.selectFocus = function ($event) { | 1038 | $scope.selectFocus = function ($event) { |
| 1035 | // Si el teclado esta en uso no selecciona el valor | 1039 | // Si el teclado esta en uso no selecciona el valor |
| 1036 | if ($scope.mostrarTeclado) { | 1040 | if ($scope.mostrarTeclado) { |
| 1037 | return; | 1041 | return; |
| 1038 | } | 1042 | } |
| 1039 | $event.target.select(); | 1043 | $event.target.select(); |
| 1040 | }; | 1044 | }; |
| 1041 | 1045 | ||
| 1042 | function addArrayCabecera(array) { | 1046 | function addArrayCabecera(array) { |
| 1043 | for (var i = 0; i < array.length; i++) { | 1047 | for (var i = 0; i < array.length; i++) { |
| 1044 | $scope.$broadcast('addCabecera', { | 1048 | $scope.$broadcast('addCabecera', { |
| 1045 | label: array[i].label, | 1049 | label: array[i].label, |
| 1046 | valor: array[i].valor | 1050 | valor: array[i].valor |
| 1047 | }); | 1051 | }); |
| 1048 | } | 1052 | } |
| 1049 | } | 1053 | } |
| 1050 | 1054 | ||
| 1051 | function rellenar(relleno, longitud) { | 1055 | function rellenar(relleno, longitud) { |
| 1052 | relleno = '' + relleno; | 1056 | relleno = '' + relleno; |
| 1053 | while (relleno.length < longitud) { | 1057 | while (relleno.length < longitud) { |
| 1054 | relleno = '0' + relleno; | 1058 | relleno = '0' + relleno; |
| 1055 | } | 1059 | } |
| 1056 | return relleno; | 1060 | return relleno; |
| 1057 | } | 1061 | } |
| 1058 | 1062 | ||
| 1059 | function varlidarRemitoFacturado() { | 1063 | function varlidarRemitoFacturado() { |
| 1060 | if ($scope.remito.estado !== 5) { | 1064 | if ($scope.remito.estado !== 5) { |
| 1061 | return true; | 1065 | return true; |
| 1062 | } else { | 1066 | } else { |
| 1063 | focaModalService.alert('No se puede editar un remito facturado'); | 1067 | focaModalService.alert('No se puede editar un remito facturado'); |
| 1064 | return false; | 1068 | return false; |
| 1065 | } | 1069 | } |
| 1066 | } | 1070 | } |
| 1067 | 1071 | ||
| 1068 | function varlidarRemitoAbierto() { | 1072 | function varlidarRemitoAbierto() { |
| 1069 | if (!$scope.remito.hojaRuta) return true; | 1073 | if (!$scope.remito.hojaRuta) return true; |
| 1070 | if ($scope.remito.hojaRuta.abierta !== '1') { | 1074 | if ($scope.remito.hojaRuta.abierta !== '1') { |
| 1071 | return true; | 1075 | return true; |
| 1072 | } else { | 1076 | } else { |
| 1073 | focaModalService.alert('No se puede editar un remito abierto'); | 1077 | focaModalService.alert('No se puede editar un remito abierto'); |
| 1074 | return false; | 1078 | return false; |
| 1075 | } | 1079 | } |
| 1076 | } | 1080 | } |
| 1077 | 1081 | ||
| 1078 | function removeItemFromArr(arr, item) { | 1082 | function removeItemFromArr(arr, item) { |
| 1079 | var i = arr.indexOf(item); | 1083 | var i = arr.indexOf(item); |
| 1080 | 1084 | ||
| 1081 | if (i !== -1) { | 1085 | if (i !== -1) { |
| 1082 | arr.splice(i, 1); | 1086 | arr.splice(i, 1); |
| 1083 | } | 1087 | } |
| 1084 | } | 1088 | } |
| 1085 | 1089 | ||
| 1086 | function salir() { | 1090 | function salir() { |
| 1087 | var confirmacion = false; | 1091 | var confirmacion = false; |
| 1088 | 1092 | ||
| 1089 | if (!angular.equals($scope.remito, $scope.inicial)) { | 1093 | if (!angular.equals($scope.remito, $scope.inicial)) { |
| 1090 | confirmacion = true; | 1094 | confirmacion = true; |
| 1091 | } | 1095 | } |
| 1092 | 1096 | ||
| 1093 | if (confirmacion) { | 1097 | if (confirmacion) { |
| 1094 | focaModalService.confirm( | 1098 | focaModalService.confirm( |
| 1095 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 1099 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
| 1096 | ).then(function (data) { | 1100 | ).then(function (data) { |
| 1097 | if (data) { | 1101 | if (data) { |
| 1098 | $location.path('/'); | 1102 | $location.path('/'); |
| 1099 | var rutaJson = JSON.parse($localStorage.rutas); | 1103 | var rutaJson = JSON.parse($localStorage.rutas); |
| 1100 | removeItemFromArr(rutaJson, 'venta-remito/crear'); | 1104 | removeItemFromArr(rutaJson, 'venta-remito/crear'); |
| 1101 | $localStorage.rutas = JSON.stringify(rutaJson); | 1105 | $localStorage.rutas = JSON.stringify(rutaJson); |
| 1102 | } | 1106 | } |
| 1103 | }); | 1107 | }); |
| 1104 | } else { | 1108 | } else { |
| 1105 | $location.path('/'); | 1109 | $location.path('/'); |
| 1106 | } | 1110 | } |
| 1107 | } | 1111 | } |
| 1108 | 1112 | ||
| 1109 | function enableObservaciones(val) { | 1113 | function enableObservaciones(val) { |
| 1110 | var boton = $scope.botonera.filter(function (botonObs) { | 1114 | var boton = $scope.botonera.filter(function (botonObs) { |
| 1111 | return botonObs.label === 'Observaciones'; | 1115 | return botonObs.label === 'Observaciones'; |
| 1112 | }); | 1116 | }); |
| 1113 | boton[0].disable = !val; | 1117 | boton[0].disable = !val; |
| 1114 | } | 1118 | } |
| 1115 | 1119 | ||
| 1116 | function setearRemito(remito) { | 1120 | function setearRemito(remito) { |
| 1117 | //añado cabeceras | 1121 | //añado cabeceras |
| 1118 | var esAbierto = remito.hojaRuta ? | 1122 | var esAbierto = remito.hojaRuta ? |
| 1119 | (remito.hojaRuta.abierta === '1') : false; | 1123 | (remito.hojaRuta.abierta === '1') : false; |
| 1120 | if (remito.estado !== 5 && remito.id && !esAbierto) { | 1124 | if (remito.estado !== 5 && remito.id && !esAbierto) { |
| 1121 | 1125 | ||
| 1122 | $scope.botonera.forEach(function (boton) { | 1126 | $scope.botonera.forEach(function (boton) { |
| 1123 | 1127 | ||
| 1124 | if (boton.label === 'Eliminar Remito') { | 1128 | if (boton.label === 'Eliminar Remito') { |
| 1125 | boton.disable = false; | 1129 | boton.disable = false; |
| 1126 | } | 1130 | } |
| 1127 | }); | 1131 | }); |
| 1128 | } | 1132 | } |
| 1129 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 1133 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
| 1130 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 1134 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
| 1131 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 1135 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
| 1132 | // $scope.$broadcast('removeCabecera', 'Vendedor:'); | 1136 | // $scope.$broadcast('removeCabecera', 'Vendedor:'); |
| 1133 | 1137 | ||
| 1134 | $scope.cabeceras = []; | 1138 | $scope.cabeceras = []; |
| 1135 | 1139 | ||
| 1136 | if (remito.cotizacion && remito.cotizacion.moneda.CODIGO_AFIP !== 'PES') { | 1140 | if (remito.cotizacion && remito.cotizacion.moneda.CODIGO_AFIP !== 'PES') { |
| 1137 | $scope.cabeceras.push({ | 1141 | $scope.cabeceras.push({ |
| 1138 | label: 'Moneda:', | 1142 | label: 'Moneda:', |
| 1139 | valor: remito.cotizacion.moneda.DETALLE | 1143 | valor: remito.cotizacion.moneda.DETALLE |
| 1140 | }); | 1144 | }); |
| 1141 | $scope.cabeceras.push({ | 1145 | $scope.cabeceras.push({ |
| 1142 | label: 'Fecha cotizacion:', | 1146 | label: 'Fecha cotizacion:', |
| 1143 | valor: $filter('date')(remito.cotizacion.FECHA, | 1147 | valor: $filter('date')(remito.cotizacion.FECHA, |
| 1144 | 'dd/MM/yyyy') | 1148 | 'dd/MM/yyyy') |
| 1145 | }); | 1149 | }); |
| 1146 | $scope.cabeceras.push({ | 1150 | $scope.cabeceras.push({ |
| 1147 | label: 'Cotizacion:', | 1151 | label: 'Cotizacion:', |
| 1148 | valor: $filter('number')(remito.cotizacion.VENDEDOR, | 1152 | valor: $filter('number')(remito.cotizacion.VENDEDOR, |
| 1149 | '2') | 1153 | '2') |
| 1150 | }); | 1154 | }); |
| 1151 | } | 1155 | } |
| 1152 | 1156 | ||
| 1153 | if (remito.cotizacion && remito.cotizacion.moneda) { | 1157 | if (remito.cotizacion && remito.cotizacion.moneda) { |
| 1154 | $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; | 1158 | $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; |
| 1155 | } | 1159 | } |
| 1156 | 1160 | ||
| 1157 | if (remito.cliente && remito.cliente.COD) { | 1161 | if (remito.cliente && remito.cliente.COD) { |
| 1158 | $scope.cabeceras.push({ | 1162 | $scope.cabeceras.push({ |
| 1159 | label: 'Cliente:', | 1163 | label: 'Cliente:', |
| 1160 | valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + | 1164 | valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + |
| 1161 | remito.cliente.NOM | 1165 | remito.cliente.NOM |
| 1162 | }); | 1166 | }); |
| 1163 | $scope.cabeceras.push({ | 1167 | $scope.cabeceras.push({ |
| 1164 | label: 'Domicilio:', | 1168 | label: 'Domicilio:', |
| 1165 | valor: remito.domicilioStamp | 1169 | valor: remito.domicilioStamp |
| 1166 | }); | 1170 | }); |
| 1167 | 1171 | ||
| 1168 | $filter('filter')($scope.botonera, | 1172 | $filter('filter')($scope.botonera, |
| 1169 | { label: 'Domicilio de Entrega' })[0].checked = true; | 1173 | { label: 'Domicilio de Entrega' })[0].checked = true; |
| 1170 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; | 1174 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; |
| 1171 | } | 1175 | } |
| 1172 | // if (remito.vendedor && remito.vendedor.NUM) { | 1176 | // if (remito.vendedor && remito.vendedor.NUM) { |
| 1173 | // $scope.cabeceras.push({ | 1177 | // $scope.cabeceras.push({ |
| 1174 | // label: 'Vendedor:', | 1178 | // label: 'Vendedor:', |
| 1175 | // valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + | 1179 | // valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + |
| 1176 | // ' - ' + remito.vendedor.NOM | 1180 | // ' - ' + remito.vendedor.NOM |
| 1177 | // }); | 1181 | // }); |
| 1178 | // } | 1182 | // } |
| 1179 | if (remito.proveedor && remito.proveedor.COD) { | 1183 | if (remito.proveedor && remito.proveedor.COD) { |
| 1180 | $scope.cabeceras.push({ | 1184 | $scope.cabeceras.push({ |
| 1181 | label: 'Proveedor:', | 1185 | label: 'Proveedor:', |
| 1182 | valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + | 1186 | valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + |
| 1183 | ' - ' + remito.proveedor.NOM | 1187 | ' - ' + remito.proveedor.NOM |
| 1184 | }); | 1188 | }); |
| 1185 | 1189 | ||
| 1186 | $filter('filter')($scope.botonera, { label: 'Proveedor' })[0].checked = true; | 1190 | $filter('filter')($scope.botonera, { label: 'Proveedor' })[0].checked = true; |
| 1187 | } | 1191 | } |
| 1188 | if (remito.flete !== undefined && remito.fob !== undefined) { | 1192 | if (remito.flete !== undefined && remito.fob !== undefined) { |
| 1189 | $scope.cabeceras.push({ | 1193 | $scope.cabeceras.push({ |
| 1190 | label: 'Flete:', | 1194 | label: 'Flete:', |
| 1191 | valor: remito.fob ? 'FOB' : ( | 1195 | valor: remito.fob ? 'FOB' : ( |
| 1192 | remito.flete ? 'Si' : 'No') | 1196 | remito.flete ? 'Si' : 'No') |
| 1193 | }); | 1197 | }); |
| 1194 | } | 1198 | } |
| 1195 | if (remito.remitoPlazo) { | 1199 | if (remito.remitoPlazo) { |
| 1196 | valorPrecioCondicion(); | 1200 | valorPrecioCondicion(); |
| 1197 | $filter('filter')($scope.botonera, | 1201 | $filter('filter')($scope.botonera, |
| 1198 | { label: 'Precios y condiciones' })[0].checked = true; | 1202 | { label: 'Precios y condiciones' })[0].checked = true; |
| 1199 | } | 1203 | } |
| 1200 | 1204 | ||
| 1201 | function valorPrecioCondicion() { | 1205 | function valorPrecioCondicion() { |
| 1202 | if (parseInt(remito.idListaPrecio)) { | 1206 | if (parseInt(remito.idListaPrecio)) { |
| 1203 | crearRemitoService.getListaPrecioById(parseInt(remito.idListaPrecio)) | 1207 | crearRemitoService.getListaPrecioById(parseInt(remito.idListaPrecio)) |
| 1204 | .then(function (res) { | 1208 | .then(function (res) { |
| 1205 | $timeout(function () { | 1209 | $timeout(function () { |
| 1206 | $scope.cabeceras.push({ | 1210 | $scope.cabeceras.push({ |
| 1207 | label: 'Precios y Condiciones:', | 1211 | label: 'Precios y Condiciones:', |
| 1208 | valor: parseInt(res.data[0].ID) + ' - ' + | 1212 | valor: parseInt(res.data[0].ID) + ' - ' + |
| 1209 | res.data[0].DES + ' ' + | 1213 | res.data[0].DES + ' ' + |
| 1210 | remitoBusinessService | 1214 | remitoBusinessService |
| 1211 | .plazoToString(remito.remitoPlazo) | 1215 | .plazoToString(remito.remitoPlazo) |
| 1212 | }); | 1216 | }); |
| 1213 | addArrayCabecera($scope.cabeceras); | 1217 | addArrayCabecera($scope.cabeceras); |
| 1214 | }, true); | 1218 | }, true); |
| 1215 | 1219 | ||
| 1216 | }); | 1220 | }); |
| 1217 | $scope.idLista = parseInt(remito.idListaPrecio); | 1221 | $scope.idLista = parseInt(remito.idListaPrecio); |
| 1218 | } | 1222 | } |
| 1219 | } | 1223 | } |
| 1220 | 1224 | ||
| 1221 | if (remito.flete === 1) { | 1225 | if (remito.flete === 1) { |
| 1222 | var cabeceraBomba = { | 1226 | var cabeceraBomba = { |
| 1223 | label: 'Bomba', | 1227 | label: 'Bomba', |
| 1224 | valor: remito.bomba === 1 ? 'Si' : 'No' | 1228 | valor: remito.bomba === 1 ? 'Si' : 'No' |
| 1225 | }; | 1229 | }; |
| 1226 | if (remito.kilometros) { | 1230 | if (remito.kilometros) { |
| 1227 | var cabeceraKilometros = { | 1231 | var cabeceraKilometros = { |
| 1228 | label: 'Kilometros', | 1232 | label: 'Kilometros', |
| 1229 | valor: remito.kilometros | 1233 | valor: remito.kilometros |
| 1230 | }; | 1234 | }; |
| 1231 | $scope.cabeceras.push(cabeceraKilometros); | 1235 | $scope.cabeceras.push(cabeceraKilometros); |
| 1232 | } | 1236 | } |
| 1233 | $scope.cabeceras.push(cabeceraBomba); | 1237 | $scope.cabeceras.push(cabeceraBomba); |
| 1234 | } | 1238 | } |
| 1235 | 1239 | ||
| 1236 | if (remito.idPrecioCondicion > 0) { | 1240 | if (remito.idPrecioCondicion > 0) { |
| 1237 | $scope.idLista = remito.precioCondicion.idListaPrecio; | 1241 | $scope.idLista = remito.precioCondicion.idListaPrecio; |
| 1238 | } else if (remito.idPrecioCondicion) { | 1242 | } else if (remito.idPrecioCondicion) { |
| 1239 | $scope.idLista = -1; | 1243 | $scope.idLista = -1; |
| 1240 | } | 1244 | } |
| 1241 | $scope.puntoVenta = rellenar(remito.sucursal, 4); | 1245 | $scope.puntoVenta = rellenar(remito.sucursal, 4); |
| 1242 | $scope.comprobante = rellenar(remito.numeroRemito, 8); | 1246 | $scope.comprobante = rellenar(remito.numeroRemito, 8); |
| 1243 | $scope.remito = remito; | 1247 | $scope.remito = remito; |
| 1244 | if ($scope.remito.remitoPuntoDescarga.length) { | 1248 | if ($scope.remito.remitoPuntoDescarga.length) { |
| 1245 | var puntoDescarga = []; | 1249 | var puntoDescarga = []; |
| 1246 | 1250 | ||
| 1247 | $scope.remito.remitoPuntoDescarga.forEach(function (remitoPuntoDescarga) { | 1251 | $scope.remito.remitoPuntoDescarga.forEach(function (remitoPuntoDescarga) { |
| 1248 | puntoDescarga.push(remitoPuntoDescarga.puntoDescarga); | 1252 | puntoDescarga.push(remitoPuntoDescarga.puntoDescarga); |
| 1249 | }); | 1253 | }); |
| 1250 | 1254 | ||
| 1251 | $scope.cabeceras.push({ | 1255 | $scope.cabeceras.push({ |
| 1252 | label: 'Puntos de descarga: ', | 1256 | label: 'Puntos de descarga: ', |
| 1253 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntoDescarga)) | 1257 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntoDescarga)) |
| 1254 | }); | 1258 | }); |
| 1255 | } | 1259 | } |
| 1256 | $scope.remitoIsDirty = false; | 1260 | $scope.remitoIsDirty = false; |
| 1257 | 1261 | ||
| 1258 | 1262 | ||
| 1259 | addArrayCabecera($scope.cabeceras); | 1263 | addArrayCabecera($scope.cabeceras); |
| 1260 | } | 1264 | } |
| 1261 | 1265 | ||
| 1262 | function getLSRemito() { | 1266 | function getLSRemito() { |
| 1263 | var remito = JSON.parse($localStorage.remito || null); | 1267 | var remito = JSON.parse($localStorage.remito || null); |
| 1264 | if (remito) { | 1268 | if (remito) { |
| 1265 | setearRemito(remito); | 1269 | setearRemito(remito); |
| 1266 | delete $localStorage.remito; | 1270 | delete $localStorage.remito; |
| 1267 | } | 1271 | } |
| 1268 | } | 1272 | } |
| 1269 | 1273 | ||
| 1270 | function getCabeceraPuntoDescarga(puntosDescarga) { | 1274 | function getCabeceraPuntoDescarga(puntosDescarga) { |
| 1271 | var puntosStamp = ''; | 1275 | var puntosStamp = ''; |
| 1272 | puntosDescarga.forEach(function (punto, idx, arr) { | 1276 | puntosDescarga.forEach(function (punto, idx, arr) { |
| 1273 | puntosStamp += punto.descripcion; | 1277 | puntosStamp += punto.descripcion; |
| 1274 | if ((idx + 1) !== arr.length) puntosStamp += ', '; | 1278 | if ((idx + 1) !== arr.length) puntosStamp += ', '; |
| 1275 | }); | 1279 | }); |
| 1276 | return puntosStamp; | 1280 | return puntosStamp; |
| 1277 | } | 1281 | } |
| 1278 | 1282 | ||
| 1279 | function abrirModalMail(id, cliente, numeroRemito) { | 1283 | function abrirModalMail(id, cliente, numeroRemito) { |
| 1280 | focaModalService.mail( | 1284 | focaModalService.mail( |
| 1281 | { | 1285 | { |
| 1282 | titulo: 'Comprobante de remito Nº ' + numeroRemito, | 1286 | titulo: 'Comprobante de remito Nº ' + numeroRemito, |
| 1283 | descarga: { | 1287 | descarga: { |
| 1284 | nombre: numeroRemito + '.pdf', | 1288 | nombre: numeroRemito + '.pdf', |
| 1285 | url: '/remito/comprobante', | 1289 | url: '/remito/comprobante', |
| 1286 | }, | 1290 | }, |
| 1287 | descargaSinValorizar: { | 1291 | descargaSinValorizar: { |
| 1288 | nombre: numeroRemito + '.pdf', | 1292 | nombre: numeroRemito + '.pdf', |
| 1289 | url: '/remito/comprobante-sin-valorizar', | 1293 | url: '/remito/comprobante-sin-valorizar', |
| 1290 | }, | 1294 | }, |
| 1291 | envio: { | 1295 | envio: { |
| 1292 | mailCliente: cliente.MAIL, | 1296 | mailCliente: cliente.MAIL, |
| 1293 | url: '/remito/mail', | 1297 | url: '/remito/mail', |
| 1294 | }, | 1298 | }, |
| 1295 | envioSinValorizar:{ | 1299 | envioSinValorizar: { |
| 1296 | mailCliente: cliente.MAIL, | 1300 | mailCliente: cliente.MAIL, |
| 1297 | url: '/remito/mail-sin-valorizar' | 1301 | url: '/remito/mail-sin-valorizar' |
| 1298 | }, | 1302 | }, |
| 1299 | options: { | 1303 | options: { |
| 1300 | idRemito: id | 1304 | idRemito: id |
| 1301 | } | 1305 | } |
| 1302 | } | 1306 | } |
| 1303 | ) | 1307 | ) |
| 1304 | .then(function (res) { | 1308 | .then(function (res) { |
| 1305 | if (res === false) { | 1309 | if (res === false) { |
| 1306 | abrirModalMail(id); | 1310 | abrirModalMail(id); |
| 1307 | focaModalService.alert('Descarga o envíe su remito ' + | 1311 | focaModalService.alert('Descarga o envíe su remito ' + |
| 1308 | 'antes de cerrar esta ventana'); | 1312 | 'antes de cerrar esta ventana'); |
| 1309 | } | 1313 | } |
| 1310 | }); | 1314 | }); |
| 1311 | } | 1315 | } |
| 1312 | //recibo la propiedad por la cual quiero obtener el valor | 1316 | //recibo la propiedad por la cual quiero obtener el valor |
| 1313 | function getImporte(propiedad) { | 1317 | function getImporte(propiedad) { |
| 1314 | var importe = 0; | 1318 | var importe = 0; |
| 1315 | 1319 | ||
| 1316 | $scope.articulosFiltro().forEach(function (articulo) { | 1320 | $scope.articulosFiltro().forEach(function (articulo) { |
| 1317 | 1321 | ||
| 1318 | if (articulo[propiedad]) { | 1322 | if (articulo[propiedad]) { |
| 1319 | importe += articulo[propiedad] * articulo.cantidad; | 1323 | importe += articulo[propiedad] * articulo.cantidad; |
| 1320 | } | 1324 | } |
| 1321 | return; | 1325 | return; |
| 1322 | 1326 | ||
| 1323 | }); | 1327 | }); |
| 1324 | 1328 | ||
| 1325 | return importe; | 1329 | return importe; |
| 1326 | } | 1330 | } |
| 1327 | } | 1331 | } |
| 1328 | ]); | 1332 | ]); |
| 1329 | 1333 |