Commit 03c151cf85e25f472a138af6a269235bdf9973c2

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'develop'

Master

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