Commit 9bfe7ac651c30fc5364b1e7f4c2f425d907eabfe

Authored by Jose Pinto
Exists in master

Merge branch 'master' into 'master'

Boton puntos de descarga

See merge request !19
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 function( 14 function(
15 $scope, $uibModal, $location, $filter, $timeout, 15 $scope, $uibModal, $location, $filter, $timeout,
16 crearNotaPedidoService, focaBotoneraLateralService, 16 crearNotaPedidoService, focaBotoneraLateralService,
17 focaModalService, notaPedidoBusinessService, $rootScope, focaSeguimientoService) 17 focaModalService, notaPedidoBusinessService, $rootScope, focaSeguimientoService)
18 { 18 {
19 19
20 $scope.botonera = crearNotaPedidoService.getBotonera(); 20 $scope.botonera = crearNotaPedidoService.getBotonera();
21 21
22 $scope.isNumber = angular.isNumber; 22 $scope.isNumber = angular.isNumber;
23 $scope.datepickerAbierto = false; 23 $scope.datepickerAbierto = false;
24 $scope.show = false; 24 $scope.show = false;
25 $scope.cargando = true; 25 $scope.cargando = true;
26 $scope.dateOptions = { 26 $scope.dateOptions = {
27 maxDate: new Date(), 27 maxDate: new Date(),
28 minDate: new Date(2010, 0, 1) 28 minDate: new Date(2010, 0, 1)
29 }; 29 };
30 30
31 $scope.notaPedido = { 31 $scope.notaPedido = {
32 id: 0, 32 id: 0,
33 vendedor: {}, 33 vendedor: {},
34 cliente: {}, 34 cliente: {},
35 proveedor: {}, 35 proveedor: {},
36 domicilio: {dom: ''}, 36 domicilio: {dom: ''},
37 moneda: {}, 37 moneda: {},
38 cotizacion: {} 38 cotizacion: {}
39 }; 39 };
40 var monedaPorDefecto; 40 var monedaPorDefecto;
41 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' 41 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
42 crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { 42 crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) {
43 monedaPorDefecto = res.data[0]; 43 monedaPorDefecto = res.data[0];
44 $scope.notaPedido.moneda = monedaPorDefecto; 44 $scope.notaPedido.moneda = monedaPorDefecto;
45 $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; 45 $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0];
46 }); 46 });
47 47
48 $scope.cabecera = []; 48 $scope.cabecera = [];
49 $scope.showCabecera = true; 49 $scope.showCabecera = true;
50 50
51 $scope.now = new Date(); 51 $scope.now = new Date();
52 $scope.puntoVenta = '0000'; 52 $scope.puntoVenta = '0000';
53 $scope.comprobante = '00000000'; 53 $scope.comprobante = '00000000';
54 $scope.articulosTabla = []; 54 $scope.articulosTabla = [];
55 $scope.idLista = undefined; 55 $scope.idLista = undefined;
56 56
57 //SETEO BOTONERA LATERAL 57 //SETEO BOTONERA LATERAL
58 $timeout(function() { 58 $timeout(function() {
59 focaBotoneraLateralService.showSalir(true); 59 focaBotoneraLateralService.showSalir(true);
60 focaBotoneraLateralService.showPausar(true); 60 focaBotoneraLateralService.showPausar(true);
61 focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); 61 focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido);
62 }); 62 });
63 63
64 crearNotaPedidoService.getPrecioCondicion().then( 64 crearNotaPedidoService.getPrecioCondicion().then(
65 function(res) { 65 function(res) {
66 $scope.precioCondiciones = res.data; 66 $scope.precioCondiciones = res.data;
67 } 67 }
68 ); 68 );
69 69
70 crearNotaPedidoService.getNumeroNotaPedido().then( 70 crearNotaPedidoService.getNumeroNotaPedido().then(
71 function(res) { 71 function(res) {
72 $scope.puntoVenta = rellenar(res.data.sucursal, 4); 72 $scope.puntoVenta = rellenar(res.data.sucursal, 4);
73 $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); 73 $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8);
74 }, 74 },
75 function(err) { 75 function(err) {
76 focaModalService.alert('La terminal no esta configurada correctamente'); 76 focaModalService.alert('La terminal no esta configurada correctamente');
77 console.info(err); 77 console.info(err);
78 } 78 }
79 ); 79 );
80 80
81 $scope.crearNotaPedido = function() { 81 $scope.crearNotaPedido = function() {
82 if(!$scope.notaPedido.vendedor.CodVen) { 82 if(!$scope.notaPedido.vendedor.CodVen) {
83 focaModalService.alert('Ingrese Vendedor'); 83 focaModalService.alert('Ingrese Vendedor');
84 return; 84 return;
85 } else if(!$scope.notaPedido.cliente.COD) { 85 } else if(!$scope.notaPedido.cliente.COD) {
86 focaModalService.alert('Ingrese Cliente'); 86 focaModalService.alert('Ingrese Cliente');
87 return; 87 return;
88 } else if(!$scope.notaPedido.proveedor.COD) { 88 } else if(!$scope.notaPedido.proveedor.COD) {
89 focaModalService.alert('Ingrese Proveedor'); 89 focaModalService.alert('Ingrese Proveedor');
90 return; 90 return;
91 } else if(!$scope.notaPedido.moneda.ID) { 91 } else if(!$scope.notaPedido.moneda.ID) {
92 focaModalService.alert('Ingrese Moneda'); 92 focaModalService.alert('Ingrese Moneda');
93 return; 93 return;
94 } else if(!$scope.notaPedido.cotizacion.ID) { 94 } else if(!$scope.notaPedido.cotizacion.ID) {
95 focaModalService.alert('Ingrese Cotización'); 95 focaModalService.alert('Ingrese Cotización');
96 return; 96 return;
97 } else if(!$scope.plazosPagos) { 97 } else if(!$scope.plazosPagos) {
98 focaModalService.alert('Ingrese Precios y Condiciones'); 98 focaModalService.alert('Ingrese Precios y Condiciones');
99 return; 99 return;
100 } else if( 100 } else if(
101 $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) 101 $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null)
102 { 102 {
103 focaModalService.alert('Ingrese Flete'); 103 focaModalService.alert('Ingrese Flete');
104 return; 104 return;
105 } else if(!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto 105 } else if(!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto
106 focaModalService.alert('Ingrese Domicilio'); 106 focaModalService.alert('Ingrese Domicilio');
107 return; 107 return;
108 } else if($scope.articulosTabla.length === 0) { 108 } else if($scope.articulosTabla.length === 0) {
109 focaModalService.alert('Debe cargar al menos un articulo'); 109 focaModalService.alert('Debe cargar al menos un articulo');
110 return; 110 return;
111 } 111 }
112 $scope.saveLoading = true; 112 $scope.saveLoading = true;
113 var notaPedido = { 113 var notaPedido = {
114 id: $scope.notaPedido.id, 114 id: $scope.notaPedido.id,
115 fechaCarga: $scope.now.toISOString().slice(0, 19).replace('T', ' '), 115 fechaCarga: $scope.now.toISOString().slice(0, 19).replace('T', ' '),
116 idVendedor: $scope.notaPedido.vendedor.CodVen, 116 idVendedor: $scope.notaPedido.vendedor.CodVen,
117 idCliente: $scope.notaPedido.cliente.COD, 117 idCliente: $scope.notaPedido.cliente.COD,
118 nombreCliente: $scope.notaPedido.cliente.NOM, 118 nombreCliente: $scope.notaPedido.cliente.NOM,
119 cuitCliente: $scope.notaPedido.cliente.CUIT, 119 cuitCliente: $scope.notaPedido.cliente.CUIT,
120 idProveedor: $scope.notaPedido.proveedor.COD, 120 idProveedor: $scope.notaPedido.proveedor.COD,
121 //idDomicilio: $scope.notaPedido.domicilio.id,TODO GUARDAR DOMICILIO ID 121 //idDomicilio: $scope.notaPedido.domicilio.id,TODO GUARDAR DOMICILIO ID
122 idCotizacion: $scope.notaPedido.cotizacion.ID, 122 idCotizacion: $scope.notaPedido.cotizacion.ID,
123 idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, 123 idPrecioCondicion: $scope.notaPedido.idPrecioCondicion,
124 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, 124 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR,
125 flete: $scope.notaPedido.flete, 125 flete: $scope.notaPedido.flete,
126 fob: $scope.notaPedido.fob, 126 fob: $scope.notaPedido.fob,
127 bomba: $scope.notaPedido.bomba, 127 bomba: $scope.notaPedido.bomba,
128 kilometros: $scope.notaPedido.kilometros, 128 kilometros: $scope.notaPedido.kilometros,
129 domicilioStamp: $scope.notaPedido.domicilioStamp, 129 domicilioStamp: $scope.notaPedido.domicilioStamp,
130 estado: 0, 130 estado: 0,
131 total: $scope.getTotal() 131 total: $scope.getTotal()
132 }; 132 };
133 crearNotaPedidoService.crearNotaPedido(notaPedido).then( 133 crearNotaPedidoService.crearNotaPedido(notaPedido).then(
134 function(data) { 134 function(data) {
135 // Al guardar los datos de la nota de pedido logueamos la 135 // Al guardar los datos de la nota de pedido logueamos la
136 // actividad para su seguimiento. 136 // actividad para su seguimiento.
137 //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? 137 //TODO: GUARDAR POSISIONAMIENTO AL EDITAR?
138 focaSeguimientoService.guardarPosicion( 138 focaSeguimientoService.guardarPosicion(
139 'Nota de pedido', 139 'Nota de pedido',
140 data.data.id, 140 data.data.id,
141 '' 141 ''
142 ); 142 );
143 notaPedidoBusinessService.addArticulos($scope.articulosTabla, 143 notaPedidoBusinessService.addArticulos($scope.articulosTabla,
144 data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); 144 data.data.id, $scope.notaPedido.cotizacion.VENDEDOR);
145 145
146 if($scope.notaPedido.puntosDescarga) { 146 if($scope.notaPedido.puntosDescarga) {
147 notaPedidoBusinessService.addPuntosDescarga(data.data.id, 147 notaPedidoBusinessService.addPuntosDescarga(data.data.id,
148 $scope.notaPedido.puntosDescarga); 148 $scope.notaPedido.puntosDescarga);
149 } 149 }
150 150
151 var plazos = $scope.plazosPagos; 151 var plazos = $scope.plazosPagos;
152 var plazosACrear = []; 152 var plazosACrear = [];
153 plazos.forEach(function(plazo) { 153 plazos.forEach(function(plazo) {
154 plazosACrear.push({ 154 plazosACrear.push({
155 idNotaPedido: data.data.id, 155 idNotaPedido: data.data.id,
156 dias: plazo.dias 156 dias: plazo.dias
157 }); 157 });
158 }); 158 });
159 crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); 159 crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear);
160 160
161 notaPedidoBusinessService.addEstado(data.data.id, 161 notaPedidoBusinessService.addEstado(data.data.id,
162 $scope.notaPedido.vendedor.CodVen); 162 $scope.notaPedido.vendedor.CodVen);
163 163
164 focaModalService.alert('Nota pedido creada'); 164 focaModalService.alert('Nota pedido creada');
165 $scope.saveLoading = false; 165 $scope.saveLoading = false;
166 $scope.$broadcast('cleanCabecera'); 166 $scope.$broadcast('cleanCabecera');
167 $scope.$broadcast('addCabecera', { 167 $scope.$broadcast('addCabecera', {
168 label: 'Moneda:', 168 label: 'Moneda:',
169 valor: $scope.notaPedido.moneda.DETALLE 169 valor: $scope.notaPedido.moneda.DETALLE
170 }); 170 });
171 $scope.$broadcast('addCabecera', { 171 $scope.$broadcast('addCabecera', {
172 label: 'Fecha cotizacion:', 172 label: 'Fecha cotizacion:',
173 valor: $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') 173 valor: $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy')
174 }); 174 });
175 $scope.$broadcast('addCabecera', { 175 $scope.$broadcast('addCabecera', {
176 label: 'Moneda:', 176 label: 'Moneda:',
177 valor: $scope.notaPedido.moneda.DETALLE 177 valor: $scope.notaPedido.moneda.DETALLE
178 }); 178 });
179 $scope.$broadcast('addCabecera', { 179 $scope.$broadcast('addCabecera', {
180 label: 'Cotizacion:', 180 label: 'Cotizacion:',
181 valor: $filter('number')($scope.notaPedido.cotizacion.VENDEDOR, '2') 181 valor: $filter('number')($scope.notaPedido.cotizacion.VENDEDOR, '2')
182 }); 182 });
183 crearNotaPedidoService.getNumeroNotaPedido().then( 183 crearNotaPedidoService.getNumeroNotaPedido().then(
184 function(res) { 184 function(res) {
185 $scope.puntoVenta = rellenar(res.data.sucursal, 4); 185 $scope.puntoVenta = rellenar(res.data.sucursal, 4);
186 $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); 186 $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8);
187 }, 187 },
188 function(err) { 188 function(err) {
189 focaModalService.alert( 189 focaModalService.alert(
190 'La terminal no esta configurada correctamente'); 190 'La terminal no esta configurada correctamente');
191 console.info(err); 191 console.info(err);
192 } 192 }
193 ); 193 );
194 $scope.notaPedido.vendedor = {}; 194 $scope.notaPedido.vendedor = {};
195 $scope.notaPedido.cliente = {}; 195 $scope.notaPedido.cliente = {};
196 $scope.notaPedido.proveedor = {}; 196 $scope.notaPedido.proveedor = {};
197 $scope.notaPedido.domicilio = {}; 197 $scope.notaPedido.domicilio = {};
198 $scope.notaPedido.flete = null; 198 $scope.notaPedido.flete = null;
199 $scope.notaPedido.fob = null; 199 $scope.notaPedido.fob = null;
200 $scope.notaPedido.bomba = null; 200 $scope.notaPedido.bomba = null;
201 $scope.notaPedido.kilometros = null; 201 $scope.notaPedido.kilometros = null;
202 $scope.articulosTabla = []; 202 $scope.articulosTabla = [];
203 }, 203 },
204 function(error) { 204 function(error) {
205 focaModalService.alert('Hubo un error al crear la nota de pedido'); 205 focaModalService.alert('Hubo un error al crear la nota de pedido');
206 $scope.saveLoading = false; 206 $scope.saveLoading = false;
207 console.info(error); 207 console.info(error);
208 } 208 }
209 ); 209 );
210 }; 210 };
211 211
212 $scope.seleccionarNotaPedido = function() { 212 $scope.seleccionarNotaPedido = function() {
213 var modalInstance = $uibModal.open( 213 var modalInstance = $uibModal.open(
214 { 214 {
215 ariaLabelledBy: 'Busqueda de Nota de Pedido', 215 ariaLabelledBy: 'Busqueda de Nota de Pedido',
216 templateUrl: 'foca-modal-nota-pedido.html', 216 templateUrl: 'foca-modal-nota-pedido.html',
217 controller: 'focaModalNotaPedidoController', 217 controller: 'focaModalNotaPedidoController',
218 size: 'lg', 218 size: 'lg',
219 resolve: {usadoPor: function() {return 'notaPedido';}} 219 resolve: {usadoPor: function() {return 'notaPedido';}}
220 } 220 }
221 ); 221 );
222 modalInstance.result.then( 222 modalInstance.result.then(
223 function(notaPedido) { 223 function(notaPedido) {
224 $scope.now = new Date(notaPedido.fechaCarga); 224 $scope.now = new Date(notaPedido.fechaCarga);
225 //añado cabeceras 225 //añado cabeceras
226 $scope.notaPedido.id = notaPedido.id; 226 $scope.notaPedido.id = notaPedido.id;
227 $scope.$broadcast('removeCabecera', 'Bomba:'); 227 $scope.$broadcast('removeCabecera', 'Bomba:');
228 $scope.$broadcast('removeCabecera', 'Kilometros:'); 228 $scope.$broadcast('removeCabecera', 'Kilometros:');
229 var cabeceras = [ 229 var cabeceras = [
230 { 230 {
231 label: 'Moneda:', 231 label: 'Moneda:',
232 valor: notaPedido.cotizacion.moneda.DETALLE 232 valor: notaPedido.cotizacion.moneda.DETALLE
233 }, 233 },
234 { 234 {
235 label: 'Fecha cotizacion:', 235 label: 'Fecha cotizacion:',
236 valor: $filter('date')(notaPedido.cotizacion.FECHA, 236 valor: $filter('date')(notaPedido.cotizacion.FECHA,
237 'dd/MM/yyyy') 237 'dd/MM/yyyy')
238 }, 238 },
239 { 239 {
240 label: 'Cotizacion:', 240 label: 'Cotizacion:',
241 valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, 241 valor: $filter('number')(notaPedido.cotizacion.VENDEDOR,
242 '2') 242 '2')
243 }, 243 },
244 { 244 {
245 label: 'Cliente:', 245 label: 'Cliente:',
246 valor: notaPedido.cliente.NOM 246 valor: notaPedido.cliente.NOM
247 }, 247 },
248 { 248 {
249 label: 'Domicilio:', 249 label: 'Domicilio:',
250 valor: notaPedido.domicilioStamp 250 valor: notaPedido.domicilioStamp
251 }, 251 },
252 { 252 {
253 label: 'Vendedor:', 253 label: 'Vendedor:',
254 valor: notaPedido.vendedor.NomVen 254 valor: notaPedido.vendedor.NomVen
255 }, 255 },
256 { 256 {
257 label: 'Proveedor:', 257 label: 'Proveedor:',
258 valor: notaPedido.proveedor.NOM 258 valor: notaPedido.proveedor.NOM
259 }, 259 },
260 { 260 {
261 label: 'Precios y condiciones:', 261 label: 'Precios y condiciones:',
262 valor: valorPrecioCondicion() + ' ' + 262 valor: valorPrecioCondicion() + ' ' +
263 notaPedidoBusinessService 263 notaPedidoBusinessService
264 .plazoToString(notaPedido.notaPedidoPlazo) 264 .plazoToString(notaPedido.notaPedidoPlazo)
265 }, 265 },
266 { 266 {
267 label: 'Flete:', 267 label: 'Flete:',
268 valor: notaPedido.fob === 1 ? 'FOB' : ( 268 valor: notaPedido.fob === 1 ? 'FOB' : (
269 notaPedido.flete === 1 ? 'Si' : 'No') 269 notaPedido.flete === 1 ? 'Si' : 'No')
270 } 270 }
271 ]; 271 ];
272 272
273 function valorPrecioCondicion() { 273 function valorPrecioCondicion() {
274 if(notaPedido.idPrecioCondicion > 0) { 274 if(notaPedido.idPrecioCondicion > 0) {
275 return notaPedido.precioCondicion.nombre; 275 return notaPedido.precioCondicion.nombre;
276 } else { 276 } else {
277 return 'Ingreso Manual'; 277 return 'Ingreso Manual';
278 } 278 }
279 } 279 }
280 280
281 if(notaPedido.flete === 1) { 281 if(notaPedido.flete === 1) {
282 var cabeceraBomba = { 282 var cabeceraBomba = {
283 label: 'Bomba:', 283 label: 'Bomba:',
284 valor: notaPedido.bomba === 1 ? 'Si' : 'No' 284 valor: notaPedido.bomba === 1 ? 'Si' : 'No'
285 }; 285 };
286 if(notaPedido.kilometros) { 286 if(notaPedido.kilometros) {
287 var cabeceraKilometros = { 287 var cabeceraKilometros = {
288 label: 'Kilometros:', 288 label: 'Kilometros:',
289 valor: notaPedido.kilometros 289 valor: notaPedido.kilometros
290 }; 290 };
291 cabeceras.push(cabeceraKilometros); 291 cabeceras.push(cabeceraKilometros);
292 } 292 }
293 cabeceras.push(cabeceraBomba); 293 cabeceras.push(cabeceraBomba);
294 } 294 }
295 $scope.articulosTabla = notaPedido.articulosNotaPedido; 295 $scope.articulosTabla = notaPedido.articulosNotaPedido;
296 notaPedidoBusinessService.calcularArticulos($scope.articulosTabla, 296 notaPedidoBusinessService.calcularArticulos($scope.articulosTabla,
297 notaPedido.cotizacion.VENDEDOR); 297 notaPedido.cotizacion.VENDEDOR);
298 if(notaPedido.idPrecioCondicion > 0) { 298 if(notaPedido.idPrecioCondicion > 0) {
299 $scope.idLista = notaPedido.precioCondicion.idListaPrecio; 299 $scope.idLista = notaPedido.precioCondicion.idListaPrecio;
300 } else { 300 } else {
301 $scope.idLista = -1; 301 $scope.idLista = -1;
302 } 302 }
303 $scope.puntoVenta = rellenar(notaPedido.sucursal, 4); 303 $scope.puntoVenta = rellenar(notaPedido.sucursal, 4);
304 $scope.comprobante = rellenar(notaPedido.numeroNotaPedido, 8); 304 $scope.comprobante = rellenar(notaPedido.numeroNotaPedido, 8);
305 $scope.notaPedido = notaPedido; 305 $scope.notaPedido = notaPedido;
306 $scope.notaPedido.moneda = notaPedido.cotizacion.moneda; 306 $scope.notaPedido.moneda = notaPedido.cotizacion.moneda;
307 $scope.plazosPagos = notaPedido.notaPedidoPlazo; 307 $scope.plazosPagos = notaPedido.notaPedidoPlazo;
308 addArrayCabecera(cabeceras); 308 $scope.notaPedido.puntosDescarga =
309 309 formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga);
310 }, function() { 310 addArrayCabecera(cabeceras);
311 // funcion ejecutada cuando se cancela el modal 311
312 } 312 }, function() {
313 // funcion ejecutada cuando se cancela el modal
314 }
313 ); 315 );
314 }; 316 };
315 317
316 $scope.seleccionarProductos = function() { 318 $scope.seleccionarProductos = function() {
317 if ($scope.idLista === undefined) { 319 if ($scope.idLista === undefined) {
318 focaModalService.alert( 320 focaModalService.alert(
319 'Primero seleccione una lista de precio y condicion'); 321 'Primero seleccione una lista de precio y condicion');
320 return; 322 return;
321 } 323 }
322 var modalInstance = $uibModal.open( 324 var modalInstance = $uibModal.open(
323 { 325 {
324 ariaLabelledBy: 'Busqueda de Productos', 326 ariaLabelledBy: 'Busqueda de Productos',
325 templateUrl: 'modal-busqueda-productos.html', 327 templateUrl: 'modal-busqueda-productos.html',
326 controller: 'modalBusquedaProductosCtrl', 328 controller: 'modalBusquedaProductosCtrl',
327 resolve: { 329 resolve: {
328 parametroProducto: { 330 parametroProducto: {
329 idLista: $scope.idLista, 331 idLista: $scope.idLista,
330 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, 332 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR,
331 simbolo: $scope.notaPedido.moneda.SIMBOLO 333 simbolo: $scope.notaPedido.moneda.SIMBOLO
332 } 334 }
333 }, 335 },
334 size: 'lg' 336 size: 'lg'
335 } 337 }
336 ); 338 );
337 modalInstance.result.then( 339 modalInstance.result.then(
338 function(producto) { 340 function(producto) {
339 var newArt = 341 var newArt =
340 { 342 {
341 id: 0, 343 id: 0,
342 codigo: producto.codigo, 344 codigo: producto.codigo,
343 sector: producto.sector, 345 sector: producto.sector,
344 sectorCodigo: producto.sector + '-' + producto.codigo, 346 sectorCodigo: producto.sector + '-' + producto.codigo,
345 descripcion: producto.descripcion, 347 descripcion: producto.descripcion,
346 item: $scope.articulosTabla.length + 1, 348 item: $scope.articulosTabla.length + 1,
347 nombre: producto.descripcion, 349 nombre: producto.descripcion,
348 precio: parseFloat(producto.precio.toFixed(4)), 350 precio: parseFloat(producto.precio.toFixed(4)),
349 costoUnitario: producto.costo, 351 costoUnitario: producto.costo,
350 editCantidad: false, 352 editCantidad: false,
351 editPrecio: false, 353 editPrecio: false,
352 rubro: producto.CodRub, 354 rubro: producto.CodRub,
353 exentoUnitario: producto.precio, 355 exentoUnitario: producto.precio,
354 ivaUnitario: producto.IMPIVA, 356 ivaUnitario: producto.IMPIVA,
355 impuestoInternoUnitario: producto.ImpInt, 357 impuestoInternoUnitario: producto.ImpInt,
356 impuestoInterno1Unitario: producto.ImpInt2, 358 impuestoInterno1Unitario: producto.ImpInt2,
357 impuestoInterno2Unitario: producto.ImpInt3, 359 impuestoInterno2Unitario: producto.ImpInt3,
358 precioLista: producto.precio, 360 precioLista: producto.precio,
359 combustible: 1, 361 combustible: 1,
360 facturado: 0, 362 facturado: 0,
361 idArticulo: producto.id 363 idArticulo: producto.id
362 }; 364 };
363 $scope.articuloACargar = newArt; 365 $scope.articuloACargar = newArt;
364 $scope.cargando = false; 366 $scope.cargando = false;
365 }, function() { 367 }, function() {
366 // funcion ejecutada cuando se cancela el modal 368 // funcion ejecutada cuando se cancela el modal
367 } 369 }
368 ); 370 );
369 }; 371 };
370 372
371 $scope.seleccionarVendedor = function() { 373 $scope.seleccionarPuntosDeDescarga = function() {
372 if(validarNotaRemitada()) { 374 if(!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) {
373 var modalInstance = $uibModal.open( 375 focaModalService.alert('Primero seleccione un cliente y un domicilio');
374 { 376 return;
377 }else {
378 var modalInstance = $uibModal.open(
379 {
380 ariaLabelledBy: 'Búsqueda de Puntos de descarga',
381 templateUrl: 'modal-punto-descarga.html',
382 controller: 'focaModalPuntoDescargaController',
383 size: 'lg',
384 resolve: {
385 filters: {
386 /*TODO: al traer nota de pedido ya creada
387 obtener idDomicilio correctamente*/
388 idDomicilio: $scope.notaPedido.domicilio.id,
389 idCliente: $scope.notaPedido.cliente.COD,
390 articulos: $scope.articulosTabla,
391 puntosDescarga: $scope.notaPedido.puntosDescarga
392 }
393 }
394 }
395 );
396 modalInstance.result.then(
397 function(puntosDescarga) {
398 $scope.notaPedido.puntosDescarga = puntosDescarga;
399 }, function() {
400
401 }
402 );
403 }
404 };
405
406 $scope.seleccionarVendedor = function() {
407 if(validarNotaRemitada()) {
408 var modalInstance = $uibModal.open(
409 {
375 ariaLabelledBy: 'Busqueda de Vendedores', 410 ariaLabelledBy: 'Busqueda de Vendedores',
376 templateUrl: 'modal-vendedores.html', 411 templateUrl: 'modal-vendedores.html',
377 controller: 'modalVendedoresCtrl', 412 controller: 'modalVendedoresCtrl',
378 size: 'lg' 413 size: 'lg'
379 } 414 }
380 ); 415 );
381 modalInstance.result.then( 416 modalInstance.result.then(
382 function(vendedor) { 417 function(vendedor) {
383 $scope.$broadcast('addCabecera', { 418 $scope.$broadcast('addCabecera', {
384 label: 'Vendedor:', 419 label: 'Vendedor:',
385 valor: vendedor.NomVen 420 valor: vendedor.NomVen
386 }); 421 });
387 $scope.notaPedido.vendedor = vendedor; 422 $scope.notaPedido.vendedor = vendedor;
388 }, function() { 423 }, function() {
389 424
390 } 425 }
391 ); 426 );
392 } 427 }
393 }; 428 };
394 429
395 $scope.seleccionarProveedor = function() { 430 $scope.seleccionarProveedor = function() {
396 if(validarNotaRemitada()) { 431 if(validarNotaRemitada()) {
397 var modalInstance = $uibModal.open( 432 var modalInstance = $uibModal.open(
398 { 433 {
399 ariaLabelledBy: 'Busqueda de Proveedor', 434 ariaLabelledBy: 'Busqueda de Proveedor',
400 templateUrl: 'modal-proveedor.html', 435 templateUrl: 'modal-proveedor.html',
401 controller: 'focaModalProveedorCtrl', 436 controller: 'focaModalProveedorCtrl',
402 size: 'lg', 437 size: 'lg',
403 resolve: { 438 resolve: {
404 transportista: function() { 439 transportista: function() {
405 return false; 440 return false;
406 } 441 }
407 } 442 }
408 } 443 }
409 ); 444 );
410 modalInstance.result.then( 445 modalInstance.result.then(
411 function(proveedor) { 446 function(proveedor) {
412 $scope.notaPedido.proveedor = proveedor; 447 $scope.notaPedido.proveedor = proveedor;
413 $scope.$broadcast('addCabecera', { 448 $scope.$broadcast('addCabecera', {
414 label: 'Proveedor:', 449 label: 'Proveedor:',
415 valor: proveedor.NOM 450 valor: proveedor.NOM
416 }); 451 });
417 }, function() { 452 }, function() {
418 453
419 } 454 }
420 ); 455 );
421 } 456 }
422 }; 457 };
423 458
424 $scope.seleccionarCliente = function() { 459 $scope.seleccionarCliente = function() {
425 if(validarNotaRemitada()) { 460 if(validarNotaRemitada()) {
426 var modalInstance = $uibModal.open( 461 var modalInstance = $uibModal.open(
427 { 462 {
428 ariaLabelledBy: 'Busqueda de Cliente', 463 ariaLabelledBy: 'Busqueda de Cliente',
429 templateUrl: 'foca-busqueda-cliente-modal.html', 464 templateUrl: 'foca-busqueda-cliente-modal.html',
430 controller: 'focaBusquedaClienteModalController', 465 controller: 'focaBusquedaClienteModalController',
431 size: 'lg' 466 size: 'lg'
432 } 467 }
433 ); 468 );
434 modalInstance.result.then( 469 modalInstance.result.then(
435 function(cliente) { 470 function(cliente) {
436 $scope.abrirModalDomicilios(cliente); 471 $scope.abrirModalDomicilios(cliente);
437 }, function() { 472 }, function() {
438 473
439 } 474 }
440 ); 475 );
441 } 476 }
442 }; 477 };
443 478
444 $scope.abrirModalDomicilios = function(cliente) { 479 $scope.abrirModalDomicilios = function(cliente) {
445 var modalInstanceDomicilio = $uibModal.open( 480 var modalInstanceDomicilio = $uibModal.open(
446 { 481 {
447 ariaLabelledBy: 'Busqueda de Domicilios', 482 ariaLabelledBy: 'Busqueda de Domicilios',
448 templateUrl: 'modal-domicilio.html', 483 templateUrl: 'modal-domicilio.html',
449 controller: 'focaModalDomicilioController', 484 controller: 'focaModalDomicilioController',
450 resolve: { 485 resolve: {
451 idCliente: function() { return cliente.cod; }, 486 idCliente: function() {
452 esNuevo: function() { return cliente.esNuevo; }, 487 return cliente.cod;
453 articulos: function() { 488 },
454 return $scope.articulosTabla; 489 esNuevo: function() { return cliente.esNuevo; },
455 } 490 articulos: function() {
491 return $scope.articulosTabla;
492 }
456 }, 493 },
457 size: 'lg', 494 size: 'lg',
458 } 495 }
459 ); 496 );
460 modalInstanceDomicilio.result.then( 497 modalInstanceDomicilio.result.then(
461 function(domicilio) { 498 function(domicilio) {
462 $scope.notaPedido.domicilio = domicilio; 499 $scope.notaPedido.domicilio = domicilio;
463 $scope.notaPedido.cliente = { 500 $scope.notaPedido.cliente = {
464 COD: cliente.cod, 501 COD: cliente.cod,
465 CUIT: cliente.cuit, 502 CUIT: cliente.cuit,
466 NOM: cliente.nom 503 NOM: cliente.nom
467 }; 504 };
468 var domicilioStamp = 505 var domicilioStamp =
469 domicilio.Calle + ' ' + domicilio.Numero + ', ' + 506 domicilio.Calle + ' ' + domicilio.Numero + ', ' +
470 domicilio.Localidad + ', ' + domicilio.Provincia; 507 domicilio.Localidad + ', ' + domicilio.Provincia;
471 $scope.notaPedido.domicilioStamp = domicilioStamp; 508 $scope.notaPedido.domicilioStamp = domicilioStamp;
472 509
473 $scope.notaPedido.puntosDescarga = domicilio.puntosDescarga; 510 $scope.notaPedido.puntosDescarga = domicilio.puntosDescarga;
474 511
475 $scope.$broadcast('addCabecera', { 512 $scope.$broadcast('addCabecera', {
476 label: 'Cliente:', 513 label: 'Cliente:',
477 valor: cliente.nom 514 valor: cliente.nom
478 }); 515 });
479 $scope.$broadcast('addCabecera', { 516 $scope.$broadcast('addCabecera', {
480 label: 'Domicilio:', 517 label: 'Domicilio:',
481 valor: domicilioStamp 518 valor: domicilioStamp
482 }); 519 });
483 }, function() { 520 }, function() {
484 $scope.seleccionarCliente(); 521 $scope.seleccionarCliente();
485 return; 522 return;
486 } 523 }
487 ); 524 );
488 }; 525 };
489 526
490 $scope.getTotal = function() { 527 $scope.getTotal = function() {
491 var total = 0; 528 var total = 0;
492 var arrayTempArticulos = $scope.articulosTabla; 529 var arrayTempArticulos = $scope.articulosTabla;
493 for (var i = 0; i < arrayTempArticulos.length; i++) { 530 for (var i = 0; i < arrayTempArticulos.length; i++) {
494 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 531 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
495 } 532 }
496 return parseFloat(total.toFixed(2)); 533 return parseFloat(total.toFixed(2));
497 }; 534 };
498 535
499 $scope.getSubTotal = function() { 536 $scope.getSubTotal = function() {
500 if($scope.articuloACargar) { 537 if($scope.articuloACargar) {
501 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 538 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
502 } 539 }
503 }; 540 };
504 541
505 $scope.seleccionarPreciosYCondiciones = function() { 542 $scope.seleccionarPreciosYCondiciones = function() {
506 if(validarNotaRemitada()) { 543 if(validarNotaRemitada()) {
507 var modalInstance = $uibModal.open( 544 var modalInstance = $uibModal.open(
508 { 545 {
509 ariaLabelledBy: 'Busqueda de Precio Condición', 546 ariaLabelledBy: 'Busqueda de Precio Condición',
510 templateUrl: 'modal-precio-condicion.html', 547 templateUrl: 'modal-precio-condicion.html',
511 controller: 'focaModalPrecioCondicionController', 548 controller: 'focaModalPrecioCondicionController',
512 size: 'lg' 549 size: 'lg'
513 } 550 }
514 ); 551 );
515 modalInstance.result.then( 552 modalInstance.result.then(
516 function(precioCondicion) { 553 function(precioCondicion) {
517 var cabecera = ''; 554 var cabecera = '';
518 var plazosConcat = ''; 555 var plazosConcat = '';
519 if(!Array.isArray(precioCondicion)) { 556 if(!Array.isArray(precioCondicion)) {
520 $scope.notaPedido.idPrecioCondicion = precioCondicion.id; 557 $scope.notaPedido.idPrecioCondicion = precioCondicion.id;
521 $scope.plazosPagos = precioCondicion.plazoPago; 558 $scope.plazosPagos = precioCondicion.plazoPago;
522 $scope.idLista = precioCondicion.idListaPrecio; 559 $scope.idLista = precioCondicion.idListaPrecio;
523 for(var i = 0; i < precioCondicion.plazoPago.length; i++) { 560 for(var i = 0; i < precioCondicion.plazoPago.length; i++) {
524 plazosConcat += precioCondicion.plazoPago[i].dias + ' '; 561 plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
525 } 562 }
526 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); 563 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim();
527 } else { //Cuando se ingresan los plazos manualmente 564 } else { //Cuando se ingresan los plazos manualmente
528 $scope.notaPedido.idPrecioCondicion = 0; 565 $scope.notaPedido.idPrecioCondicion = 0;
529 //-1, el modal productos busca todos los productos 566 //-1, el modal productos busca todos los productos
530 $scope.idLista = -1; 567 $scope.idLista = -1;
531 $scope.plazosPagos = precioCondicion; 568 $scope.plazosPagos = precioCondicion;
532 for(var j = 0; j < precioCondicion.length; j++) { 569 for(var j = 0; j < precioCondicion.length; j++) {
533 plazosConcat += precioCondicion[j].dias + ' '; 570 plazosConcat += precioCondicion[j].dias + ' ';
534 } 571 }
535 cabecera = 'Ingreso manual ' + plazosConcat.trim(); 572 cabecera = 'Ingreso manual ' + plazosConcat.trim();
536 } 573 }
537 $scope.articulosTabla = []; 574 $scope.articulosTabla = [];
538 $scope.$broadcast('addCabecera', { 575 $scope.$broadcast('addCabecera', {
539 label: 'Precios y condiciones:', 576 label: 'Precios y condiciones:',
540 valor: cabecera 577 valor: cabecera
541 }); 578 });
542 }, function() { 579 }, function() {
543 580
544 } 581 }
545 ); 582 );
546 } 583 }
547 }; 584 };
548 585
549 $scope.seleccionarFlete = function() { 586 $scope.seleccionarFlete = function() {
550 if(validarNotaRemitada()) { 587 if(validarNotaRemitada()) {
551 var modalInstance = $uibModal.open( 588 var modalInstance = $uibModal.open(
552 { 589 {
553 ariaLabelledBy: 'Busqueda de Flete', 590 ariaLabelledBy: 'Busqueda de Flete',
554 templateUrl: 'modal-flete.html', 591 templateUrl: 'modal-flete.html',
555 controller: 'focaModalFleteController', 592 controller: 'focaModalFleteController',
556 size: 'lg', 593 size: 'lg',
557 resolve: { 594 resolve: {
558 parametrosFlete: 595 parametrosFlete:
559 function() { 596 function() {
560 return { 597 return {
561 flete: $scope.notaPedido.fob ? 'FOB' : 598 flete: $scope.notaPedido.fob ? 'FOB' :
562 ( $scope.notaPedido.flete ? '1' : 599 ( $scope.notaPedido.flete ? '1' :
563 ($scope.notaPedido.flete === undefined ? 600 ($scope.notaPedido.flete === undefined ?
564 null : '0')), 601 null : '0')),
565 bomba: $scope.notaPedido.bomba ? '1' : 602 bomba: $scope.notaPedido.bomba ? '1' :
566 ($scope.notaPedido.bomba === undefined ? 603 ($scope.notaPedido.bomba === undefined ?
567 null : '0'), 604 null : '0'),
568 kilometros: $scope.notaPedido.kilometros 605 kilometros: $scope.notaPedido.kilometros
569 }; 606 };
570 } 607 }
571 } 608 }
572 } 609 }
573 ); 610 );
574 modalInstance.result.then( 611 modalInstance.result.then(
575 function(datos) { 612 function(datos) {
576 $scope.notaPedido.flete = datos.flete; 613 $scope.notaPedido.flete = datos.flete;
577 $scope.notaPedido.fob = datos.FOB; 614 $scope.notaPedido.fob = datos.FOB;
578 $scope.notaPedido.bomba = datos.bomba; 615 $scope.notaPedido.bomba = datos.bomba;
579 $scope.notaPedido.kilometros = datos.kilometros; 616 $scope.notaPedido.kilometros = datos.kilometros;
580 $scope.$broadcast('addCabecera', { 617 $scope.$broadcast('addCabecera', {
581 label: 'Flete:', 618 label: 'Flete:',
582 valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') 619 valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No')
583 }); 620 });
584 if(datos.flete) { 621 if(datos.flete) {
585 $scope.$broadcast('addCabecera', { 622 $scope.$broadcast('addCabecera', {
586 label: 'Bomba:', 623 label: 'Bomba:',
587 valor: datos.bomba ? 'Si' : 'No' 624 valor: datos.bomba ? 'Si' : 'No'
588 }); 625 });
589 $scope.$broadcast('addCabecera', { 626 $scope.$broadcast('addCabecera', {
590 label: 'Kilometros:', 627 label: 'Kilometros:',
591 valor: datos.kilometros 628 valor: datos.kilometros
592 }); 629 });
593 } else { 630 } else {
594 $scope.$broadcast('removeCabecera', 'Bomba:'); 631 $scope.$broadcast('removeCabecera', 'Bomba:');
595 $scope.$broadcast('removeCabecera', 'Kilometros:'); 632 $scope.$broadcast('removeCabecera', 'Kilometros:');
596 $scope.notaPedido.bomba = false; 633 $scope.notaPedido.bomba = false;
597 $scope.notaPedido.kilometros = null; 634 $scope.notaPedido.kilometros = null;
598 } 635 }
599 }, function() { 636 }, function() {
600 637
601 } 638 }
602 ); 639 );
603 } 640 }
604 }; 641 };
605 642
606 $scope.seleccionarMoneda = function() { 643 $scope.seleccionarMoneda = function() {
607 if(validarNotaRemitada()) { 644 if(validarNotaRemitada()) {
608 var modalInstance = $uibModal.open( 645 var modalInstance = $uibModal.open(
609 { 646 {
610 ariaLabelledBy: 'Busqueda de Moneda', 647 ariaLabelledBy: 'Busqueda de Moneda',
611 templateUrl: 'modal-moneda.html', 648 templateUrl: 'modal-moneda.html',
612 controller: 'focaModalMonedaController', 649 controller: 'focaModalMonedaController',
613 size: 'lg' 650 size: 'lg'
614 } 651 }
615 ); 652 );
616 modalInstance.result.then( 653 modalInstance.result.then(
617 function(moneda) { 654 function(moneda) {
618 $scope.abrirModalCotizacion(moneda); 655 $scope.abrirModalCotizacion(moneda);
619 }, function() { 656 }, function() {
620 657
621 } 658 }
622 ); 659 );
623 } 660 }
624 }; 661 };
625 662
626 $scope.abrirModalCotizacion = function(moneda) { 663 $scope.abrirModalCotizacion = function(moneda) {
627 var modalInstance = $uibModal.open( 664 var modalInstance = $uibModal.open(
628 { 665 {
629 ariaLabelledBy: 'Busqueda de Cotización', 666 ariaLabelledBy: 'Busqueda de Cotización',
630 templateUrl: 'modal-cotizacion.html', 667 templateUrl: 'modal-cotizacion.html',
631 controller: 'focaModalCotizacionController', 668 controller: 'focaModalCotizacionController',
632 size: 'lg', 669 size: 'lg',
633 resolve: {idMoneda: function() {return moneda.ID;}} 670 resolve: {idMoneda: function() {return moneda.ID;}}
634 } 671 }
635 ); 672 );
636 modalInstance.result.then( 673 modalInstance.result.then(
637 function(cotizacion) { 674 function(cotizacion) {
638 var articulosTablaTemp = $scope.articulosTabla; 675 var articulosTablaTemp = $scope.articulosTabla;
639 for(var i = 0; i < articulosTablaTemp.length; i++) { 676 for(var i = 0; i < articulosTablaTemp.length; i++) {
640 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * 677 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
641 $scope.notaPedido.cotizacion.VENDEDOR; 678 $scope.notaPedido.cotizacion.VENDEDOR;
642 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / 679 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio /
643 cotizacion.VENDEDOR; 680 cotizacion.VENDEDOR;
644 } 681 }
645 $scope.articulosTabla = articulosTablaTemp; 682 $scope.articulosTabla = articulosTablaTemp;
646 $scope.notaPedido.moneda = moneda; 683 $scope.notaPedido.moneda = moneda;
647 $scope.notaPedido.cotizacion = cotizacion; 684 $scope.notaPedido.cotizacion = cotizacion;
648 if(moneda.DETALLE === 'PESOS ARGENTINOS') { 685 if(moneda.DETALLE === 'PESOS ARGENTINOS') {
649 $scope.$broadcast('removeCabecera', 'Moneda:'); 686 $scope.$broadcast('removeCabecera', 'Moneda:');
650 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); 687 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
651 $scope.$broadcast('removeCabecera', 'Cotizacion:'); 688 $scope.$broadcast('removeCabecera', 'Cotizacion:');
652 }else { 689 }else {
653 $scope.$broadcast('addCabecera', { 690 $scope.$broadcast('addCabecera', {
654 label: 'Moneda:', 691 label: 'Moneda:',
655 valor: moneda.DETALLE 692 valor: moneda.DETALLE
656 }); 693 });
657 $scope.$broadcast('addCabecera', { 694 $scope.$broadcast('addCabecera', {
658 label: 'Fecha cotizacion:', 695 label: 'Fecha cotizacion:',
659 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 696 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
660 }); 697 });
661 $scope.$broadcast('addCabecera', { 698 $scope.$broadcast('addCabecera', {
662 label: 'Cotizacion:', 699 label: 'Cotizacion:',
663 valor: $filter('number')(cotizacion.VENDEDOR, '2') 700 valor: $filter('number')(cotizacion.VENDEDOR, '2')
664 }); 701 });
665 } 702 }
666 }, function() { 703 }, function() {
667 704
668 } 705 }
669 ); 706 );
670 }; 707 };
671 708
672 $scope.agregarATabla = function(key) { 709 $scope.agregarATabla = function(key) {
673 if(key === 13) { 710 if(key === 13) {
674 if($scope.articuloACargar.cantidad === undefined || 711 if($scope.articuloACargar.cantidad === undefined ||
675 $scope.articuloACargar.cantidad === 0 || 712 $scope.articuloACargar.cantidad === 0 ||
676 $scope.articuloACargar.cantidad === null ) { 713 $scope.articuloACargar.cantidad === null ) {
677 focaModalService.alert('El valor debe ser al menos 1'); 714 focaModalService.alert('El valor debe ser al menos 1');
678 return; 715 return;
679 } 716 }
680 delete $scope.articuloACargar.sectorCodigo; 717 delete $scope.articuloACargar.sectorCodigo;
681 $scope.articulosTabla.push($scope.articuloACargar); 718 $scope.articulosTabla.push($scope.articuloACargar);
682 $scope.cargando = true; 719 $scope.cargando = true;
683 } 720 }
684 }; 721 };
685 722
686 $scope.quitarArticulo = function(key) { 723 $scope.quitarArticulo = function(key) {
687 $scope.articulosTabla.splice(key, 1); 724 $scope.articulosTabla.splice(key, 1);
688 }; 725 };
689 726
690 $scope.editarArticulo = function(key, articulo) { 727 $scope.editarArticulo = function(key, articulo) {
691 if(key === 13) { 728 if(key === 13) {
692 if(articulo.cantidad === null || articulo.cantidad === 0 || 729 if(articulo.cantidad === null || articulo.cantidad === 0 ||
693 articulo.cantidad === undefined) { 730 articulo.cantidad === undefined) {
694 focaModalService.alert('El valor debe ser al menos 1'); 731 focaModalService.alert('El valor debe ser al menos 1');
695 return; 732 return;
696 } 733 }
697 articulo.editCantidad = false; 734 articulo.editCantidad = false;
698 articulo.editPrecio = false; 735 articulo.editPrecio = false;
699 } 736 }
700 }; 737 };
701 738
702 $scope.cambioEdit = function(articulo, propiedad) { 739 $scope.cambioEdit = function(articulo, propiedad) {
703 if(propiedad === 'cantidad') { 740 if(propiedad === 'cantidad') {
704 articulo.editCantidad = true; 741 articulo.editCantidad = true;
705 } else if(propiedad === 'precio') { 742 } else if(propiedad === 'precio') {
706 articulo.editPrecio = true; 743 articulo.editPrecio = true;
707 } 744 }
708 }; 745 };
709 746
710 $scope.resetFilter = function() { 747 $scope.resetFilter = function() {
711 $scope.articuloACargar = {}; 748 $scope.articuloACargar = {};
712 $scope.cargando = true; 749 $scope.cargando = true;
713 }; 750 };
714 //Recibe aviso si el teclado está en uso 751 //Recibe aviso si el teclado está en uso
715 $rootScope.$on('usarTeclado', function(event, data) { 752 $rootScope.$on('usarTeclado', function(event, data) {
716 if(data) { 753 if(data) {
717 $scope.mostrarTeclado = true; 754 $scope.mostrarTeclado = true;
718 return; 755 return;
719 } 756 }
720 $scope.mostrarTeclado = false; 757 $scope.mostrarTeclado = false;
721 }); 758 });
722 759
723 $scope.selectFocus = function($event) { 760 $scope.selectFocus = function($event) {
724 // Si el teclado esta en uso no selecciona el valor 761 // Si el teclado esta en uso no selecciona el valor
725 if($scope.mostrarTeclado) { 762 if($scope.mostrarTeclado) {
726 return; 763 return;
727 } 764 }
728 $event.target.select(); 765 $event.target.select();
729 }; 766 };
730 767
731 $scope.salir = function() { 768 $scope.salir = function() {
732 $location.path('/'); 769 $location.path('/');
733 }; 770 };
734 771
735 $scope.parsearATexto = function(articulo) { 772 $scope.parsearATexto = function(articulo) {
736 articulo.cantidad = parseFloat(articulo.cantidad); 773 articulo.cantidad = parseFloat(articulo.cantidad);
737 articulo.precio = parseFloat(articulo.precio); 774 articulo.precio = parseFloat(articulo.precio);
738 }; 775 };
739 776
740 function addArrayCabecera(array) { 777 function addArrayCabecera(array) {
741 for(var i = 0; i < array.length; i++) { 778 for(var i = 0; i < array.length; i++) {
742 $scope.$broadcast('addCabecera', { 779 $scope.$broadcast('addCabecera', {
743 label: array[i].label, 780 label: array[i].label,
744 valor: array[i].valor 781 valor: array[i].valor
745 }); 782 });
746 } 783 }
747 } 784 }
748 785
749 function rellenar(relleno, longitud) { 786 function rellenar(relleno, longitud) {
750 relleno = '' + relleno; 787 relleno = '' + relleno;
751 while (relleno.length < longitud) { 788 while (relleno.length < longitud) {
752 relleno = '0' + relleno; 789 relleno = '0' + relleno;
753 } 790 }
754 791
755 return relleno; 792 return relleno;
756 } 793 }
757 794
758 function validarNotaRemitada() { 795 function validarNotaRemitada() {
759 if(!$scope.notaPedido.idRemito) { 796 if(!$scope.notaPedido.idRemito) {
760 return true; 797 return true;
761 }else{ 798 }else{
762 focaModalService.alert('No se puede editar una nota de pedido remitada'); 799 focaModalService.alert('No se puede editar una nota de pedido remitada');
763 return false; 800 return false;
764 } 801 }
765 } 802 }
766 } 803 function formatearPuntosDescarga(puntosDescarga) {
767 ]); 804 var result = [];
768 805
806 puntosDescarga.forEach(function(el) {
807 var puntoDescarga = result.filter(function(resultPunto) {
808 return resultPunto.id == el.idPuntoDescarga;
809 });
810
811 if(puntoDescarga.length) {
812 puntoDescarga[0].articulosAgregados.push({
813 cantidad: el.cantidad,
814 descripcion: el.producto.descripcion,
815 id: el.producto.id
816 });
817 }else {
818 result.push({
819 id: el.puntoDescarga.id,
820 id_cliente: el.puntoDescarga.id_cliente,
821 id_da_config_0: el.puntoDescarga.id_da_config_0,
822 latitud: el.puntoDescarga.latitud,
823 longitud: el.puntoDescarga.longitud,
824 descripcion: el.puntoDescarga.descripcion,
825 articulosAgregados: [
826 {
827 cantidad: el.cantidad,
828 descripcion: el.producto.descripcion,
829 id: el.producto.id
830 }
831 ]
832 });
833 }
834 });
835 return result;
836 }
837 }
838 ]);
839
1 angular.module('focaCrearNotaPedido') 1 angular.module('focaCrearNotaPedido')
2 .service('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { 2 .service('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 return ['Vendedor', 'Cliente', 'Proveedor', 'Moneda', 59 return [
60 'Precios y condiciones', 'Flete', 'Productos']; 60 {
61 label: 'Vendedor',
62 image: 'vendedor.png'
63 },
64 {
65 label: 'Cliente',
66 image: 'cliente.png'
67 },
68 {
69 label: 'Proveedor',
70 image: 'proveedor.png'
71 },
72 {
73 label: 'Moneda',
74 image: 'moneda.png'
75 },
76 {
77 label: 'Precios y condiciones',
78 image: 'precios-condiciones.png'
79 },
80 {
81 label: 'Flete',
82 image: 'flete.png'
83 },
84 {
85 label: 'Productos',
86 image: 'productos.png'
87 },
88 {
89 label: 'Puntos de descarga',
90 image: 'seguimientoCobranza.png'
91 }
92 ];
61 }, 93 },
62 crearPuntosDescarga: function(puntosDescarga) { 94 crearPuntosDescarga: function(puntosDescarga) {
63 return $http.post(route + '/puntos-descarga/nota-pedido', 95 return $http.post(route + '/puntos-descarga/nota-pedido',
64 {puntosDescarga: puntosDescarga}); 96 {puntosDescarga: puntosDescarga});
65 } 97 }
66 }; 98 };
67 }]); 99 }]);
68 100
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="now" 5 fecha="now"
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 <div class="col-lg-12"> 9 <div class="col-lg-12">
10 <div class="row mt-4"> 10 <div class="row mt-4">
11 <div class="col-12 col-md-10 col-lg-10 border border-light rounded"> 11 <div class="col-12 col-md-10 col-lg-10 border border-light rounded">
12 <div class="row px-5 py-2 botonera-secundaria"> 12 <div class="row px-5 py-2 botonera-secundaria">
13 <div class="col-12"> 13 <div class="col-12">
14 <foca-botonera-facturador botones="botonera" extra="5" class="row"></foca-botonera-facturador> 14 <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador>
15 </div> 15 </div>
16 </div> 16 </div>
17 <!-- PC --> 17 <!-- PC -->
18 <div class="row grilla-articulo align-items-end d-none d-sm-flex"> 18 <div class="row grilla-articulo align-items-end d-none d-sm-flex">
19 <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> 19 <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom">
20 <thead> 20 <thead>
21 <tr class="d-flex"> 21 <tr class="d-flex">
22 <th valign="middle" class="">#</th> 22 <th valign="middle" class="">#</th>
23 <th valign="middle" class="col">Código</th> 23 <th valign="middle" class="col">Código</th>
24 <th valign="middle" class="col-4">Descripción</th> 24 <th valign="middle" class="col-4">Descripción</th>
25 <th valign="middle" class="col text-right">Cantidad</th> 25 <th valign="middle" class="col text-right">Cantidad</th>
26 <th valign="middle" class="col text-right">Precio Unitario</th> 26 <th valign="middle" class="col text-right">Precio Unitario</th>
27 <th valign="middle" class="col text-right">SubTotal</th> 27 <th valign="middle" class="col text-right">SubTotal</th>
28 <th valign="middle" class="text-right"> 28 <th valign="middle" class="text-right">
29 <button 29 <button
30 class="btn btn-outline-light selectable" 30 class="btn btn-outline-light selectable"
31 ng-click="show = !show; masMenos()" 31 ng-click="show = !show; masMenos()"
32 > 32 >
33 <i 33 <i
34 class="fa fa-chevron-down" 34 class="fa fa-chevron-down"
35 ng-show="show" 35 ng-show="show"
36 aria-hidden="true" 36 aria-hidden="true"
37 > 37 >
38 </i> 38 </i>
39 <i 39 <i
40 class="fa fa-chevron-up" 40 class="fa fa-chevron-up"
41 ng-hide="show" 41 ng-hide="show"
42 aria-hidden="true"> 42 aria-hidden="true">
43 </i> 43 </i>
44 </button> 44 </button>
45 </th> 45 </th>
46 </tr> 46 </tr>
47 </thead> 47 </thead>
48 <tbody class="tabla-articulo-body"> 48 <tbody class="tabla-articulo-body">
49 <tr 49 <tr
50 ng-repeat="(key, articulo) in articulosTabla" 50 ng-repeat="(key, articulo) in articulosTabla"
51 ng-show="show || key == (articulosTabla.length - 1)" 51 ng-show="show || key == (articulosTabla.length - 1)"
52 class="d-flex" 52 class="d-flex"
53 > 53 >
54 <td ng-bind="key + 1"></td> 54 <td ng-bind="key + 1"></td>
55 <td 55 <td
56 class="col" 56 class="col"
57 ng-bind="articulo.sector + '-' + articulo.codigo" 57 ng-bind="articulo.sector + '-' + articulo.codigo"
58 ></td> 58 ></td>
59 <td 59 <td
60 class="col-4" 60 class="col-4"
61 ng-bind="articulo.descripcion" 61 ng-bind="articulo.descripcion"
62 ></td> 62 ></td>
63 <td class="col text-right"> 63 <td class="col text-right">
64 <input 64 <input
65 ng-show="articulo.editCantidad" 65 ng-show="articulo.editCantidad"
66 ng-model="articulo.cantidad" 66 ng-model="articulo.cantidad"
67 class="form-control" 67 class="form-control"
68 foca-tipo-input 68 foca-tipo-input
69 min="1" 69 min="1"
70 step="0.001" 70 step="0.001"
71 foca-focus="articulo.editCantidad" 71 foca-focus="articulo.editCantidad"
72 ng-keypress="editarArticulo($event.keyCode, articulo)" 72 ng-keypress="editarArticulo($event.keyCode, articulo)"
73 ng-focus="selectFocus($event)" 73 ng-focus="selectFocus($event)"
74 teclado-virtual 74 teclado-virtual
75 > 75 >
76 <i 76 <i
77 class="selectable" 77 class="selectable"
78 ng-click="cambioEdit(articulo, 'cantidad')" 78 ng-click="cambioEdit(articulo, 'cantidad')"
79 ng-hide="articulo.editCantidad" 79 ng-hide="articulo.editCantidad"
80 ng-bind="articulo.cantidad"> 80 ng-bind="articulo.cantidad">
81 </i> 81 </i>
82 </td> 82 </td>
83 <td class="col text-right"> 83 <td class="col text-right">
84 <input 84 <input
85 ng-show="articulo.editPrecio" 85 ng-show="articulo.editPrecio"
86 ng-model="articulo.precio" 86 ng-model="articulo.precio"
87 class="form-control" 87 class="form-control"
88 foca-tipo-input 88 foca-tipo-input
89 min="0" 89 min="0"
90 step="0.0001" 90 step="0.0001"
91 foca-focus="articulo.editPrecio" 91 foca-focus="articulo.editPrecio"
92 ng-keypress="editarArticulo($event.keyCode, articulo)" 92 ng-keypress="editarArticulo($event.keyCode, articulo)"
93 ng-focus="selectFocus($event)" 93 ng-focus="selectFocus($event)"
94 teclado-virtual 94 teclado-virtual
95 > 95 >
96 <i 96 <i
97 class="selectable" 97 class="selectable"
98 ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" 98 ng-click="idLista == -1 && cambioEdit(articulo, 'precio')"
99 ng-hide="articulo.editPrecio" 99 ng-hide="articulo.editPrecio"
100 ng-bind="articulo.precio | 100 ng-bind="articulo.precio |
101 number: 4"> 101 number: 4">
102 </i> 102 </i>
103 </td> 103 </td>
104 <td 104 <td
105 class="col text-right" 105 class="col text-right"
106 ng-bind="(articulo.precio * articulo.cantidad) | 106 ng-bind="(articulo.precio * articulo.cantidad) |
107 number: 2"> 107 number: 2">
108 </td> 108 </td>
109 <td class="text-center"> 109 <td class="text-center">
110 <button 110 <button
111 ng-show="articulo.editCantidad || articulo.editPrecio" 111 ng-show="articulo.editCantidad || articulo.editPrecio"
112 class="btn btn-outline-light" 112 class="btn btn-outline-light"
113 ng-click="editarArticulo(13, articulo)" 113 ng-click="editarArticulo(13, articulo)"
114 > 114 >
115 <i class="fa fa-save"></i> 115 <i class="fa fa-save"></i>
116 </button> 116 </button>
117 <button 117 <button
118 class="btn btn-outline-light" 118 class="btn btn-outline-light"
119 ng-click="quitarArticulo(key)" 119 ng-click="quitarArticulo(key)"
120 > 120 >
121 <i class="fa fa-trash"></i> 121 <i class="fa fa-trash"></i>
122 </button> 122 </button>
123 </td> 123 </td>
124 </tr> 124 </tr>
125 </tbody> 125 </tbody>
126 <tfoot> 126 <tfoot>
127 <tr ng-show="!cargando" class="d-flex"> 127 <tr ng-show="!cargando" class="d-flex">
128 <td 128 <td
129 class="align-middle" 129 class="align-middle"
130 ng-bind="articulosTabla.length + 1" 130 ng-bind="articulosTabla.length + 1"
131 ></td> 131 ></td>
132 <td class="col"> 132 <td class="col">
133 <input 133 <input
134 class="form-control" 134 class="form-control"
135 ng-model="articuloACargar.sectorCodigo" 135 ng-model="articuloACargar.sectorCodigo"
136 readonly 136 readonly
137 > 137 >
138 </td> 138 </td>
139 <td class="col-4 tabla-articulo-descripcion"> 139 <td class="col-4 tabla-articulo-descripcion">
140 <input 140 <input
141 class="form-control" 141 class="form-control"
142 ng-model="articuloACargar.descripcion" 142 ng-model="articuloACargar.descripcion"
143 readonly 143 readonly
144 > 144 >
145 </td> 145 </td>
146 <td class="col text-right"> 146 <td class="col text-right">
147 <input 147 <input
148 class="form-control" 148 class="form-control"
149 foca-tipo-input 149 foca-tipo-input
150 min="1" 150 min="1"
151 step="0.001" 151 step="0.001"
152 ng-model="articuloACargar.cantidad" 152 ng-model="articuloACargar.cantidad"
153 foca-focus="!cargando" 153 foca-focus="!cargando"
154 esc-key="resetFilter()" 154 esc-key="resetFilter()"
155 ng-keypress="agregarATabla($event.keyCode)" 155 ng-keypress="agregarATabla($event.keyCode)"
156 teclado-virtual 156 teclado-virtual
157 > 157 >
158 </td> 158 </td>
159 <td class="col text-right"> 159 <td class="col text-right">
160 <input 160 <input
161 class="form-control" 161 class="form-control"
162 ng-value="articuloACargar.precio | number: 2" 162 ng-value="articuloACargar.precio | number: 2"
163 ng-show="idLista != -1" 163 ng-show="idLista != -1"
164 readonly 164 readonly
165 > 165 >
166 <input 166 <input
167 class="form-control" 167 class="form-control"
168 foca-tipo-input 168 foca-tipo-input
169 min="0" 169 min="0"
170 step="0.0001" 170 step="0.0001"
171 ng-model="articuloACargar.precio" 171 ng-model="articuloACargar.precio"
172 esc-key="resetFilter()" 172 esc-key="resetFilter()"
173 ng-keypress="agregarATabla($event.keyCode)" 173 ng-keypress="agregarATabla($event.keyCode)"
174 ng-show="idLista == -1" 174 ng-show="idLista == -1"
175 teclado-virtual 175 teclado-virtual
176 > 176 >
177 </td> 177 </td>
178 <td class="col text-right"> 178 <td class="col text-right">
179 <input 179 <input
180 class="form-control" 180 class="form-control"
181 ng-value="getSubTotal() | number: 2" 181 ng-value="getSubTotal() | number: 2"
182 readonly 182 readonly
183 ></td> 183 ></td>
184 <td class="text-center align-middle"> 184 <td class="text-center align-middle">
185 <button 185 <button
186 class="btn btn-outline-light" 186 class="btn btn-outline-light"
187 ng-click="agregarATabla(13)" 187 ng-click="agregarATabla(13)"
188 > 188 >
189 <i class="fa fa-save"></i> 189 <i class="fa fa-save"></i>
190 </button> 190 </button>
191 </td> 191 </td>
192 </tr> 192 </tr>
193 <tr class="d-flex"> 193 <tr class="d-flex">
194 <td colspan="4" class="no-border-top"> 194 <td colspan="4" class="no-border-top">
195 <strong>Items:</strong> 195 <strong>Items:</strong>
196 <a ng-bind="articulosTabla.length"></a> 196 <a ng-bind="articulosTabla.length"></a>
197 </td> 197 </td>
198 <td class="text-right ml-auto table-celda-total no-border-top"> 198 <td class="text-right ml-auto table-celda-total no-border-top">
199 <h3>Total:</h3> 199 <h3>Total:</h3>
200 </td> 200 </td>
201 <td class="table-celda-total text-right no-border-top" colspan="1"> 201 <td class="table-celda-total text-right no-border-top" colspan="1">
202 <h3>{{getTotal() | currency: notaPedido.moneda.SIMBOLO}}</h3> 202 <h3>{{getTotal() | currency: notaPedido.moneda.SIMBOLO}}</h3>
203 </td> 203 </td>
204 <td class="text-right no-border-top"> 204 <td class="text-right no-border-top">
205 <button 205 <button
206 type="button" 206 type="button"
207 class="btn btn-default btn-sm" 207 class="btn btn-default btn-sm"
208 > 208 >
209 Totales 209 Totales
210 </button> 210 </button>
211 </td> 211 </td>
212 </tr> 212 </tr>
213 </tfoot> 213 </tfoot>
214 </table> 214 </table>
215 </div> 215 </div>
216 <!-- MOBILE --> 216 <!-- MOBILE -->
217 <div class="row d-sm-none"> 217 <div class="row d-sm-none">
218 <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile"> 218 <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile">
219 <thead> 219 <thead>
220 <tr class="d-flex"> 220 <tr class="d-flex">
221 <th class="">#</th> 221 <th class="">#</th>
222 <th class="col px-0"> 222 <th class="col px-0">
223 <div class="d-flex"> 223 <div class="d-flex">
224 <div class="col-4 px-1">Código</div> 224 <div class="col-4 px-1">Código</div>
225 <div class="col-8 px-1">Descripción</div> 225 <div class="col-8 px-1">Descripción</div>
226 </div> 226 </div>
227 <div class="d-flex"> 227 <div class="d-flex">
228 <div class="col-3 px-1">Cantidad</div> 228 <div class="col-3 px-1">Cantidad</div>
229 <div class="col px-1 text-right">P. Uni.</div> 229 <div class="col px-1 text-right">P. Uni.</div>
230 <div class="col px-1 text-right">Subtotal</div> 230 <div class="col px-1 text-right">Subtotal</div>
231 </div> 231 </div>
232 </th> 232 </th>
233 <th class="text-center tamaño-boton"> 233 <th class="text-center tamaño-boton">
234 &nbsp; 234 &nbsp;
235 </th> 235 </th>
236 </tr> 236 </tr>
237 </thead> 237 </thead>
238 <tbody> 238 <tbody>
239 <tr 239 <tr
240 ng-repeat="(key, articulo) in articulosTabla" 240 ng-repeat="(key, articulo) in articulosTabla"
241 ng-show="show || key == articulosTabla.length - 1" 241 ng-show="show || key == articulosTabla.length - 1"
242 > 242 >
243 <td class="w-100 align-middle d-flex p-0"> 243 <td class="w-100 align-middle d-flex p-0">
244 <div class="align-middle p-1"> 244 <div class="align-middle p-1">
245 <span ng-bind="key+1" class="align-middle"></span> 245 <span ng-bind="key+1" class="align-middle"></span>
246 </div> 246 </div>
247 <div class="col px-0"> 247 <div class="col px-0">
248 <div class="d-flex"> 248 <div class="d-flex">
249 <div class="col-4 px-1"> 249 <div class="col-4 px-1">
250 <span 250 <span
251 ng-bind="articulo.sector + '-' + articulo.codigo" 251 ng-bind="articulo.sector + '-' + articulo.codigo"
252 ></span> 252 ></span>
253 </div> 253 </div>
254 <div class="col-8 px-1"> 254 <div class="col-8 px-1">
255 <span ng-bind="articulo.descripcion"></span> 255 <span ng-bind="articulo.descripcion"></span>
256 </div> 256 </div>
257 </div> 257 </div>
258 <div class="d-flex"> 258 <div class="d-flex">
259 <div class="col-3 px-1"> 259 <div class="col-3 px-1">
260 <span 260 <span
261 ng-bind="'x' + articulo.cantidad" 261 ng-bind="'x' + articulo.cantidad"
262 ng-hide="articulo.editCantidad" 262 ng-hide="articulo.editCantidad"
263 ></span> 263 ></span>
264 <i 264 <i
265 class="fa fa-pencil text-white-50" 265 class="fa fa-pencil text-white-50"
266 aria-hidden="true" 266 aria-hidden="true"
267 ng-hide="articulo.editCantidad" 267 ng-hide="articulo.editCantidad"
268 ng-click="articulo.editCantidad = true" 268 ng-click="articulo.editCantidad = true"
269 ></i> 269 ></i>
270 <input 270 <input
271 ng-show="articulo.editCantidad" 271 ng-show="articulo.editCantidad"
272 ng-model="articulo.cantidad" 272 ng-model="articulo.cantidad"
273 class="form-control" 273 class="form-control"
274 foca-tipo-input 274 foca-tipo-input
275 min="1" 275 min="1"
276 step="0.001" 276 step="0.001"
277 foca-focus="articulo.editCantidad" 277 foca-focus="articulo.editCantidad"
278 ng-keypress="editarArticulo($event.keyCode, articulo)" 278 ng-keypress="editarArticulo($event.keyCode, articulo)"
279 ng-focus="selectFocus($event)" 279 ng-focus="selectFocus($event)"
280 > 280 >
281 </div> 281 </div>
282 <div class="col px-1 text-right"> 282 <div class="col px-1 text-right">
283 <span ng-bind="articulo.precio | 283 <span ng-bind="articulo.precio |
284 currency: notaPedido.moneda.SIMBOLO : 4"></span> 284 currency: notaPedido.moneda.SIMBOLO : 4"></span>
285 ></span> 285 ></span>
286 </div> 286 </div>
287 <div class="col px-1 text-right"> 287 <div class="col px-1 text-right">
288 <span 288 <span
289 ng-bind="(articulo.precio * articulo.cantidad) | 289 ng-bind="(articulo.precio * articulo.cantidad) |
290 currency: notaPedido.moneda.SIMBOLO" 290 currency: notaPedido.moneda.SIMBOLO"
291 > 291 >
292 </span> 292 </span>
293 </div> 293 </div>
294 </div> 294 </div>
295 </div> 295 </div>
296 <div class="align-middle p-1"> 296 <div class="align-middle p-1">
297 <button 297 <button
298 class="btn btn-outline-light" 298 class="btn btn-outline-light"
299 ng-click="quitarArticulo(key)" 299 ng-click="quitarArticulo(key)"
300 > 300 >
301 <i class="fa fa-trash"></i> 301 <i class="fa fa-trash"></i>
302 </button> 302 </button>
303 </div> 303 </div>
304 </td> 304 </td>
305 </tr> 305 </tr>
306 </tbody> 306 </tbody>
307 <tfoot> 307 <tfoot>
308 <!-- CARGANDO ITEM --> 308 <!-- CARGANDO ITEM -->
309 <tr ng-show="!cargando" class="d-flex"> 309 <tr ng-show="!cargando" class="d-flex">
310 <td 310 <td
311 class="align-middle p-1" 311 class="align-middle p-1"
312 ng-bind="articulosTabla.length + 1" 312 ng-bind="articulosTabla.length + 1"
313 ></td> 313 ></td>
314 <td class="col p-0"> 314 <td class="col p-0">
315 <div class="d-flex"> 315 <div class="d-flex">
316 <div class="col-4 px-1"> 316 <div class="col-4 px-1">
317 <span 317 <span
318 ng-bind="articuloACargar.sectorCodigo" 318 ng-bind="articuloACargar.sectorCodigo"
319 ></span> 319 ></span>
320 </div> 320 </div>
321 <div class="col-8 px-1"> 321 <div class="col-8 px-1">
322 <span ng-bind="articuloACargar.descripcion"></span> 322 <span ng-bind="articuloACargar.descripcion"></span>
323 </div> 323 </div>
324 </div> 324 </div>
325 <div class="d-flex"> 325 <div class="d-flex">
326 <div class="col-3 px-1 m-1"> 326 <div class="col-3 px-1 m-1">
327 <input 327 <input
328 class="form-control p-1" 328 class="form-control p-1"
329 foca-tipo-input 329 foca-tipo-input
330 min="1" 330 min="1"
331 ng-model="articuloACargar.cantidad" 331 ng-model="articuloACargar.cantidad"
332 foca-focus="!cargando" 332 foca-focus="!cargando"
333 ng-keypress="agregarATabla($event.keyCode)" 333 ng-keypress="agregarATabla($event.keyCode)"
334 style="height: auto; line-height: 1.1em" 334 style="height: auto; line-height: 1.1em"
335 > 335 >
336 </div> 336 </div>
337 <div class="col px-1 text-right"> 337 <div class="col px-1 text-right">
338 <span ng-bind="articuloACargar.precio | 338 <span ng-bind="articuloACargar.precio |
339 currency: notaPedido.moneda.SIMBOLO : 4" 339 currency: notaPedido.moneda.SIMBOLO : 4"
340 ></span> 340 ></span>
341 </div> 341 </div>
342 <div class="col px-1 text-right"> 342 <div class="col px-1 text-right">
343 <span 343 <span
344 ng-bind="getSubTotal() | 344 ng-bind="getSubTotal() |
345 currency: notaPedido.moneda.SIMBOLO" 345 currency: notaPedido.moneda.SIMBOLO"
346 > 346 >
347 </span> 347 </span>
348 </div> 348 </div>
349 </div> 349 </div>
350 </td> 350 </td>
351 <td class="text-center align-middle"> 351 <td class="text-center align-middle">
352 <button 352 <button
353 class="btn btn-outline-light" 353 class="btn btn-outline-light"
354 ng-click="agregarATabla(13)" 354 ng-click="agregarATabla(13)"
355 > 355 >
356 <i class="fa fa-save"></i> 356 <i class="fa fa-save"></i>
357 </button> 357 </button>
358 </td> 358 </td>
359 </tr> 359 </tr>
360 <!-- SELECCIONAR PRODUCTO --> 360 <!-- SELECCIONAR PRODUCTO -->
361 <tr ng-show="cargando" class="d-flex"> 361 <tr ng-show="cargando" class="d-flex">
362 <td class="col-12"> 362 <td class="col-12">
363 <input 363 <input
364 placeholder="Seleccione Articulo" 364 placeholder="Seleccione Articulo"
365 class="form-control form-control-sm" 365 class="form-control form-control-sm"
366 readonly 366 readonly
367 ng-click="seleccionarArticulo()" 367 ng-click="seleccionarArticulo()"
368 /> 368 />
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="articulosTabla.length > 0" 377 ng-show="articulosTabla.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="articulosTabla.length"></a> 397 <a ng-bind="articulosTabla.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.moneda.SIMBOLO}}</h3> 403 <h3>{{getTotal() | currency: notaPedido.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