Commit 13b8ea7401e22fe7f4d9f226e317ac4a203a05e4

Authored by Eric Fernandez
Exists in master and in 1 other branch develop

Merge branch 'master' into 'develop'

Master

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