Commit 88ba9a27edfacafedea2331481270e3ac45f32b3

Authored by Luis Suarez
1 parent 7a947cbd5d
Exists in develop

con alerta de bootstrap

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