Commit dbbb1b199ca7a4e4f60307d815f989ba66eff7a5

Authored by Eric Fernandez
Exists in master

Merge branch 'develop' into 'master'

Develop

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