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