Commit aa7f9a9e49afc96d1c714cf7f0cdeaa8da4bfe26

Authored by Eric
1 parent b598c80ad3
Exists in master

observaciones

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