Commit 0b61458012dc315c73e3497c1b24e717679788b3

Authored by Nicolás Guarnieri
1 parent 6d40a0d282
Exists in master

rellenar al seleccionar nota pedido

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