Commit 03ecc36c1b87de4848583ab735648c9b41014957

Authored by Marcelo
1 parent 8fc201c41d
Exists in master

Agregada funcionalidad para que si se editan los detalles y se apreta esc, los v…

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