Commit 9b31d344c5d541d397679374b3fa511dda49382a

Authored by Jose Pinto
1 parent 99532cb1a9
Exists in master

Auto stash before merge of "master" and "upstream/master"

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