Commit 6d24c72f1624841bb2b57ec8bc5ed8d009bc2623

Authored by Luigi
1 parent 116fa8f424
Exists in master

Eliminar forEach de articulos

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