Commit 8039daa241d8e97af0d777ea8f25c9485e902205
1 parent
e154b067c3
Exists in
develop
se elimina tarea pausada al guardar o salir
Showing
1 changed file
with
25 additions
and
0 deletions
Show diff stats
src/js/controller.js
| 1 | angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', | 1 | angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
| 2 | [ | 2 | [ |
| 3 | '$scope', | 3 | '$scope', |
| 4 | '$uibModal', | 4 | '$uibModal', |
| 5 | '$location', | 5 | '$location', |
| 6 | '$filter', | 6 | '$filter', |
| 7 | '$timeout', | 7 | '$timeout', |
| 8 | 'crearNotaPedidoService', | 8 | 'crearNotaPedidoService', |
| 9 | 'focaBotoneraLateralService', | 9 | 'focaBotoneraLateralService', |
| 10 | 'focaModalService', | 10 | 'focaModalService', |
| 11 | 'notaPedidoBusinessService', | 11 | 'notaPedidoBusinessService', |
| 12 | '$rootScope', | 12 | '$rootScope', |
| 13 | 'focaSeguimientoService', | 13 | 'focaSeguimientoService', |
| 14 | 'APP', | 14 | 'APP', |
| 15 | 'focaLoginService', | 15 | 'focaLoginService', |
| 16 | '$localStorage', | 16 | '$localStorage', |
| 17 | function ( | 17 | function ( |
| 18 | $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService, | 18 | $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService, |
| 19 | focaBotoneraLateralService, focaModalService, notaPedidoBusinessService, | 19 | focaBotoneraLateralService, focaModalService, notaPedidoBusinessService, |
| 20 | $rootScope, focaSeguimientoService, APP, focaLoginService, $localStorage) { | 20 | $rootScope, focaSeguimientoService, APP, focaLoginService, $localStorage) { |
| 21 | config(); | 21 | config(); |
| 22 | var cotizacionPArgentino = {}; | 22 | var cotizacionPArgentino = {}; |
| 23 | 23 | ||
| 24 | function config() { | 24 | function config() { |
| 25 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA | 25 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA |
| 26 | $scope.tmpCantidad = Number; | 26 | $scope.tmpCantidad = Number; |
| 27 | $scope.tmpPrecio = Number; | 27 | $scope.tmpPrecio = Number; |
| 28 | $scope.notaPedido = {}; | 28 | $scope.notaPedido = {}; |
| 29 | $scope.isNumber = angular.isNumber; | 29 | $scope.isNumber = angular.isNumber; |
| 30 | $scope.datepickerAbierto = false; | 30 | $scope.datepickerAbierto = false; |
| 31 | $scope.show = false; | 31 | $scope.show = false; |
| 32 | $scope.cargando = true; | 32 | $scope.cargando = true; |
| 33 | $scope.cabeceras = []; | 33 | $scope.cabeceras = []; |
| 34 | $scope.botonera = crearNotaPedidoService.getBotonera(); | 34 | $scope.botonera = crearNotaPedidoService.getBotonera(); |
| 35 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); | 35 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
| 36 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); | 36 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
| 37 | $scope.dateOptions = { | 37 | $scope.dateOptions = { |
| 38 | maxDate: new Date(), | 38 | maxDate: new Date(), |
| 39 | minDate: new Date(2010, 0, 1) | 39 | minDate: new Date(2010, 0, 1) |
| 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.crearNotaPedido); | 46 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); |
| 47 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 47 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
| 48 | }); | 48 | }); |
| 49 | 49 | ||
| 50 | // SETEA BOTONERA DE FACTURADOR TENIENDO EN CUENTA SI ESTA SETEADO EL VENDEDOR | 50 | // SETEA BOTONERA DE FACTURADOR TENIENDO EN CUENTA SI ESTA SETEADO EL VENDEDOR |
| 51 | if (APP === 'distribuidor') { | 51 | if (APP === 'distribuidor') { |
| 52 | $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; | 52 | $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | crearNotaPedidoService.getParametros().then(function (res) { | 55 | crearNotaPedidoService.getParametros().then(function (res) { |
| 56 | var parametros = JSON.parse(res.data[0].jsonText); | 56 | var parametros = JSON.parse(res.data[0].jsonText); |
| 57 | if ($localStorage.notaPedido) { | 57 | if ($localStorage.notaPedido) { |
| 58 | $timeout(function () { getLSNotaPedido(); }); | 58 | $timeout(function () { getLSNotaPedido(); }); |
| 59 | } else { | 59 | } else { |
| 60 | for (var property in parametros) { | 60 | for (var property in parametros) { |
| 61 | $scope.notaPedido[property] = parametros[property]; | 61 | $scope.notaPedido[property] = parametros[property]; |
| 62 | $scope.inicial[property] = parametros[property]; | 62 | $scope.inicial[property] = parametros[property]; |
| 63 | } | 63 | } |
| 64 | setearNotaPedido($scope.notaPedido); | 64 | setearNotaPedido($scope.notaPedido); |
| 65 | } | 65 | } |
| 66 | }); | 66 | }); |
| 67 | 67 | ||
| 68 | init(); | 68 | init(); |
| 69 | 69 | ||
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | function init() { | 72 | function init() { |
| 73 | $scope.$broadcast('cleanCabecera'); | 73 | $scope.$broadcast('cleanCabecera'); |
| 74 | 74 | ||
| 75 | $scope.notaPedido = { | 75 | $scope.notaPedido = { |
| 76 | id: 0, | 76 | id: 0, |
| 77 | cliente: {}, | 77 | cliente: {}, |
| 78 | proveedor: {}, | 78 | proveedor: {}, |
| 79 | domicilio: { dom: '' }, | 79 | domicilio: { dom: '' }, |
| 80 | vendedor: {}, | 80 | vendedor: {}, |
| 81 | fechaCarga: new Date(), | 81 | fechaCarga: new Date(), |
| 82 | cotizacion: {}, | 82 | cotizacion: {}, |
| 83 | articulosNotaPedido: [], | 83 | articulosNotaPedido: [], |
| 84 | notaPedidoPlazo: [], | 84 | notaPedidoPlazo: [], |
| 85 | notaPedidoPuntoDescarga: [] | 85 | notaPedidoPuntoDescarga: [] |
| 86 | |||
| 86 | }; | 87 | }; |
| 87 | $scope.idLista = undefined; | 88 | $scope.idLista = undefined; |
| 88 | 89 | ||
| 89 | crearNotaPedidoService.getNumeroNotaPedido().then( | 90 | crearNotaPedidoService.getNumeroNotaPedido().then( |
| 90 | function (res) { | 91 | function (res) { |
| 91 | $scope.puntoVenta = $filter('rellenarDigitos')( | 92 | $scope.puntoVenta = $filter('rellenarDigitos')( |
| 92 | res.data.sucursal, 4 | 93 | res.data.sucursal, 4 |
| 93 | ); | 94 | ); |
| 94 | 95 | ||
| 95 | $scope.comprobante = $filter('rellenarDigitos')( | 96 | $scope.comprobante = $filter('rellenarDigitos')( |
| 96 | res.data.numeroNotaPedido, 8 | 97 | res.data.numeroNotaPedido, 8 |
| 97 | ); | 98 | ); |
| 98 | }, | 99 | }, |
| 99 | function (err) { | 100 | function (err) { |
| 100 | focaModalService.alert('La terminal no esta configurada correctamente'); | 101 | focaModalService.alert('La terminal no esta configurada correctamente'); |
| 101 | console.info(err); | 102 | console.info(err); |
| 102 | } | 103 | } |
| 103 | ); | 104 | ); |
| 104 | 105 | ||
| 105 | if (APP === 'distribuidor') { | 106 | if (APP === 'distribuidor') { |
| 106 | crearNotaPedidoService.getVendedorById($scope.idVendedor).then( | 107 | crearNotaPedidoService.getVendedorById($scope.idVendedor).then( |
| 107 | function (res) { | 108 | function (res) { |
| 108 | var vendedor = res.data; | 109 | var vendedor = res.data; |
| 109 | $scope.$broadcast('addCabecera', { | 110 | $scope.$broadcast('addCabecera', { |
| 110 | label: 'Vendedor:', | 111 | label: 'Vendedor:', |
| 111 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 112 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
| 112 | vendedor.NOM | 113 | vendedor.NOM |
| 113 | }); | 114 | }); |
| 114 | 115 | ||
| 115 | $scope.notaPedido.vendedor = vendedor; | 116 | $scope.notaPedido.vendedor = vendedor; |
| 116 | $scope.inicial.vendedor = $scope.notaPedido.vendedor; | 117 | $scope.inicial.vendedor = $scope.notaPedido.vendedor; |
| 117 | } | 118 | } |
| 118 | ); | 119 | ); |
| 119 | } | 120 | } |
| 120 | 121 | ||
| 121 | $scope.inicial = angular.copy($scope.notaPedido); | 122 | $scope.inicial = angular.copy($scope.notaPedido); |
| 122 | } | 123 | } |
| 123 | 124 | ||
| 124 | $scope.$watch('notaPedido', function (newValue) { | 125 | $scope.$watch('notaPedido', function (newValue) { |
| 125 | focaBotoneraLateralService.setPausarData({ | 126 | focaBotoneraLateralService.setPausarData({ |
| 126 | label: 'notaPedido', | 127 | label: 'notaPedido', |
| 127 | val: newValue | 128 | val: newValue |
| 128 | }); | 129 | }); |
| 129 | }, true); | 130 | }, true); |
| 130 | 131 | ||
| 131 | $scope.$watch('NotaPedido', function (newValue) { | 132 | $scope.$watch('NotaPedido', function (newValue) { |
| 132 | focaBotoneraLateralService.setPausarData({ | 133 | focaBotoneraLateralService.setPausarData({ |
| 133 | label: 'notaPedido', | 134 | label: 'notaPedido', |
| 134 | val: newValue | 135 | val: newValue |
| 135 | }); | 136 | }); |
| 136 | focaBotoneraLateralService.setRutasPausadas({ | 137 | focaBotoneraLateralService.setRutasPausadas({ |
| 137 | label: 'rutas', | 138 | label: 'rutas', |
| 138 | val: 'venta-nota-pedido/crear' | 139 | val: 'venta-nota-pedido/crear' |
| 139 | }); | 140 | }); |
| 140 | }, true); | 141 | }, true); |
| 141 | 142 | ||
| 142 | $scope.crearNotaPedido = function () { | 143 | $scope.crearNotaPedido = function () { |
| 143 | if (!$scope.notaPedido.cliente.COD) { | 144 | if (!$scope.notaPedido.cliente.COD) { |
| 144 | focaModalService.alert('Ingrese Cliente'); | 145 | focaModalService.alert('Ingrese Cliente'); |
| 145 | return; | 146 | return; |
| 146 | } | 147 | } |
| 147 | if (!$scope.notaPedido.vendedor.id) { | 148 | if (!$scope.notaPedido.vendedor.id) { |
| 148 | focaModalService.alert('Este cliente no tiene vendedor asignado'); | 149 | focaModalService.alert('Este cliente no tiene vendedor asignado'); |
| 149 | return; | 150 | return; |
| 150 | } else if ($scope.notaPedido.idRemito === -1) { | 151 | } else if ($scope.notaPedido.idRemito === -1) { |
| 151 | focaBotoneraLateralService.alert('No se puede modificar esta nota de pedido'); | 152 | focaBotoneraLateralService.alert('No se puede modificar esta nota de pedido'); |
| 152 | return; | 153 | return; |
| 153 | } else if (!$scope.notaPedido.proveedor.COD) { | 154 | } else if (!$scope.notaPedido.proveedor.COD) { |
| 154 | focaModalService.alert('Ingrese Proveedor'); | 155 | focaModalService.alert('Ingrese Proveedor'); |
| 155 | return; | 156 | return; |
| 156 | } else if (!$scope.notaPedido.cotizacion.ID) { | 157 | } else if (!$scope.notaPedido.cotizacion.ID) { |
| 157 | focaModalService.alert('Ingrese Cotización'); | 158 | focaModalService.alert('Ingrese Cotización'); |
| 158 | return; | 159 | return; |
| 159 | } else if (!$scope.notaPedido.cotizacion.moneda.ID) { | 160 | } else if (!$scope.notaPedido.cotizacion.moneda.ID) { |
| 160 | focaModalService.alert('Ingrese Moneda'); | 161 | focaModalService.alert('Ingrese Moneda'); |
| 161 | return; | 162 | return; |
| 162 | } else if (!$scope.notaPedido.notaPedidoPlazo) { | 163 | } else if (!$scope.notaPedido.notaPedidoPlazo) { |
| 163 | focaModalService.alert('Ingrese Precios y Condiciones'); | 164 | focaModalService.alert('Ingrese Precios y Condiciones'); |
| 164 | return; | 165 | return; |
| 165 | } else if ( | 166 | } else if ( |
| 166 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) { | 167 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) { |
| 167 | focaModalService.alert('Ingrese Flete'); | 168 | focaModalService.alert('Ingrese Flete'); |
| 168 | return; | 169 | return; |
| 169 | } else if (!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto | 170 | } else if (!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto |
| 170 | focaModalService.alert('Ingrese Domicilio'); | 171 | focaModalService.alert('Ingrese Domicilio'); |
| 171 | return; | 172 | return; |
| 172 | } else if ($scope.notaPedido.articulosNotaPedido.length === 0) { | 173 | } else if ($scope.notaPedido.articulosNotaPedido.length === 0) { |
| 173 | focaModalService.alert('Debe cargar al menos un articulo'); | 174 | focaModalService.alert('Debe cargar al menos un articulo'); |
| 174 | return; | 175 | return; |
| 175 | } | 176 | } |
| 176 | 177 | ||
| 177 | focaBotoneraLateralService.startGuardar(); | 178 | focaBotoneraLateralService.startGuardar(); |
| 178 | $scope.saveLoading = true; | 179 | $scope.saveLoading = true; |
| 179 | var notaPedido = { | 180 | var notaPedido = { |
| 180 | id: $scope.notaPedido.id, | 181 | id: $scope.notaPedido.id, |
| 181 | fechaCarga: new Date($scope.notaPedido.fechaCarga) | 182 | fechaCarga: new Date($scope.notaPedido.fechaCarga) |
| 182 | .toISOString().slice(0, 19).replace('T', ' '), | 183 | .toISOString().slice(0, 19).replace('T', ' '), |
| 183 | idVendedor: $scope.notaPedido.vendedor.id, | 184 | idVendedor: $scope.notaPedido.vendedor.id, |
| 184 | idCliente: $scope.notaPedido.cliente.COD, | 185 | idCliente: $scope.notaPedido.cliente.COD, |
| 185 | nombreCliente: $scope.notaPedido.cliente.NOM, | 186 | nombreCliente: $scope.notaPedido.cliente.NOM, |
| 186 | cuitCliente: $scope.notaPedido.cliente.CUIT, | 187 | cuitCliente: $scope.notaPedido.cliente.CUIT, |
| 187 | idProveedor: $scope.notaPedido.proveedor.COD, | 188 | idProveedor: $scope.notaPedido.proveedor.COD, |
| 188 | idDomicilio: $scope.notaPedido.domicilio.id, | 189 | idDomicilio: $scope.notaPedido.domicilio.id, |
| 189 | idCotizacion: $scope.notaPedido.cotizacion.ID, | 190 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
| 190 | idListaPrecio: $scope.idLista, | 191 | idListaPrecio: $scope.idLista, |
| 191 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 192 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
| 192 | flete: $scope.notaPedido.flete, | 193 | flete: $scope.notaPedido.flete, |
| 193 | fob: $scope.notaPedido.fob, | 194 | fob: $scope.notaPedido.fob, |
| 194 | bomba: $scope.notaPedido.bomba, | 195 | bomba: $scope.notaPedido.bomba, |
| 195 | kilometros: $scope.notaPedido.kilometros, | 196 | kilometros: $scope.notaPedido.kilometros, |
| 196 | domicilioStamp: $scope.notaPedido.domicilioStamp, | 197 | domicilioStamp: $scope.notaPedido.domicilioStamp, |
| 197 | observaciones: $scope.notaPedido.observaciones, | 198 | observaciones: $scope.notaPedido.observaciones, |
| 198 | estado: 0, | 199 | estado: 0, |
| 199 | total: $scope.getTotal() | 200 | total: $scope.getTotal() |
| 200 | }; | 201 | }; |
| 201 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 202 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
| 202 | function (data) { | 203 | function (data) { |
| 203 | // Al guardar los datos de la nota de pedido logueamos la | 204 | // Al guardar los datos de la nota de pedido logueamos la |
| 204 | // actividad para su seguimiento. | 205 | // actividad para su seguimiento. |
| 205 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? | 206 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? |
| 206 | focaSeguimientoService.guardarPosicion( | 207 | focaSeguimientoService.guardarPosicion( |
| 207 | 'Nota de pedido', | 208 | 'Nota de pedido', |
| 208 | data.data.id, | 209 | data.data.id, |
| 209 | '' | 210 | '' |
| 210 | ); | 211 | ); |
| 211 | notaPedidoBusinessService.addArticulos( | 212 | notaPedidoBusinessService.addArticulos( |
| 212 | $scope.notaPedido.articulosNotaPedido, | 213 | $scope.notaPedido.articulosNotaPedido, |
| 213 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); | 214 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); |
| 214 | 215 | ||
| 215 | if ($scope.notaPedido.notaPedidoPuntoDescarga.length > 0) { | 216 | if ($scope.notaPedido.notaPedidoPuntoDescarga.length > 0) { |
| 216 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, | 217 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, |
| 217 | $scope.notaPedido.notaPedidoPuntoDescarga); | 218 | $scope.notaPedido.notaPedidoPuntoDescarga); |
| 218 | } | 219 | } |
| 219 | 220 | ||
| 221 | var ar = JSON.parse($localStorage.rutas); | ||
| 222 | function removeItemFromArr ( arr, item ) { | ||
| 223 | var i = arr.indexOf( item ); | ||
| 224 | |||
| 225 | if ( i !== -1 ) { | ||
| 226 | arr.splice( i, 1 ); | ||
| 227 | } | ||
| 228 | } | ||
| 229 | |||
| 230 | removeItemFromArr( ar, 'venta-nota-pedido/crear' ); | ||
| 231 | $localStorage.rutas = JSON.stringify(ar); | ||
| 232 | |||
| 220 | var plazos = $scope.notaPedido.notaPedidoPlazo; | 233 | var plazos = $scope.notaPedido.notaPedidoPlazo; |
| 221 | var plazosACrear = []; | 234 | var plazosACrear = []; |
| 222 | plazos.forEach(function (plazo) { | 235 | plazos.forEach(function (plazo) { |
| 223 | plazosACrear.push({ | 236 | plazosACrear.push({ |
| 224 | idNotaPedido: data.data.id, | 237 | idNotaPedido: data.data.id, |
| 225 | dias: plazo.dias | 238 | dias: plazo.dias |
| 226 | }); | 239 | }); |
| 227 | }); | 240 | }); |
| 228 | 241 | ||
| 229 | if (plazosACrear.length) { | 242 | if (plazosACrear.length) { |
| 230 | crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); | 243 | crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); |
| 231 | } | 244 | } |
| 232 | 245 | ||
| 233 | notaPedidoBusinessService.addEstado(data.data.id, | 246 | notaPedidoBusinessService.addEstado(data.data.id, |
| 234 | $scope.notaPedido.vendedor.id); | 247 | $scope.notaPedido.vendedor.id); |
| 235 | 248 | ||
| 236 | focaBotoneraLateralService.endGuardar(true); | 249 | focaBotoneraLateralService.endGuardar(true); |
| 237 | $scope.saveLoading = false; | 250 | $scope.saveLoading = false; |
| 238 | 251 | ||
| 239 | config(); | 252 | config(); |
| 240 | }, function (error) { | 253 | }, function (error) { |
| 241 | focaModalService.alert('Hubo un error al crear la nota de pedido'); | 254 | focaModalService.alert('Hubo un error al crear la nota de pedido'); |
| 242 | focaBotoneraLateralService.endGuardar(); | 255 | focaBotoneraLateralService.endGuardar(); |
| 243 | $scope.saveLoading = false; | 256 | $scope.saveLoading = false; |
| 244 | console.info(error); | 257 | console.info(error); |
| 245 | }); | 258 | }); |
| 246 | }; | 259 | }; |
| 247 | 260 | ||
| 248 | $scope.seleccionarNotaPedido = function () { | 261 | $scope.seleccionarNotaPedido = function () { |
| 249 | var modalInstance = $uibModal.open( | 262 | var modalInstance = $uibModal.open( |
| 250 | { | 263 | { |
| 251 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 264 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
| 252 | templateUrl: 'foca-modal-nota-pedido.html', | 265 | templateUrl: 'foca-modal-nota-pedido.html', |
| 253 | controller: 'focaModalNotaPedidoController', | 266 | controller: 'focaModalNotaPedidoController', |
| 254 | size: 'lg', | 267 | size: 'lg', |
| 255 | resolve: { | 268 | resolve: { |
| 256 | usadoPor: function () { return 'notaPedido'; }, | 269 | usadoPor: function () { return 'notaPedido'; }, |
| 257 | idVendedor: function () { | 270 | idVendedor: function () { |
| 258 | if (APP === 'distribuidor') | 271 | if (APP === 'distribuidor') |
| 259 | return $scope.notaPedido.vendedor.id; | 272 | return $scope.notaPedido.vendedor.id; |
| 260 | else | 273 | else |
| 261 | return null; | 274 | return null; |
| 262 | } | 275 | } |
| 263 | } | 276 | } |
| 264 | } | 277 | } |
| 265 | ); | 278 | ); |
| 266 | modalInstance.result.then(function (notaPedido) { | 279 | modalInstance.result.then(function (notaPedido) { |
| 267 | 280 | ||
| 268 | notaPedido.articulosNotaPedido.forEach(function (articulo) { | 281 | notaPedido.articulosNotaPedido.forEach(function (articulo) { |
| 269 | articulo.precio = | 282 | articulo.precio = |
| 270 | (articulo.precio / notaPedido.cotizacion.VENDEDOR).toFixed(4); | 283 | (articulo.precio / notaPedido.cotizacion.VENDEDOR).toFixed(4); |
| 271 | }); | 284 | }); |
| 272 | 285 | ||
| 273 | setearNotaPedido(notaPedido); | 286 | setearNotaPedido(notaPedido); |
| 274 | }); | 287 | }); |
| 275 | }; | 288 | }; |
| 276 | 289 | ||
| 277 | $scope.seleccionarProductos = function () { | 290 | $scope.seleccionarProductos = function () { |
| 278 | if ($scope.idLista === undefined) { | 291 | if ($scope.idLista === undefined) { |
| 279 | focaModalService.alert('Primero seleccione una lista de precio y condición'); | 292 | focaModalService.alert('Primero seleccione una lista de precio y condición'); |
| 280 | return; | 293 | return; |
| 281 | } else if (!validarNotaRemitada()) { | 294 | } else if (!validarNotaRemitada()) { |
| 282 | return; | 295 | return; |
| 283 | } | 296 | } |
| 284 | 297 | ||
| 285 | var modalInstance = $uibModal.open( | 298 | var modalInstance = $uibModal.open( |
| 286 | { | 299 | { |
| 287 | ariaLabelledBy: 'Busqueda de Productos', | 300 | ariaLabelledBy: 'Busqueda de Productos', |
| 288 | templateUrl: 'modal-busqueda-productos.html', | 301 | templateUrl: 'modal-busqueda-productos.html', |
| 289 | controller: 'modalBusquedaProductosCtrl', | 302 | controller: 'modalBusquedaProductosCtrl', |
| 290 | resolve: { | 303 | resolve: { |
| 291 | parametroProducto: { | 304 | parametroProducto: { |
| 292 | idLista: $scope.idLista, | 305 | idLista: $scope.idLista, |
| 293 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 306 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
| 294 | simbolo: $scope.notaPedido.cotizacion.moneda.SIMBOLO | 307 | simbolo: $scope.notaPedido.cotizacion.moneda.SIMBOLO |
| 295 | } | 308 | } |
| 296 | }, | 309 | }, |
| 297 | size: 'lg' | 310 | size: 'lg' |
| 298 | } | 311 | } |
| 299 | ); | 312 | ); |
| 300 | modalInstance.result.then( | 313 | modalInstance.result.then( |
| 301 | function (producto) { | 314 | function (producto) { |
| 302 | var newArt = | 315 | var newArt = |
| 303 | { | 316 | { |
| 304 | id: 0, | 317 | id: 0, |
| 305 | codigo: producto.codigo, | 318 | codigo: producto.codigo, |
| 306 | sector: producto.sector, | 319 | sector: producto.sector, |
| 307 | sectorCodigo: producto.sector + '-' + producto.codigo, | 320 | sectorCodigo: producto.sector + '-' + producto.codigo, |
| 308 | descripcion: producto.descripcionLarga, | 321 | descripcion: producto.descripcionLarga, |
| 309 | item: $scope.notaPedido.articulosNotaPedido.length + 1, | 322 | item: $scope.notaPedido.articulosNotaPedido.length + 1, |
| 310 | nombre: producto.descripcion, | 323 | nombre: producto.descripcion, |
| 311 | precio: parseFloat(producto.precio.toFixed(4)), | 324 | precio: parseFloat(producto.precio.toFixed(4)), |
| 312 | costoUnitario: producto.costo, | 325 | costoUnitario: producto.costo, |
| 313 | editCantidad: false, | 326 | editCantidad: false, |
| 314 | editPrecio: false, | 327 | editPrecio: false, |
| 315 | rubro: producto.CodRub, | 328 | rubro: producto.CodRub, |
| 316 | ivaUnitario: producto.IMPIVA, | 329 | ivaUnitario: producto.IMPIVA, |
| 317 | impuestoInternoUnitario: producto.ImpInt, | 330 | impuestoInternoUnitario: producto.ImpInt, |
| 318 | impuestoInterno1Unitario: producto.ImpInt2, | 331 | impuestoInterno1Unitario: producto.ImpInt2, |
| 319 | impuestoInterno2Unitario: producto.ImpInt3, | 332 | impuestoInterno2Unitario: producto.ImpInt3, |
| 320 | precioLista: producto.precio, | 333 | precioLista: producto.precio, |
| 321 | combustible: 1, | 334 | combustible: 1, |
| 322 | facturado: 0, | 335 | facturado: 0, |
| 323 | idArticulo: producto.id, | 336 | idArticulo: producto.id, |
| 324 | tasaIva: producto.tasaIVA | 337 | tasaIva: producto.tasaIVA |
| 325 | }; | 338 | }; |
| 326 | 339 | ||
| 327 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : producto.neto; | 340 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : producto.neto; |
| 328 | newArt.netoUnitario = newArt.ivaUnitario ? producto.neto : 0; | 341 | newArt.netoUnitario = newArt.ivaUnitario ? producto.neto : 0; |
| 329 | 342 | ||
| 330 | $scope.articuloACargar = newArt; | 343 | $scope.articuloACargar = newArt; |
| 331 | $scope.cargando = false; | 344 | $scope.cargando = false; |
| 332 | }, function () { | 345 | }, function () { |
| 333 | // funcion ejecutada cuando se cancela el modal | 346 | // funcion ejecutada cuando se cancela el modal |
| 334 | } | 347 | } |
| 335 | ); | 348 | ); |
| 336 | }; | 349 | }; |
| 337 | 350 | ||
| 338 | $scope.seleccionarPuntosDeDescarga = function () { | 351 | $scope.seleccionarPuntosDeDescarga = function () { |
| 339 | if (!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { | 352 | if (!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { |
| 340 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 353 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
| 341 | return; | 354 | return; |
| 342 | } else { | 355 | } else { |
| 343 | var modalInstance = $uibModal.open( | 356 | var modalInstance = $uibModal.open( |
| 344 | { | 357 | { |
| 345 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', | 358 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
| 346 | templateUrl: 'modal-punto-descarga.html', | 359 | templateUrl: 'modal-punto-descarga.html', |
| 347 | controller: 'focaModalPuntoDescargaController', | 360 | controller: 'focaModalPuntoDescargaController', |
| 348 | size: 'lg', | 361 | size: 'lg', |
| 349 | resolve: { | 362 | resolve: { |
| 350 | filters: { | 363 | filters: { |
| 351 | idDomicilio: $scope.notaPedido.domicilio.id, | 364 | idDomicilio: $scope.notaPedido.domicilio.id, |
| 352 | idCliente: $scope.notaPedido.cliente.COD, | 365 | idCliente: $scope.notaPedido.cliente.COD, |
| 353 | articulos: $scope.notaPedido.articulosNotaPedido, | 366 | articulos: $scope.notaPedido.articulosNotaPedido, |
| 354 | puntoDescarga: $scope.notaPedido.notaPedidoPuntoDescarga, | 367 | puntoDescarga: $scope.notaPedido.notaPedidoPuntoDescarga, |
| 355 | domicilio: $scope.notaPedido.domicilio | 368 | domicilio: $scope.notaPedido.domicilio |
| 356 | } | 369 | } |
| 357 | } | 370 | } |
| 358 | } | 371 | } |
| 359 | ); | 372 | ); |
| 360 | modalInstance.result.then( | 373 | modalInstance.result.then( |
| 361 | function (puntoDescarga) { | 374 | function (puntoDescarga) { |
| 362 | 375 | ||
| 363 | puntoDescarga.forEach(function (punto) { | 376 | puntoDescarga.forEach(function (punto) { |
| 364 | $scope.notaPedido.notaPedidoPuntoDescarga.push( | 377 | $scope.notaPedido.notaPedidoPuntoDescarga.push( |
| 365 | { | 378 | { |
| 366 | puntoDescarga: punto | 379 | puntoDescarga: punto |
| 367 | } | 380 | } |
| 368 | ); | 381 | ); |
| 369 | }); | 382 | }); |
| 370 | 383 | ||
| 371 | $scope.$broadcast('addCabecera', { | 384 | $scope.$broadcast('addCabecera', { |
| 372 | label: 'Puntos de descarga:', | 385 | label: 'Puntos de descarga:', |
| 373 | valor: getCabeceraPuntoDescarga(puntoDescarga) | 386 | valor: getCabeceraPuntoDescarga(puntoDescarga) |
| 374 | }); | 387 | }); |
| 375 | }, function () { | 388 | }, function () { |
| 376 | $scope.abrirModalDomicilios($scope.notaPedido.cliente); | 389 | $scope.abrirModalDomicilios($scope.notaPedido.cliente); |
| 377 | } | 390 | } |
| 378 | ); | 391 | ); |
| 379 | } | 392 | } |
| 380 | }; | 393 | }; |
| 381 | 394 | ||
| 382 | $scope.seleccionarDomicilioDeEntrega = function () { | 395 | $scope.seleccionarDomicilioDeEntrega = function () { |
| 383 | if (!$scope.notaPedido.cliente.COD) { | 396 | if (!$scope.notaPedido.cliente.COD) { |
| 384 | focaModalService.alert('Seleccione un Cliente'); | 397 | focaModalService.alert('Seleccione un Cliente'); |
| 385 | return; | 398 | return; |
| 386 | } else { | 399 | } else { |
| 387 | $scope.abrirModalDomicilios($scope.notaPedido.cliente); | 400 | $scope.abrirModalDomicilios($scope.notaPedido.cliente); |
| 388 | } | 401 | } |
| 389 | }; | 402 | }; |
| 390 | $scope.seleccionarProveedor = function () { | 403 | $scope.seleccionarProveedor = function () { |
| 391 | $scope.abrirModalProveedores(function () { | 404 | $scope.abrirModalProveedores(function () { |
| 392 | if (validarNotaRemitada()) { | 405 | if (validarNotaRemitada()) { |
| 393 | var modalInstance = $uibModal.open( | 406 | var modalInstance = $uibModal.open( |
| 394 | { | 407 | { |
| 395 | ariaLabelledBy: 'Busqueda de Flete', | 408 | ariaLabelledBy: 'Busqueda de Flete', |
| 396 | templateUrl: 'modal-flete.html', | 409 | templateUrl: 'modal-flete.html', |
| 397 | controller: 'focaModalFleteController', | 410 | controller: 'focaModalFleteController', |
| 398 | size: 'lg', | 411 | size: 'lg', |
| 399 | resolve: { | 412 | resolve: { |
| 400 | parametrosFlete: | 413 | parametrosFlete: |
| 401 | function () { | 414 | function () { |
| 402 | return { | 415 | return { |
| 403 | flete: $scope.notaPedido.fob ? 'FOB' : | 416 | flete: $scope.notaPedido.fob ? 'FOB' : |
| 404 | ($scope.notaPedido.flete ? '1' : | 417 | ($scope.notaPedido.flete ? '1' : |
| 405 | ($scope.notaPedido.flete === undefined ? | 418 | ($scope.notaPedido.flete === undefined ? |
| 406 | null : '0')), | 419 | null : '0')), |
| 407 | bomba: $scope.notaPedido.bomba ? '1' : | 420 | bomba: $scope.notaPedido.bomba ? '1' : |
| 408 | ($scope.notaPedido.bomba === undefined ? | 421 | ($scope.notaPedido.bomba === undefined ? |
| 409 | null : '0'), | 422 | null : '0'), |
| 410 | kilometros: $scope.notaPedido.kilometros | 423 | kilometros: $scope.notaPedido.kilometros |
| 411 | }; | 424 | }; |
| 412 | } | 425 | } |
| 413 | } | 426 | } |
| 414 | } | 427 | } |
| 415 | ); | 428 | ); |
| 416 | modalInstance.result.then( | 429 | modalInstance.result.then( |
| 417 | function (datos) { | 430 | function (datos) { |
| 418 | $scope.notaPedido.flete = datos.flete; | 431 | $scope.notaPedido.flete = datos.flete; |
| 419 | $scope.notaPedido.fob = datos.FOB; | 432 | $scope.notaPedido.fob = datos.FOB; |
| 420 | $scope.notaPedido.bomba = datos.bomba; | 433 | $scope.notaPedido.bomba = datos.bomba; |
| 421 | $scope.notaPedido.kilometros = datos.kilometros; | 434 | $scope.notaPedido.kilometros = datos.kilometros; |
| 422 | $scope.$broadcast('addCabecera', { | 435 | $scope.$broadcast('addCabecera', { |
| 423 | label: 'Flete:', | 436 | label: 'Flete:', |
| 424 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') | 437 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') |
| 425 | }); | 438 | }); |
| 426 | if (datos.flete) { | 439 | if (datos.flete) { |
| 427 | $scope.$broadcast('addCabecera', { | 440 | $scope.$broadcast('addCabecera', { |
| 428 | label: 'Bomba:', | 441 | label: 'Bomba:', |
| 429 | valor: datos.bomba ? 'Si' : 'No' | 442 | valor: datos.bomba ? 'Si' : 'No' |
| 430 | }); | 443 | }); |
| 431 | $scope.$broadcast('addCabecera', { | 444 | $scope.$broadcast('addCabecera', { |
| 432 | label: 'Kilometros:', | 445 | label: 'Kilometros:', |
| 433 | valor: datos.kilometros | 446 | valor: datos.kilometros |
| 434 | }); | 447 | }); |
| 435 | } else { | 448 | } else { |
| 436 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 449 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
| 437 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 450 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
| 438 | $scope.notaPedido.bomba = false; | 451 | $scope.notaPedido.bomba = false; |
| 439 | $scope.notaPedido.kilometros = null; | 452 | $scope.notaPedido.kilometros = null; |
| 440 | } | 453 | } |
| 441 | 454 | ||
| 442 | $filter('filter')($scope.botonera, | 455 | $filter('filter')($scope.botonera, |
| 443 | { label: 'Proveedor' })[0].checked = true; | 456 | { label: 'Proveedor' })[0].checked = true; |
| 444 | }, function () { | 457 | }, function () { |
| 445 | $scope.seleccionarTransportista(); | 458 | $scope.seleccionarTransportista(); |
| 446 | } | 459 | } |
| 447 | ); | 460 | ); |
| 448 | } | 461 | } |
| 449 | }); | 462 | }); |
| 450 | }; | 463 | }; |
| 451 | 464 | ||
| 452 | $scope.seleccionarVendedor = function (callback, ocultarVendedor) { | 465 | $scope.seleccionarVendedor = function (callback, ocultarVendedor) { |
| 453 | if (APP === 'distribuidor' || ocultarVendedor) { | 466 | if (APP === 'distribuidor' || ocultarVendedor) { |
| 454 | callback(); | 467 | callback(); |
| 455 | return; | 468 | return; |
| 456 | } | 469 | } |
| 457 | 470 | ||
| 458 | if (validarNotaRemitada()) { | 471 | if (validarNotaRemitada()) { |
| 459 | var parametrosModal = { | 472 | var parametrosModal = { |
| 460 | titulo: 'Búsqueda vendedores', | 473 | titulo: 'Búsqueda vendedores', |
| 461 | query: '/vendedor', | 474 | query: '/vendedor', |
| 462 | columnas: [ | 475 | columnas: [ |
| 463 | { | 476 | { |
| 464 | propiedad: 'NUM', | 477 | propiedad: 'NUM', |
| 465 | nombre: 'Código', | 478 | nombre: 'Código', |
| 466 | filtro: { | 479 | filtro: { |
| 467 | nombre: 'rellenarDigitos', | 480 | nombre: 'rellenarDigitos', |
| 468 | parametro: 3 | 481 | parametro: 3 |
| 469 | } | 482 | } |
| 470 | }, | 483 | }, |
| 471 | { | 484 | { |
| 472 | propiedad: 'NOM', | 485 | propiedad: 'NOM', |
| 473 | nombre: 'Nombre' | 486 | nombre: 'Nombre' |
| 474 | } | 487 | } |
| 475 | ], | 488 | ], |
| 476 | size: 'md' | 489 | size: 'md' |
| 477 | }; | 490 | }; |
| 478 | focaModalService.modal(parametrosModal).then( | 491 | focaModalService.modal(parametrosModal).then( |
| 479 | function (vendedor) { | 492 | function (vendedor) { |
| 480 | $scope.$broadcast('addCabecera', { | 493 | $scope.$broadcast('addCabecera', { |
| 481 | label: 'Vendedor:', | 494 | label: 'Vendedor:', |
| 482 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 495 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
| 483 | vendedor.NOM | 496 | vendedor.NOM |
| 484 | }); | 497 | }); |
| 485 | $scope.notaPedido.vendedor = vendedor; | 498 | $scope.notaPedido.vendedor = vendedor; |
| 486 | deleteCliente(); | 499 | deleteCliente(); |
| 487 | callback(); | 500 | callback(); |
| 488 | }, function () { } | 501 | }, function () { } |
| 489 | ); | 502 | ); |
| 490 | } | 503 | } |
| 491 | }; | 504 | }; |
| 492 | 505 | ||
| 493 | $scope.seleccionarCliente = function () { | 506 | $scope.seleccionarCliente = function () { |
| 494 | if (validarNotaRemitada()) { | 507 | if (validarNotaRemitada()) { |
| 495 | 508 | ||
| 496 | var modalInstance = $uibModal.open( | 509 | var modalInstance = $uibModal.open( |
| 497 | { | 510 | { |
| 498 | ariaLabelledBy: 'Busqueda de Cliente', | 511 | ariaLabelledBy: 'Busqueda de Cliente', |
| 499 | templateUrl: 'foca-busqueda-cliente-modal.html', | 512 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 500 | controller: 'focaBusquedaClienteModalController', | 513 | controller: 'focaBusquedaClienteModalController', |
| 501 | resolve: { | 514 | resolve: { |
| 502 | parametros: function () { | 515 | parametros: function () { |
| 503 | return { | 516 | return { |
| 504 | vendedor: $scope.idVendedor, | 517 | vendedor: $scope.idVendedor, |
| 505 | cobrador: null, | 518 | cobrador: null, |
| 506 | searchText: $scope.notaPedido.cliente ? | 519 | searchText: $scope.notaPedido.cliente ? |
| 507 | $scope.notaPedido.cliente.NOM : '' | 520 | $scope.notaPedido.cliente.NOM : '' |
| 508 | }; | 521 | }; |
| 509 | } | 522 | } |
| 510 | }, | 523 | }, |
| 511 | size: 'lg' | 524 | size: 'lg' |
| 512 | } | 525 | } |
| 513 | ); | 526 | ); |
| 514 | modalInstance.result.then( | 527 | modalInstance.result.then( |
| 515 | function (cliente) { | 528 | function (cliente) { |
| 516 | 529 | ||
| 517 | if ($scope.notaPedido.precioCondicion !== undefined) { | 530 | if ($scope.notaPedido.precioCondicion !== undefined) { |
| 518 | focaModalService | 531 | focaModalService |
| 519 | .alert('Debe agregar lista de precio de cliente actual') | 532 | .alert('Debe agregar lista de precio de cliente actual') |
| 520 | .then(function () { | 533 | .then(function () { |
| 521 | $scope.notaPedido.precioCondicion = undefined; | 534 | $scope.notaPedido.precioCondicion = undefined; |
| 522 | $scope.$broadcast('removeCabecera', | 535 | $scope.$broadcast('removeCabecera', |
| 523 | 'Precios y Condiciones:'); | 536 | 'Precios y Condiciones:'); |
| 524 | $filter('filter')($scope.botonera, | 537 | $filter('filter')($scope.botonera, |
| 525 | { label: 'Precios y Condiciones' })[0].checked = false; | 538 | { label: 'Precios y Condiciones' })[0].checked = false; |
| 526 | }) | 539 | }) |
| 527 | .catch(function () { | 540 | .catch(function () { |
| 528 | }); | 541 | }); |
| 529 | } | 542 | } |
| 530 | 543 | ||
| 531 | if (angular.equals({}, cliente.vendedor)) { | 544 | if (angular.equals({}, cliente.vendedor)) { |
| 532 | 545 | ||
| 533 | focaModalService | 546 | focaModalService |
| 534 | .alert('El cliente seleccionado no tiene tiene ' + | 547 | .alert('El cliente seleccionado no tiene tiene ' + |
| 535 | 'vendedor asignado.') | 548 | 'vendedor asignado.') |
| 536 | .then($scope.seleccionarCliente); | 549 | .then($scope.seleccionarCliente); |
| 537 | 550 | ||
| 538 | return; | 551 | return; |
| 539 | } | 552 | } |
| 540 | 553 | ||
| 541 | $scope.abrirModalDomicilios(cliente); | 554 | $scope.abrirModalDomicilios(cliente); |
| 542 | }, function () { } | 555 | }, function () { } |
| 543 | ); | 556 | ); |
| 544 | } | 557 | } |
| 545 | }; | 558 | }; |
| 546 | 559 | ||
| 547 | $scope.abrirModalProveedores = function (callback) { | 560 | $scope.abrirModalProveedores = function (callback) { |
| 548 | if (validarNotaRemitada()) { | 561 | if (validarNotaRemitada()) { |
| 549 | var parametrosModal = { | 562 | var parametrosModal = { |
| 550 | titulo: 'Búsqueda de Proveedor', | 563 | titulo: 'Búsqueda de Proveedor', |
| 551 | query: '/proveedor', | 564 | query: '/proveedor', |
| 552 | columnas: [ | 565 | columnas: [ |
| 553 | { | 566 | { |
| 554 | nombre: 'Código', | 567 | nombre: 'Código', |
| 555 | propiedad: 'COD', | 568 | propiedad: 'COD', |
| 556 | filtro: { | 569 | filtro: { |
| 557 | nombre: 'rellenarDigitos', | 570 | nombre: 'rellenarDigitos', |
| 558 | parametro: 5 | 571 | parametro: 5 |
| 559 | } | 572 | } |
| 560 | }, | 573 | }, |
| 561 | { | 574 | { |
| 562 | nombre: 'Nombre', | 575 | nombre: 'Nombre', |
| 563 | propiedad: 'NOM' | 576 | propiedad: 'NOM' |
| 564 | }, | 577 | }, |
| 565 | { | 578 | { |
| 566 | nombre: 'CUIT', | 579 | nombre: 'CUIT', |
| 567 | propiedad: 'CUIT' | 580 | propiedad: 'CUIT' |
| 568 | } | 581 | } |
| 569 | ], | 582 | ], |
| 570 | tipo: 'POST', | 583 | tipo: 'POST', |
| 571 | json: { razonCuitCod: '' } | 584 | json: { razonCuitCod: '' } |
| 572 | }; | 585 | }; |
| 573 | focaModalService.modal(parametrosModal).then( | 586 | focaModalService.modal(parametrosModal).then( |
| 574 | function (proveedor) { | 587 | function (proveedor) { |
| 575 | $scope.notaPedido.proveedor = proveedor; | 588 | $scope.notaPedido.proveedor = proveedor; |
| 576 | $scope.$broadcast('addCabecera', { | 589 | $scope.$broadcast('addCabecera', { |
| 577 | label: 'Proveedor:', | 590 | label: 'Proveedor:', |
| 578 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 591 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
| 579 | proveedor.NOM | 592 | proveedor.NOM |
| 580 | }); | 593 | }); |
| 581 | callback(); | 594 | callback(); |
| 582 | }, function () { | 595 | }, function () { |
| 583 | 596 | ||
| 584 | } | 597 | } |
| 585 | ); | 598 | ); |
| 586 | } | 599 | } |
| 587 | }; | 600 | }; |
| 588 | 601 | ||
| 589 | $scope.abrirModalDomicilios = function (cliente) { | 602 | $scope.abrirModalDomicilios = function (cliente) { |
| 590 | var modalInstanceDomicilio = $uibModal.open( | 603 | var modalInstanceDomicilio = $uibModal.open( |
| 591 | { | 604 | { |
| 592 | ariaLabelledBy: 'Busqueda de Domicilios', | 605 | ariaLabelledBy: 'Busqueda de Domicilios', |
| 593 | templateUrl: 'modal-domicilio.html', | 606 | templateUrl: 'modal-domicilio.html', |
| 594 | controller: 'focaModalDomicilioController', | 607 | controller: 'focaModalDomicilioController', |
| 595 | resolve: { | 608 | resolve: { |
| 596 | idCliente: function () { return cliente.COD; }, | 609 | idCliente: function () { return cliente.COD; }, |
| 597 | esNuevo: function () { return cliente.esNuevo; } | 610 | esNuevo: function () { return cliente.esNuevo; } |
| 598 | }, | 611 | }, |
| 599 | size: 'lg', | 612 | size: 'lg', |
| 600 | } | 613 | } |
| 601 | ); | 614 | ); |
| 602 | modalInstanceDomicilio.result.then( | 615 | modalInstanceDomicilio.result.then( |
| 603 | function (domicilio) { | 616 | function (domicilio) { |
| 604 | 617 | ||
| 605 | $scope.notaPedido.domicilio = domicilio; | 618 | $scope.notaPedido.domicilio = domicilio; |
| 606 | $scope.notaPedido.cliente = cliente; | 619 | $scope.notaPedido.cliente = cliente; |
| 607 | $scope.notaPedido.vendedor = cliente.vendedor; | 620 | $scope.notaPedido.vendedor = cliente.vendedor; |
| 608 | 621 | ||
| 609 | $scope.$broadcast('addCabecera', { | 622 | $scope.$broadcast('addCabecera', { |
| 610 | label: 'Vendedor:', | 623 | label: 'Vendedor:', |
| 611 | valor: $filter('rellenarDigitos') | 624 | valor: $filter('rellenarDigitos') |
| 612 | ($scope.notaPedido.vendedor.NUM, 3) + | 625 | ($scope.notaPedido.vendedor.NUM, 3) + |
| 613 | ' - ' + $scope.notaPedido.vendedor.NOM | 626 | ' - ' + $scope.notaPedido.vendedor.NOM |
| 614 | }); | 627 | }); |
| 615 | 628 | ||
| 616 | var domicilioStamp = | 629 | var domicilioStamp = |
| 617 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 630 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
| 618 | domicilio.Localidad + ', ' + domicilio.Provincia; | 631 | domicilio.Localidad + ', ' + domicilio.Provincia; |
| 619 | $scope.notaPedido.domicilioStamp = domicilioStamp; | 632 | $scope.notaPedido.domicilioStamp = domicilioStamp; |
| 620 | 633 | ||
| 621 | $scope.$broadcast('addCabecera', { | 634 | $scope.$broadcast('addCabecera', { |
| 622 | label: 'Cliente:', | 635 | label: 'Cliente:', |
| 623 | valor: $filter('rellenarDigitos')(cliente.COD, 5) + | 636 | valor: $filter('rellenarDigitos')(cliente.COD, 5) + |
| 624 | ' - ' + cliente.NOM | 637 | ' - ' + cliente.NOM |
| 625 | }); | 638 | }); |
| 626 | 639 | ||
| 627 | $scope.$broadcast('addCabecera', { | 640 | $scope.$broadcast('addCabecera', { |
| 628 | label: 'Domicilio:', | 641 | label: 'Domicilio:', |
| 629 | valor: domicilioStamp | 642 | valor: domicilioStamp |
| 630 | }); | 643 | }); |
| 631 | 644 | ||
| 632 | if (domicilio.verPuntos) { | 645 | if (domicilio.verPuntos) { |
| 633 | delete $scope.notaPedido.domicilio.verPuntos; | 646 | delete $scope.notaPedido.domicilio.verPuntos; |
| 634 | $scope.seleccionarPuntosDeDescarga(); | 647 | $scope.seleccionarPuntosDeDescarga(); |
| 635 | } | 648 | } |
| 636 | 649 | ||
| 637 | // Seteo checked en botonera | 650 | // Seteo checked en botonera |
| 638 | $filter('filter')($scope.botonera, | 651 | $filter('filter')($scope.botonera, |
| 639 | { label: 'Cliente' })[0].checked = true; | 652 | { label: 'Cliente' })[0].checked = true; |
| 640 | $filter('filter')($scope.botonera, | 653 | $filter('filter')($scope.botonera, |
| 641 | { label: 'Domicilio de Entrega' })[0].checked = true; | 654 | { label: 'Domicilio de Entrega' })[0].checked = true; |
| 642 | 655 | ||
| 643 | }, function () { | 656 | }, function () { |
| 644 | $scope.seleccionarCliente(true); | 657 | $scope.seleccionarCliente(true); |
| 645 | return; | 658 | return; |
| 646 | } | 659 | } |
| 647 | ); | 660 | ); |
| 648 | }; | 661 | }; |
| 649 | 662 | ||
| 650 | $scope.getTotal = function () { | 663 | $scope.getTotal = function () { |
| 651 | var total = 0; | 664 | var total = 0; |
| 652 | if ($scope.notaPedido.articulosNotaPedido) { | 665 | if ($scope.notaPedido.articulosNotaPedido) { |
| 653 | var arrayTempArticulos = $scope.notaPedido.articulosNotaPedido; | 666 | var arrayTempArticulos = $scope.notaPedido.articulosNotaPedido; |
| 654 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 667 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
| 655 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 668 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 656 | } | 669 | } |
| 657 | } | 670 | } |
| 658 | return parseFloat(total.toFixed(2)); | 671 | return parseFloat(total.toFixed(2)); |
| 659 | }; | 672 | }; |
| 660 | 673 | ||
| 661 | $scope.getSubTotal = function () { | 674 | $scope.getSubTotal = function () { |
| 662 | if ($scope.articuloACargar) { | 675 | if ($scope.articuloACargar) { |
| 663 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 676 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 664 | } | 677 | } |
| 665 | }; | 678 | }; |
| 666 | 679 | ||
| 667 | $scope.seleccionarPreciosYCondiciones = function () { | 680 | $scope.seleccionarPreciosYCondiciones = function () { |
| 668 | 681 | ||
| 669 | if (!validarNotaRemitada()) return; | 682 | if (!validarNotaRemitada()) return; |
| 670 | 683 | ||
| 671 | if (!$scope.notaPedido.cliente.COD) { | 684 | if (!$scope.notaPedido.cliente.COD) { |
| 672 | focaModalService.alert('Primero seleccione un cliente'); | 685 | focaModalService.alert('Primero seleccione un cliente'); |
| 673 | return; | 686 | return; |
| 674 | } else { | 687 | } else { |
| 675 | abrirModal(); | 688 | abrirModal(); |
| 676 | } | 689 | } |
| 677 | 690 | ||
| 678 | function abrirModal() { | 691 | function abrirModal() { |
| 679 | var parametros = { | 692 | var parametros = { |
| 680 | idCliente: $scope.notaPedido.cliente.COD, | 693 | idCliente: $scope.notaPedido.cliente.COD, |
| 681 | idListaPrecio: $scope.notaPedido.cliente.MOD, | 694 | idListaPrecio: $scope.notaPedido.cliente.MOD, |
| 682 | notaPedido: $scope.notaPedido | 695 | notaPedido: $scope.notaPedido |
| 683 | }; | 696 | }; |
| 684 | var modalInstance = $uibModal.open( | 697 | var modalInstance = $uibModal.open( |
| 685 | { | 698 | { |
| 686 | ariaLabelledBy: 'Busqueda de Precio Condición', | 699 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 687 | templateUrl: 'modal-precio-condicion.html', | 700 | templateUrl: 'modal-precio-condicion.html', |
| 688 | controller: 'focaModalPrecioCondicionController', | 701 | controller: 'focaModalPrecioCondicionController', |
| 689 | size: 'lg', | 702 | size: 'lg', |
| 690 | resolve: { | 703 | resolve: { |
| 691 | parametros: function () { return parametros; }, | 704 | parametros: function () { return parametros; }, |
| 692 | } | 705 | } |
| 693 | } | 706 | } |
| 694 | ); | 707 | ); |
| 695 | 708 | ||
| 696 | modalInstance.result.then(function (precioCondicion) { | 709 | modalInstance.result.then(function (precioCondicion) { |
| 697 | var cabecera = ''; | 710 | var cabecera = ''; |
| 698 | var plazosConcat = ''; | 711 | var plazosConcat = ''; |
| 699 | if (!Array.isArray(precioCondicion)) { | 712 | if (!Array.isArray(precioCondicion)) { |
| 700 | $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; | 713 | $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; |
| 701 | $scope.notaPedido.precioCondicion = precioCondicion; | 714 | $scope.notaPedido.precioCondicion = precioCondicion; |
| 702 | $scope.notaPedido.cliente.MOD = precioCondicion.listaPrecio.ID; | 715 | $scope.notaPedido.cliente.MOD = precioCondicion.listaPrecio.ID; |
| 703 | $scope.idLista = parseInt(precioCondicion.listaPrecio.ID) ? | 716 | $scope.idLista = parseInt(precioCondicion.listaPrecio.ID) ? |
| 704 | parseInt(precioCondicion.listaPrecio.ID) : -1; | 717 | parseInt(precioCondicion.listaPrecio.ID) : -1; |
| 705 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | 718 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { |
| 706 | plazosConcat += precioCondicion.plazoPago[i].dias + ', '; | 719 | plazosConcat += precioCondicion.plazoPago[i].dias + ', '; |
| 707 | } | 720 | } |
| 708 | plazosConcat = plazosConcat.substring(0, plazosConcat.length - 2); | 721 | plazosConcat = plazosConcat.substring(0, plazosConcat.length - 2); |
| 709 | cabecera = $filter('rellenarDigitos')($scope.idLista, 4) + | 722 | cabecera = $filter('rellenarDigitos')($scope.idLista, 4) + |
| 710 | ' - ' + precioCondicion.listaPrecio.DES + | 723 | ' - ' + precioCondicion.listaPrecio.DES + |
| 711 | ' ' + plazosConcat.trim(); | 724 | ' ' + plazosConcat.trim(); |
| 712 | } else { //Cuando se ingresan los plazos manualmente | 725 | } else { //Cuando se ingresan los plazos manualmente |
| 713 | //-1, el modal productos busca todos los productos | 726 | //-1, el modal productos busca todos los productos |
| 714 | $scope.idLista = -1; | 727 | $scope.idLista = -1; |
| 715 | $scope.notaPedido.notaPedidoPlazo = precioCondicion; | 728 | $scope.notaPedido.notaPedidoPlazo = precioCondicion; |
| 716 | for (var j = 0; j < precioCondicion.length; j++) { | 729 | for (var j = 0; j < precioCondicion.length; j++) { |
| 717 | plazosConcat += precioCondicion[j].dias + ' '; | 730 | plazosConcat += precioCondicion[j].dias + ' '; |
| 718 | } | 731 | } |
| 719 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 732 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
| 720 | } | 733 | } |
| 721 | $scope.cabeceras.push({ | 734 | $scope.cabeceras.push({ |
| 722 | label: 'Precios y Condiciones:', | 735 | label: 'Precios y Condiciones:', |
| 723 | valor: $scope.idLista + ' - ' + precioCondicion.listaPrecio.DES + ' ' + | 736 | valor: $scope.idLista + ' - ' + precioCondicion.listaPrecio.DES + ' ' + |
| 724 | notaPedidoBusinessService.plazoToString(precioCondicion.plazoPago) | 737 | notaPedidoBusinessService.plazoToString(precioCondicion.plazoPago) |
| 725 | }); | 738 | }); |
| 726 | 739 | ||
| 727 | $filter('filter')($scope.botonera, | 740 | $filter('filter')($scope.botonera, |
| 728 | { label: 'Precios y Condiciones' })[0].checked = true; | 741 | { label: 'Precios y Condiciones' })[0].checked = true; |
| 729 | 742 | ||
| 730 | addArrayCabecera($scope.cabeceras); | 743 | addArrayCabecera($scope.cabeceras); |
| 731 | 744 | ||
| 732 | }) | 745 | }) |
| 733 | .catch(function (e) { | 746 | .catch(function (e) { |
| 734 | console.log(e); | 747 | console.log(e); |
| 735 | }); | 748 | }); |
| 736 | 749 | ||
| 737 | } | 750 | } |
| 738 | }; | 751 | }; |
| 739 | 752 | ||
| 740 | $scope.seleccionarMoneda = function () { | 753 | $scope.seleccionarMoneda = function () { |
| 741 | if (validarNotaRemitada()) { | 754 | if (validarNotaRemitada()) { |
| 742 | var parametrosModal = { | 755 | var parametrosModal = { |
| 743 | titulo: 'Búsqueda de monedas', | 756 | titulo: 'Búsqueda de monedas', |
| 744 | query: '/moneda', | 757 | query: '/moneda', |
| 745 | columnas: [ | 758 | columnas: [ |
| 746 | { | 759 | { |
| 747 | propiedad: 'DETALLE', | 760 | propiedad: 'DETALLE', |
| 748 | nombre: 'Nombre' | 761 | nombre: 'Nombre' |
| 749 | }, | 762 | }, |
| 750 | { | 763 | { |
| 751 | propiedad: 'SIMBOLO', | 764 | propiedad: 'SIMBOLO', |
| 752 | nombre: 'Símbolo' | 765 | nombre: 'Símbolo' |
| 753 | } | 766 | } |
| 754 | ], | 767 | ], |
| 755 | size: 'md' | 768 | size: 'md' |
| 756 | }; | 769 | }; |
| 757 | focaModalService.modal(parametrosModal).then( | 770 | focaModalService.modal(parametrosModal).then( |
| 758 | function (moneda) { | 771 | function (moneda) { |
| 759 | 772 | ||
| 760 | if (moneda.ID !== 1) { | 773 | if (moneda.ID !== 1) { |
| 761 | $scope.abrirModalCotizacion(moneda); | 774 | $scope.abrirModalCotizacion(moneda); |
| 762 | return; | 775 | return; |
| 763 | } | 776 | } |
| 764 | 777 | ||
| 765 | crearNotaPedidoService.getCotizacionByIdMoneda(1) | 778 | crearNotaPedidoService.getCotizacionByIdMoneda(1) |
| 766 | .then(function (res) { | 779 | .then(function (res) { |
| 767 | 780 | ||
| 768 | cotizacionPArgentino = res.data[0].cotizaciones[0]; | 781 | cotizacionPArgentino = res.data[0].cotizaciones[0]; |
| 769 | cotizacionPArgentino.moneda = moneda; | 782 | cotizacionPArgentino.moneda = moneda; |
| 770 | 783 | ||
| 771 | actualizarCabeceraMoneda(cotizacionPArgentino); | 784 | actualizarCabeceraMoneda(cotizacionPArgentino); |
| 772 | $filter('filter')($scope.botonera, | 785 | $filter('filter')($scope.botonera, |
| 773 | { label: 'Moneda' })[0].checked = true; | 786 | { label: 'Moneda' })[0].checked = true; |
| 774 | $scope.notaPedido.cotizacion = cotizacionPArgentino; | 787 | $scope.notaPedido.cotizacion = cotizacionPArgentino; |
| 775 | }); | 788 | }); |
| 776 | } | 789 | } |
| 777 | ); | 790 | ); |
| 778 | } | 791 | } |
| 779 | }; | 792 | }; |
| 780 | 793 | ||
| 781 | $scope.seleccionarObservaciones = function () { | 794 | $scope.seleccionarObservaciones = function () { |
| 782 | var observacion = { | 795 | var observacion = { |
| 783 | titulo: 'Ingrese Observaciones', | 796 | titulo: 'Ingrese Observaciones', |
| 784 | value: $scope.notaPedido.observaciones, | 797 | value: $scope.notaPedido.observaciones, |
| 785 | maxlength: 155, | 798 | maxlength: 155, |
| 786 | textarea: true | 799 | textarea: true |
| 787 | }; | 800 | }; |
| 788 | 801 | ||
| 789 | focaModalService | 802 | focaModalService |
| 790 | .prompt(observacion) | 803 | .prompt(observacion) |
| 791 | .then(function (observaciones) { | 804 | .then(function (observaciones) { |
| 792 | $scope.notaPedido.observaciones = observaciones; | 805 | $scope.notaPedido.observaciones = observaciones; |
| 793 | }); | 806 | }); |
| 794 | }; | 807 | }; |
| 795 | 808 | ||
| 796 | $scope.abrirModalCotizacion = function (moneda) { | 809 | $scope.abrirModalCotizacion = function (moneda) { |
| 797 | var modalInstance = $uibModal.open( | 810 | var modalInstance = $uibModal.open( |
| 798 | { | 811 | { |
| 799 | ariaLabelledBy: 'Busqueda de Cotización', | 812 | ariaLabelledBy: 'Busqueda de Cotización', |
| 800 | templateUrl: 'modal-cotizacion.html', | 813 | templateUrl: 'modal-cotizacion.html', |
| 801 | controller: 'focaModalCotizacionController', | 814 | controller: 'focaModalCotizacionController', |
| 802 | size: 'lg', | 815 | size: 'lg', |
| 803 | resolve: { | 816 | resolve: { |
| 804 | idMoneda: function () { | 817 | idMoneda: function () { |
| 805 | return moneda.ID; | 818 | return moneda.ID; |
| 806 | } | 819 | } |
| 807 | } | 820 | } |
| 808 | } | 821 | } |
| 809 | ); | 822 | ); |
| 810 | modalInstance.result.then( | 823 | modalInstance.result.then( |
| 811 | function (cotizacion) { | 824 | function (cotizacion) { |
| 812 | 825 | ||
| 813 | cotizacion.moneda = moneda; | 826 | cotizacion.moneda = moneda; |
| 814 | actualizarCabeceraMoneda(cotizacion); | 827 | actualizarCabeceraMoneda(cotizacion); |
| 815 | 828 | ||
| 816 | $scope.notaPedido.cotizacion = cotizacion; | 829 | $scope.notaPedido.cotizacion = cotizacion; |
| 817 | $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; | 830 | $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; |
| 818 | }, function () { | 831 | }, function () { |
| 819 | 832 | ||
| 820 | } | 833 | } |
| 821 | ); | 834 | ); |
| 822 | }; | 835 | }; |
| 823 | 836 | ||
| 824 | function actualizarCabeceraMoneda(cotizacion) { | 837 | function actualizarCabeceraMoneda(cotizacion) { |
| 825 | 838 | ||
| 826 | $scope.notaPedido.articulosNotaPedido.forEach(function (art) { | 839 | $scope.notaPedido.articulosNotaPedido.forEach(function (art) { |
| 827 | art.precio = (art.precio * $scope.notaPedido.cotizacion.VENDEDOR).toFixed(4); | 840 | art.precio = (art.precio * $scope.notaPedido.cotizacion.VENDEDOR).toFixed(4); |
| 828 | art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4); | 841 | art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4); |
| 829 | }); | 842 | }); |
| 830 | 843 | ||
| 831 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { | 844 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { |
| 832 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 845 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
| 833 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 846 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
| 834 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 847 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
| 835 | } else { | 848 | } else { |
| 836 | $scope.$broadcast('addCabecera', { | 849 | $scope.$broadcast('addCabecera', { |
| 837 | label: 'Moneda:', | 850 | label: 'Moneda:', |
| 838 | valor: cotizacion.moneda.DETALLE | 851 | valor: cotizacion.moneda.DETALLE |
| 839 | }); | 852 | }); |
| 840 | $scope.$broadcast('addCabecera', { | 853 | $scope.$broadcast('addCabecera', { |
| 841 | label: 'Fecha cotizacion:', | 854 | label: 'Fecha cotizacion:', |
| 842 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 855 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
| 843 | }); | 856 | }); |
| 844 | $scope.$broadcast('addCabecera', { | 857 | $scope.$broadcast('addCabecera', { |
| 845 | label: 'Cotizacion:', | 858 | label: 'Cotizacion:', |
| 846 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 859 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
| 847 | }); | 860 | }); |
| 848 | } | 861 | } |
| 849 | } | 862 | } |
| 850 | 863 | ||
| 851 | $scope.agregarATabla = function (key) { | 864 | $scope.agregarATabla = function (key) { |
| 852 | if (key === 13) { | 865 | if (key === 13) { |
| 853 | if (!$scope.articuloACargar.cantidad || !$scope.articuloACargar.precio) { | 866 | if (!$scope.articuloACargar.cantidad || !$scope.articuloACargar.precio) { |
| 854 | focaModalService.alert('El valor debe ser al menos 1'); | 867 | focaModalService.alert('El valor debe ser al menos 1'); |
| 855 | return; | 868 | return; |
| 856 | } | 869 | } |
| 857 | delete $scope.articuloACargar.sectorCodigo; | 870 | delete $scope.articuloACargar.sectorCodigo; |
| 858 | $scope.notaPedido.articulosNotaPedido.push($scope.articuloACargar); | 871 | $scope.notaPedido.articulosNotaPedido.push($scope.articuloACargar); |
| 859 | $scope.cargando = true; | 872 | $scope.cargando = true; |
| 860 | } | 873 | } |
| 861 | }; | 874 | }; |
| 862 | 875 | ||
| 863 | $scope.quitarArticulo = function (key) { | 876 | $scope.quitarArticulo = function (key) { |
| 864 | if (validarNotaRemitada()) { | 877 | if (validarNotaRemitada()) { |
| 865 | $scope.notaPedido.articulosNotaPedido.splice(key, 1); | 878 | $scope.notaPedido.articulosNotaPedido.splice(key, 1); |
| 866 | } | 879 | } |
| 867 | }; | 880 | }; |
| 868 | 881 | ||
| 869 | $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) { | 882 | $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) { |
| 870 | if (key === 13) { | 883 | if (key === 13) { |
| 871 | if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) { | 884 | if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) { |
| 872 | focaModalService.alert('Los valores deben ser al menos 1'); | 885 | focaModalService.alert('Los valores deben ser al menos 1'); |
| 873 | return; | 886 | return; |
| 874 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { | 887 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { |
| 875 | focaModalService.alert('Los valores no pueden ser negativos'); | 888 | focaModalService.alert('Los valores no pueden ser negativos'); |
| 876 | return; | 889 | return; |
| 877 | } | 890 | } |
| 878 | articulo.cantidad = tmpCantidad; | 891 | articulo.cantidad = tmpCantidad; |
| 879 | articulo.precio = tmpPrecio; | 892 | articulo.precio = tmpPrecio; |
| 880 | $scope.getTotal(); | 893 | $scope.getTotal(); |
| 881 | articulo.editCantidad = articulo.editPrecio = false; | 894 | articulo.editCantidad = articulo.editPrecio = false; |
| 882 | } | 895 | } |
| 883 | }; | 896 | }; |
| 884 | 897 | ||
| 885 | $scope.cancelarEditar = function (articulo) { | 898 | $scope.cancelarEditar = function (articulo) { |
| 886 | $scope.tmpCantidad = articulo.cantidad; | 899 | $scope.tmpCantidad = articulo.cantidad; |
| 887 | $scope.tmpPrecio = articulo.precio; | 900 | $scope.tmpPrecio = articulo.precio; |
| 888 | articulo.editCantidad = articulo.editPrecio = false; | 901 | articulo.editCantidad = articulo.editPrecio = false; |
| 889 | }; | 902 | }; |
| 890 | 903 | ||
| 891 | $scope.cambioEdit = function (articulo, propiedad) { | 904 | $scope.cambioEdit = function (articulo, propiedad) { |
| 892 | if (propiedad === 'cantidad') { | 905 | if (propiedad === 'cantidad') { |
| 893 | articulo.editCantidad = true; | 906 | articulo.editCantidad = true; |
| 894 | } else if (propiedad === 'precio') { | 907 | } else if (propiedad === 'precio') { |
| 895 | articulo.editPrecio = true; | 908 | articulo.editPrecio = true; |
| 896 | } | 909 | } |
| 897 | }; | 910 | }; |
| 898 | 911 | ||
| 899 | $scope.resetFilter = function () { | 912 | $scope.resetFilter = function () { |
| 900 | $scope.articuloACargar = {}; | 913 | $scope.articuloACargar = {}; |
| 901 | $scope.cargando = true; | 914 | $scope.cargando = true; |
| 902 | }; | 915 | }; |
| 903 | //Recibe aviso si el teclado está en uso | 916 | //Recibe aviso si el teclado está en uso |
| 904 | $rootScope.$on('usarTeclado', function (event, data) { | 917 | $rootScope.$on('usarTeclado', function (event, data) { |
| 905 | if (data) { | 918 | if (data) { |
| 906 | $scope.mostrarTeclado = true; | 919 | $scope.mostrarTeclado = true; |
| 907 | return; | 920 | return; |
| 908 | } | 921 | } |
| 909 | $scope.mostrarTeclado = false; | 922 | $scope.mostrarTeclado = false; |
| 910 | }); | 923 | }); |
| 911 | 924 | ||
| 912 | $scope.selectFocus = function ($event) { | 925 | $scope.selectFocus = function ($event) { |
| 913 | // Si el teclado esta en uso no selecciona el valor | 926 | // Si el teclado esta en uso no selecciona el valor |
| 914 | if ($scope.mostrarTeclado) { | 927 | if ($scope.mostrarTeclado) { |
| 915 | return; | 928 | return; |
| 916 | } | 929 | } |
| 917 | $event.target.select(); | 930 | $event.target.select(); |
| 918 | }; | 931 | }; |
| 919 | 932 | ||
| 920 | $scope.salir = function () { | 933 | $scope.salir = function () { |
| 921 | $location.path('/'); | 934 | $location.path('/'); |
| 922 | }; | 935 | }; |
| 923 | 936 | ||
| 924 | $scope.parsearATexto = function (articulo) { | 937 | $scope.parsearATexto = function (articulo) { |
| 925 | articulo.cantidad = parseFloat(articulo.cantidad); | 938 | articulo.cantidad = parseFloat(articulo.cantidad); |
| 926 | articulo.precio = parseFloat(articulo.precio); | 939 | articulo.precio = parseFloat(articulo.precio); |
| 927 | }; | 940 | }; |
| 928 | 941 | ||
| 929 | // TODO: quitar watch usar función de articulos pedido cuando se haga | 942 | // TODO: quitar watch usar función de articulos pedido cuando se haga |
| 930 | $scope.$watch('notaPedido.articulosNotaPedido', function () { | 943 | $scope.$watch('notaPedido.articulosNotaPedido', function () { |
| 931 | if ($scope.notaPedido.articulosNotaPedido.length) { | 944 | if ($scope.notaPedido.articulosNotaPedido.length) { |
| 932 | $filter('filter')($scope.botonera, | 945 | $filter('filter')($scope.botonera, |
| 933 | { label: 'Productos' })[0].checked = true; | 946 | { label: 'Productos' })[0].checked = true; |
| 934 | } else { | 947 | } else { |
| 935 | $filter('filter')($scope.botonera, | 948 | $filter('filter')($scope.botonera, |
| 936 | { label: 'Productos' })[0].checked = false; | 949 | { label: 'Productos' })[0].checked = false; |
| 937 | } | 950 | } |
| 938 | }, true); | 951 | }, true); |
| 939 | 952 | ||
| 940 | function setearNotaPedido(notaPedido) { | 953 | function setearNotaPedido(notaPedido) { |
| 941 | //añado cabeceras | 954 | //añado cabeceras |
| 942 | $scope.notaPedido = notaPedido; | 955 | $scope.notaPedido = notaPedido; |
| 943 | if (!$scope.notaPedido.domicilio) { | 956 | if (!$scope.notaPedido.domicilio) { |
| 944 | $scope.notaPedido.domicilio = { | 957 | $scope.notaPedido.domicilio = { |
| 945 | id: $scope.notaPedido.idDomicilio | 958 | id: $scope.notaPedido.idDomicilio |
| 946 | }; | 959 | }; |
| 947 | } | 960 | } |
| 948 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 961 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
| 949 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 962 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
| 950 | $scope.$broadcast('cleanCabecera'); | 963 | $scope.$broadcast('cleanCabecera'); |
| 951 | 964 | ||
| 952 | $scope.cabeceras = []; | 965 | $scope.cabeceras = []; |
| 953 | 966 | ||
| 954 | if (notaPedido.cotizacion.moneda.CODIGO_AFIP !== 'PES') { | 967 | if (notaPedido.cotizacion.moneda.CODIGO_AFIP !== 'PES') { |
| 955 | $scope.cabeceras.push({ | 968 | $scope.cabeceras.push({ |
| 956 | label: 'Moneda:', | 969 | label: 'Moneda:', |
| 957 | valor: notaPedido.cotizacion.moneda.DETALLE | 970 | valor: notaPedido.cotizacion.moneda.DETALLE |
| 958 | }); | 971 | }); |
| 959 | $scope.cabeceras.push({ | 972 | $scope.cabeceras.push({ |
| 960 | label: 'Fecha cotizacion:', | 973 | label: 'Fecha cotizacion:', |
| 961 | valor: $filter('date')(notaPedido.cotizacion.FECHA, | 974 | valor: $filter('date')(notaPedido.cotizacion.FECHA, |
| 962 | 'dd/MM/yyyy') | 975 | 'dd/MM/yyyy') |
| 963 | }); | 976 | }); |
| 964 | $scope.cabeceras.push({ | 977 | $scope.cabeceras.push({ |
| 965 | label: 'Cotizacion:', | 978 | label: 'Cotizacion:', |
| 966 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, | 979 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, |
| 967 | '2') | 980 | '2') |
| 968 | }); | 981 | }); |
| 969 | } | 982 | } |
| 970 | 983 | ||
| 971 | if (notaPedido.cotizacion.moneda) { | 984 | if (notaPedido.cotizacion.moneda) { |
| 972 | $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; | 985 | $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; |
| 973 | } | 986 | } |
| 974 | 987 | ||
| 975 | if (notaPedido.vendedor.NUM) { | 988 | if (notaPedido.vendedor.NUM) { |
| 976 | $scope.cabeceras.push({ | 989 | $scope.cabeceras.push({ |
| 977 | label: 'Vendedor:', | 990 | label: 'Vendedor:', |
| 978 | valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + | 991 | valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + |
| 979 | ' - ' + notaPedido.vendedor.NOM | 992 | ' - ' + notaPedido.vendedor.NOM |
| 980 | }); | 993 | }); |
| 981 | } | 994 | } |
| 982 | 995 | ||
| 983 | if (notaPedido.cliente.COD) { | 996 | if (notaPedido.cliente.COD) { |
| 984 | $scope.cabeceras.push({ | 997 | $scope.cabeceras.push({ |
| 985 | label: 'Cliente:', | 998 | label: 'Cliente:', |
| 986 | valor: notaPedido.cliente.NOM | 999 | valor: notaPedido.cliente.NOM |
| 987 | }); | 1000 | }); |
| 988 | $scope.cabeceras.push({ | 1001 | $scope.cabeceras.push({ |
| 989 | label: 'Domicilio:', | 1002 | label: 'Domicilio:', |
| 990 | valor: notaPedido.domicilioStamp | 1003 | valor: notaPedido.domicilioStamp |
| 991 | }); | 1004 | }); |
| 992 | 1005 | ||
| 993 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; | 1006 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; |
| 994 | } | 1007 | } |
| 995 | 1008 | ||
| 996 | if (notaPedido.proveedor.COD) { | 1009 | if (notaPedido.proveedor.COD) { |
| 997 | $scope.cabeceras.push({ | 1010 | $scope.cabeceras.push({ |
| 998 | label: 'Proveedor:', | 1011 | label: 'Proveedor:', |
| 999 | valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) + | 1012 | valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) + |
| 1000 | ' - ' + notaPedido.proveedor.NOM | 1013 | ' - ' + notaPedido.proveedor.NOM |
| 1001 | }); | 1014 | }); |
| 1002 | 1015 | ||
| 1003 | $filter('filter')($scope.botonera, { label: 'Proveedor' })[0].checked = true; | 1016 | $filter('filter')($scope.botonera, { label: 'Proveedor' })[0].checked = true; |
| 1004 | } | 1017 | } |
| 1005 | 1018 | ||
| 1006 | if (notaPedido.notaPedidoPlazo.length) { | 1019 | if (notaPedido.notaPedidoPlazo.length) { |
| 1007 | valorPrecioCondicion(); | 1020 | valorPrecioCondicion(); |
| 1008 | $filter('filter')($scope.botonera, | 1021 | $filter('filter')($scope.botonera, |
| 1009 | { label: 'Precios y condiciones' })[0].checked = true; | 1022 | { label: 'Precios y condiciones' })[0].checked = true; |
| 1010 | } | 1023 | } |
| 1011 | 1024 | ||
| 1012 | if (notaPedido.flete !== undefined) { | 1025 | if (notaPedido.flete !== undefined) { |
| 1013 | $scope.cabeceras.push({ | 1026 | $scope.cabeceras.push({ |
| 1014 | label: 'Flete:', | 1027 | label: 'Flete:', |
| 1015 | valor: notaPedido.fob === 1 ? 'FOB' : ( | 1028 | valor: notaPedido.fob === 1 ? 'FOB' : ( |
| 1016 | notaPedido.flete === 1 ? 'Si' : 'No') | 1029 | notaPedido.flete === 1 ? 'Si' : 'No') |
| 1017 | }); | 1030 | }); |
| 1018 | } | 1031 | } |
| 1019 | 1032 | ||
| 1020 | function valorPrecioCondicion() { | 1033 | function valorPrecioCondicion() { |
| 1021 | if (notaPedido.idListaPrecio > 0) { | 1034 | if (notaPedido.idListaPrecio > 0) { |
| 1022 | crearNotaPedidoService | 1035 | crearNotaPedidoService |
| 1023 | .getPrecioCondicionById(parseInt(notaPedido.idListaPrecio)) | 1036 | .getPrecioCondicionById(parseInt(notaPedido.idListaPrecio)) |
| 1024 | .then(function (res) { | 1037 | .then(function (res) { |
| 1025 | $scope.cabeceras.push({ | 1038 | $scope.cabeceras.push({ |
| 1026 | label: 'Precios y Condiciones:', | 1039 | label: 'Precios y Condiciones:', |
| 1027 | valor: parseInt(res.data[0].ID) + ' - ' + | 1040 | valor: parseInt(res.data[0].ID) + ' - ' + |
| 1028 | res.data[0].DES + ' ' + | 1041 | res.data[0].DES + ' ' + |
| 1029 | notaPedidoBusinessService | 1042 | notaPedidoBusinessService |
| 1030 | .plazoToString(notaPedido.notaPedidoPlazo) | 1043 | .plazoToString(notaPedido.notaPedidoPlazo) |
| 1031 | }); | 1044 | }); |
| 1032 | addArrayCabecera($scope.cabeceras); | 1045 | addArrayCabecera($scope.cabeceras); |
| 1033 | }); | 1046 | }); |
| 1034 | } | 1047 | } |
| 1035 | $scope.idLista = parseInt(notaPedido.idListaPrecio); | 1048 | $scope.idLista = parseInt(notaPedido.idListaPrecio); |
| 1036 | } | 1049 | } |
| 1037 | 1050 | ||
| 1038 | if (notaPedido.flete === 1) { | 1051 | if (notaPedido.flete === 1) { |
| 1039 | var cabeceraBomba = { | 1052 | var cabeceraBomba = { |
| 1040 | label: 'Bomba:', | 1053 | label: 'Bomba:', |
| 1041 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 1054 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
| 1042 | }; | 1055 | }; |
| 1043 | if (notaPedido.kilometros) { | 1056 | if (notaPedido.kilometros) { |
| 1044 | var cabeceraKilometros = { | 1057 | var cabeceraKilometros = { |
| 1045 | label: 'Kilometros:', | 1058 | label: 'Kilometros:', |
| 1046 | valor: notaPedido.kilometros | 1059 | valor: notaPedido.kilometros |
| 1047 | }; | 1060 | }; |
| 1048 | $scope.cabeceras.push(cabeceraKilometros); | 1061 | $scope.cabeceras.push(cabeceraKilometros); |
| 1049 | } | 1062 | } |
| 1050 | $scope.cabeceras.push(cabeceraBomba); | 1063 | $scope.cabeceras.push(cabeceraBomba); |
| 1051 | } | 1064 | } |
| 1052 | 1065 | ||
| 1053 | if (notaPedido.idPrecioCondicion > 0) { | 1066 | if (notaPedido.idPrecioCondicion > 0) { |
| 1054 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | 1067 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; |
| 1055 | } else if (notaPedido.idPrecioCondicion) { | 1068 | } else if (notaPedido.idPrecioCondicion) { |
| 1056 | $scope.idLista = -1; | 1069 | $scope.idLista = -1; |
| 1057 | } | 1070 | } |
| 1058 | 1071 | ||
| 1059 | $scope.puntoVenta = $filter('rellenarDigitos')( | 1072 | $scope.puntoVenta = $filter('rellenarDigitos')( |
| 1060 | notaPedido.sucursal, 4 | 1073 | notaPedido.sucursal, 4 |
| 1061 | ); | 1074 | ); |
| 1062 | 1075 | ||
| 1063 | $scope.comprobante = $filter('rellenarDigitos')( | 1076 | $scope.comprobante = $filter('rellenarDigitos')( |
| 1064 | notaPedido.numeroNotaPedido, 8 | 1077 | notaPedido.numeroNotaPedido, 8 |
| 1065 | ); | 1078 | ); |
| 1066 | 1079 | ||
| 1067 | if (notaPedido.notaPedidoPuntoDescarga.length) { | 1080 | if (notaPedido.notaPedidoPuntoDescarga.length) { |
| 1068 | var puntos = []; | 1081 | var puntos = []; |
| 1069 | notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedidoPuntoDescarga) { | 1082 | notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedidoPuntoDescarga) { |
| 1070 | puntos.push(notaPedidoPuntoDescarga.puntoDescarga); | 1083 | puntos.push(notaPedidoPuntoDescarga.puntoDescarga); |
| 1071 | }); | 1084 | }); |
| 1072 | $scope.cabeceras.push({ | 1085 | $scope.cabeceras.push({ |
| 1073 | label: 'Puntos de descarga: ', | 1086 | label: 'Puntos de descarga: ', |
| 1074 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) | 1087 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) |
| 1075 | }); | 1088 | }); |
| 1076 | } | 1089 | } |
| 1077 | 1090 | ||
| 1078 | addArrayCabecera($scope.cabeceras); | 1091 | addArrayCabecera($scope.cabeceras); |
| 1079 | } | 1092 | } |
| 1080 | 1093 | ||
| 1081 | function getCabeceraPuntoDescarga(puntoDescarga) { | 1094 | function getCabeceraPuntoDescarga(puntoDescarga) { |
| 1082 | var puntosStamp = ''; | 1095 | var puntosStamp = ''; |
| 1083 | puntoDescarga.forEach(function (punto, idx, arr) { | 1096 | puntoDescarga.forEach(function (punto, idx, arr) { |
| 1084 | puntosStamp += punto.descripcion; | 1097 | puntosStamp += punto.descripcion; |
| 1085 | if ((idx + 1) !== arr.length) puntosStamp += ', '; | 1098 | if ((idx + 1) !== arr.length) puntosStamp += ', '; |
| 1086 | }); | 1099 | }); |
| 1087 | return puntosStamp; | 1100 | return puntosStamp; |
| 1088 | } | 1101 | } |
| 1089 | 1102 | ||
| 1090 | function addArrayCabecera(array) { | 1103 | function addArrayCabecera(array) { |
| 1091 | for (var i = 0; i < array.length; i++) { | 1104 | for (var i = 0; i < array.length; i++) { |
| 1092 | $scope.$broadcast('addCabecera', { | 1105 | $scope.$broadcast('addCabecera', { |
| 1093 | label: array[i].label, | 1106 | label: array[i].label, |
| 1094 | valor: array[i].valor | 1107 | valor: array[i].valor |
| 1095 | }); | 1108 | }); |
| 1096 | } | 1109 | } |
| 1097 | } | 1110 | } |
| 1098 | 1111 | ||
| 1099 | function validarNotaRemitada() { | 1112 | function validarNotaRemitada() { |
| 1100 | if (!$scope.notaPedido.idRemito) { | 1113 | if (!$scope.notaPedido.idRemito) { |
| 1101 | return true; | 1114 | return true; |
| 1102 | } else { | 1115 | } else { |
| 1103 | focaModalService.alert('No se puede editar una nota de pedido remitada'); | 1116 | focaModalService.alert('No se puede editar una nota de pedido remitada'); |
| 1104 | return false; | 1117 | return false; |
| 1105 | } | 1118 | } |
| 1106 | } | 1119 | } |
| 1107 | 1120 | ||
| 1121 | function removeItemFromArr ( arr, item ) { | ||
| 1122 | var i = arr.indexOf( item ); | ||
| 1123 | |||
| 1124 | if ( i !== -1 ) { | ||
| 1125 | arr.splice( i, 1 ); | ||
| 1126 | } | ||
| 1127 | } | ||
| 1128 | |||
| 1108 | function salir() { | 1129 | function salir() { |
| 1109 | var confirmacion = false; | 1130 | var confirmacion = false; |
| 1110 | 1131 | ||
| 1111 | if (!angular.equals($scope.notaPedido, $scope.inicial)) { | 1132 | if (!angular.equals($scope.notaPedido, $scope.inicial)) { |
| 1112 | confirmacion = true; | 1133 | confirmacion = true; |
| 1113 | } | 1134 | } |
| 1114 | 1135 | ||
| 1115 | if (confirmacion) { | 1136 | if (confirmacion) { |
| 1116 | focaModalService.confirm( | 1137 | focaModalService.confirm( |
| 1117 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 1138 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
| 1118 | ).then(function (data) { | 1139 | ).then(function (data) { |
| 1119 | if (data) { | 1140 | if (data) { |
| 1120 | $location.path('/'); | 1141 | $location.path('/'); |
| 1142 | var ar = JSON.parse($localStorage.rutas); | ||
| 1143 | |||
| 1144 | removeItemFromArr( ar, 'venta-nota-pedido/crear' ); | ||
| 1145 | $localStorage.rutas = JSON.stringify(ar); | ||
| 1121 | } | 1146 | } |
| 1122 | }); | 1147 | }); |
| 1123 | } else { | 1148 | } else { |
| 1124 | $location.path('/'); | 1149 | $location.path('/'); |
| 1125 | } | 1150 | } |
| 1126 | } | 1151 | } |
| 1127 | 1152 | ||
| 1128 | function getLSNotaPedido() { | 1153 | function getLSNotaPedido() { |
| 1129 | var notaPedido = JSON.parse($localStorage.notaPedido || null); | 1154 | var notaPedido = JSON.parse($localStorage.notaPedido || null); |
| 1130 | if (notaPedido) { | 1155 | if (notaPedido) { |
| 1131 | delete $localStorage.notaPedido; | 1156 | delete $localStorage.notaPedido; |
| 1132 | setearNotaPedido(notaPedido); | 1157 | setearNotaPedido(notaPedido); |
| 1133 | } | 1158 | } |
| 1134 | } | 1159 | } |
| 1135 | 1160 | ||
| 1136 | function deleteCliente() { | 1161 | function deleteCliente() { |
| 1137 | $scope.notaPedido.domicilioStamp = ''; | 1162 | $scope.notaPedido.domicilioStamp = ''; |
| 1138 | $scope.notaPedido.notaPedidoPuntoDescarga = []; | 1163 | $scope.notaPedido.notaPedidoPuntoDescarga = []; |
| 1139 | $scope.notaPedido.domicilio = { dom: '' }; | 1164 | $scope.notaPedido.domicilio = { dom: '' }; |
| 1140 | $scope.notaPedido.cliente = {}; | 1165 | $scope.notaPedido.cliente = {}; |
| 1141 | $scope.$broadcast('removeCabecera', 'Cliente:'); | 1166 | $scope.$broadcast('removeCabecera', 'Cliente:'); |
| 1142 | $scope.$broadcast('removeCabecera', 'Domicilio:'); | 1167 | $scope.$broadcast('removeCabecera', 'Domicilio:'); |
| 1143 | $scope.$broadcast('removeCabecera', 'Puntos de descarga:'); | 1168 | $scope.$broadcast('removeCabecera', 'Puntos de descarga:'); |
| 1144 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = false; | 1169 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = false; |
| 1145 | } | 1170 | } |
| 1146 | } | 1171 | } |
| 1147 | ]); | 1172 | ]); |
| 1148 | 1173 |