Commit 8c656f6b867ab396adae97754778c3e60cfe86d1
Exists in
master
and in
1 other branch
Merge branch 'develop' into 'master'
Develop See merge request !89
Showing
4 changed files
Show diff stats
src/js/businessService.js
| 1 | angular.module('focaCrearNotaPedido') | 1 | angular.module('focaCrearNotaPedido') |
| 2 | .factory('notaPedidoBusinessService', [ | 2 | .factory('notaPedidoBusinessService', [ |
| 3 | 'crearNotaPedidoService', | 3 | 'crearNotaPedidoService', |
| 4 | function(crearNotaPedidoService) { | 4 | function(crearNotaPedidoService) { |
| 5 | return { | 5 | return { |
| 6 | addArticulos: function(articulosNotaPedido, idNotaPedido, cotizacion) { | 6 | addArticulos: function(articulosNotaPedido, idNotaPedido, cotizacion) { |
| 7 | for(var i = 0; i < articulosNotaPedido.length; i++) { | 7 | for(var i = 0; i < articulosNotaPedido.length; i++) { |
| 8 | delete articulosNotaPedido[i].editCantidad; | 8 | delete articulosNotaPedido[i].editCantidad; |
| 9 | delete articulosNotaPedido[i].editPrecio; | 9 | delete articulosNotaPedido[i].editPrecio; |
| 10 | articulosNotaPedido[i].idNotaPedido = idNotaPedido; | 10 | articulosNotaPedido[i].idNotaPedido = idNotaPedido; |
| 11 | articulosNotaPedido[i].precio = articulosNotaPedido[i].precio * cotizacion; | 11 | articulosNotaPedido[i].precio = articulosNotaPedido[i].precio * cotizacion; |
| 12 | crearNotaPedidoService.crearArticulosParaNotaPedido(articulosNotaPedido[i]); | 12 | crearNotaPedidoService.crearArticulosParaNotaPedido(articulosNotaPedido[i]); |
| 13 | } | 13 | } |
| 14 | }, | 14 | }, |
| 15 | addEstado: function(idNotaPedido, idVendedor) { | 15 | addEstado: function(idNotaPedido, idVendedor) { |
| 16 | var date = new Date(); | 16 | var date = new Date(); |
| 17 | var estado = { | 17 | var estado = { |
| 18 | idNotaPedido: idNotaPedido, | 18 | idNotaPedido: idNotaPedido, |
| 19 | fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 19 | fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
| 20 | .toISOString().slice(0, 19).replace('T', ' '), | 20 | .toISOString().slice(0, 19).replace('T', ' '), |
| 21 | estado: 0, | 21 | estado: 0, |
| 22 | idVendedor: idVendedor | 22 | idVendedor: idVendedor |
| 23 | }; | 23 | }; |
| 24 | crearNotaPedidoService.crearEstadoParaNotaPedido(estado); | 24 | crearNotaPedidoService.crearEstadoParaNotaPedido(estado); |
| 25 | }, | 25 | }, |
| 26 | addPuntosDescarga: function(idNotaPedido, puntosDescarga) { | 26 | addPuntosDescarga: function(idNotaPedido, puntosDescarga) { |
| 27 | 27 | ||
| 28 | var puntos = []; | 28 | var puntos = []; |
| 29 | 29 | ||
| 30 | puntosDescarga.forEach(function(punto) { | 30 | puntosDescarga.forEach(function(punto) { |
| 31 | puntos.push({ | 31 | puntos.push({ |
| 32 | idPuntoDescarga: punto.id, | 32 | idPuntoDescarga: punto.puntoDescarga.id, |
| 33 | idNotaPedido: idNotaPedido, | 33 | idNotaPedido: idNotaPedido, |
| 34 | }); | 34 | }); |
| 35 | }); | 35 | }); |
| 36 | 36 | ||
| 37 | return crearNotaPedidoService.crearPuntosDescarga(puntos); | 37 | return crearNotaPedidoService.crearPuntosDescarga(puntos); |
| 38 | }, | 38 | }, |
| 39 | calcularArticulos: function(articulos, cotizacion) { | 39 | calcularArticulos: function(articulos, cotizacion) { |
| 40 | for(var i = 0; i < articulos.length; i++) { | 40 | for(var i = 0; i < articulos.length; i++) { |
| 41 | articulos[i].precio = articulos[i].precio / cotizacion; | 41 | articulos[i].precio = articulos[i].precio / cotizacion; |
| 42 | } | 42 | } |
| 43 | }, | 43 | }, |
| 44 | plazoToString: function(plazos) { | 44 | plazoToString: function(plazos) { |
| 45 | var result = ''; | 45 | var result = ''; |
| 46 | for(var i = 0; i < plazos.length; i++) { | 46 | for(var i = 0; i < plazos.length; i++) { |
| 47 | result += plazos[i].dias + ' '; | 47 | result += plazos[i].dias + ' '; |
| 48 | } | 48 | } |
| 49 | return result.trim(); | 49 | return result.trim(); |
| 50 | } | 50 | } |
| 51 | }; | 51 | }; |
| 52 | }]); | 52 | }]); |
| 53 | 53 |
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 | { | 21 | { |
| 22 | config(); | 22 | config(); |
| 23 | var cotizacionPArgentino = {}; | ||
| 23 | 24 | ||
| 24 | function config() { | 25 | function config() { |
| 25 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA | 26 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA |
| 26 | $scope.tmpCantidad = Number; | 27 | $scope.tmpCantidad = Number; |
| 27 | $scope.tmpPrecio = Number; | 28 | $scope.tmpPrecio = Number; |
| 28 | $scope.notaPedido = {}; | 29 | $scope.notaPedido = {}; |
| 29 | $scope.isNumber = angular.isNumber; | 30 | $scope.isNumber = angular.isNumber; |
| 30 | $scope.datepickerAbierto = false; | 31 | $scope.datepickerAbierto = false; |
| 31 | $scope.show = false; | 32 | $scope.show = false; |
| 32 | $scope.cargando = true; | 33 | $scope.cargando = true; |
| 33 | $scope.botonera = crearNotaPedidoService.getBotonera(); | 34 | $scope.botonera = crearNotaPedidoService.getBotonera(); |
| 34 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); | 35 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
| 35 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); | 36 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
| 36 | $scope.dateOptions = { | 37 | $scope.dateOptions = { |
| 37 | maxDate: new Date(), | 38 | maxDate: new Date(), |
| 38 | minDate: new Date(2010, 0, 1) | 39 | minDate: new Date(2010, 0, 1) |
| 39 | }; | 40 | }; |
| 40 | 41 | ||
| 41 | //SETEO BOTONERA LATERAL | 42 | //SETEO BOTONERA LATERAL |
| 42 | $timeout(function() { | 43 | $timeout(function() { |
| 43 | focaBotoneraLateralService.showSalir(false); | 44 | focaBotoneraLateralService.showSalir(false); |
| 44 | focaBotoneraLateralService.showPausar(true); | 45 | focaBotoneraLateralService.showPausar(true); |
| 45 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); | 46 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); |
| 46 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 47 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
| 47 | }); | 48 | }); |
| 48 | 49 | ||
| 49 | // 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 |
| 50 | if (APP === 'distribuidor') { | 51 | if (APP === 'distribuidor') { |
| 51 | $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; | 52 | $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; |
| 52 | } | 53 | } |
| 53 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | ||
| 54 | //Trabajo con el proveedor YPF, por eso uso siempre la primera | ||
| 55 | |||
| 56 | var promiseMoneda = crearNotaPedidoService.getCotizacionByIdMoneda(1); | ||
| 57 | var promiseProveedor = crearNotaPedidoService.getProveedorById(1); | ||
| 58 | 54 | ||
| 59 | Promise.all([promiseMoneda, promiseProveedor]).then(function(res) { | 55 | crearNotaPedidoService.getParametros().then(function(res) { |
| 60 | var monedaPorDefecto = res[0].data[0]; | 56 | var parametros = JSON.parse(res.data[0].jsonText); |
| 61 | $scope.notaPedido.cotizacion = Object.assign( | 57 | if ($localStorage.notaPedido) { |
| 62 | {moneda: monedaPorDefecto}, | 58 | $timeout(function() { getLSNotaPedido();} ); |
| 63 | monedaPorDefecto.cotizaciones[0] | 59 | } else { |
| 64 | ); | 60 | for (var property in parametros) { |
| 65 | $scope.inicial.cotizacion = $scope.notaPedido.cotizacion; | 61 | $scope.notaPedido[property] = parametros[property]; |
| 66 | var proveedorPorDefecto = res[1].data[0]; | 62 | $scope.inicial[property] = parametros[property]; |
| 67 | $scope.notaPedido.proveedor = Object.assign( | 63 | } |
| 68 | {proveedor: proveedorPorDefecto} | 64 | setearNotaPedido($scope.notaPedido); |
| 69 | ); | 65 | } |
| 70 | $scope.inicial.proveedor = $scope.notaPedido.proveedor; | ||
| 71 | |||
| 72 | $timeout(function() {getLSNotaPedido();}); | ||
| 73 | }); | 66 | }); |
| 74 | 67 | ||
| 75 | init(); | 68 | init(); |
| 76 | 69 | ||
| 77 | } | 70 | } |
| 78 | 71 | ||
| 79 | function init() { | 72 | function init() { |
| 80 | $scope.$broadcast('cleanCabecera'); | 73 | $scope.$broadcast('cleanCabecera'); |
| 81 | 74 | ||
| 82 | $scope.notaPedido = { | 75 | $scope.notaPedido = { |
| 83 | id: 0, | 76 | id: 0, |
| 84 | cliente: {}, | 77 | cliente: {}, |
| 85 | proveedor: {}, | 78 | proveedor: {}, |
| 86 | domicilio: {dom: ''}, | 79 | domicilio: {dom: ''}, |
| 87 | vendedor: {}, | 80 | vendedor: {}, |
| 88 | fechaCarga: new Date(), | 81 | fechaCarga: new Date(), |
| 89 | cotizacion: {}, | 82 | cotizacion: {}, |
| 90 | articulosNotaPedido: [], | 83 | articulosNotaPedido: [], |
| 91 | notaPedidoPlazo: [], | 84 | notaPedidoPlazo: [], |
| 92 | notaPedidoPuntoDescarga: { | 85 | notaPedidoPuntoDescarga: [] |
| 93 | puntoDescarga: {} | ||
| 94 | } | ||
| 95 | }; | 86 | }; |
| 96 | $scope.idLista = undefined; | 87 | $scope.idLista = undefined; |
| 97 | 88 | ||
| 98 | crearNotaPedidoService.getNumeroNotaPedido().then( | 89 | crearNotaPedidoService.getNumeroNotaPedido().then( |
| 99 | function(res) { | 90 | function(res) { |
| 100 | $scope.puntoVenta = $filter('rellenarDigitos')( | 91 | $scope.puntoVenta = $filter('rellenarDigitos')( |
| 101 | res.data.sucursal, 4 | 92 | res.data.sucursal, 4 |
| 102 | ); | 93 | ); |
| 103 | 94 | ||
| 104 | $scope.comprobante = $filter('rellenarDigitos')( | 95 | $scope.comprobante = $filter('rellenarDigitos')( |
| 105 | res.data.numeroNotaPedido, 8 | 96 | res.data.numeroNotaPedido, 8 |
| 106 | ); | 97 | ); |
| 107 | }, | 98 | }, |
| 108 | function(err) { | 99 | function(err) { |
| 109 | focaModalService.alert('La terminal no esta configurada correctamente'); | 100 | focaModalService.alert('La terminal no esta configurada correctamente'); |
| 110 | console.info(err); | 101 | console.info(err); |
| 111 | } | 102 | } |
| 112 | ); | 103 | ); |
| 113 | 104 | ||
| 114 | if (APP === 'distribuidor') { | 105 | if (APP === 'distribuidor') { |
| 115 | crearNotaPedidoService.getVendedorById($scope.idVendedor).then( | 106 | crearNotaPedidoService.getVendedorById($scope.idVendedor).then( |
| 116 | function(res) { | 107 | function(res) { |
| 117 | var vendedor = res.data; | 108 | var vendedor = res.data; |
| 118 | $scope.$broadcast('addCabecera', { | 109 | $scope.$broadcast('addCabecera', { |
| 119 | label: 'Vendedor:', | 110 | label: 'Vendedor:', |
| 120 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 111 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
| 121 | vendedor.NOM | 112 | vendedor.NOM |
| 122 | }); | 113 | }); |
| 123 | 114 | ||
| 124 | $scope.notaPedido.vendedor = vendedor; | 115 | $scope.notaPedido.vendedor = vendedor; |
| 116 | $scope.inicial.vendedor = $scope.notaPedido.vendedor; | ||
| 125 | } | 117 | } |
| 126 | ); | 118 | ); |
| 127 | } | 119 | } |
| 128 | 120 | ||
| 129 | $scope.inicial = angular.copy($scope.notaPedido); | 121 | $scope.inicial = angular.copy($scope.notaPedido); |
| 130 | } | 122 | } |
| 131 | 123 | ||
| 132 | $scope.$watch('notaPedido', function(newValue) { | 124 | $scope.$watch('notaPedido', function(newValue) { |
| 133 | focaBotoneraLateralService.setPausarData({ | 125 | focaBotoneraLateralService.setPausarData({ |
| 134 | label: 'notaPedido', | 126 | label: 'notaPedido', |
| 135 | val: newValue | 127 | val: newValue |
| 136 | }); | 128 | }); |
| 137 | }, true); | 129 | }, true); |
| 138 | 130 | ||
| 139 | $scope.crearNotaPedido = function() { | 131 | $scope.crearNotaPedido = function() { |
| 140 | if (!$scope.notaPedido.cliente.COD) { | 132 | if (!$scope.notaPedido.cliente.COD) { |
| 141 | focaModalService.alert('Ingrese Cliente'); | 133 | focaModalService.alert('Ingrese Cliente'); |
| 142 | return; | 134 | return; |
| 143 | } else if ($scope.notaPedido.idRemito === -1) { | 135 | } else if ($scope.notaPedido.idRemito === -1) { |
| 144 | focaBotoneraLateralService.alert('No se puede modificar esta nota de pedido'); | 136 | focaBotoneraLateralService.alert('No se puede modificar esta nota de pedido'); |
| 145 | return; | 137 | return; |
| 146 | } else if (!$scope.notaPedido.proveedor.COD) { | 138 | } else if (!$scope.notaPedido.proveedor.COD) { |
| 147 | focaModalService.alert('Ingrese Proveedor'); | 139 | focaModalService.alert('Ingrese Proveedor'); |
| 148 | return; | 140 | return; |
| 149 | } else if (!$scope.notaPedido.cotizacion.ID) { | 141 | } else if (!$scope.notaPedido.cotizacion.ID) { |
| 150 | focaModalService.alert('Ingrese Cotización'); | 142 | focaModalService.alert('Ingrese Cotización'); |
| 151 | return; | 143 | return; |
| 152 | } else if (!$scope.notaPedido.cotizacion.moneda.ID) { | 144 | } else if (!$scope.notaPedido.cotizacion.moneda.ID) { |
| 153 | focaModalService.alert('Ingrese Moneda'); | 145 | focaModalService.alert('Ingrese Moneda'); |
| 154 | return; | 146 | return; |
| 155 | } else if (!$scope.notaPedido.notaPedidoPlazo) { | 147 | } else if (!$scope.notaPedido.notaPedidoPlazo) { |
| 156 | focaModalService.alert('Ingrese Precios y Condiciones'); | 148 | focaModalService.alert('Ingrese Precios y Condiciones'); |
| 157 | return; | 149 | return; |
| 158 | } else if ( | 150 | } else if ( |
| 159 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) | 151 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) |
| 160 | { | 152 | { |
| 161 | focaModalService.alert('Ingrese Flete'); | 153 | focaModalService.alert('Ingrese Flete'); |
| 162 | return; | 154 | return; |
| 163 | } else if (!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto | 155 | } else if (!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto |
| 164 | focaModalService.alert('Ingrese Domicilio'); | 156 | focaModalService.alert('Ingrese Domicilio'); |
| 165 | return; | 157 | return; |
| 166 | } else if ($scope.notaPedido.articulosNotaPedido.length === 0) { | 158 | } else if ($scope.notaPedido.articulosNotaPedido.length === 0) { |
| 167 | focaModalService.alert('Debe cargar al menos un articulo'); | 159 | focaModalService.alert('Debe cargar al menos un articulo'); |
| 168 | return; | 160 | return; |
| 169 | } | 161 | } |
| 170 | 162 | ||
| 171 | focaBotoneraLateralService.startGuardar(); | 163 | focaBotoneraLateralService.startGuardar(); |
| 172 | $scope.saveLoading = true; | 164 | $scope.saveLoading = true; |
| 173 | var notaPedido = { | 165 | var notaPedido = { |
| 174 | id: $scope.notaPedido.id, | 166 | id: $scope.notaPedido.id, |
| 175 | fechaCarga: new Date($scope.notaPedido.fechaCarga) | 167 | fechaCarga: new Date($scope.notaPedido.fechaCarga) |
| 176 | .toISOString().slice(0, 19).replace('T', ' '), | 168 | .toISOString().slice(0, 19).replace('T', ' '), |
| 177 | idVendedor: $scope.notaPedido.vendedor.id, | 169 | idVendedor: $scope.notaPedido.vendedor.id, |
| 178 | idCliente: $scope.notaPedido.cliente.COD, | 170 | idCliente: $scope.notaPedido.cliente.COD, |
| 179 | nombreCliente: $scope.notaPedido.cliente.NOM, | 171 | nombreCliente: $scope.notaPedido.cliente.NOM, |
| 180 | cuitCliente: $scope.notaPedido.cliente.CUIT, | 172 | cuitCliente: $scope.notaPedido.cliente.CUIT, |
| 181 | idProveedor: $scope.notaPedido.proveedor.COD, | 173 | idProveedor: $scope.notaPedido.proveedor.COD, |
| 182 | idDomicilio: $scope.notaPedido.domicilio.id, | 174 | idDomicilio: $scope.notaPedido.domicilio.id, |
| 183 | idCotizacion: $scope.notaPedido.cotizacion.ID, | 175 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
| 184 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, | 176 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, |
| 185 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 177 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
| 186 | flete: $scope.notaPedido.flete, | 178 | flete: $scope.notaPedido.flete, |
| 187 | fob: $scope.notaPedido.fob, | 179 | fob: $scope.notaPedido.fob, |
| 188 | bomba: $scope.notaPedido.bomba, | 180 | bomba: $scope.notaPedido.bomba, |
| 189 | kilometros: $scope.notaPedido.kilometros, | 181 | kilometros: $scope.notaPedido.kilometros, |
| 190 | domicilioStamp: $scope.notaPedido.domicilioStamp, | 182 | domicilioStamp: $scope.notaPedido.domicilioStamp, |
| 191 | observaciones: $scope.notaPedido.observaciones, | 183 | observaciones: $scope.notaPedido.observaciones, |
| 192 | estado: 0, | 184 | estado: 0, |
| 193 | total: $scope.getTotal() | 185 | total: $scope.getTotal() |
| 194 | }; | 186 | }; |
| 195 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 187 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
| 196 | function(data) { | 188 | function(data) { |
| 197 | // Al guardar los datos de la nota de pedido logueamos la | 189 | // Al guardar los datos de la nota de pedido logueamos la |
| 198 | // actividad para su seguimiento. | 190 | // actividad para su seguimiento. |
| 199 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? | 191 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? |
| 200 | focaSeguimientoService.guardarPosicion( | 192 | focaSeguimientoService.guardarPosicion( |
| 201 | 'Nota de pedido', | 193 | 'Nota de pedido', |
| 202 | data.data.id, | 194 | data.data.id, |
| 203 | '' | 195 | '' |
| 204 | ); | 196 | ); |
| 205 | notaPedidoBusinessService.addArticulos( | 197 | notaPedidoBusinessService.addArticulos( |
| 206 | $scope.notaPedido.articulosNotaPedido, | 198 | $scope.notaPedido.articulosNotaPedido, |
| 207 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); | 199 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); |
| 208 | 200 | ||
| 209 | if ($scope.notaPedido.notaPedidoPuntoDescarga) { | 201 | if ($scope.notaPedido.notaPedidoPuntoDescarga) { |
| 210 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, | 202 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, |
| 211 | $scope.notaPedido.notaPedidoPuntoDescarga); | 203 | $scope.notaPedido.notaPedidoPuntoDescarga); |
| 212 | } | 204 | } |
| 213 | 205 | ||
| 214 | var plazos = $scope.notaPedido.notaPedidoPlazo; | 206 | var plazos = $scope.notaPedido.notaPedidoPlazo; |
| 215 | var plazosACrear = []; | 207 | var plazosACrear = []; |
| 216 | plazos.forEach(function(plazo) { | 208 | plazos.forEach(function(plazo) { |
| 217 | plazosACrear.push({ | 209 | plazosACrear.push({ |
| 218 | idNotaPedido: data.data.id, | 210 | idNotaPedido: data.data.id, |
| 219 | dias: plazo.dias | 211 | dias: plazo.dias |
| 220 | }); | 212 | }); |
| 221 | }); | 213 | }); |
| 222 | 214 | ||
| 223 | if (plazosACrear.length) { | 215 | if (plazosACrear.length) { |
| 224 | crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); | 216 | crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); |
| 225 | } | 217 | } |
| 226 | 218 | ||
| 227 | notaPedidoBusinessService.addEstado(data.data.id, | 219 | notaPedidoBusinessService.addEstado(data.data.id, |
| 228 | $scope.notaPedido.vendedor.id); | 220 | $scope.notaPedido.vendedor.id); |
| 229 | 221 | ||
| 230 | focaBotoneraLateralService.endGuardar(true); | 222 | focaBotoneraLateralService.endGuardar(true); |
| 231 | $scope.saveLoading = false; | 223 | $scope.saveLoading = false; |
| 232 | 224 | ||
| 233 | init(); | 225 | config(); |
| 234 | }, function(error) { | 226 | }, function(error) { |
| 235 | focaModalService.alert('Hubo un error al crear la nota de pedido'); | 227 | focaModalService.alert('Hubo un error al crear la nota de pedido'); |
| 236 | focaBotoneraLateralService.endGuardar(); | 228 | focaBotoneraLateralService.endGuardar(); |
| 237 | $scope.saveLoading = false; | 229 | $scope.saveLoading = false; |
| 238 | console.info(error); | 230 | console.info(error); |
| 239 | }); | 231 | }); |
| 240 | }; | 232 | }; |
| 241 | 233 | ||
| 242 | $scope.seleccionarNotaPedido = function() { | 234 | $scope.seleccionarNotaPedido = function() { |
| 243 | var modalInstance = $uibModal.open( | 235 | var modalInstance = $uibModal.open( |
| 244 | { | 236 | { |
| 245 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 237 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
| 246 | templateUrl: 'foca-modal-nota-pedido.html', | 238 | templateUrl: 'foca-modal-nota-pedido.html', |
| 247 | controller: 'focaModalNotaPedidoController', | 239 | controller: 'focaModalNotaPedidoController', |
| 248 | size: 'lg', | 240 | size: 'lg', |
| 249 | resolve: { | 241 | resolve: { |
| 250 | usadoPor: function() {return 'notaPedido';}, | 242 | usadoPor: function() {return 'notaPedido';}, |
| 251 | idVendedor: function() { | 243 | idVendedor: function() { |
| 252 | if (APP === 'distribuidor') | 244 | if (APP === 'distribuidor') |
| 253 | return $scope.notaPedido.vendedor.id; | 245 | return $scope.notaPedido.vendedor.id; |
| 254 | else | 246 | else |
| 255 | return null; | 247 | return null; |
| 256 | } | 248 | } |
| 257 | } | 249 | } |
| 258 | } | 250 | } |
| 259 | ); | 251 | ); |
| 260 | modalInstance.result.then(setearNotaPedido); | 252 | modalInstance.result.then(setearNotaPedido); |
| 261 | }; | 253 | }; |
| 262 | 254 | ||
| 263 | $scope.seleccionarProductos = function() { | 255 | $scope.seleccionarProductos = function() { |
| 264 | if ($scope.idLista === undefined) { | 256 | if ($scope.idLista === undefined) { |
| 265 | focaModalService.alert( | 257 | focaModalService.alert( |
| 266 | 'Primero seleccione una lista de precio y condicion'); | 258 | 'Primero seleccione una lista de precio y condicion'); |
| 267 | return; | 259 | return; |
| 268 | } | 260 | } |
| 269 | var modalInstance = $uibModal.open( | 261 | var modalInstance = $uibModal.open( |
| 270 | { | 262 | { |
| 271 | ariaLabelledBy: 'Busqueda de Productos', | 263 | ariaLabelledBy: 'Busqueda de Productos', |
| 272 | templateUrl: 'modal-busqueda-productos.html', | 264 | templateUrl: 'modal-busqueda-productos.html', |
| 273 | controller: 'modalBusquedaProductosCtrl', | 265 | controller: 'modalBusquedaProductosCtrl', |
| 274 | resolve: { | 266 | resolve: { |
| 275 | parametroProducto: { | 267 | parametroProducto: { |
| 276 | idLista: $scope.idLista, | 268 | idLista: $scope.idLista, |
| 277 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 269 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
| 278 | simbolo: $scope.notaPedido.cotizacion.moneda.SIMBOLO | 270 | simbolo: $scope.notaPedido.cotizacion.moneda.SIMBOLO |
| 279 | } | 271 | } |
| 280 | }, | 272 | }, |
| 281 | size: 'lg' | 273 | size: 'lg' |
| 282 | } | 274 | } |
| 283 | ); | 275 | ); |
| 284 | modalInstance.result.then( | 276 | modalInstance.result.then( |
| 285 | function(producto) { | 277 | function(producto) { |
| 286 | var newArt = | 278 | var newArt = |
| 287 | { | 279 | { |
| 288 | id: 0, | 280 | id: 0, |
| 289 | codigo: producto.codigo, | 281 | codigo: producto.codigo, |
| 290 | sector: producto.sector, | 282 | sector: producto.sector, |
| 291 | sectorCodigo: producto.sector + '-' + producto.codigo, | 283 | sectorCodigo: producto.sector + '-' + producto.codigo, |
| 292 | descripcion: producto.descripcion, | 284 | descripcion: producto.descripcion, |
| 293 | item: $scope.notaPedido.articulosNotaPedido.length + 1, | 285 | item: $scope.notaPedido.articulosNotaPedido.length + 1, |
| 294 | nombre: producto.descripcion, | 286 | nombre: producto.descripcion, |
| 295 | precio: parseFloat(producto.precio.toFixed(4)), | 287 | precio: parseFloat(producto.precio.toFixed(4)), |
| 296 | costoUnitario: producto.costo, | 288 | costoUnitario: producto.costo, |
| 297 | editCantidad: false, | 289 | editCantidad: false, |
| 298 | editPrecio: false, | 290 | editPrecio: false, |
| 299 | rubro: producto.CodRub, | 291 | rubro: producto.CodRub, |
| 300 | exentoUnitario: producto.precio, | ||
| 301 | ivaUnitario: producto.IMPIVA, | 292 | ivaUnitario: producto.IMPIVA, |
| 302 | impuestoInternoUnitario: producto.ImpInt, | 293 | impuestoInternoUnitario: producto.ImpInt, |
| 303 | impuestoInterno1Unitario: producto.ImpInt2, | 294 | impuestoInterno1Unitario: producto.ImpInt2, |
| 304 | impuestoInterno2Unitario: producto.ImpInt3, | 295 | impuestoInterno2Unitario: producto.ImpInt3, |
| 305 | precioLista: producto.precio, | 296 | precioLista: producto.precio, |
| 306 | combustible: 1, | 297 | combustible: 1, |
| 307 | facturado: 0, | 298 | facturado: 0, |
| 308 | idArticulo: producto.id | 299 | idArticulo: producto.id, |
| 300 | tasaIva: producto.tasaIVA | ||
| 309 | }; | 301 | }; |
| 302 | |||
| 303 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : producto.neto; | ||
| 304 | newArt.netoUnitario = newArt.ivaUnitario ? producto.neto : 0; | ||
| 305 | |||
| 310 | $scope.articuloACargar = newArt; | 306 | $scope.articuloACargar = newArt; |
| 311 | $scope.cargando = false; | 307 | $scope.cargando = false; |
| 312 | }, function() { | 308 | }, function() { |
| 313 | // funcion ejecutada cuando se cancela el modal | 309 | // funcion ejecutada cuando se cancela el modal |
| 314 | } | 310 | } |
| 315 | ); | 311 | ); |
| 316 | }; | 312 | }; |
| 317 | 313 | ||
| 318 | $scope.seleccionarPuntosDeDescarga = function() { | 314 | $scope.seleccionarPuntosDeDescarga = function() { |
| 319 | if (!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { | 315 | if (!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { |
| 320 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 316 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
| 321 | return; | 317 | return; |
| 322 | } else { | 318 | } else { |
| 323 | var modalInstance = $uibModal.open( | 319 | var modalInstance = $uibModal.open( |
| 324 | { | 320 | { |
| 325 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', | 321 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
| 326 | templateUrl: 'modal-punto-descarga.html', | 322 | templateUrl: 'modal-punto-descarga.html', |
| 327 | controller: 'focaModalPuntoDescargaController', | 323 | controller: 'focaModalPuntoDescargaController', |
| 328 | size: 'lg', | 324 | size: 'lg', |
| 329 | resolve: { | 325 | resolve: { |
| 330 | filters: { | 326 | filters: { |
| 331 | idDomicilio: $scope.notaPedido.domicilio.id, | 327 | idDomicilio: $scope.notaPedido.domicilio.id, |
| 332 | idCliente: $scope.notaPedido.cliente.COD, | 328 | idCliente: $scope.notaPedido.cliente.COD, |
| 333 | articulos: $scope.notaPedido.articulosNotaPedido, | 329 | articulos: $scope.notaPedido.articulosNotaPedido, |
| 334 | puntoDescarga: $scope.notaPedido.notaPedidoPuntoDescarga, | 330 | puntoDescarga: $scope.notaPedido.notaPedidoPuntoDescarga, |
| 335 | domicilio: $scope.notaPedido.domicilio | 331 | domicilio: $scope.notaPedido.domicilio |
| 336 | } | 332 | } |
| 337 | } | 333 | } |
| 338 | } | 334 | } |
| 339 | ); | 335 | ); |
| 340 | modalInstance.result.then( | 336 | modalInstance.result.then( |
| 341 | function(puntoDescarga) { | 337 | function(puntoDescarga) { |
| 342 | $scope.notaPedido.notaPedidoPuntoDescarga = puntoDescarga; | 338 | |
| 339 | puntoDescarga.forEach(function(punto) { | ||
| 340 | $scope.notaPedido.notaPedidoPuntoDescarga.push( | ||
| 341 | { | ||
| 342 | puntoDescarga: punto | ||
| 343 | } | ||
| 344 | ) | ||
| 345 | }); | ||
| 343 | 346 | ||
| 344 | $scope.$broadcast('addCabecera', { | 347 | $scope.$broadcast('addCabecera', { |
| 345 | label: 'Puntos de descarga:', | 348 | label: 'Puntos de descarga:', |
| 346 | valor: getCabeceraPuntoDescarga(puntoDescarga) | 349 | valor: getCabeceraPuntoDescarga(puntoDescarga) |
| 347 | }); | 350 | }); |
| 348 | }, function() { | 351 | }, function() { |
| 349 | $scope.abrirModalDomicilios($scope.cliente); | 352 | $scope.abrirModalDomicilios($scope.cliente); |
| 350 | } | 353 | } |
| 351 | ); | 354 | ); |
| 352 | } | 355 | } |
| 353 | }; | 356 | }; |
| 354 | 357 | ||
| 355 | $scope.seleccionarProveedor = function() { | 358 | $scope.seleccionarProveedor = function() { |
| 356 | $scope.abrirModalProveedores(function() { | 359 | $scope.abrirModalProveedores(function() { |
| 357 | if (validarNotaRemitada()) { | 360 | if (validarNotaRemitada()) { |
| 358 | var modalInstance = $uibModal.open( | 361 | var modalInstance = $uibModal.open( |
| 359 | { | 362 | { |
| 360 | ariaLabelledBy: 'Busqueda de Flete', | 363 | ariaLabelledBy: 'Busqueda de Flete', |
| 361 | templateUrl: 'modal-flete.html', | 364 | templateUrl: 'modal-flete.html', |
| 362 | controller: 'focaModalFleteController', | 365 | controller: 'focaModalFleteController', |
| 363 | size: 'lg', | 366 | size: 'lg', |
| 364 | resolve: { | 367 | resolve: { |
| 365 | parametrosFlete: | 368 | parametrosFlete: |
| 366 | function() { | 369 | function() { |
| 367 | return { | 370 | return { |
| 368 | flete: $scope.notaPedido.fob ? 'FOB' : | 371 | flete: $scope.notaPedido.fob ? 'FOB' : |
| 369 | ( $scope.notaPedido.flete ? '1' : | 372 | ( $scope.notaPedido.flete ? '1' : |
| 370 | ($scope.notaPedido.flete === undefined ? | 373 | ($scope.notaPedido.flete === undefined ? |
| 371 | null : '0')), | 374 | null : '0')), |
| 372 | bomba: $scope.notaPedido.bomba ? '1' : | 375 | bomba: $scope.notaPedido.bomba ? '1' : |
| 373 | ($scope.notaPedido.bomba === undefined ? | 376 | ($scope.notaPedido.bomba === undefined ? |
| 374 | null : '0'), | 377 | null : '0'), |
| 375 | kilometros: $scope.notaPedido.kilometros | 378 | kilometros: $scope.notaPedido.kilometros |
| 376 | }; | 379 | }; |
| 377 | } | 380 | } |
| 378 | } | 381 | } |
| 379 | } | 382 | } |
| 380 | ); | 383 | ); |
| 381 | modalInstance.result.then( | 384 | modalInstance.result.then( |
| 382 | function(datos) { | 385 | function(datos) { |
| 383 | $scope.notaPedido.flete = datos.flete; | 386 | $scope.notaPedido.flete = datos.flete; |
| 384 | $scope.notaPedido.fob = datos.FOB; | 387 | $scope.notaPedido.fob = datos.FOB; |
| 385 | $scope.notaPedido.bomba = datos.bomba; | 388 | $scope.notaPedido.bomba = datos.bomba; |
| 386 | $scope.notaPedido.kilometros = datos.kilometros; | 389 | $scope.notaPedido.kilometros = datos.kilometros; |
| 387 | $scope.$broadcast('addCabecera', { | 390 | $scope.$broadcast('addCabecera', { |
| 388 | label: 'Flete:', | 391 | label: 'Flete:', |
| 389 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') | 392 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') |
| 390 | }); | 393 | }); |
| 391 | if (datos.flete) { | 394 | if (datos.flete) { |
| 392 | $scope.$broadcast('addCabecera', { | 395 | $scope.$broadcast('addCabecera', { |
| 393 | label: 'Bomba:', | 396 | label: 'Bomba:', |
| 394 | valor: datos.bomba ? 'Si' : 'No' | 397 | valor: datos.bomba ? 'Si' : 'No' |
| 395 | }); | 398 | }); |
| 396 | $scope.$broadcast('addCabecera', { | 399 | $scope.$broadcast('addCabecera', { |
| 397 | label: 'Kilometros:', | 400 | label: 'Kilometros:', |
| 398 | valor: datos.kilometros | 401 | valor: datos.kilometros |
| 399 | }); | 402 | }); |
| 400 | } else { | 403 | } else { |
| 401 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 404 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
| 402 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 405 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
| 403 | $scope.notaPedido.bomba = false; | 406 | $scope.notaPedido.bomba = false; |
| 404 | $scope.notaPedido.kilometros = null; | 407 | $scope.notaPedido.kilometros = null; |
| 405 | } | 408 | } |
| 409 | |||
| 410 | $filter('filter')($scope.botonera, | ||
| 411 | { label: 'Proveedor'})[0].checked = true; | ||
| 406 | }, function() { | 412 | }, function() { |
| 407 | $scope.seleccionarTransportista(); | 413 | $scope.seleccionarTransportista(); |
| 408 | } | 414 | } |
| 409 | ); | 415 | ); |
| 410 | } | 416 | } |
| 411 | }); | 417 | }); |
| 412 | }; | 418 | }; |
| 413 | 419 | ||
| 414 | $scope.seleccionarVendedor = function(callback, ocultarVendedor) { | 420 | $scope.seleccionarVendedor = function(callback, ocultarVendedor) { |
| 415 | if (APP === 'distribuidor' || ocultarVendedor) { | 421 | if (APP === 'distribuidor' || ocultarVendedor) { |
| 416 | callback(); | 422 | callback(); |
| 417 | return; | 423 | return; |
| 418 | } | 424 | } |
| 419 | 425 | ||
| 420 | if (validarNotaRemitada()) { | 426 | if (validarNotaRemitada()) { |
| 421 | var parametrosModal = { | 427 | var parametrosModal = { |
| 422 | titulo: 'Búsqueda vendedores', | 428 | titulo: 'Búsqueda vendedores', |
| 423 | query: '/vendedor', | 429 | query: '/vendedor', |
| 424 | columnas: [ | 430 | columnas: [ |
| 425 | { | 431 | { |
| 426 | propiedad: 'NUM', | 432 | propiedad: 'NUM', |
| 427 | nombre: 'Código', | 433 | nombre: 'Código', |
| 428 | filtro: { | 434 | filtro: { |
| 429 | nombre: 'rellenarDigitos', | 435 | nombre: 'rellenarDigitos', |
| 430 | parametro: 3 | 436 | parametro: 3 |
| 431 | } | 437 | } |
| 432 | }, | 438 | }, |
| 433 | { | 439 | { |
| 434 | propiedad: 'NOM', | 440 | propiedad: 'NOM', |
| 435 | nombre: 'Nombre' | 441 | nombre: 'Nombre' |
| 436 | } | 442 | } |
| 437 | ], | 443 | ], |
| 438 | size: 'md' | 444 | size: 'md' |
| 439 | }; | 445 | }; |
| 440 | focaModalService.modal(parametrosModal).then( | 446 | focaModalService.modal(parametrosModal).then( |
| 441 | function(vendedor) { | 447 | function(vendedor) { |
| 442 | $scope.$broadcast('addCabecera', { | 448 | $scope.$broadcast('addCabecera', { |
| 443 | label: 'Vendedor:', | 449 | label: 'Vendedor:', |
| 444 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 450 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
| 445 | vendedor.NOM | 451 | vendedor.NOM |
| 446 | }); | 452 | }); |
| 447 | $scope.notaPedido.vendedor = vendedor; | 453 | $scope.notaPedido.vendedor = vendedor; |
| 448 | deleteCliente(); | 454 | deleteCliente(); |
| 449 | callback(); | 455 | callback(); |
| 450 | }, function() {} | 456 | }, function() {} |
| 451 | ); | 457 | ); |
| 452 | } | 458 | } |
| 453 | }; | 459 | }; |
| 454 | 460 | ||
| 455 | $scope.seleccionarCliente = function(ocultarVendedor) { | 461 | $scope.seleccionarCliente = function(ocultarVendedor) { |
| 456 | $scope.seleccionarVendedor(function() { | 462 | $scope.seleccionarVendedor(function() { |
| 457 | if (validarNotaRemitada()) { | 463 | if (validarNotaRemitada()) { |
| 458 | var modalInstance = $uibModal.open( | 464 | var modalInstance = $uibModal.open( |
| 459 | { | 465 | { |
| 460 | ariaLabelledBy: 'Busqueda de Cliente', | 466 | ariaLabelledBy: 'Busqueda de Cliente', |
| 461 | templateUrl: 'foca-busqueda-cliente-modal.html', | 467 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 462 | controller: 'focaBusquedaClienteModalController', | 468 | controller: 'focaBusquedaClienteModalController', |
| 463 | resolve: { | 469 | resolve: { |
| 464 | vendedor: function() { return $scope.notaPedido.vendedor; }, | 470 | vendedor: function() { return $scope.notaPedido.vendedor; }, |
| 465 | cobrador: function() { return null; } | 471 | cobrador: function() { return null; } |
| 466 | }, | 472 | }, |
| 467 | size: 'lg' | 473 | size: 'lg' |
| 468 | } | 474 | } |
| 469 | ); | 475 | ); |
| 470 | modalInstance.result.then( | 476 | modalInstance.result.then( |
| 471 | function(cliente) { | 477 | function(cliente) { |
| 472 | $scope.abrirModalDomicilios(cliente); | 478 | $scope.abrirModalDomicilios(cliente); |
| 473 | $scope.cliente = cliente; | 479 | $scope.cliente = cliente; |
| 474 | }, function() { | 480 | }, function() { |
| 475 | if (APP !== 'distribuidor') $scope.seleccionarCliente(); | 481 | if (APP !== 'distribuidor') $scope.seleccionarCliente(); |
| 476 | } | 482 | } |
| 477 | ); | 483 | ); |
| 478 | } | 484 | } |
| 479 | }, ocultarVendedor); | 485 | }, ocultarVendedor); |
| 480 | }; | 486 | }; |
| 481 | 487 | ||
| 482 | $scope.abrirModalProveedores = function(callback) { | 488 | $scope.abrirModalProveedores = function(callback) { |
| 483 | if (validarNotaRemitada()) { | 489 | if (validarNotaRemitada()) { |
| 484 | var parametrosModal = { | 490 | var parametrosModal = { |
| 485 | titulo: 'Búsqueda de Proveedor', | 491 | titulo: 'Búsqueda de Proveedor', |
| 486 | query: '/proveedor', | 492 | query: '/proveedor', |
| 487 | columnas: [ | 493 | columnas: [ |
| 488 | { | 494 | { |
| 489 | nombre: 'Código', | 495 | nombre: 'Código', |
| 490 | propiedad: 'COD', | 496 | propiedad: 'COD', |
| 491 | filtro: { | 497 | filtro: { |
| 492 | nombre: 'rellenarDigitos', | 498 | nombre: 'rellenarDigitos', |
| 493 | parametro: 5 | 499 | parametro: 5 |
| 494 | } | 500 | } |
| 495 | }, | 501 | }, |
| 496 | { | 502 | { |
| 497 | nombre: 'Nombre', | 503 | nombre: 'Nombre', |
| 498 | propiedad: 'NOM' | 504 | propiedad: 'NOM' |
| 499 | }, | 505 | }, |
| 500 | { | 506 | { |
| 501 | nombre: 'CUIT', | 507 | nombre: 'CUIT', |
| 502 | propiedad: 'CUIT' | 508 | propiedad: 'CUIT' |
| 503 | } | 509 | } |
| 504 | ], | 510 | ], |
| 505 | tipo: 'POST', | 511 | tipo: 'POST', |
| 506 | json: {razonCuitCod: ''} | 512 | json: {razonCuitCod: ''} |
| 507 | }; | 513 | }; |
| 508 | focaModalService.modal(parametrosModal).then( | 514 | focaModalService.modal(parametrosModal).then( |
| 509 | function(proveedor) { | 515 | function(proveedor) { |
| 510 | $scope.notaPedido.proveedor = proveedor; | 516 | $scope.notaPedido.proveedor = proveedor; |
| 511 | $scope.$broadcast('addCabecera', { | 517 | $scope.$broadcast('addCabecera', { |
| 512 | label: 'Proveedor:', | 518 | label: 'Proveedor:', |
| 513 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 519 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
| 514 | proveedor.NOM | 520 | proveedor.NOM |
| 515 | }); | 521 | }); |
| 516 | callback(); | 522 | callback(); |
| 517 | }, function() { | 523 | }, function() { |
| 518 | 524 | ||
| 519 | } | 525 | } |
| 520 | ); | 526 | ); |
| 521 | } | 527 | } |
| 522 | }; | 528 | }; |
| 523 | 529 | ||
| 524 | $scope.abrirModalDomicilios = function(cliente) { | 530 | $scope.abrirModalDomicilios = function(cliente) { |
| 525 | var modalInstanceDomicilio = $uibModal.open( | 531 | var modalInstanceDomicilio = $uibModal.open( |
| 526 | { | 532 | { |
| 527 | ariaLabelledBy: 'Busqueda de Domicilios', | 533 | ariaLabelledBy: 'Busqueda de Domicilios', |
| 528 | templateUrl: 'modal-domicilio.html', | 534 | templateUrl: 'modal-domicilio.html', |
| 529 | controller: 'focaModalDomicilioController', | 535 | controller: 'focaModalDomicilioController', |
| 530 | resolve: { | 536 | resolve: { |
| 531 | idCliente: function() { return cliente.cod; }, | 537 | idCliente: function() { return cliente.cod; }, |
| 532 | esNuevo: function() { return cliente.esNuevo; } | 538 | esNuevo: function() { return cliente.esNuevo; } |
| 533 | }, | 539 | }, |
| 534 | size: 'lg', | 540 | size: 'lg', |
| 535 | } | 541 | } |
| 536 | ); | 542 | ); |
| 537 | modalInstanceDomicilio.result.then( | 543 | modalInstanceDomicilio.result.then( |
| 538 | function(domicilio) { | 544 | function(domicilio) { |
| 539 | $scope.notaPedido.domicilio = domicilio; | 545 | $scope.notaPedido.domicilio = domicilio; |
| 540 | $scope.notaPedido.cliente = { | 546 | $scope.notaPedido.cliente = { |
| 541 | COD: cliente.cod, | 547 | COD: cliente.cod, |
| 542 | CUIT: cliente.cuit, | 548 | CUIT: cliente.cuit, |
| 543 | NOM: cliente.nom, | 549 | NOM: cliente.nom, |
| 544 | MOD: cliente.mod | 550 | MOD: cliente.mod |
| 545 | }; | 551 | }; |
| 546 | var domicilioStamp = | 552 | var domicilioStamp = |
| 547 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 553 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
| 548 | domicilio.Localidad + ', ' + domicilio.Provincia; | 554 | domicilio.Localidad + ', ' + domicilio.Provincia; |
| 549 | $scope.notaPedido.domicilioStamp = domicilioStamp; | 555 | $scope.notaPedido.domicilioStamp = domicilioStamp; |
| 550 | 556 | ||
| 551 | $scope.notaPedido.notaPedidoPuntoDescarga = domicilio.puntoDescarga; | ||
| 552 | |||
| 553 | $scope.$broadcast('addCabecera', { | 557 | $scope.$broadcast('addCabecera', { |
| 554 | label: 'Cliente:', | 558 | label: 'Cliente:', |
| 555 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom | 559 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom |
| 556 | }); | 560 | }); |
| 561 | |||
| 557 | $scope.$broadcast('addCabecera', { | 562 | $scope.$broadcast('addCabecera', { |
| 558 | label: 'Domicilio:', | 563 | label: 'Domicilio:', |
| 559 | valor: domicilioStamp | 564 | valor: domicilioStamp |
| 560 | }); | 565 | }); |
| 566 | |||
| 561 | if (domicilio.verPuntos) { | 567 | if (domicilio.verPuntos) { |
| 562 | delete $scope.notaPedido.domicilio.verPuntos; | 568 | delete $scope.notaPedido.domicilio.verPuntos; |
| 563 | $scope.seleccionarPuntosDeDescarga(); | 569 | $scope.seleccionarPuntosDeDescarga(); |
| 564 | } else { | ||
| 565 | crearNotaPedidoService | ||
| 566 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | ||
| 567 | .then(function(res) { | ||
| 568 | if (res.data.length) $scope.seleccionarPuntosDeDescarga(); | ||
| 569 | }); | ||
| 570 | } | 570 | } |
| 571 | |||
| 572 | // Seteo checked en botonera | ||
| 573 | $filter('filter')($scope.botonera, { label: 'Cliente'})[0].checked = true; | ||
| 574 | |||
| 571 | }, function() { | 575 | }, function() { |
| 572 | $scope.seleccionarCliente(true); | 576 | $scope.seleccionarCliente(true); |
| 573 | return; | 577 | return; |
| 574 | } | 578 | } |
| 575 | ); | 579 | ); |
| 576 | }; | 580 | }; |
| 577 | 581 | ||
| 578 | $scope.getTotal = function() { | 582 | $scope.getTotal = function() { |
| 579 | var total = 0; | 583 | var total = 0; |
| 580 | if ($scope.notaPedido.articulosNotaPedido) { | 584 | if ($scope.notaPedido.articulosNotaPedido) { |
| 581 | var arrayTempArticulos = $scope.notaPedido.articulosNotaPedido; | 585 | var arrayTempArticulos = $scope.notaPedido.articulosNotaPedido; |
| 582 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 586 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
| 583 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 587 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 584 | } | 588 | } |
| 585 | } | 589 | } |
| 586 | return parseFloat(total.toFixed(2)); | 590 | return parseFloat(total.toFixed(2)); |
| 587 | }; | 591 | }; |
| 588 | 592 | ||
| 589 | $scope.getSubTotal = function() { | 593 | $scope.getSubTotal = function() { |
| 590 | if ($scope.articuloACargar) { | 594 | if ($scope.articuloACargar) { |
| 591 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 595 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 592 | } | 596 | } |
| 593 | }; | 597 | }; |
| 594 | 598 | ||
| 595 | $scope.seleccionarPreciosYCondiciones = function() { | 599 | $scope.seleccionarPreciosYCondiciones = function() { |
| 596 | if (!$scope.notaPedido.cliente.COD) { | 600 | if (!$scope.notaPedido.cliente.COD) { |
| 597 | focaModalService.alert('Primero seleccione un cliente'); | 601 | focaModalService.alert('Primero seleccione un cliente'); |
| 598 | return; | 602 | return; |
| 599 | } | 603 | } |
| 600 | if ($scope.notaPedido.articulosNotaPedido.length !== 0) { | 604 | if ($scope.notaPedido.articulosNotaPedido.length !== 0) { |
| 601 | focaModalService.confirm('Se perderan los productos ingresados').then(function(data) { | 605 | focaModalService.confirm('Se perderan los productos ingresados') |
| 602 | if (data) { | 606 | .then(function(data) { |
| 603 | abrirModal(); | 607 | if (data) { |
| 604 | } | 608 | abrirModal(); |
| 605 | }); | 609 | } |
| 610 | }); | ||
| 606 | } else if (validarNotaRemitada()) { | 611 | } else if (validarNotaRemitada()) { |
| 607 | abrirModal(); | 612 | abrirModal(); |
| 608 | } | 613 | } |
| 609 | function abrirModal() { | 614 | function abrirModal() { |
| 610 | var modalInstance = $uibModal.open( | 615 | var modalInstance = $uibModal.open( |
| 611 | { | 616 | { |
| 612 | ariaLabelledBy: 'Busqueda de Precio Condición', | 617 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 613 | templateUrl: 'modal-precio-condicion.html', | 618 | templateUrl: 'modal-precio-condicion.html', |
| 614 | controller: 'focaModalPrecioCondicionController', | 619 | controller: 'focaModalPrecioCondicionController', |
| 615 | size: 'lg', | 620 | size: 'lg', |
| 616 | resolve: { | 621 | resolve: { |
| 617 | idListaPrecio: function() { | 622 | idListaPrecio: function() { |
| 618 | return $scope.notaPedido.cliente.MOD || null; | 623 | return $scope.notaPedido.cliente.MOD || null; |
| 619 | } | 624 | } |
| 620 | } | 625 | } |
| 621 | } | 626 | } |
| 622 | ); | 627 | ); |
| 623 | 628 | ||
| 624 | modalInstance.result.then( | 629 | modalInstance.result.then( |
| 625 | function(precioCondicion) { | 630 | function(precioCondicion) { |
| 626 | var cabecera = ''; | 631 | var cabecera = ''; |
| 627 | var plazosConcat = ''; | 632 | var plazosConcat = ''; |
| 628 | if (!Array.isArray(precioCondicion)) { | 633 | if (!Array.isArray(precioCondicion)) { |
| 629 | $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; | 634 | $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; |
| 630 | $scope.notaPedido.precioCondicion = precioCondicion; | 635 | $scope.notaPedido.precioCondicion = precioCondicion; |
| 631 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; | 636 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; |
| 632 | $scope.idLista = precioCondicion.idListaPrecio; | 637 | $scope.idLista = precioCondicion.idListaPrecio; |
| 633 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | 638 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { |
| 634 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 639 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
| 635 | } | 640 | } |
| 636 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + | 641 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + |
| 637 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); | 642 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); |
| 638 | } else { //Cuando se ingresan los plazos manualmente | 643 | } else { //Cuando se ingresan los plazos manualmente |
| 639 | $scope.notaPedido.idPrecioCondicion = 0; | 644 | $scope.notaPedido.idPrecioCondicion = 0; |
| 640 | //-1, el modal productos busca todos los productos | 645 | //-1, el modal productos busca todos los productos |
| 641 | $scope.idLista = -1; | 646 | $scope.idLista = -1; |
| 642 | $scope.notaPedido.notaPedidoPlazo = precioCondicion; | 647 | $scope.notaPedido.notaPedidoPlazo = precioCondicion; |
| 643 | for (var j = 0; j < precioCondicion.length; j++) { | 648 | for (var j = 0; j < precioCondicion.length; j++) { |
| 644 | plazosConcat += precioCondicion[j].dias + ' '; | 649 | plazosConcat += precioCondicion[j].dias + ' '; |
| 645 | } | 650 | } |
| 646 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 651 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
| 647 | } | 652 | } |
| 648 | $scope.notaPedido.articulosNotaPedido = []; | 653 | $scope.notaPedido.articulosNotaPedido = []; |
| 649 | $scope.$broadcast('addCabecera', { | 654 | $scope.$broadcast('addCabecera', { |
| 650 | label: 'Precios y condiciones:', | 655 | label: 'Precios y condiciones:', |
| 651 | valor: cabecera | 656 | valor: cabecera |
| 652 | }); | 657 | }); |
| 658 | |||
| 659 | $filter('filter')($scope.botonera, | ||
| 660 | { label: 'Precios y Condiciones'})[0].checked = true; | ||
| 653 | }, function() { | 661 | }, function() { |
| 654 | 662 | ||
| 655 | } | 663 | } |
| 656 | ); | 664 | ); |
| 657 | } | 665 | } |
| 658 | }; | 666 | }; |
| 659 | 667 | ||
| 660 | $scope.seleccionarMoneda = function() { | 668 | $scope.seleccionarMoneda = function() { |
| 661 | if (validarNotaRemitada()) { | 669 | if (validarNotaRemitada()) { |
| 662 | var parametrosModal = { | 670 | var parametrosModal = { |
| 663 | titulo: 'Búsqueda de monedas', | 671 | titulo: 'Búsqueda de monedas', |
| 664 | query: '/moneda', | 672 | query: '/moneda', |
| 665 | columnas: [ | 673 | columnas: [ |
| 666 | { | 674 | { |
| 667 | propiedad: 'DETALLE', | 675 | propiedad: 'DETALLE', |
| 668 | nombre: 'Nombre' | 676 | nombre: 'Nombre' |
| 669 | }, | 677 | }, |
| 670 | { | 678 | { |
| 671 | propiedad: 'SIMBOLO', | 679 | propiedad: 'SIMBOLO', |
| 672 | nombre: 'Símbolo' | 680 | nombre: 'Símbolo' |
| 673 | } | 681 | } |
| 674 | ], | 682 | ], |
| 675 | size: 'md' | 683 | size: 'md' |
| 676 | }; | 684 | }; |
| 677 | focaModalService.modal(parametrosModal).then( | 685 | focaModalService.modal(parametrosModal).then( |
| 678 | function(moneda) { | 686 | function(moneda) { |
| 679 | $scope.abrirModalCotizacion(moneda); | ||
| 680 | }, function() { | ||
| 681 | 687 | ||
| 688 | if (moneda.ID !== 1) { | ||
| 689 | $scope.abrirModalCotizacion(moneda); | ||
| 690 | return; | ||
| 691 | } | ||
| 692 | |||
| 693 | crearNotaPedidoService.getCotizacionByIdMoneda(1) | ||
| 694 | .then(function (res) { | ||
| 695 | |||
| 696 | cotizacionPArgentino = res.data[0].cotizaciones[0]; | ||
| 697 | cotizacionPArgentino.moneda = moneda; | ||
| 698 | |||
| 699 | actualizarCabeceraMoneda(cotizacionPArgentino); | ||
| 700 | $scope.notaPedido.cotizacion = cotizacionPArgentino; | ||
| 701 | }); | ||
| 682 | } | 702 | } |
| 683 | ); | 703 | ); |
| 684 | } | 704 | } |
| 685 | }; | 705 | }; |
| 686 | 706 | ||
| 687 | $scope.seleccionarObservaciones = function() { | 707 | $scope.seleccionarObservaciones = function() { |
| 688 | var observacion = { | 708 | var observacion = { |
| 689 | titulo: 'Ingrese Observaciones', | 709 | titulo: 'Ingrese Observaciones', |
| 690 | value: $scope.notaPedido.observaciones, | 710 | value: $scope.notaPedido.observaciones, |
| 691 | maxlength: 155, | 711 | maxlength: 155, |
| 692 | textarea: true | 712 | textarea: true |
| 693 | }; | 713 | }; |
| 694 | 714 | ||
| 695 | focaModalService | 715 | focaModalService |
| 696 | .prompt(observacion) | 716 | .prompt(observacion) |
| 697 | .then(function(observaciones) { | 717 | .then(function(observaciones) { |
| 698 | $scope.notaPedido.observaciones = observaciones; | 718 | $scope.notaPedido.observaciones = observaciones; |
| 699 | }); | 719 | }); |
| 700 | }; | 720 | }; |
| 701 | 721 | ||
| 702 | $scope.abrirModalCotizacion = function(moneda) { | 722 | $scope.abrirModalCotizacion = function(moneda) { |
| 703 | var modalInstance = $uibModal.open( | 723 | var modalInstance = $uibModal.open( |
| 704 | { | 724 | { |
| 705 | ariaLabelledBy: 'Busqueda de Cotización', | 725 | ariaLabelledBy: 'Busqueda de Cotización', |
| 706 | templateUrl: 'modal-cotizacion.html', | 726 | templateUrl: 'modal-cotizacion.html', |
| 707 | controller: 'focaModalCotizacionController', | 727 | controller: 'focaModalCotizacionController', |
| 708 | size: 'lg', | 728 | size: 'lg', |
| 709 | resolve: { | 729 | resolve: { |
| 710 | idMoneda: function() { | 730 | idMoneda: function() { |
| 711 | return moneda.ID; | 731 | return moneda.ID; |
| 712 | } | 732 | } |
| 713 | } | 733 | } |
| 714 | } | 734 | } |
| 715 | ); | 735 | ); |
| 716 | modalInstance.result.then( | 736 | modalInstance.result.then( |
| 717 | function(cotizacion) { | 737 | function(cotizacion) { |
| 718 | var articulosTablaTemp = $scope.notaPedido.articulosNotaPedido || []; | 738 | |
| 719 | for (var i = 0; i < articulosTablaTemp.length; i++) { | 739 | cotizacion.moneda = moneda; |
| 720 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 740 | actualizarCabeceraMoneda(cotizacion); |
| 721 | $scope.notaPedido.cotizacion.VENDEDOR; | 741 | |
| 722 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | ||
| 723 | cotizacion.VENDEDOR; | ||
| 724 | } | ||
| 725 | $scope.notaPedido.articulosNotaPedido = articulosTablaTemp; | ||
| 726 | $scope.notaPedido.cotizacion = cotizacion; | 742 | $scope.notaPedido.cotizacion = cotizacion; |
| 727 | $scope.notaPedido.cotizacion.moneda = moneda; | 743 | $filter('filter')($scope.botonera, { label: 'Moneda'})[0].checked = true; |
| 728 | if (moneda.DETALLE === 'PESOS ARGENTINOS') { | ||
| 729 | $scope.$broadcast('removeCabecera', 'Moneda:'); | ||
| 730 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | ||
| 731 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | ||
| 732 | } else { | ||
| 733 | $scope.$broadcast('addCabecera', { | ||
| 734 | label: 'Moneda:', | ||
| 735 | valor: moneda.DETALLE | ||
| 736 | }); | ||
| 737 | $scope.$broadcast('addCabecera', { | ||
| 738 | label: 'Fecha cotizacion:', | ||
| 739 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | ||
| 740 | }); | ||
| 741 | $scope.$broadcast('addCabecera', { | ||
| 742 | label: 'Cotizacion:', | ||
| 743 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | ||
| 744 | }); | ||
| 745 | } | ||
| 746 | }, function() { | 744 | }, function() { |
| 747 | 745 | ||
| 748 | } | 746 | } |
| 749 | ); | 747 | ); |
| 750 | }; | 748 | }; |
| 751 | 749 | ||
| 750 | function actualizarCabeceraMoneda (cotizacion) { | ||
| 751 | |||
| 752 | $scope.notaPedido.articulosNotaPedido.forEach(function(art) { | ||
| 753 | art.precio = (art.precio * $scope.notaPedido.cotizacion.VENDEDOR).toFixed(4); | ||
| 754 | art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4); | ||
| 755 | }); | ||
| 756 | |||
| 757 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { | ||
| 758 | $scope.$broadcast('removeCabecera', 'Moneda:'); | ||
| 759 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | ||
| 760 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | ||
| 761 | } else { | ||
| 762 | $scope.$broadcast('addCabecera', { | ||
| 763 | label: 'Moneda:', | ||
| 764 | valor: cotizacion.moneda.DETALLE | ||
| 765 | }); | ||
| 766 | $scope.$broadcast('addCabecera', { | ||
| 767 | label: 'Fecha cotizacion:', | ||
| 768 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | ||
| 769 | }); | ||
| 770 | $scope.$broadcast('addCabecera', { | ||
| 771 | label: 'Cotizacion:', | ||
| 772 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | ||
| 773 | }); | ||
| 774 | } | ||
| 775 | } | ||
| 776 | |||
| 752 | $scope.agregarATabla = function(key) { | 777 | $scope.agregarATabla = function(key) { |
| 753 | if (key === 13) { | 778 | if (key === 13) { |
| 754 | if ($scope.articuloACargar.cantidad === undefined || | 779 | if ($scope.articuloACargar.cantidad === undefined || |
| 755 | $scope.articuloACargar.cantidad === 0 || | 780 | $scope.articuloACargar.cantidad === 0 || |
| 756 | $scope.articuloACargar.cantidad === null ) { | 781 | $scope.articuloACargar.cantidad === null ) { |
| 757 | focaModalService.alert('El valor debe ser al menos 1'); | 782 | focaModalService.alert('El valor debe ser al menos 1'); |
| 758 | return; | 783 | return; |
| 759 | } | 784 | } |
| 760 | delete $scope.articuloACargar.sectorCodigo; | 785 | delete $scope.articuloACargar.sectorCodigo; |
| 761 | $scope.notaPedido.articulosNotaPedido.push($scope.articuloACargar); | 786 | $scope.notaPedido.articulosNotaPedido.push($scope.articuloACargar); |
| 762 | $scope.cargando = true; | 787 | $scope.cargando = true; |
| 763 | } | 788 | } |
| 764 | }; | 789 | }; |
| 765 | 790 | ||
| 766 | $scope.quitarArticulo = function(key) { | 791 | $scope.quitarArticulo = function(key) { |
| 767 | $scope.notaPedido.articulosNotaPedido.splice(key, 1); | 792 | $scope.notaPedido.articulosNotaPedido.splice(key, 1); |
| 768 | }; | 793 | }; |
| 769 | 794 | ||
| 770 | $scope.editarArticulo = function(key, articulo, tmpCantidad, tmpPrecio) { | 795 | $scope.editarArticulo = function(key, articulo, tmpCantidad, tmpPrecio) { |
| 771 | if (key === 13) { | 796 | if (key === 13) { |
| 772 | if (!articulo.cantidad || !articulo.precio) { | 797 | if (!articulo.cantidad || !articulo.precio) { |
| 773 | focaModalService.alert('Los valores deben ser al menos 1'); | 798 | focaModalService.alert('Los valores deben ser al menos 1'); |
| 774 | return; | 799 | return; |
| 775 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { | 800 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { |
| 776 | focaModalService.alert('Los valores no pueden ser negativos'); | 801 | focaModalService.alert('Los valores no pueden ser negativos'); |
| 777 | return; | 802 | return; |
| 778 | } | 803 | } |
| 779 | articulo.cantidad = tmpCantidad; | 804 | articulo.cantidad = tmpCantidad; |
| 780 | articulo.precio = tmpPrecio; | 805 | articulo.precio = tmpPrecio; |
| 781 | $scope.getTotal(); | 806 | $scope.getTotal(); |
| 782 | articulo.editCantidad = articulo.editPrecio = false; | 807 | articulo.editCantidad = articulo.editPrecio = false; |
| 783 | } | 808 | } |
| 784 | }; | 809 | }; |
| 785 | 810 | ||
| 786 | $scope.cancelarEditar = function(articulo) { | 811 | $scope.cancelarEditar = function(articulo) { |
| 787 | $scope.tmpCantidad = articulo.cantidad; | 812 | $scope.tmpCantidad = articulo.cantidad; |
| 788 | $scope.tmpPrecio = articulo.precio; | 813 | $scope.tmpPrecio = articulo.precio; |
| 789 | articulo.editCantidad = articulo.editPrecio = false; | 814 | articulo.editCantidad = articulo.editPrecio = false; |
| 790 | }; | 815 | }; |
| 791 | 816 | ||
| 792 | $scope.cambioEdit = function(articulo, propiedad) { | 817 | $scope.cambioEdit = function(articulo, propiedad) { |
| 793 | if (propiedad === 'cantidad') { | 818 | if (propiedad === 'cantidad') { |
| 794 | articulo.editCantidad = true; | 819 | articulo.editCantidad = true; |
| 795 | } else if (propiedad === 'precio') { | 820 | } else if (propiedad === 'precio') { |
| 796 | articulo.editPrecio = true; | 821 | articulo.editPrecio = true; |
| 797 | } | 822 | } |
| 798 | }; | 823 | }; |
| 799 | 824 | ||
| 800 | $scope.resetFilter = function() { | 825 | $scope.resetFilter = function() { |
| 801 | $scope.articuloACargar = {}; | 826 | $scope.articuloACargar = {}; |
| 802 | $scope.cargando = true; | 827 | $scope.cargando = true; |
| 803 | }; | 828 | }; |
| 804 | //Recibe aviso si el teclado está en uso | 829 | //Recibe aviso si el teclado está en uso |
| 805 | $rootScope.$on('usarTeclado', function(event, data) { | 830 | $rootScope.$on('usarTeclado', function(event, data) { |
| 806 | if (data) { | 831 | if (data) { |
| 807 | $scope.mostrarTeclado = true; | 832 | $scope.mostrarTeclado = true; |
| 808 | return; | 833 | return; |
| 809 | } | 834 | } |
| 810 | $scope.mostrarTeclado = false; | 835 | $scope.mostrarTeclado = false; |
| 811 | }); | 836 | }); |
| 812 | 837 | ||
| 813 | $scope.selectFocus = function($event) { | 838 | $scope.selectFocus = function($event) { |
| 814 | // Si el teclado esta en uso no selecciona el valor | 839 | // Si el teclado esta en uso no selecciona el valor |
| 815 | if ($scope.mostrarTeclado) { | 840 | if ($scope.mostrarTeclado) { |
| 816 | return; | 841 | return; |
| 817 | } | 842 | } |
| 818 | $event.target.select(); | 843 | $event.target.select(); |
| 819 | }; | 844 | }; |
| 820 | 845 | ||
| 821 | $scope.salir = function() { | 846 | $scope.salir = function() { |
| 822 | $location.path('/'); | 847 | $location.path('/'); |
| 823 | }; | 848 | }; |
| 824 | 849 | ||
| 825 | $scope.parsearATexto = function(articulo) { | 850 | $scope.parsearATexto = function(articulo) { |
| 826 | articulo.cantidad = parseFloat(articulo.cantidad); | 851 | articulo.cantidad = parseFloat(articulo.cantidad); |
| 827 | articulo.precio = parseFloat(articulo.precio); | 852 | articulo.precio = parseFloat(articulo.precio); |
| 828 | }; | 853 | }; |
| 829 | 854 | ||
| 855 | // TODO: quitar watch usar función de articulos pedido cuando se haga | ||
| 856 | $scope.$watch('notaPedido.articulosNotaPedido', function() { | ||
| 857 | if ($scope.notaPedido.articulosNotaPedido.length) { | ||
| 858 | $filter('filter')($scope.botonera, | ||
| 859 | { label: 'Productos'})[0].checked = true; | ||
| 860 | } else { | ||
| 861 | $filter('filter')($scope.botonera, | ||
| 862 | { label: 'Productos'})[0].checked = false; | ||
| 863 | } | ||
| 864 | }, true); | ||
| 865 | |||
| 830 | function setearNotaPedido(notaPedido) { | 866 | function setearNotaPedido(notaPedido) { |
| 831 | //añado cabeceras | 867 | //añado cabeceras |
| 832 | $scope.notaPedido = notaPedido; | 868 | $scope.notaPedido = notaPedido; |
| 833 | if (!$scope.notaPedido.domicilio) { | 869 | if (!$scope.notaPedido.domicilio) { |
| 834 | $scope.notaPedido.domicilio = { | 870 | $scope.notaPedido.domicilio = { |
| 835 | id: $scope.notaPedido.idDomicilio | 871 | id: $scope.notaPedido.idDomicilio |
| 836 | }; | 872 | }; |
| 837 | } | 873 | } |
| 838 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 874 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
| 839 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 875 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
| 840 | $scope.$broadcast('cleanCabecera'); | 876 | $scope.$broadcast('cleanCabecera'); |
| 841 | 877 | ||
| 842 | var cabeceras = []; | 878 | var cabeceras = []; |
| 843 | 879 | ||
| 844 | if (notaPedido.cotizacion.moneda.CODIGO_AFIP !== 'PES') { | 880 | if (notaPedido.cotizacion.moneda.CODIGO_AFIP !== 'PES') { |
| 845 | cabeceras.push({ | 881 | cabeceras.push({ |
| 846 | label: 'Moneda:', | 882 | label: 'Moneda:', |
| 847 | valor: notaPedido.cotizacion.moneda.DETALLE | 883 | valor: notaPedido.cotizacion.moneda.DETALLE |
| 848 | }); | 884 | }); |
| 849 | cabeceras.push({ | 885 | cabeceras.push({ |
| 850 | label: 'Fecha cotizacion:', | 886 | label: 'Fecha cotizacion:', |
| 851 | valor: $filter('date')(notaPedido.cotizacion.FECHA, | 887 | valor: $filter('date')(notaPedido.cotizacion.FECHA, |
| 852 | 'dd/MM/yyyy') | 888 | 'dd/MM/yyyy') |
| 853 | }); | 889 | }); |
| 854 | cabeceras.push({ | 890 | cabeceras.push({ |
| 855 | label: 'Cotizacion:', | 891 | label: 'Cotizacion:', |
| 856 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, | 892 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, |
| 857 | '2') | 893 | '2') |
| 858 | }); | 894 | }); |
| 859 | } | 895 | } |
| 860 | 896 | ||
| 897 | if (notaPedido.cotizacion.moneda) { | ||
| 898 | $filter('filter')($scope.botonera, { label: 'Moneda'})[0].checked = true; | ||
| 899 | } | ||
| 900 | |||
| 861 | if (notaPedido.vendedor.NUM) { | 901 | if (notaPedido.vendedor.NUM) { |
| 862 | cabeceras.push({ | 902 | cabeceras.push({ |
| 863 | label: 'Vendedor:', | 903 | label: 'Vendedor:', |
| 864 | valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + | 904 | valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + |
| 865 | ' - ' + notaPedido.vendedor.NOM | 905 | ' - ' + notaPedido.vendedor.NOM |
| 866 | }); | 906 | }); |
| 867 | } | 907 | } |
| 868 | 908 | ||
| 869 | if (notaPedido.cliente.COD) { | 909 | if (notaPedido.cliente.COD) { |
| 870 | cabeceras.push({ | 910 | cabeceras.push({ |
| 871 | label: 'Cliente:', | 911 | label: 'Cliente:', |
| 872 | valor: notaPedido.cliente.NOM | 912 | valor: notaPedido.cliente.NOM |
| 873 | }); | 913 | }); |
| 874 | cabeceras.push({ | 914 | cabeceras.push({ |
| 875 | label: 'Domicilio:', | 915 | label: 'Domicilio:', |
| 876 | valor: notaPedido.domicilioStamp | 916 | valor: notaPedido.domicilioStamp |
| 877 | }); | 917 | }); |
| 918 | |||
| 919 | $filter('filter')($scope.botonera, { label: 'Cliente'})[0].checked = true; | ||
| 878 | } | 920 | } |
| 879 | 921 | ||
| 880 | if (notaPedido.proveedor.COD) { | 922 | if (notaPedido.proveedor.COD) { |
| 881 | cabeceras.push({ | 923 | cabeceras.push({ |
| 882 | label: 'Proveedor:', | 924 | label: 'Proveedor:', |
| 883 | valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) + | 925 | valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) + |
| 884 | ' - ' + notaPedido.proveedor.NOM | 926 | ' - ' + notaPedido.proveedor.NOM |
| 885 | }); | 927 | }); |
| 928 | |||
| 929 | $filter('filter')($scope.botonera, { label: 'Proveedor'})[0].checked = true; | ||
| 886 | } | 930 | } |
| 887 | 931 | ||
| 888 | if (notaPedido.notaPedidoPlazo.length) { | 932 | if (notaPedido.notaPedidoPlazo.length) { |
| 889 | cabeceras.push({ | 933 | cabeceras.push({ |
| 890 | label: 'Precios y condiciones:', | 934 | label: 'Precios y condiciones:', |
| 891 | valor: valorPrecioCondicion() + ' ' + | 935 | valor: valorPrecioCondicion() + ' ' + |
| 892 | notaPedidoBusinessService | 936 | notaPedidoBusinessService |
| 893 | .plazoToString(notaPedido.notaPedidoPlazo) | 937 | .plazoToString(notaPedido.notaPedidoPlazo) |
| 894 | }); | 938 | }); |
| 939 | |||
| 940 | $filter('filter')($scope.botonera, | ||
| 941 | { label: 'Precios y condiciones'})[0].checked = true; | ||
| 895 | } | 942 | } |
| 896 | 943 | ||
| 897 | if (notaPedido.flete !== undefined) { | 944 | if (notaPedido.flete !== undefined) { |
| 898 | cabeceras.push({ | 945 | cabeceras.push({ |
| 899 | label: 'Flete:', | 946 | label: 'Flete:', |
| 900 | valor: notaPedido.fob === 1 ? 'FOB' : ( | 947 | valor: notaPedido.fob === 1 ? 'FOB' : ( |
| 901 | notaPedido.flete === 1 ? 'Si' : 'No') | 948 | notaPedido.flete === 1 ? 'Si' : 'No') |
| 902 | }); | 949 | }); |
| 903 | } | 950 | } |
| 904 | 951 | ||
| 905 | function valorPrecioCondicion() { | 952 | function valorPrecioCondicion() { |
| 906 | if (notaPedido.idPrecioCondicion > 0) { | 953 | if (notaPedido.idPrecioCondicion > 0) { |
| 907 | return notaPedido.precioCondicion.nombre; | 954 | return notaPedido.precioCondicion.nombre; |
| 908 | } else { | 955 | } else { |
| 909 | return 'Ingreso Manual'; | 956 | return 'Ingreso Manual'; |
| 910 | } | 957 | } |
| 911 | } | 958 | } |
| 912 | 959 | ||
| 913 | if (notaPedido.flete === 1) { | 960 | if (notaPedido.flete === 1) { |
| 914 | var cabeceraBomba = { | 961 | var cabeceraBomba = { |
| 915 | label: 'Bomba:', | 962 | label: 'Bomba:', |
| 916 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 963 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
| 917 | }; | 964 | }; |
| 918 | if (notaPedido.kilometros) { | 965 | if (notaPedido.kilometros) { |
| 919 | var cabeceraKilometros = { | 966 | var cabeceraKilometros = { |
| 920 | label: 'Kilometros:', | 967 | label: 'Kilometros:', |
| 921 | valor: notaPedido.kilometros | 968 | valor: notaPedido.kilometros |
| 922 | }; | 969 | }; |
| 923 | cabeceras.push(cabeceraKilometros); | 970 | cabeceras.push(cabeceraKilometros); |
| 924 | } | 971 | } |
| 925 | cabeceras.push(cabeceraBomba); | 972 | cabeceras.push(cabeceraBomba); |
| 926 | } | 973 | } |
| 927 | 974 | ||
| 928 | if (notaPedido.idPrecioCondicion > 0) { | 975 | if (notaPedido.idPrecioCondicion > 0) { |
| 929 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | 976 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; |
| 930 | } else { | 977 | } else if (notaPedido.idPrecioCondicion) { |
| 931 | $scope.idLista = -1; | 978 | $scope.idLista = -1; |
| 932 | } | 979 | } |
| 933 | 980 | ||
| 934 | $scope.puntoVenta = $filter('rellenarDigitos')( | 981 | $scope.puntoVenta = $filter('rellenarDigitos')( |
| 935 | notaPedido.sucursal, 4 | 982 | notaPedido.sucursal, 4 |
| 936 | ); | 983 | ); |
| 937 | 984 | ||
| 938 | $scope.comprobante = $filter('rellenarDigitos')( | 985 | $scope.comprobante = $filter('rellenarDigitos')( |
| 939 | notaPedido.numeroNotaPedido, 8 | 986 | notaPedido.numeroNotaPedido, 8 |
| 940 | ); | 987 | ); |
| 941 | 988 | ||
| 942 | if (notaPedido.notaPedidoPuntoDescarga) { | 989 | if (notaPedido.notaPedidoPuntoDescarga.length) { |
| 943 | var puntos = []; | 990 | var puntos = []; |
| 944 | notaPedido.notaPedidoPuntoDescarga.forEach(function(notaPedidoPuntoDescarga, idx, arr) { | 991 | notaPedido.notaPedidoPuntoDescarga.forEach(function(notaPedidoPuntoDescarga) { |
| 945 | puntos.push(notaPedidoPuntoDescarga.puntoDescarga); | 992 | puntos.push(notaPedidoPuntoDescarga.puntoDescarga); |
| 946 | }); | 993 | }); |
| 947 | cabeceras.push({ | 994 | cabeceras.push({ |
| 948 | label: 'Puntos de descarga: ', | 995 | label: 'Puntos de descarga: ', |
| 949 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) | 996 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) |
| 950 | }); | 997 | }); |
| 951 | } | 998 | } |
| 952 | 999 | ||
| 1000 | if ($scope.notaPedido.articulosNotaPedido.length) { | ||
| 1001 | $scope.notaPedido.articulosNotaPedido.forEach(function (articulo) { | ||
| 1002 | articulo.precio = | ||
| 1003 | (articulo.precio / $scope.notaPedido.cotizacion.VENDEDOR).toFixed(4); | ||
| 1004 | }); | ||
| 1005 | } | ||
| 1006 | |||
| 953 | addArrayCabecera(cabeceras); | 1007 | addArrayCabecera(cabeceras); |
| 954 | } | 1008 | } |
| 955 | 1009 | ||
| 956 | function getCabeceraPuntoDescarga(puntoDescarga){ | 1010 | function getCabeceraPuntoDescarga(puntoDescarga) { |
| 957 | var puntosStamp = ''; | 1011 | var puntosStamp = ''; |
| 958 | puntoDescarga.forEach(function(punto, idx, arr) { | 1012 | puntoDescarga.forEach(function(punto, idx, arr) { |
| 959 | puntosStamp += punto.descripcion; | 1013 | puntosStamp += punto.descripcion; |
| 960 | if ((idx + 1) !== arr.length) puntosStamp += ', '; | 1014 | if ((idx + 1) !== arr.length) puntosStamp += ', '; |
| 961 | }); | 1015 | }); |
| 962 | return puntosStamp; | 1016 | return puntosStamp; |
| 963 | } | 1017 | } |
| 964 | 1018 | ||
| 965 | function addArrayCabecera(array) { | 1019 | function addArrayCabecera(array) { |
| 966 | for (var i = 0; i < array.length; i++) { | 1020 | for (var i = 0; i < array.length; i++) { |
| 967 | $scope.$broadcast('addCabecera', { | 1021 | $scope.$broadcast('addCabecera', { |
| 968 | label: array[i].label, | 1022 | label: array[i].label, |
| 969 | valor: array[i].valor | 1023 | valor: array[i].valor |
| 970 | }); | 1024 | }); |
| 971 | } | 1025 | } |
| 972 | } | 1026 | } |
| 973 | 1027 | ||
| 974 | function validarNotaRemitada() { | 1028 | function validarNotaRemitada() { |
| 975 | if (!$scope.notaPedido.idRemito) { | 1029 | if (!$scope.notaPedido.idRemito) { |
| 976 | return true; | 1030 | return true; |
| 977 | } else { | 1031 | } else { |
| 978 | focaModalService.alert('No se puede editar una nota de pedido remitada'); | 1032 | focaModalService.alert('No se puede editar una nota de pedido remitada'); |
| 979 | return false; | 1033 | return false; |
| 980 | } | 1034 | } |
src/js/service.js
| 1 | angular.module('focaCrearNotaPedido') | 1 | angular.module('focaCrearNotaPedido') |
| 2 | .factory('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | 2 | .factory('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { |
| 3 | var route = API_ENDPOINT.URL; | 3 | var route = API_ENDPOINT.URL; |
| 4 | return { | 4 | return { |
| 5 | crearNotaPedido: function(notaPedido) { | 5 | crearNotaPedido: function(notaPedido) { |
| 6 | return $http.post(route + '/nota-pedido', {notaPedido: notaPedido}); | 6 | return $http.post(route + '/nota-pedido', {notaPedido: notaPedido}); |
| 7 | }, | 7 | }, |
| 8 | obtenerNotaPedido: function() { | 8 | obtenerNotaPedido: function() { |
| 9 | return $http.get(route +'/nota-pedido'); | 9 | return $http.get(route +'/nota-pedido'); |
| 10 | }, | 10 | }, |
| 11 | setNotaPedido: function(notaPedido) { | 11 | setNotaPedido: function(notaPedido) { |
| 12 | this.notaPedido = notaPedido; | 12 | this.notaPedido = notaPedido; |
| 13 | }, | 13 | }, |
| 14 | clearNotaPedido: function() { | 14 | clearNotaPedido: function() { |
| 15 | this.notaPedido = undefined; | 15 | this.notaPedido = undefined; |
| 16 | }, | 16 | }, |
| 17 | getNotaPedido: function() { | 17 | getNotaPedido: function() { |
| 18 | return this.notaPedido; | 18 | return this.notaPedido; |
| 19 | }, | 19 | }, |
| 20 | getArticulosByIdNotaPedido: function(id) { | 20 | getArticulosByIdNotaPedido: function(id) { |
| 21 | return $http.get(route+'/articulos/nota-pedido/'+id); | 21 | return $http.get(route+'/articulos/nota-pedido/'+id); |
| 22 | }, | 22 | }, |
| 23 | crearArticulosParaNotaPedido: function(articuloNotaPedido) { | 23 | crearArticulosParaNotaPedido: function(articuloNotaPedido) { |
| 24 | return $http.post(route + '/articulos/nota-pedido', | 24 | return $http.post(route + '/articulos/nota-pedido', |
| 25 | {articuloNotaPedido: articuloNotaPedido}); | 25 | {articuloNotaPedido: articuloNotaPedido}); |
| 26 | }, | 26 | }, |
| 27 | getDomiciliosByIdNotaPedido: function(id) { | 27 | getDomiciliosByIdNotaPedido: function(id) { |
| 28 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); | 28 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); |
| 29 | }, | 29 | }, |
| 30 | getDomiciliosByIdCliente: function(id) { | 30 | getDomiciliosByIdCliente: function(id) { |
| 31 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) | 31 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) |
| 32 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); | 32 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); |
| 33 | }, | 33 | }, |
| 34 | getPrecioCondicion: function() { | 34 | getPrecioCondicion: function() { |
| 35 | return $http.get(route + '/precio-condicion'); | 35 | return $http.get(route + '/precio-condicion'); |
| 36 | }, | 36 | }, |
| 37 | getPrecioCondicionById: function(id) { | 37 | getPrecioCondicionById: function(id) { |
| 38 | return $http.get(route + '/precio-condicion/' + id); | 38 | return $http.get(route + '/precio-condicion/' + id); |
| 39 | }, | 39 | }, |
| 40 | getPlazoPagoByPrecioCondicion: function(id) { | 40 | getPlazoPagoByPrecioCondicion: function(id) { |
| 41 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); | 41 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); |
| 42 | }, | 42 | }, |
| 43 | crearFlete: function(flete) { | 43 | crearFlete: function(flete) { |
| 44 | return $http.post(route + '/flete', {flete : flete}); | 44 | return $http.post(route + '/flete', {flete : flete}); |
| 45 | }, | 45 | }, |
| 46 | crearPlazosParaNotaPedido: function(plazos) { | 46 | crearPlazosParaNotaPedido: function(plazos) { |
| 47 | return $http.post(route + '/plazo-pago/nota-pedido', {plazos: plazos}); | 47 | return $http.post(route + '/plazo-pago/nota-pedido', {plazos: plazos}); |
| 48 | }, | 48 | }, |
| 49 | getCotizacionByIdMoneda: function(id) { | 49 | getCotizacionByIdMoneda: function(id) { |
| 50 | return $http.get(route + '/moneda/' + id); | 50 | return $http.get(route + '/moneda/' + id); |
| 51 | }, | 51 | }, |
| 52 | crearEstadoParaNotaPedido: function(estado) { | 52 | crearEstadoParaNotaPedido: function(estado) { |
| 53 | return $http.post(route + '/estado', {estado: estado}); | 53 | return $http.post(route + '/estado', {estado: estado}); |
| 54 | }, | 54 | }, |
| 55 | getNumeroNotaPedido: function() { | 55 | getNumeroNotaPedido: function() { |
| 56 | return $http.get(route + '/nota-pedido/numero-siguiente'); | 56 | return $http.get(route + '/nota-pedido/numero-siguiente'); |
| 57 | }, | 57 | }, |
| 58 | getBotonera: function() { | 58 | getBotonera: function() { |
| 59 | var result = [ | 59 | var result = [ |
| 60 | { | 60 | { |
| 61 | label: 'Cliente', | 61 | label: 'Cliente', |
| 62 | image: 'cliente.png' | 62 | image: 'cliente.png' |
| 63 | }, | 63 | }, |
| 64 | { | 64 | { |
| 65 | label: 'Proveedor', | 65 | label: 'Proveedor', |
| 66 | image: 'proveedor.png' | 66 | image: 'proveedor.png' |
| 67 | }, | 67 | }, |
| 68 | { | 68 | { |
| 69 | label: 'Moneda', | 69 | label: 'Moneda', |
| 70 | image: 'moneda.png' | 70 | image: 'moneda.png' |
| 71 | }, | 71 | }, |
| 72 | { | 72 | { |
| 73 | label: 'Precios y condiciones', | 73 | label: 'Precios y condiciones', |
| 74 | image: 'precios-condiciones.png' | 74 | image: 'precios-condiciones.png' |
| 75 | }, | 75 | }, |
| 76 | { | 76 | { |
| 77 | label: 'Productos', | 77 | label: 'Productos', |
| 78 | image: 'productos.png' | 78 | image: 'productos.png' |
| 79 | }, | 79 | }, |
| 80 | { | 80 | { |
| 81 | label: 'Observaciones', | 81 | label: 'Observaciones', |
| 82 | image: 'botonObservaciones.png' | 82 | image: 'botonObservaciones.png' |
| 83 | } | 83 | } |
| 84 | ]; | 84 | ]; |
| 85 | return result; | 85 | return result; |
| 86 | }, | 86 | }, |
| 87 | crearPuntosDescarga: function(puntosDescarga) { | 87 | crearPuntosDescarga: function(puntosDescarga) { |
| 88 | return $http.post(route + '/puntos-descarga/nota-pedido', | 88 | return $http.post(route + '/puntos-descarga/nota-pedido', |
| 89 | {puntosDescarga: puntosDescarga}); | 89 | {puntosDescarga: puntosDescarga}); |
| 90 | }, | 90 | }, |
| 91 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { | 91 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { |
| 92 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + | 92 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + |
| 93 | idDomicilio + '/' + idCliente); | 93 | idDomicilio + '/' + idCliente); |
| 94 | }, | 94 | }, |
| 95 | getVendedorById: function(id) { | 95 | getVendedorById: function(id) { |
| 96 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + id); | 96 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + id); |
| 97 | }, | 97 | }, |
| 98 | getProveedorById: function(id) { | 98 | getProveedorById: function(id) { |
| 99 | return $http.get(API_ENDPOINT.URL + '/proveedor/' + id); | 99 | return $http.get(API_ENDPOINT.URL + '/proveedor/' + id); |
| 100 | }, | ||
| 101 | getParametros: function() { | ||
| 102 | return $http.get(API_ENDPOINT.URL + '/parametros/' + 'notaPedido') | ||
| 100 | } | 103 | } |
| 101 | |||
| 102 | }; | 104 | }; |
| 103 | }]); | 105 | }]); |
src/views/nota-pedido.html
| 1 | <div class="crear-nota-pedido foca-crear row"> | 1 | <div class="crear-nota-pedido foca-crear row"> |
| 2 | <foca-cabecera-facturador | 2 | <foca-cabecera-facturador |
| 3 | titulo="'Nota de pedido'" | 3 | titulo="'Nota de pedido'" |
| 4 | numero="puntoVenta + '-' + comprobante" | 4 | numero="puntoVenta + '-' + comprobante" |
| 5 | fecha="notaPedido.fechaCarga" | 5 | fecha="notaPedido.fechaCarga" |
| 6 | class="mb-0 col-lg-12" | 6 | class="mb-0 col-lg-12" |
| 7 | busqueda="seleccionarNotaPedido" | 7 | busqueda="seleccionarNotaPedido" |
| 8 | ></foca-cabecera-facturador> | 8 | ></foca-cabecera-facturador> |
| 9 | <marquee | 9 | <marquee |
| 10 | bgcolor="#FF9900" | 10 | bgcolor="#FF9900" |
| 11 | behavior="scroll" | 11 | behavior="scroll" |
| 12 | direction="left" | 12 | direction="left" |
| 13 | ng-bind="notaPedido.observaciones" | 13 | ng-bind="notaPedido.observaciones" |
| 14 | ></marquee> | 14 | ></marquee> |
| 15 | <div class="col-lg-12"> | 15 | <div class="col-lg-12"> |
| 16 | <div class="row"> | 16 | <div class="row"> |
| 17 | <div class="col-12 col-md-10 col-lg-10 border border-light rounded"> | 17 | <div class="col-12 col-md-10 col-lg-10 border border-light rounded"> |
| 18 | <div class="row py-2 botonera-secundaria"> | 18 | <div class="row py-2 botonera-secundaria"> |
| 19 | <div class="col-12 foca-facturador-px"> | 19 | <div class="col-12 foca-facturador-px"> |
| 20 | <foca-botonera-facturador botones="botonera" extra="5" class="row"></foca-botonera-facturador> | 20 | <foca-botonera-facturador botones="botonera" extra="5" class="row"></foca-botonera-facturador> |
| 21 | </div> | 21 | </div> |
| 22 | </div> | 22 | </div> |
| 23 | <!-- PC --> | 23 | <!-- PC --> |
| 24 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> | 24 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> |
| 25 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> | 25 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> |
| 26 | <thead> | 26 | <thead> |
| 27 | <tr class="d-flex"> | 27 | <tr class="d-flex"> |
| 28 | <th valign="middle" class="">#</th> | 28 | <th valign="middle" class="">#</th> |
| 29 | <th valign="middle" class="col">Código</th> | 29 | <th valign="middle" class="col">Código</th> |
| 30 | <th valign="middle" class="col-4">Descripción</th> | 30 | <th valign="middle" class="col-4">Descripción</th> |
| 31 | <th valign="middle" class="col text-right">Cantidad</th> | 31 | <th valign="middle" class="col text-right">Cantidad</th> |
| 32 | <th valign="middle" class="col text-right">Precio Unitario</th> | 32 | <th valign="middle" class="col text-right">Precio Unitario</th> |
| 33 | <th valign="middle" class="col text-right">SubTotal</th> | 33 | <th valign="middle" class="col text-right">SubTotal</th> |
| 34 | <th valign="middle" class="text-right"> | 34 | <th valign="middle" class="text-right"> |
| 35 | <button | 35 | <button |
| 36 | class="btn btn-outline-light selectable" | 36 | class="btn btn-outline-light selectable" |
| 37 | ng-click="show = !show; masMenos()" | 37 | ng-click="show = !show; masMenos()" |
| 38 | > | 38 | > |
| 39 | <i | 39 | <i |
| 40 | class="fa fa-chevron-down" | 40 | class="fa fa-chevron-down" |
| 41 | ng-show="show" | 41 | ng-show="show" |
| 42 | aria-hidden="true" | 42 | aria-hidden="true" |
| 43 | > | 43 | > |
| 44 | </i> | 44 | </i> |
| 45 | <i | 45 | <i |
| 46 | class="fa fa-chevron-up" | 46 | class="fa fa-chevron-up" |
| 47 | ng-hide="show" | 47 | ng-hide="show" |
| 48 | aria-hidden="true"> | 48 | aria-hidden="true"> |
| 49 | </i> | 49 | </i> |
| 50 | </button> | 50 | </button> |
| 51 | </th> | 51 | </th> |
| 52 | </tr> | 52 | </tr> |
| 53 | </thead> | 53 | </thead> |
| 54 | <tbody class="tabla-articulo-body"> | 54 | <tbody class="tabla-articulo-body"> |
| 55 | <tr | 55 | <tr |
| 56 | ng-repeat="(key, articulo) in notaPedido.articulosNotaPedido" | 56 | ng-repeat="(key, articulo) in notaPedido.articulosNotaPedido" |
| 57 | ng-show="show || key == (notaPedido.articulosNotaPedido.length - 1)" | 57 | ng-show="show || key == (notaPedido.articulosNotaPedido.length - 1)" |
| 58 | class="d-flex" | 58 | class="d-flex" |
| 59 | > | 59 | > |
| 60 | <td ng-bind="key + 1"></td> | 60 | <td ng-bind="key + 1"></td> |
| 61 | <td | 61 | <td |
| 62 | class="col" | 62 | class="col" |
| 63 | ng-bind="articulo.sector + '-' + articulo.codigo" | 63 | ng-bind="articulo.sector + '-' + articulo.codigo" |
| 64 | ></td> | 64 | ></td> |
| 65 | <td | 65 | <td |
| 66 | class="col-4" | 66 | class="col-4" |
| 67 | ng-bind="articulo.descripcion" | 67 | ng-bind="articulo.descripcion" |
| 68 | ></td> | 68 | ></td> |
| 69 | <td class="col text-right"> | 69 | <td class="col text-right"> |
| 70 | <input | 70 | <input |
| 71 | ng-show="articulo.editCantidad && notaPedido.idRemito !== -1" | 71 | ng-show="articulo.editCantidad && notaPedido.idRemito !== -1" |
| 72 | ng-model="tmpCantidad" | 72 | ng-model="tmpCantidad" |
| 73 | class="form-control" | 73 | class="form-control" |
| 74 | foca-tipo-input | 74 | foca-tipo-input |
| 75 | min="1" | 75 | min="1" |
| 76 | foca-focus="articulo.editCantidad" | 76 | foca-focus="articulo.editCantidad" |
| 77 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" | 77 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" |
| 78 | esc-key="cancelarEditar(articulo)" | 78 | esc-key="cancelarEditar(articulo)" |
| 79 | ng-focus="selectFocus($event); | 79 | ng-focus="selectFocus($event); |
| 80 | tmpCantidad = articulo.cantidad; | 80 | tmpCantidad = articulo.cantidad; |
| 81 | tmpPrecio = articulo.precio" | 81 | tmpPrecio = articulo.precio" |
| 82 | teclado-virtual | 82 | teclado-virtual |
| 83 | > | 83 | > |
| 84 | <i | 84 | <i |
| 85 | class="selectable" | 85 | class="selectable" |
| 86 | ng-click="cambioEdit(articulo, 'cantidad')" | 86 | ng-click="cambioEdit(articulo, 'cantidad')" |
| 87 | ng-hide="articulo.editCantidad && notaPedido.idRemito !== -1" | 87 | ng-hide="articulo.editCantidad && notaPedido.idRemito !== -1" |
| 88 | ng-bind="articulo.cantidad"> | 88 | ng-bind="articulo.cantidad"> |
| 89 | </i> | 89 | </i> |
| 90 | </td> | 90 | </td> |
| 91 | <td class="col text-right"> | 91 | <td class="col text-right"> |
| 92 | <input | 92 | <input |
| 93 | ng-show="articulo.editPrecio && notaPedido.idRemito !== -1" | 93 | ng-show="articulo.editPrecio && notaPedido.idRemito !== -1" |
| 94 | ng-model="tmpPrecio" | 94 | ng-model="tmpPrecio" |
| 95 | class="form-control" | 95 | class="form-control" |
| 96 | foca-tipo-input | 96 | foca-tipo-input |
| 97 | min="1" | 97 | min="0" |
| 98 | step="0.0001" | 98 | step="0.0001" |
| 99 | foca-focus="articulo.editPrecio" | 99 | foca-focus="articulo.editPrecio" |
| 100 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" | 100 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" |
| 101 | esc-key="cancelarEditar(articulo)" | 101 | esc-key="cancelarEditar(articulo)" |
| 102 | ng-focus="selectFocus($event); | 102 | ng-focus="selectFocus($event); |
| 103 | tmpCantidad = articulo.cantidad; | 103 | tmpCantidad = articulo.cantidad; |
| 104 | tmpPrecio = articulo.precio" | 104 | tmpPrecio = articulo.precio" |
| 105 | teclado-virtual | 105 | teclado-virtual |
| 106 | > | 106 | > |
| 107 | <i | 107 | <i |
| 108 | class="selectable" | 108 | class="selectable" |
| 109 | ng-click="cambioEdit(articulo, 'precio')" | 109 | ng-click="cambioEdit(articulo, 'precio')" |
| 110 | ng-hide="articulo.editPrecio && notaPedido.idRemito !== -1" | 110 | ng-hide="articulo.editPrecio && notaPedido.idRemito !== -1" |
| 111 | ng-bind="articulo.precio | number: 4" | 111 | ng-bind="articulo.precio | number: 4" |
| 112 | > | 112 | > |
| 113 | </i> | 113 | </i> |
| 114 | </td> | 114 | </td> |
| 115 | <td | 115 | <td |
| 116 | class="col text-right" | 116 | class="col text-right" |
| 117 | ng-bind="(articulo.precio * articulo.cantidad) | | 117 | ng-bind="(articulo.precio * articulo.cantidad) | |
| 118 | number: 2"> | 118 | number: 2"> |
| 119 | </td> | 119 | </td> |
| 120 | <td class="text-center"> | 120 | <td class="text-center"> |
| 121 | <button | 121 | <button |
| 122 | ng-show="articulo.editCantidad || articulo.editPrecio" | 122 | ng-show="articulo.editCantidad || articulo.editPrecio" |
| 123 | class="btn btn-outline-light" | 123 | class="btn btn-outline-light" |
| 124 | ng-click="editarArticulo(13, articulo)" | 124 | ng-click="editarArticulo(13, articulo)" |
| 125 | > | 125 | > |
| 126 | <i class="fa fa-save"></i> | 126 | <i class="fa fa-save"></i> |
| 127 | </button> | 127 | </button> |
| 128 | <button | 128 | <button |
| 129 | class="btn btn-outline-light" | 129 | class="btn btn-outline-light" |
| 130 | ng-click="quitarArticulo(key)" | 130 | ng-click="quitarArticulo(key)" |
| 131 | > | 131 | > |
| 132 | <i class="fa fa-trash"></i> | 132 | <i class="fa fa-trash"></i> |
| 133 | </button> | 133 | </button> |
| 134 | </td> | 134 | </td> |
| 135 | </tr> | 135 | </tr> |
| 136 | </tbody> | 136 | </tbody> |
| 137 | <tfoot> | 137 | <tfoot> |
| 138 | <tr ng-show="!cargando" class="d-flex"> | 138 | <tr ng-show="!cargando" class="d-flex"> |
| 139 | <td | 139 | <td |
| 140 | class="align-middle" | 140 | class="align-middle" |
| 141 | ng-bind="notaPedido.articulosNotaPedido.length + 1" | 141 | ng-bind="notaPedido.articulosNotaPedido.length + 1" |
| 142 | ></td> | 142 | ></td> |
| 143 | <td class="col"> | 143 | <td class="col"> |
| 144 | <input | 144 | <input |
| 145 | class="form-control" | 145 | class="form-control" |
| 146 | ng-model="articuloACargar.sectorCodigo" | 146 | ng-model="articuloACargar.sectorCodigo" |
| 147 | readonly | 147 | readonly |
| 148 | > | 148 | > |
| 149 | </td> | 149 | </td> |
| 150 | <td class="col-4 tabla-articulo-descripcion"> | 150 | <td class="col-4 tabla-articulo-descripcion"> |
| 151 | <input | 151 | <input |
| 152 | class="form-control" | 152 | class="form-control" |
| 153 | ng-model="articuloACargar.descripcion" | 153 | ng-model="articuloACargar.descripcion" |
| 154 | readonly | 154 | readonly |
| 155 | > | 155 | > |
| 156 | </td> | 156 | </td> |
| 157 | <td class="col text-right"> | 157 | <td class="col text-right"> |
| 158 | <input | 158 | <input |
| 159 | class="form-control" | 159 | class="form-control" |
| 160 | foca-tipo-input | 160 | foca-tipo-input |
| 161 | min="1" | 161 | min="1" |
| 162 | step="0.001" | 162 | step="0.001" |
| 163 | ng-model="articuloACargar.cantidad" | 163 | ng-model="articuloACargar.cantidad" |
| 164 | foca-focus="!cargando" | 164 | foca-focus="!cargando" |
| 165 | esc-key="resetFilter()" | 165 | esc-key="resetFilter()" |
| 166 | ng-keypress="agregarATabla($event.keyCode)" | 166 | ng-keypress="agregarATabla($event.keyCode)" |
| 167 | teclado-virtual | 167 | teclado-virtual |
| 168 | > | 168 | > |
| 169 | </td> | 169 | </td> |
| 170 | <td class="col text-right"> | 170 | <td class="col text-right"> |
| 171 | <input | 171 | <input |
| 172 | class="form-control" | 172 | class="form-control" |
| 173 | ng-value="articuloACargar.precio | number: 2" | 173 | ng-value="articuloACargar.precio | number: 4" |
| 174 | ng-show="idLista != -1" | 174 | ng-show="idLista != -1" |
| 175 | readonly | 175 | readonly |
| 176 | > | 176 | > |
| 177 | <input | 177 | <input |
| 178 | class="form-control" | 178 | class="form-control" |
| 179 | foca-tipo-input | 179 | foca-tipo-input |
| 180 | min="0" | 180 | min="0" |
| 181 | step="0.0001" | 181 | step="0.0001" |
| 182 | ng-model="articuloACargar.precio" | 182 | ng-model="articuloACargar.precio" |
| 183 | esc-key="resetFilter()" | 183 | esc-key="resetFilter()" |
| 184 | ng-keypress="agregarATabla($event.keyCode)" | 184 | ng-keypress="agregarATabla($event.keyCode)" |
| 185 | ng-show="idLista == -1" | 185 | ng-show="idLista == -1" |
| 186 | teclado-virtual | 186 | teclado-virtual |
| 187 | > | 187 | > |
| 188 | </td> | 188 | </td> |
| 189 | <td class="col text-right"> | 189 | <td class="col text-right"> |
| 190 | <input | 190 | <input |
| 191 | class="form-control" | 191 | class="form-control" |
| 192 | ng-value="getSubTotal() | number: 2" | 192 | ng-value="getSubTotal() | number: 2" |
| 193 | readonly | 193 | readonly |
| 194 | ></td> | 194 | ></td> |
| 195 | <td class="text-center align-middle"> | 195 | <td class="text-center align-middle"> |
| 196 | <button | 196 | <button |
| 197 | class="btn btn-outline-light" | 197 | class="btn btn-outline-light" |
| 198 | ng-click="agregarATabla(13)" | 198 | ng-click="agregarATabla(13)" |
| 199 | > | 199 | > |
| 200 | <i class="fa fa-save"></i> | 200 | <i class="fa fa-save"></i> |
| 201 | </button> | 201 | </button> |
| 202 | </td> | 202 | </td> |
| 203 | </tr> | 203 | </tr> |
| 204 | <tr class="d-flex"> | 204 | <tr class="d-flex"> |
| 205 | <td colspan="4" class="no-border-top"> | 205 | <td colspan="4" class="no-border-top"> |
| 206 | <strong>Items:</strong> | 206 | <strong>Items:</strong> |
| 207 | <a ng-bind="notaPedido.articulosNotaPedido.length"></a> | 207 | <a ng-bind="notaPedido.articulosNotaPedido.length"></a> |
| 208 | </td> | 208 | </td> |
| 209 | <td class="text-right ml-auto table-celda-total no-border-top"> | 209 | <td class="text-right ml-auto table-celda-total no-border-top"> |
| 210 | <h3>Total:</h3> | 210 | <h3>Total:</h3> |
| 211 | </td> | 211 | </td> |
| 212 | <td class="table-celda-total text-right no-border-top" colspan="1"> | 212 | <td class="table-celda-total text-right no-border-top" colspan="1"> |
| 213 | <h3>{{getTotal() | currency: notaPedido.cotizacion.moneda.SIMBOLO}}</h3> | 213 | <h3>{{getTotal() | currency: notaPedido.cotizacion.moneda.SIMBOLO}}</h3> |
| 214 | </td> | 214 | </td> |
| 215 | <td class="text-right no-border-top"> | 215 | <td class="text-right no-border-top"> |
| 216 | <button | 216 | <button |
| 217 | type="button" | 217 | type="button" |
| 218 | class="btn btn-default btn-sm" | 218 | class="btn btn-sm" |
| 219 | > | 219 | > |
| 220 | Totales | 220 | Totales |
| 221 | </button> | 221 | </button> |
| 222 | </td> | 222 | </td> |
| 223 | </tr> | 223 | </tr> |
| 224 | </tfoot> | 224 | </tfoot> |
| 225 | </table> | 225 | </table> |
| 226 | </div> | 226 | </div> |
| 227 | <!-- MOBILE --> | 227 | <!-- MOBILE --> |
| 228 | <div class="row d-sm-none"> | 228 | <div class="row d-sm-none"> |
| 229 | <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile"> | 229 | <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile"> |
| 230 | <thead> | 230 | <thead> |
| 231 | <tr class="d-flex"> | 231 | <tr class="d-flex"> |
| 232 | <th class="">#</th> | 232 | <th class="">#</th> |
| 233 | <th class="col px-0"> | 233 | <th class="col px-0"> |
| 234 | <div class="d-flex"> | 234 | <div class="d-flex"> |
| 235 | <div class="col-4 px-1">Código</div> | 235 | <div class="col-4 px-1">Código</div> |
| 236 | <div class="col-8 px-1">Descripción</div> | 236 | <div class="col-8 px-1">Descripción</div> |
| 237 | </div> | 237 | </div> |
| 238 | <div class="d-flex"> | 238 | <div class="d-flex"> |
| 239 | <div class="col-3 px-1">Cantidad</div> | 239 | <div class="col-3 px-1">Cantidad</div> |
| 240 | <div class="col px-1 text-right">P. Uni.</div> | 240 | <div class="col px-1 text-right">P. Uni.</div> |
| 241 | <div class="col px-1 text-right">Subtotal</div> | 241 | <div class="col px-1 text-right">Subtotal</div> |
| 242 | </div> | 242 | </div> |
| 243 | </th> | 243 | </th> |
| 244 | <th class="text-center tamaño-boton"> | 244 | <th class="text-center tamaño-boton"> |
| 245 | | 245 | |
| 246 | </th> | 246 | </th> |
| 247 | </tr> | 247 | </tr> |
| 248 | </thead> | 248 | </thead> |
| 249 | <tbody> | 249 | <tbody> |
| 250 | <tr | 250 | <tr |
| 251 | ng-repeat="(key, articulo) in notaPedido.articulosNotaPedido" | 251 | ng-repeat="(key, articulo) in notaPedido.articulosNotaPedido" |
| 252 | ng-show="show || key == notaPedido.articulosNotaPedido.length - 1" | 252 | ng-show="show || key == notaPedido.articulosNotaPedido.length - 1" |
| 253 | > | 253 | > |
| 254 | <td class="w-100 align-middle d-flex p-0"> | 254 | <td class="w-100 align-middle d-flex p-0"> |
| 255 | <div class="align-middle p-1"> | 255 | <div class="align-middle p-1"> |
| 256 | <span ng-bind="key+1" class="align-middle"></span> | 256 | <span ng-bind="key+1" class="align-middle"></span> |
| 257 | </div> | 257 | </div> |
| 258 | <div class="col px-0"> | 258 | <div class="col px-0"> |
| 259 | <div class="d-flex"> | 259 | <div class="d-flex"> |
| 260 | <div class="col-4 px-1"> | 260 | <div class="col-4 px-1"> |
| 261 | <span | 261 | <span |
| 262 | ng-bind="articulo.sector + '-' + articulo.codigo" | 262 | ng-bind="articulo.sector + '-' + articulo.codigo" |
| 263 | ></span> | 263 | ></span> |
| 264 | </div> | 264 | </div> |
| 265 | <div class="col-8 px-1"> | 265 | <div class="col-8 px-1"> |
| 266 | <span ng-bind="articulo.descripcion"></span> | 266 | <span ng-bind="articulo.descripcion"></span> |
| 267 | </div> | 267 | </div> |
| 268 | </div> | 268 | </div> |
| 269 | <div class="d-flex"> | 269 | <div class="d-flex"> |
| 270 | <div class="col-3 px-1"> | 270 | <div class="col-3 px-1"> |
| 271 | <span | 271 | <span |
| 272 | ng-bind="'x' + articulo.cantidad" | 272 | ng-bind="'x' + articulo.cantidad" |
| 273 | ng-hide="articulo.editCantidad" | 273 | ng-hide="articulo.editCantidad" |
| 274 | ></span> | 274 | ></span> |
| 275 | <i | 275 | <i |
| 276 | class="fa fa-pencil text-white-50" | 276 | class="fa fa-pencil text-white-50" |
| 277 | aria-hidden="true" | 277 | aria-hidden="true" |
| 278 | ng-hide="articulo.editCantidad" | 278 | ng-hide="articulo.editCantidad" |
| 279 | ng-click="articulo.editCantidad = true" | 279 | ng-click="articulo.editCantidad = true" |
| 280 | ></i> | 280 | ></i> |
| 281 | <input | 281 | <input |
| 282 | ng-show="articulo.editCantidad" | 282 | ng-show="articulo.editCantidad" |
| 283 | ng-model="articulo.cantidad" | 283 | ng-model="articulo.cantidad" |
| 284 | class="form-control" | 284 | class="form-control" |
| 285 | foca-tipo-input | 285 | foca-tipo-input |
| 286 | min="1" | 286 | min="1" |
| 287 | step="0.001" | 287 | step="0.001" |
| 288 | foca-focus="articulo.editCantidad" | 288 | foca-focus="articulo.editCantidad" |
| 289 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 289 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
| 290 | ng-focus="selectFocus($event)" | 290 | ng-focus="selectFocus($event)" |
| 291 | > | 291 | > |
| 292 | </div> | 292 | </div> |
| 293 | <div class="col px-1 text-right"> | 293 | <div class="col px-1 text-right"> |
| 294 | <span ng-bind="articulo.precio | | 294 | <span ng-bind="articulo.precio | |
| 295 | currency: notaPedido.moneda.SIMBOLO : 4"></span> | 295 | currency: notaPedido.moneda.SIMBOLO : 4"></span> |
| 296 | ></span> | 296 | ></span> |
| 297 | </div> | 297 | </div> |
| 298 | <div class="col px-1 text-right"> | 298 | <div class="col px-1 text-right"> |
| 299 | <span | 299 | <span |
| 300 | ng-bind="(articulo.precio * articulo.cantidad) | | 300 | ng-bind="(articulo.precio * articulo.cantidad) | |
| 301 | currency: notaPedido.moneda.SIMBOLO" | 301 | currency: notaPedido.moneda.SIMBOLO" |
| 302 | > | 302 | > |
| 303 | </span> | 303 | </span> |
| 304 | </div> | 304 | </div> |
| 305 | </div> | 305 | </div> |
| 306 | </div> | 306 | </div> |
| 307 | <div class="align-middle p-1"> | 307 | <div class="align-middle p-1"> |
| 308 | <button | 308 | <button |
| 309 | class="btn btn-outline-light" | 309 | class="btn btn-outline-light" |
| 310 | ng-click="quitarArticulo(key)" | 310 | ng-click="quitarArticulo(key)" |
| 311 | > | 311 | > |
| 312 | <i class="fa fa-trash"></i> | 312 | <i class="fa fa-trash"></i> |
| 313 | </button> | 313 | </button> |
| 314 | </div> | 314 | </div> |
| 315 | </td> | 315 | </td> |
| 316 | </tr> | 316 | </tr> |
| 317 | </tbody> | 317 | </tbody> |
| 318 | <tfoot> | 318 | <tfoot> |
| 319 | <!-- CARGANDO ITEM --> | 319 | <!-- CARGANDO ITEM --> |
| 320 | <tr ng-show="!cargando" class="d-flex"> | 320 | <tr ng-show="!cargando" class="d-flex"> |
| 321 | <td | 321 | <td |
| 322 | class="align-middle p-1" | 322 | class="align-middle p-1" |
| 323 | ng-bind="notaPedido.articulosNotaPedido.length + 1" | 323 | ng-bind="notaPedido.articulosNotaPedido.length + 1" |
| 324 | ></td> | 324 | ></td> |
| 325 | <td class="col p-0"> | 325 | <td class="col p-0"> |
| 326 | <div class="d-flex"> | 326 | <div class="d-flex"> |
| 327 | <div class="col-4 px-1"> | 327 | <div class="col-4 px-1"> |
| 328 | <span | 328 | <span |
| 329 | ng-bind="articuloACargar.sectorCodigo" | 329 | ng-bind="articuloACargar.sectorCodigo" |
| 330 | ></span> | 330 | ></span> |
| 331 | </div> | 331 | </div> |
| 332 | <div class="col-8 px-1"> | 332 | <div class="col-8 px-1"> |
| 333 | <span ng-bind="articuloACargar.descripcion"></span> | 333 | <span ng-bind="articuloACargar.descripcion"></span> |
| 334 | </div> | 334 | </div> |
| 335 | </div> | 335 | </div> |
| 336 | <div class="d-flex"> | 336 | <div class="d-flex"> |
| 337 | <div class="col-3 px-1 m-1"> | 337 | <div class="col-3 px-1 m-1"> |
| 338 | <input | 338 | <input |
| 339 | class="form-control p-1" | 339 | class="form-control p-1" |
| 340 | foca-tipo-input | 340 | foca-tipo-input |
| 341 | min="1" | 341 | min="1" |
| 342 | ng-model="articuloACargar.cantidad" | 342 | ng-model="articuloACargar.cantidad" |
| 343 | foca-focus="!cargando" | 343 | foca-focus="!cargando" |
| 344 | ng-keypress="agregarATabla($event.keyCode)" | 344 | ng-keypress="agregarATabla($event.keyCode)" |
| 345 | style="height: auto; line-height: 1.1em" | 345 | style="height: auto; line-height: 1.1em" |
| 346 | > | 346 | > |
| 347 | </div> | 347 | </div> |
| 348 | <div class="col px-1 text-right"> | 348 | <div class="col px-1 text-right"> |
| 349 | <span ng-bind="articuloACargar.precio | | 349 | <span ng-bind="articuloACargar.precio | |
| 350 | currency: notaPedido.moneda.SIMBOLO : 4" | 350 | currency: notaPedido.moneda.SIMBOLO : 4" |
| 351 | ></span> | 351 | ></span> |
| 352 | </div> | 352 | </div> |
| 353 | <div class="col px-1 text-right"> | 353 | <div class="col px-1 text-right"> |
| 354 | <span | 354 | <span |
| 355 | ng-bind="getSubTotal() | | 355 | ng-bind="getSubTotal() | |
| 356 | currency: notaPedido.moneda.SIMBOLO" | 356 | currency: notaPedido.moneda.SIMBOLO" |
| 357 | > | 357 | > |
| 358 | </span> | 358 | </span> |
| 359 | </div> | 359 | </div> |
| 360 | </div> | 360 | </div> |
| 361 | </td> | 361 | </td> |
| 362 | <td class="text-center align-middle"> | 362 | <td class="text-center align-middle"> |
| 363 | <button | 363 | <button |
| 364 | class="btn btn-outline-light" | 364 | class="btn btn-outline-light" |
| 365 | ng-click="agregarATabla(13)" | 365 | ng-click="agregarATabla(13)" |
| 366 | > | 366 | > |
| 367 | <i class="fa fa-save"></i> | 367 | <i class="fa fa-save"></i> |
| 368 | </button> | 368 | </button> |
| 369 | </td> | 369 | </td> |
| 370 | </tr> | 370 | </tr> |
| 371 | <!-- TOOGLE EXPANDIR --> | 371 | <!-- TOOGLE EXPANDIR --> |
| 372 | <tr> | 372 | <tr> |
| 373 | <td class="col"> | 373 | <td class="col"> |
| 374 | <button | 374 | <button |
| 375 | class="btn btn-outline-light selectable w-100" | 375 | class="btn btn-outline-light selectable w-100" |
| 376 | ng-click="show = !show; masMenos()" | 376 | ng-click="show = !show; masMenos()" |
| 377 | ng-show="notaPedido.articulosNotaPedido.length > 0" | 377 | ng-show="notaPedido.articulosNotaPedido.length > 0" |
| 378 | > | 378 | > |
| 379 | <i | 379 | <i |
| 380 | class="fa fa-chevron-down" | 380 | class="fa fa-chevron-down" |
| 381 | ng-hide="show" | 381 | ng-hide="show" |
| 382 | aria-hidden="true" | 382 | aria-hidden="true" |
| 383 | > | 383 | > |
| 384 | </i> | 384 | </i> |
| 385 | <i | 385 | <i |
| 386 | class="fa fa-chevron-up" | 386 | class="fa fa-chevron-up" |
| 387 | ng-show="show" | 387 | ng-show="show" |
| 388 | aria-hidden="true"> | 388 | aria-hidden="true"> |
| 389 | </i> | 389 | </i> |
| 390 | </button> | 390 | </button> |
| 391 | </td> | 391 | </td> |
| 392 | </tr> | 392 | </tr> |
| 393 | <!-- FOOTER --> | 393 | <!-- FOOTER --> |
| 394 | <tr class="d-flex"> | 394 | <tr class="d-flex"> |
| 395 | <td class="align-middle no-border-top" colspan="2"> | 395 | <td class="align-middle no-border-top" colspan="2"> |
| 396 | <strong>Cantidad Items:</strong> | 396 | <strong>Cantidad Items:</strong> |
| 397 | <a ng-bind="notaPedido.articulosNotaPedido.length"></a> | 397 | <a ng-bind="notaPedido.articulosNotaPedido.length"></a> |
| 398 | </td> | 398 | </td> |
| 399 | <td class="text-right ml-auto table-celda-total no-border-top"> | 399 | <td class="text-right ml-auto table-celda-total no-border-top"> |
| 400 | <h3>Total:</h3> | 400 | <h3>Total:</h3> |
| 401 | </td> | 401 | </td> |
| 402 | <td class="table-celda-total text-right no-border-top"> | 402 | <td class="table-celda-total text-right no-border-top"> |
| 403 | <h3>{{getTotal() | currency: notaPedido.cotizacion.moneda.SIMBOLO}}</h3> | 403 | <h3>{{getTotal() | currency: notaPedido.cotizacion.moneda.SIMBOLO}}</h3> |
| 404 | </td> | 404 | </td> |
| 405 | </tr> | 405 | </tr> |
| 406 | </tfoot> | 406 | </tfoot> |
| 407 | </table> | 407 | </table> |
| 408 | </div> | 408 | </div> |
| 409 | </div> | 409 | </div> |
| 410 | </div> | 410 | </div> |
| 411 | </div> | 411 | </div> |
| 412 | <div class="row d-md-none fixed-bottom"> | 412 | <div class="row d-md-none fixed-bottom"> |
| 413 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> | 413 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> |
| 414 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> | 414 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> |
| 415 | <span | 415 | <span |
| 416 | class="mr-3 ml-auto" | 416 | class="mr-3 ml-auto" |
| 417 | ng-class="saveLoading ? 'text-muted' : ''" | 417 | ng-class="saveLoading ? 'text-muted' : ''" |
| 418 | ng-click="crearNotaPedido()" | 418 | ng-click="crearNotaPedido()" |
| 419 | ladda="saveLoading" | 419 | ladda="saveLoading" |
| 420 | data-style="expand-left" | 420 | data-style="expand-left" |
| 421 | >Guardar</span> | 421 | >Guardar</span> |
| 422 | </div> | 422 | </div> |
| 423 | </div> | 423 | </div> |
| 424 | </div> | 424 | </div> |
| 425 | 425 |