Commit dc8ce4a6c192ae08d89f155def4a045dcd34b2df

Authored by Luigi
1 parent 522d6b028e
Exists in master

Alerta de valores en editar producto

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