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