Commit 5034496622e345701f39de8241baa693624ee965

Authored by Eric Fernandez
1 parent bc3d89d890
Exists in master

spinner en mobile

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