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