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