Commit 44d96ee19c3c80cb96fdab5d72e707fc88891af5

Authored by Luigi
1 parent 638e7c6e59
Exists in master

Cambio

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