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