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