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