Commit 4aa13a42e362330e984bf7f2a2b1f83017d3c490

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'develop'

Master(efernandez)

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