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