Commit 15efcde8ad4f79fde15a535fe07d6de12c9185c8

Authored by Jose Pinto
1 parent 9f48224aad
Exists in master

seleccionar vendedor al seleccionar cliente

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