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