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