Commit 4fadda5a86bf0d6fc5881b6f40622ef7767ffffc

Authored by Luigi
1 parent 2d38a92295
Exists in master and in 1 other branch develop

Revert "Alerta de valores en editar producto"

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