Commit 34519c4b29deee90506da6597e84ef0d939730a7
1 parent
740b50ea56
Exists in
master
agrego foca-cabecera-facturador
Showing
2 changed files
with
80 additions
and
123 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
2 | [ | 2 | [ |
3 | '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', |
4 | 'focaModalService', 'notaPedidoBusinessService', '$rootScope', 'focaSeguimientoService', | 4 | 'focaModalService', 'notaPedidoBusinessService', '$rootScope', 'focaSeguimientoService', |
5 | function( | 5 | function( |
6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService, | 6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService, |
7 | notaPedidoBusinessService, $rootScope, focaSeguimientoService) | 7 | notaPedidoBusinessService, $rootScope, focaSeguimientoService) |
8 | { | 8 | { |
9 | 9 | ||
10 | $scope.botonera = crearNotaPedidoService.getBotonera(); | 10 | $scope.botonera = crearNotaPedidoService.getBotonera(); |
11 | 11 | ||
12 | $scope.isNumber = angular.isNumber; | 12 | $scope.isNumber = angular.isNumber; |
13 | $scope.datepickerAbierto = false; | 13 | $scope.datepickerAbierto = false; |
14 | $scope.show = false; | 14 | $scope.show = false; |
15 | $scope.cargando = true; | 15 | $scope.cargando = true; |
16 | $scope.dateOptions = { | 16 | $scope.dateOptions = { |
17 | maxDate: new Date(), | 17 | maxDate: new Date(), |
18 | minDate: new Date(2010, 0, 1) | 18 | minDate: new Date(2010, 0, 1) |
19 | }; | 19 | }; |
20 | 20 | ||
21 | $scope.notaPedido = { | 21 | $scope.notaPedido = { |
22 | id: 0, | 22 | id: 0, |
23 | vendedor: {}, | 23 | vendedor: {}, |
24 | cliente: {}, | 24 | cliente: {}, |
25 | proveedor: {}, | 25 | proveedor: {}, |
26 | domicilio: {dom: ''}, | 26 | domicilio: {dom: ''}, |
27 | moneda: {}, | 27 | moneda: {}, |
28 | cotizacion: {} | 28 | cotizacion: {} |
29 | }; | 29 | }; |
30 | var monedaPorDefecto; | 30 | var monedaPorDefecto; |
31 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 31 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
32 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | 32 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { |
33 | monedaPorDefecto = res.data[0]; | 33 | monedaPorDefecto = res.data[0]; |
34 | $scope.notaPedido.moneda = monedaPorDefecto; | 34 | $scope.notaPedido.moneda = monedaPorDefecto; |
35 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; | 35 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; |
36 | }); | 36 | }); |
37 | 37 | ||
38 | $scope.cabecera = []; | 38 | $scope.cabecera = []; |
39 | $scope.showCabecera = true; | 39 | $scope.showCabecera = true; |
40 | 40 | ||
41 | $scope.now = new Date(); | 41 | $scope.now = new Date(); |
42 | $scope.puntoVenta = '0000'; | 42 | $scope.puntoVenta = '0000'; |
43 | $scope.comprobante = '00000000'; | 43 | $scope.comprobante = '00000000'; |
44 | $scope.articulosTabla = []; | 44 | $scope.articulosTabla = []; |
45 | $scope.idLista = undefined; | 45 | $scope.idLista = undefined; |
46 | 46 | ||
47 | crearNotaPedidoService.getPrecioCondicion().then( | 47 | crearNotaPedidoService.getPrecioCondicion().then( |
48 | function(res) { | 48 | function(res) { |
49 | $scope.precioCondiciones = res.data; | 49 | $scope.precioCondiciones = res.data; |
50 | } | 50 | } |
51 | ); | 51 | ); |
52 | 52 | ||
53 | crearNotaPedidoService.getNumeroNotaPedido().then( | 53 | crearNotaPedidoService.getNumeroNotaPedido().then( |
54 | function(res) { | 54 | function(res) { |
55 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 55 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
56 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); | 56 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); |
57 | }, | 57 | }, |
58 | function(err) { | 58 | function(err) { |
59 | focaModalService.alert('La terminal no esta configurada correctamente'); | 59 | focaModalService.alert('La terminal no esta configurada correctamente'); |
60 | console.info(err); | 60 | console.info(err); |
61 | } | 61 | } |
62 | ); | 62 | ); |
63 | 63 | ||
64 | $scope.crearNotaPedido = function() { | 64 | $scope.crearNotaPedido = function() { |
65 | if(!$scope.notaPedido.vendedor.CodVen) { | 65 | if(!$scope.notaPedido.vendedor.CodVen) { |
66 | focaModalService.alert('Ingrese Vendedor'); | 66 | focaModalService.alert('Ingrese Vendedor'); |
67 | return; | 67 | return; |
68 | } else if(!$scope.notaPedido.cliente.COD) { | 68 | } else if(!$scope.notaPedido.cliente.COD) { |
69 | focaModalService.alert('Ingrese Cliente'); | 69 | focaModalService.alert('Ingrese Cliente'); |
70 | return; | 70 | return; |
71 | } else if(!$scope.notaPedido.proveedor.COD) { | 71 | } else if(!$scope.notaPedido.proveedor.COD) { |
72 | focaModalService.alert('Ingrese Proveedor'); | 72 | focaModalService.alert('Ingrese Proveedor'); |
73 | return; | 73 | return; |
74 | } else if(!$scope.notaPedido.moneda.ID) { | 74 | } else if(!$scope.notaPedido.moneda.ID) { |
75 | focaModalService.alert('Ingrese Moneda'); | 75 | focaModalService.alert('Ingrese Moneda'); |
76 | return; | 76 | return; |
77 | } else if(!$scope.notaPedido.cotizacion.ID) { | 77 | } else if(!$scope.notaPedido.cotizacion.ID) { |
78 | focaModalService.alert('Ingrese Cotización'); | 78 | focaModalService.alert('Ingrese Cotización'); |
79 | return; | 79 | return; |
80 | } else if(!$scope.plazosPagos) { | 80 | } else if(!$scope.plazosPagos) { |
81 | focaModalService.alert('Ingrese Precios y Condiciones'); | 81 | focaModalService.alert('Ingrese Precios y Condiciones'); |
82 | return; | 82 | return; |
83 | } else if( | 83 | } else if( |
84 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) | 84 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) |
85 | { | 85 | { |
86 | focaModalService.alert('Ingrese Flete'); | 86 | focaModalService.alert('Ingrese Flete'); |
87 | return; | 87 | return; |
88 | } else if(!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto | 88 | } else if(!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto |
89 | focaModalService.alert('Ingrese Domicilio'); | 89 | focaModalService.alert('Ingrese Domicilio'); |
90 | return; | 90 | return; |
91 | } else if($scope.articulosTabla.length === 0) { | 91 | } else if($scope.articulosTabla.length === 0) { |
92 | focaModalService.alert('Debe cargar al menos un articulo'); | 92 | focaModalService.alert('Debe cargar al menos un articulo'); |
93 | return; | 93 | return; |
94 | } | 94 | } |
95 | $scope.saveLoading = true; | 95 | $scope.saveLoading = true; |
96 | var notaPedido = { | 96 | var notaPedido = { |
97 | id: $scope.notaPedido.id, | 97 | id: $scope.notaPedido.id, |
98 | fechaCarga: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | 98 | fechaCarga: $scope.now.toISOString().slice(0, 19).replace('T', ' '), |
99 | idVendedor: $scope.notaPedido.vendedor.CodVen, | 99 | idVendedor: $scope.notaPedido.vendedor.CodVen, |
100 | idCliente: $scope.notaPedido.cliente.COD, | 100 | idCliente: $scope.notaPedido.cliente.COD, |
101 | nombreCliente: $scope.notaPedido.cliente.NOM, | 101 | nombreCliente: $scope.notaPedido.cliente.NOM, |
102 | cuitCliente: $scope.notaPedido.cliente.CUIT, | 102 | cuitCliente: $scope.notaPedido.cliente.CUIT, |
103 | idProveedor: $scope.notaPedido.proveedor.COD, | 103 | idProveedor: $scope.notaPedido.proveedor.COD, |
104 | //idDomicilio: $scope.notaPedido.domicilio.id,TODO GUARDAR DOMICILIO ID | 104 | //idDomicilio: $scope.notaPedido.domicilio.id,TODO GUARDAR DOMICILIO ID |
105 | idCotizacion: $scope.notaPedido.cotizacion.ID, | 105 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
106 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, | 106 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, |
107 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 107 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
108 | flete: $scope.notaPedido.flete, | 108 | flete: $scope.notaPedido.flete, |
109 | fob: $scope.notaPedido.fob, | 109 | fob: $scope.notaPedido.fob, |
110 | bomba: $scope.notaPedido.bomba, | 110 | bomba: $scope.notaPedido.bomba, |
111 | kilometros: $scope.notaPedido.kilometros, | 111 | kilometros: $scope.notaPedido.kilometros, |
112 | domicilioStamp: $scope.notaPedido.domicilioStamp, | 112 | domicilioStamp: $scope.notaPedido.domicilioStamp, |
113 | estado: 0, | 113 | estado: 0, |
114 | total: $scope.getTotal() | 114 | total: $scope.getTotal() |
115 | }; | 115 | }; |
116 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 116 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
117 | function(data) { | 117 | function(data) { |
118 | // Al guardar los datos de la nota de pedido logueamos la | 118 | // Al guardar los datos de la nota de pedido logueamos la |
119 | // actividad para su seguimiento. | 119 | // actividad para su seguimiento. |
120 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? | 120 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? |
121 | focaSeguimientoService.guardarPosicion( | 121 | focaSeguimientoService.guardarPosicion( |
122 | data.data.id, | 122 | data.data.id, |
123 | 'Nota de pedido', | 123 | 'Nota de pedido', |
124 | 'Nº: ' + $filter('comprobante')([ | 124 | 'Nº: ' + $filter('comprobante')([ |
125 | $scope.puntoVenta, | 125 | $scope.puntoVenta, |
126 | $scope.comprobante | 126 | $scope.comprobante |
127 | ]) + '<br/>' + | 127 | ]) + '<br/>' + |
128 | 'Vendedor: ' + $scope.notaPedido.vendedor.NomVen + '<br/>' + | 128 | 'Vendedor: ' + $scope.notaPedido.vendedor.NomVen + '<br/>' + |
129 | 'Total: ' + $filter('currency')($scope.getTotal()) | 129 | 'Total: ' + $filter('currency')($scope.getTotal()) |
130 | ); | 130 | ); |
131 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, | 131 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, |
132 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); | 132 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); |
133 | var plazos = $scope.plazosPagos; | 133 | var plazos = $scope.plazosPagos; |
134 | 134 | ||
135 | for(var j = 0; j < plazos.length; j++) { | 135 | for(var j = 0; j < plazos.length; j++) { |
136 | var json = { | 136 | var json = { |
137 | idPedido: data.data.id, | 137 | idPedido: data.data.id, |
138 | dias: plazos[j].dias | 138 | dias: plazos[j].dias |
139 | }; | 139 | }; |
140 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); | 140 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); |
141 | } | 141 | } |
142 | notaPedidoBusinessService.addEstado(data.data.id, | 142 | notaPedidoBusinessService.addEstado(data.data.id, |
143 | $scope.notaPedido.vendedor.CodVen); | 143 | $scope.notaPedido.vendedor.CodVen); |
144 | 144 | ||
145 | focaModalService.alert('Nota pedido creada'); | 145 | focaModalService.alert('Nota pedido creada'); |
146 | $scope.saveLoading = false; | 146 | $scope.saveLoading = false; |
147 | $scope.cabecera = []; | 147 | $scope.$broadcast('cleanCabecera'); |
148 | addCabecera('Moneda:', $scope.notaPedido.moneda.DETALLE); | 148 | $scope.$broadcast('addCabecera', { |
149 | addCabecera( | 149 | label: 'Moneda:', |
150 | 'Fecha cotizacion:', | 150 | valor: $scope.notaPedido.moneda.DETALLE |
151 | $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') | 151 | }); |
152 | ); | 152 | $scope.$broadcast('addCabecera', { |
153 | addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.VENDEDOR); | 153 | label: 'Fecha cotizacion:', |
154 | valor: $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') | ||
155 | }); | ||
156 | $scope.$broadcast('addCabecera', { | ||
157 | label: 'Moneda:', | ||
158 | valor: $scope.notaPedido.moneda.DETALLE | ||
159 | }); | ||
160 | $scope.$broadcast('addCabecera', { | ||
161 | label: 'Cotizacion:', | ||
162 | valor: $scope.notaPedido.cotizacion.VENDEDOR | ||
163 | }); | ||
154 | crearNotaPedidoService.getNumeroNotaPedido().then( | 164 | crearNotaPedidoService.getNumeroNotaPedido().then( |
155 | function(res) { | 165 | function(res) { |
156 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 166 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
157 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); | 167 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); |
158 | }, | 168 | }, |
159 | function(err) { | 169 | function(err) { |
160 | focaModalService.alert( | 170 | focaModalService.alert( |
161 | 'La terminal no esta configurada correctamente'); | 171 | 'La terminal no esta configurada correctamente'); |
162 | console.info(err); | 172 | console.info(err); |
163 | } | 173 | } |
164 | ); | 174 | ); |
165 | $scope.notaPedido.vendedor = {}; | 175 | $scope.notaPedido.vendedor = {}; |
166 | $scope.notaPedido.cliente = {}; | 176 | $scope.notaPedido.cliente = {}; |
167 | $scope.notaPedido.proveedor = {}; | 177 | $scope.notaPedido.proveedor = {}; |
168 | $scope.notaPedido.domicilio = {}; | 178 | $scope.notaPedido.domicilio = {}; |
169 | $scope.notaPedido.flete = null; | 179 | $scope.notaPedido.flete = null; |
170 | $scope.notaPedido.fob = null; | 180 | $scope.notaPedido.fob = null; |
171 | $scope.notaPedido.bomba = null; | 181 | $scope.notaPedido.bomba = null; |
172 | $scope.notaPedido.kilometros = null; | 182 | $scope.notaPedido.kilometros = null; |
173 | $scope.articulosTabla = []; | 183 | $scope.articulosTabla = []; |
174 | }, | 184 | }, |
175 | function(error) { | 185 | function(error) { |
176 | focaModalService.alert('Hubo un error al crear la nota de pedido'); | 186 | focaModalService.alert('Hubo un error al crear la nota de pedido'); |
177 | $scope.saveLoading = false; | 187 | $scope.saveLoading = false; |
178 | console.info(error); | 188 | console.info(error); |
179 | } | 189 | } |
180 | ); | 190 | ); |
181 | }; | 191 | }; |
182 | 192 | ||
183 | $scope.seleccionarNotaPedido = function() { | 193 | $scope.seleccionarNotaPedido = function() { |
184 | var modalInstance = $uibModal.open( | 194 | var modalInstance = $uibModal.open( |
185 | { | 195 | { |
186 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 196 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
187 | templateUrl: 'foca-modal-nota-pedido.html', | 197 | templateUrl: 'foca-modal-nota-pedido.html', |
188 | controller: 'focaModalNotaPedidoController', | 198 | controller: 'focaModalNotaPedidoController', |
189 | size: 'lg', | 199 | size: 'lg', |
190 | resolve: {usadoPor: function() {return 'notaPedido';}} | 200 | resolve: {usadoPor: function() {return 'notaPedido';}} |
191 | } | 201 | } |
192 | ); | 202 | ); |
193 | modalInstance.result.then( | 203 | modalInstance.result.then( |
194 | function(notaPedido) { | 204 | function(notaPedido) { |
195 | $scope.now = new Date(notaPedido.fechaCarga); | 205 | $scope.now = new Date(notaPedido.fechaCarga); |
196 | //añado cabeceras | 206 | //añado cabeceras |
197 | $scope.notaPedido.id = notaPedido.id; | 207 | $scope.notaPedido.id = notaPedido.id; |
198 | removeCabecera('Bomba:'); | 208 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
199 | removeCabecera('Kilometros:'); | 209 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
200 | var cabeceras = [ | 210 | var cabeceras = [ |
201 | { | 211 | { |
202 | label: 'Moneda:', | 212 | label: 'Moneda:', |
203 | valor: notaPedido.cotizacion.moneda.DETALLE | 213 | valor: notaPedido.cotizacion.moneda.DETALLE |
204 | }, | 214 | }, |
205 | { | 215 | { |
206 | label: 'Fecha cotizacion:', | 216 | label: 'Fecha cotizacion:', |
207 | valor: $filter('date')(notaPedido.cotizacion.FECHA, | 217 | valor: $filter('date')(notaPedido.cotizacion.FECHA, |
208 | 'dd/MM/yyyy') | 218 | 'dd/MM/yyyy') |
209 | }, | 219 | }, |
210 | { | 220 | { |
211 | label: 'Cotizacion:', | 221 | label: 'Cotizacion:', |
212 | valor: notaPedido.cotizacion.VENDEDOR | 222 | valor: notaPedido.cotizacion.VENDEDOR |
213 | }, | 223 | }, |
214 | { | 224 | { |
215 | label: 'Cliente:', | 225 | label: 'Cliente:', |
216 | valor: notaPedido.cliente.NOM | 226 | valor: notaPedido.cliente.NOM |
217 | }, | 227 | }, |
218 | { | 228 | { |
219 | label: 'Domicilio:', | 229 | label: 'Domicilio:', |
220 | valor: notaPedido.domicilioStamp | 230 | valor: notaPedido.domicilioStamp |
221 | }, | 231 | }, |
222 | { | 232 | { |
223 | label: 'Vendedor:', | 233 | label: 'Vendedor:', |
224 | valor: notaPedido.vendedor.NomVen | 234 | valor: notaPedido.vendedor.NomVen |
225 | }, | 235 | }, |
226 | { | 236 | { |
227 | label: 'Proveedor:', | 237 | label: 'Proveedor:', |
228 | valor: notaPedido.proveedor.NOM | 238 | valor: notaPedido.proveedor.NOM |
229 | }, | 239 | }, |
230 | { | 240 | { |
231 | label: 'Precio condicion:', | 241 | label: 'Precio condicion:', |
232 | valor: valorPrecioCondicion() + ' ' + | 242 | valor: valorPrecioCondicion() + ' ' + |
233 | notaPedidoBusinessService | 243 | notaPedidoBusinessService |
234 | .plazoToString(notaPedido.notaPedidoPlazo) | 244 | .plazoToString(notaPedido.notaPedidoPlazo) |
235 | }, | 245 | }, |
236 | { | 246 | { |
237 | label: 'Flete:', | 247 | label: 'Flete:', |
238 | valor: notaPedido.fob === 1 ? 'FOB' : ( | 248 | valor: notaPedido.fob === 1 ? 'FOB' : ( |
239 | notaPedido.flete === 1 ? 'Si' : 'No') | 249 | notaPedido.flete === 1 ? 'Si' : 'No') |
240 | } | 250 | } |
241 | ]; | 251 | ]; |
242 | 252 | ||
243 | function valorPrecioCondicion() { | 253 | function valorPrecioCondicion() { |
244 | if(notaPedido.idPrecioCondicion > 0) { | 254 | if(notaPedido.idPrecioCondicion > 0) { |
245 | return notaPedido.precioCondicion.nombre; | 255 | return notaPedido.precioCondicion.nombre; |
246 | } else { | 256 | } else { |
247 | return 'Ingreso Manual'; | 257 | return 'Ingreso Manual'; |
248 | } | 258 | } |
249 | } | 259 | } |
250 | 260 | ||
251 | if(notaPedido.flete === 1) { | 261 | if(notaPedido.flete === 1) { |
252 | var cabeceraBomba = { | 262 | var cabeceraBomba = { |
253 | label: 'Bomba:', | 263 | label: 'Bomba:', |
254 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 264 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
255 | }; | 265 | }; |
256 | if(notaPedido.kilometros) { | 266 | if(notaPedido.kilometros) { |
257 | var cabeceraKilometros = { | 267 | var cabeceraKilometros = { |
258 | label: 'Kilometros:', | 268 | label: 'Kilometros:', |
259 | valor: notaPedido.kilometros | 269 | valor: notaPedido.kilometros |
260 | }; | 270 | }; |
261 | cabeceras.push(cabeceraKilometros); | 271 | cabeceras.push(cabeceraKilometros); |
262 | } | 272 | } |
263 | cabeceras.push(cabeceraBomba); | 273 | cabeceras.push(cabeceraBomba); |
264 | } | 274 | } |
265 | $scope.articulosTabla = notaPedido.articulosNotaPedido; | 275 | $scope.articulosTabla = notaPedido.articulosNotaPedido; |
266 | notaPedidoBusinessService.calcularArticulos($scope.articulosTabla, | 276 | notaPedidoBusinessService.calcularArticulos($scope.articulosTabla, |
267 | notaPedido.cotizacion.VENDEDOR); | 277 | notaPedido.cotizacion.VENDEDOR); |
268 | if(notaPedido.idPrecioCondicion > 0) { | 278 | if(notaPedido.idPrecioCondicion > 0) { |
269 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | 279 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; |
270 | } else { | 280 | } else { |
271 | $scope.idLista = -1; | 281 | $scope.idLista = -1; |
272 | } | 282 | } |
273 | $scope.puntoVenta = rellenar(notaPedido.sucursal, 4); | 283 | $scope.puntoVenta = rellenar(notaPedido.sucursal, 4); |
274 | $scope.comprobante = rellenar(notaPedido.numeroNotaPedido, 8); | 284 | $scope.comprobante = rellenar(notaPedido.numeroNotaPedido, 8); |
275 | $scope.notaPedido = notaPedido; | 285 | $scope.notaPedido = notaPedido; |
276 | $scope.notaPedido.moneda = notaPedido.cotizacion.moneda; | 286 | $scope.notaPedido.moneda = notaPedido.cotizacion.moneda; |
277 | $scope.plazosPagos = notaPedido.notaPedidoPlazo; | 287 | $scope.plazosPagos = notaPedido.notaPedidoPlazo; |
278 | addArrayCabecera(cabeceras); | 288 | addArrayCabecera(cabeceras); |
279 | 289 | ||
280 | }, function() { | 290 | }, function() { |
281 | // funcion ejecutada cuando se cancela el modal | 291 | // funcion ejecutada cuando se cancela el modal |
282 | } | 292 | } |
283 | ); | 293 | ); |
284 | }; | 294 | }; |
285 | 295 | ||
286 | $scope.seleccionarProductos = function() { | 296 | $scope.seleccionarProductos = function() { |
287 | if ($scope.idLista === undefined) { | 297 | if ($scope.idLista === undefined) { |
288 | focaModalService.alert( | 298 | focaModalService.alert( |
289 | 'Primero seleccione una lista de precio y condicion'); | 299 | 'Primero seleccione una lista de precio y condicion'); |
290 | return; | 300 | return; |
291 | } | 301 | } |
292 | var modalInstance = $uibModal.open( | 302 | var modalInstance = $uibModal.open( |
293 | { | 303 | { |
294 | ariaLabelledBy: 'Busqueda de Productos', | 304 | ariaLabelledBy: 'Busqueda de Productos', |
295 | templateUrl: 'modal-busqueda-productos.html', | 305 | templateUrl: 'modal-busqueda-productos.html', |
296 | controller: 'modalBusquedaProductosCtrl', | 306 | controller: 'modalBusquedaProductosCtrl', |
297 | resolve: { | 307 | resolve: { |
298 | parametroProducto: { | 308 | parametroProducto: { |
299 | idLista: $scope.idLista, | 309 | idLista: $scope.idLista, |
300 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 310 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
301 | simbolo: $scope.notaPedido.moneda.SIMBOLO | 311 | simbolo: $scope.notaPedido.moneda.SIMBOLO |
302 | } | 312 | } |
303 | }, | 313 | }, |
304 | size: 'lg' | 314 | size: 'lg' |
305 | } | 315 | } |
306 | ); | 316 | ); |
307 | modalInstance.result.then( | 317 | modalInstance.result.then( |
308 | function(producto) { | 318 | function(producto) { |
309 | var newArt = | 319 | var newArt = |
310 | { | 320 | { |
311 | id: 0, | 321 | id: 0, |
312 | codigo: producto.codigo, | 322 | codigo: producto.codigo, |
313 | sector: producto.sector, | 323 | sector: producto.sector, |
314 | sectorCodigo: producto.sector + '-' + producto.codigo, | 324 | sectorCodigo: producto.sector + '-' + producto.codigo, |
315 | descripcion: producto.descripcion, | 325 | descripcion: producto.descripcion, |
316 | item: $scope.articulosTabla.length + 1, | 326 | item: $scope.articulosTabla.length + 1, |
317 | nombre: producto.descripcion, | 327 | nombre: producto.descripcion, |
318 | precio: parseFloat(producto.precio.toFixed(4)), | 328 | precio: parseFloat(producto.precio.toFixed(4)), |
319 | costoUnitario: producto.costo, | 329 | costoUnitario: producto.costo, |
320 | editCantidad: false, | 330 | editCantidad: false, |
321 | editPrecio: false, | 331 | editPrecio: false, |
322 | rubro: producto.CodRub, | 332 | rubro: producto.CodRub, |
323 | exentoUnitario: producto.precio, | 333 | exentoUnitario: producto.precio, |
324 | ivaUnitario: producto.IMPIVA, | 334 | ivaUnitario: producto.IMPIVA, |
325 | impuestoInternoUnitario: producto.ImpInt, | 335 | impuestoInternoUnitario: producto.ImpInt, |
326 | impuestoInterno1Unitario: producto.ImpInt2, | 336 | impuestoInterno1Unitario: producto.ImpInt2, |
327 | impuestoInterno2Unitario: producto.ImpInt3, | 337 | impuestoInterno2Unitario: producto.ImpInt3, |
328 | precioLista: producto.precio, | 338 | precioLista: producto.precio, |
329 | combustible: 1, | 339 | combustible: 1, |
330 | facturado: 0 | 340 | facturado: 0 |
331 | }; | 341 | }; |
332 | $scope.articuloACargar = newArt; | 342 | $scope.articuloACargar = newArt; |
333 | $scope.cargando = false; | 343 | $scope.cargando = false; |
334 | }, function() { | 344 | }, function() { |
335 | // funcion ejecutada cuando se cancela el modal | 345 | // funcion ejecutada cuando se cancela el modal |
336 | } | 346 | } |
337 | ); | 347 | ); |
338 | }; | 348 | }; |
339 | 349 | ||
340 | $scope.seleccionarVendedor = function() { | 350 | $scope.seleccionarVendedor = function() { |
341 | if(validarNotaRemitada()) { | 351 | if(validarNotaRemitada()) { |
342 | var modalInstance = $uibModal.open( | 352 | var modalInstance = $uibModal.open( |
343 | { | 353 | { |
344 | ariaLabelledBy: 'Busqueda de Vendedores', | 354 | ariaLabelledBy: 'Busqueda de Vendedores', |
345 | templateUrl: 'modal-vendedores.html', | 355 | templateUrl: 'modal-vendedores.html', |
346 | controller: 'modalVendedoresCtrl', | 356 | controller: 'modalVendedoresCtrl', |
347 | size: 'lg' | 357 | size: 'lg' |
348 | } | 358 | } |
349 | ); | 359 | ); |
350 | modalInstance.result.then( | 360 | modalInstance.result.then( |
351 | function(vendedor) { | 361 | function(vendedor) { |
352 | addCabecera('Vendedor:', vendedor.NomVen); | 362 | $scope.$broadcast('addCabecera',{ |
363 | label: 'Vendedor:', | ||
364 | valor: vendedor.NomVen | ||
365 | }); | ||
353 | $scope.notaPedido.vendedor = vendedor; | 366 | $scope.notaPedido.vendedor = vendedor; |
354 | }, function() { | 367 | }, function() { |
355 | 368 | ||
356 | } | 369 | } |
357 | ); | 370 | ); |
358 | } | 371 | } |
359 | }; | 372 | }; |
360 | 373 | ||
361 | $scope.seleccionarProveedor = function() { | 374 | $scope.seleccionarProveedor = function() { |
362 | if(validarNotaRemitada()) { | 375 | if(validarNotaRemitada()) { |
363 | var modalInstance = $uibModal.open( | 376 | var modalInstance = $uibModal.open( |
364 | { | 377 | { |
365 | ariaLabelledBy: 'Busqueda de Proveedor', | 378 | ariaLabelledBy: 'Busqueda de Proveedor', |
366 | templateUrl: 'modal-proveedor.html', | 379 | templateUrl: 'modal-proveedor.html', |
367 | controller: 'focaModalProveedorCtrl', | 380 | controller: 'focaModalProveedorCtrl', |
368 | size: 'lg', | 381 | size: 'lg', |
369 | resolve: { | 382 | resolve: { |
370 | transportista: function() { | 383 | transportista: function() { |
371 | return false; | 384 | return false; |
372 | } | 385 | } |
373 | } | 386 | } |
374 | } | 387 | } |
375 | ); | 388 | ); |
376 | modalInstance.result.then( | 389 | modalInstance.result.then( |
377 | function(proveedor) { | 390 | function(proveedor) { |
378 | $scope.notaPedido.proveedor = proveedor; | 391 | $scope.notaPedido.proveedor = proveedor; |
379 | addCabecera('Proveedor:', proveedor.NOM); | 392 | $scope.$broadcast('addCabecera',{ |
393 | label: 'Proveedor:', | ||
394 | valor: proveedor.NOM | ||
395 | }); | ||
380 | }, function() { | 396 | }, function() { |
381 | 397 | ||
382 | } | 398 | } |
383 | ); | 399 | ); |
384 | } | 400 | } |
385 | }; | 401 | }; |
386 | 402 | ||
387 | $scope.seleccionarCliente = function() { | 403 | $scope.seleccionarCliente = function() { |
388 | if(validarNotaRemitada()) { | 404 | if(validarNotaRemitada()) { |
389 | var modalInstance = $uibModal.open( | 405 | var modalInstance = $uibModal.open( |
390 | { | 406 | { |
391 | ariaLabelledBy: 'Busqueda de Cliente', | 407 | ariaLabelledBy: 'Busqueda de Cliente', |
392 | templateUrl: 'foca-busqueda-cliente-modal.html', | 408 | templateUrl: 'foca-busqueda-cliente-modal.html', |
393 | controller: 'focaBusquedaClienteModalController', | 409 | controller: 'focaBusquedaClienteModalController', |
394 | size: 'lg' | 410 | size: 'lg' |
395 | } | 411 | } |
396 | ); | 412 | ); |
397 | modalInstance.result.then( | 413 | modalInstance.result.then( |
398 | function(cliente) { | 414 | function(cliente) { |
399 | $scope.abrirModalDomicilios(cliente); | 415 | $scope.abrirModalDomicilios(cliente); |
400 | }, function() { | 416 | }, function() { |
401 | 417 | ||
402 | } | 418 | } |
403 | ); | 419 | ); |
404 | } | 420 | } |
405 | }; | 421 | }; |
406 | 422 | ||
407 | $scope.abrirModalDomicilios = function(cliente) { | 423 | $scope.abrirModalDomicilios = function(cliente) { |
408 | var modalInstanceDomicilio = $uibModal.open( | 424 | var modalInstanceDomicilio = $uibModal.open( |
409 | { | 425 | { |
410 | ariaLabelledBy: 'Busqueda de Domicilios', | 426 | ariaLabelledBy: 'Busqueda de Domicilios', |
411 | templateUrl: 'modal-domicilio.html', | 427 | templateUrl: 'modal-domicilio.html', |
412 | controller: 'focaModalDomicilioController', | 428 | controller: 'focaModalDomicilioController', |
413 | resolve: { idCliente: function() { return cliente.cod; }}, | 429 | resolve: { idCliente: function() { return cliente.cod; }}, |
414 | size: 'lg', | 430 | size: 'lg', |
415 | } | 431 | } |
416 | ); | 432 | ); |
417 | modalInstanceDomicilio.result.then( | 433 | modalInstanceDomicilio.result.then( |
418 | function(domicilio) { | 434 | function(domicilio) { |
419 | $scope.notaPedido.domicilio = domicilio; | 435 | $scope.notaPedido.domicilio = domicilio; |
420 | $scope.notaPedido.cliente = { | 436 | $scope.notaPedido.cliente = { |
421 | COD: cliente.cod, | 437 | COD: cliente.cod, |
422 | CUIT: cliente.cuit, | 438 | CUIT: cliente.cuit, |
423 | NOM: cliente.nom | 439 | NOM: cliente.nom |
424 | }; | 440 | }; |
425 | addCabecera('Cliente:', cliente.nom); | ||
426 | var domicilioStamp = | 441 | var domicilioStamp = |
427 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 442 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
428 | domicilio.Localidad + ', ' + domicilio.Provincia; | 443 | domicilio.Localidad + ', ' + domicilio.Provincia; |
429 | $scope.notaPedido.domicilioStamp = domicilioStamp; | 444 | $scope.notaPedido.domicilioStamp = domicilioStamp; |
430 | addCabecera('Domicilio:', domicilioStamp); | 445 | |
446 | $scope.$broadcast('addCabecera',{ | ||
447 | label: 'Cliente:', | ||
448 | valor: cliente.nom | ||
449 | }); | ||
450 | $scope.$broadcast('addCabecera',{ | ||
451 | label: 'Domicilio:', | ||
452 | valor: domicilioStamp | ||
453 | }); | ||
431 | }, function() { | 454 | }, function() { |
432 | $scope.seleccionarCliente(); | 455 | $scope.seleccionarCliente(); |
433 | return; | 456 | return; |
434 | } | 457 | } |
435 | ); | 458 | ); |
436 | }; | 459 | }; |
437 | 460 | ||
438 | $scope.getTotal = function() { | 461 | $scope.getTotal = function() { |
439 | var total = 0; | 462 | var total = 0; |
440 | var arrayTempArticulos = $scope.articulosTabla; | 463 | var arrayTempArticulos = $scope.articulosTabla; |
441 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 464 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
442 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 465 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
443 | } | 466 | } |
444 | return parseFloat(total.toFixed(2)); | 467 | return parseFloat(total.toFixed(2)); |
445 | }; | 468 | }; |
446 | 469 | ||
447 | $scope.getSubTotal = function() { | 470 | $scope.getSubTotal = function() { |
448 | if($scope.articuloACargar) { | 471 | if($scope.articuloACargar) { |
449 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 472 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
450 | } | 473 | } |
451 | }; | 474 | }; |
452 | 475 | ||
453 | $scope.seleccionarPreciosYCondiciones = function() { | 476 | $scope.seleccionarPreciosYCondiciones = function() { |
454 | if(validarNotaRemitada()) { | 477 | if(validarNotaRemitada()) { |
455 | var modalInstance = $uibModal.open( | 478 | var modalInstance = $uibModal.open( |
456 | { | 479 | { |
457 | ariaLabelledBy: 'Busqueda de Precio Condición', | 480 | ariaLabelledBy: 'Busqueda de Precio Condición', |
458 | templateUrl: 'modal-precio-condicion.html', | 481 | templateUrl: 'modal-precio-condicion.html', |
459 | controller: 'focaModalPrecioCondicionController', | 482 | controller: 'focaModalPrecioCondicionController', |
460 | size: 'lg' | 483 | size: 'lg' |
461 | } | 484 | } |
462 | ); | 485 | ); |
463 | modalInstance.result.then( | 486 | modalInstance.result.then( |
464 | function(precioCondicion) { | 487 | function(precioCondicion) { |
465 | var cabecera = ''; | 488 | var cabecera = ''; |
466 | var plazosConcat = ''; | 489 | var plazosConcat = ''; |
467 | if(!Array.isArray(precioCondicion)) { | 490 | if(!Array.isArray(precioCondicion)) { |
468 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; | 491 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; |
469 | $scope.plazosPagos = precioCondicion.plazoPago; | 492 | $scope.plazosPagos = precioCondicion.plazoPago; |
470 | $scope.idLista = precioCondicion.idListaPrecio; | 493 | $scope.idLista = precioCondicion.idListaPrecio; |
471 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 494 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
472 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 495 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
473 | } | 496 | } |
474 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 497 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
475 | } else { //Cuando se ingresan los plazos manualmente | 498 | } else { //Cuando se ingresan los plazos manualmente |
476 | $scope.notaPedido.idPrecioCondicion = 0; | 499 | $scope.notaPedido.idPrecioCondicion = 0; |
477 | //-1, el modal productos busca todos los productos | 500 | //-1, el modal productos busca todos los productos |
478 | $scope.idLista = -1; | 501 | $scope.idLista = -1; |
479 | $scope.plazosPagos = precioCondicion; | 502 | $scope.plazosPagos = precioCondicion; |
480 | for(var j = 0; j < precioCondicion.length; j++) { | 503 | for(var j = 0; j < precioCondicion.length; j++) { |
481 | plazosConcat += precioCondicion[j].dias + ' '; | 504 | plazosConcat += precioCondicion[j].dias + ' '; |
482 | } | 505 | } |
483 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 506 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
484 | } | 507 | } |
485 | $scope.articulosTabla = []; | 508 | $scope.articulosTabla = []; |
486 | addCabecera('Precios y condiciones:', cabecera); | 509 | $scope.$broadcast('addCabecera',{ |
510 | label: 'Precios y condiciones:', | ||
511 | valor: cabecera | ||
512 | }); | ||
487 | }, function() { | 513 | }, function() { |
488 | 514 | ||
489 | } | 515 | } |
490 | ); | 516 | ); |
491 | } | 517 | } |
492 | }; | 518 | }; |
493 | 519 | ||
494 | $scope.seleccionarFlete = function() { | 520 | $scope.seleccionarFlete = function() { |
495 | if(validarNotaRemitada()) { | 521 | if(validarNotaRemitada()) { |
496 | var modalInstance = $uibModal.open( | 522 | var modalInstance = $uibModal.open( |
497 | { | 523 | { |
498 | ariaLabelledBy: 'Busqueda de Flete', | 524 | ariaLabelledBy: 'Busqueda de Flete', |
499 | templateUrl: 'modal-flete.html', | 525 | templateUrl: 'modal-flete.html', |
500 | controller: 'focaModalFleteController', | 526 | controller: 'focaModalFleteController', |
501 | size: 'lg', | 527 | size: 'lg', |
502 | resolve: { | 528 | resolve: { |
503 | parametrosFlete: | 529 | parametrosFlete: |
504 | function() { | 530 | function() { |
505 | return { | 531 | return { |
506 | flete: $scope.notaPedido.fob ? 'FOB' : | 532 | flete: $scope.notaPedido.fob ? 'FOB' : |
507 | ( $scope.notaPedido.flete ? '1' : | 533 | ( $scope.notaPedido.flete ? '1' : |
508 | ($scope.notaPedido.flete === undefined ? | 534 | ($scope.notaPedido.flete === undefined ? |
509 | null : '0')), | 535 | null : '0')), |
510 | bomba: $scope.notaPedido.bomba ? '1' : | 536 | bomba: $scope.notaPedido.bomba ? '1' : |
511 | ($scope.notaPedido.bomba === undefined ? | 537 | ($scope.notaPedido.bomba === undefined ? |
512 | null : '0'), | 538 | null : '0'), |
513 | kilometros: $scope.notaPedido.kilometros | 539 | kilometros: $scope.notaPedido.kilometros |
514 | }; | 540 | }; |
515 | } | 541 | } |
516 | } | 542 | } |
517 | } | 543 | } |
518 | ); | 544 | ); |
519 | modalInstance.result.then( | 545 | modalInstance.result.then( |
520 | function(datos) { | 546 | function(datos) { |
521 | $scope.notaPedido.flete = datos.flete; | 547 | $scope.notaPedido.flete = datos.flete; |
522 | $scope.notaPedido.fob = datos.FOB; | 548 | $scope.notaPedido.fob = datos.FOB; |
523 | $scope.notaPedido.bomba = datos.bomba; | 549 | $scope.notaPedido.bomba = datos.bomba; |
524 | $scope.notaPedido.kilometros = datos.kilometros; | 550 | $scope.notaPedido.kilometros = datos.kilometros; |
525 | addCabecera('Flete:', datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No')); | 551 | $scope.$broadcast('addCabecera',{ |
552 | label: 'Flete:', | ||
553 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') | ||
554 | }); | ||
526 | if(datos.flete) { | 555 | if(datos.flete) { |
527 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | 556 | $scope.$broadcast('addCabecera',{ |
528 | addCabecera('Kilometros:', datos.kilometros); | 557 | label: 'Bomba:', |
558 | valor: datos.bomba ? 'Si' : 'No' | ||
559 | }); | ||
560 | $scope.$broadcast('addCabecera',{ | ||
561 | label: 'Kilometros:', | ||
562 | valor: datos.kilometros | ||
563 | }); | ||
529 | } else { | 564 | } else { |
530 | removeCabecera('Bomba:'); | 565 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
531 | removeCabecera('Kilometros:'); | 566 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
532 | $scope.notaPedido.bomba = false; | 567 | $scope.notaPedido.bomba = false; |
533 | $scope.notaPedido.kilometros = null; | 568 | $scope.notaPedido.kilometros = null; |
534 | } | 569 | } |
535 | }, function() { | 570 | }, function() { |
536 | 571 | ||
537 | } | 572 | } |
538 | ); | 573 | ); |
539 | } | 574 | } |
540 | }; | 575 | }; |
541 | 576 | ||
542 | $scope.seleccionarMoneda = function() { | 577 | $scope.seleccionarMoneda = function() { |
543 | if(validarNotaRemitada()) { | 578 | if(validarNotaRemitada()) { |
544 | var modalInstance = $uibModal.open( | 579 | var modalInstance = $uibModal.open( |
545 | { | 580 | { |
546 | ariaLabelledBy: 'Busqueda de Moneda', | 581 | ariaLabelledBy: 'Busqueda de Moneda', |
547 | templateUrl: 'modal-moneda.html', | 582 | templateUrl: 'modal-moneda.html', |
548 | controller: 'focaModalMonedaController', | 583 | controller: 'focaModalMonedaController', |
549 | size: 'lg' | 584 | size: 'lg' |
550 | } | 585 | } |
551 | ); | 586 | ); |
552 | modalInstance.result.then( | 587 | modalInstance.result.then( |
553 | function(moneda) { | 588 | function(moneda) { |
554 | $scope.abrirModalCotizacion(moneda); | 589 | $scope.abrirModalCotizacion(moneda); |
555 | }, function() { | 590 | }, function() { |
556 | 591 | ||
557 | } | 592 | } |
558 | ); | 593 | ); |
559 | } | 594 | } |
560 | }; | 595 | }; |
561 | 596 | ||
562 | $scope.abrirModalCotizacion = function(moneda) { | 597 | $scope.abrirModalCotizacion = function(moneda) { |
563 | var modalInstance = $uibModal.open( | 598 | var modalInstance = $uibModal.open( |
564 | { | 599 | { |
565 | ariaLabelledBy: 'Busqueda de Cotización', | 600 | ariaLabelledBy: 'Busqueda de Cotización', |
566 | templateUrl: 'modal-cotizacion.html', | 601 | templateUrl: 'modal-cotizacion.html', |
567 | controller: 'focaModalCotizacionController', | 602 | controller: 'focaModalCotizacionController', |
568 | size: 'lg', | 603 | size: 'lg', |
569 | resolve: {idMoneda: function() {return moneda.ID;}} | 604 | resolve: {idMoneda: function() {return moneda.ID;}} |
570 | } | 605 | } |
571 | ); | 606 | ); |
572 | modalInstance.result.then( | 607 | modalInstance.result.then( |
573 | function(cotizacion) { | 608 | function(cotizacion) { |
574 | var articulosTablaTemp = $scope.articulosTabla; | 609 | var articulosTablaTemp = $scope.articulosTabla; |
575 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 610 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
576 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 611 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
577 | $scope.notaPedido.cotizacion.VENDEDOR; | 612 | $scope.notaPedido.cotizacion.VENDEDOR; |
578 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 613 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
579 | cotizacion.VENDEDOR; | 614 | cotizacion.VENDEDOR; |
580 | } | 615 | } |
581 | $scope.articulosTabla = articulosTablaTemp; | 616 | $scope.articulosTabla = articulosTablaTemp; |
582 | $scope.notaPedido.moneda = moneda; | 617 | $scope.notaPedido.moneda = moneda; |
583 | $scope.notaPedido.cotizacion = cotizacion; | 618 | $scope.notaPedido.cotizacion = cotizacion; |
584 | if(moneda.DETALLE === 'PESOS ARGENTINOS'){ | 619 | if(moneda.DETALLE === 'PESOS ARGENTINOS'){ |
585 | removeCabecera('Moneda:'); | 620 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
586 | removeCabecera('Fecha cotizacion:'); | 621 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
587 | removeCabecera('Cotizacion:'); | 622 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
588 | }else{ | 623 | }else{ |
589 | addCabecera('Moneda:', moneda.DETALLE); | 624 | $scope.$broadcast('addCabecera',{ |
590 | addCabecera( | 625 | label: 'Moneda:', |
591 | 'Fecha cotizacion:', | 626 | valor: moneda.DETALLE |
592 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 627 | }); |
593 | ); | 628 | $scope.$broadcast('addCabecera',{ |
594 | addCabecera('Cotizacion:', cotizacion.VENDEDOR); | 629 | label: 'Fecha cotizacion:', |
630 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | ||
631 | }); | ||
632 | $scope.$broadcast('addCabecera',{ | ||
633 | label: 'Cotizacion:', | ||
634 | valor: cotizacion.VENDEDOR | ||
635 | }); | ||
595 | } | 636 | } |
596 | }, function() { | 637 | }, function() { |
597 | 638 | ||
598 | } | 639 | } |
599 | ); | 640 | ); |
600 | }; | 641 | }; |
601 | 642 | ||
602 | $scope.agregarATabla = function(key) { | 643 | $scope.agregarATabla = function(key) { |
603 | if(key === 13) { | 644 | if(key === 13) { |
604 | if($scope.articuloACargar.cantidad === undefined || | 645 | if($scope.articuloACargar.cantidad === undefined || |
605 | $scope.articuloACargar.cantidad === 0 || | 646 | $scope.articuloACargar.cantidad === 0 || |
606 | $scope.articuloACargar.cantidad === null ) { | 647 | $scope.articuloACargar.cantidad === null ) { |
607 | focaModalService.alert('El valor debe ser al menos 1'); | 648 | focaModalService.alert('El valor debe ser al menos 1'); |
608 | return; | 649 | return; |
609 | } | 650 | } |
610 | delete $scope.articuloACargar.sectorCodigo; | 651 | delete $scope.articuloACargar.sectorCodigo; |
611 | $scope.articulosTabla.push($scope.articuloACargar); | 652 | $scope.articulosTabla.push($scope.articuloACargar); |
612 | $scope.cargando = true; | 653 | $scope.cargando = true; |
613 | } | 654 | } |
614 | }; | 655 | }; |
615 | 656 | ||
616 | $scope.quitarArticulo = function(key) { | 657 | $scope.quitarArticulo = function(key) { |
617 | $scope.articulosTabla.splice(key, 1); | 658 | $scope.articulosTabla.splice(key, 1); |
618 | }; | 659 | }; |
619 | 660 | ||
620 | $scope.editarArticulo = function(key, articulo) { | 661 | $scope.editarArticulo = function(key, articulo) { |
621 | if(key === 13) { | 662 | if(key === 13) { |
622 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 663 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
623 | articulo.cantidad === undefined) { | 664 | articulo.cantidad === undefined) { |
624 | focaModalService.alert('El valor debe ser al menos 1'); | 665 | focaModalService.alert('El valor debe ser al menos 1'); |
625 | return; | 666 | return; |
626 | } | 667 | } |
627 | articulo.editCantidad = false; | 668 | articulo.editCantidad = false; |
628 | articulo.editPrecio = false; | 669 | articulo.editPrecio = false; |
629 | } | 670 | } |
630 | }; | 671 | }; |
631 | 672 | ||
632 | $scope.cambioEdit = function(articulo, propiedad) { | 673 | $scope.cambioEdit = function(articulo, propiedad) { |
633 | if(propiedad === 'cantidad') { | 674 | if(propiedad === 'cantidad') { |
634 | articulo.editCantidad = true; | 675 | articulo.editCantidad = true; |
635 | } else if(propiedad === 'precio') { | 676 | } else if(propiedad === 'precio') { |
636 | articulo.editPrecio = true; | 677 | articulo.editPrecio = true; |
637 | } | 678 | } |
638 | }; | 679 | }; |
639 | 680 | ||
640 | $scope.resetFilter = function() { | 681 | $scope.resetFilter = function() { |
641 | $scope.articuloACargar = {}; | 682 | $scope.articuloACargar = {}; |
642 | $scope.cargando = true; | 683 | $scope.cargando = true; |
643 | }; | 684 | }; |
644 | //Recibe aviso si el teclado está en uso | 685 | //Recibe aviso si el teclado está en uso |
645 | $rootScope.$on('usarTeclado', function(event, data) { | 686 | $rootScope.$on('usarTeclado', function(event, data) { |
646 | if(data) { | 687 | if(data) { |
647 | $scope.mostrarTeclado = true; | 688 | $scope.mostrarTeclado = true; |
648 | return; | 689 | return; |
649 | } | 690 | } |
650 | $scope.mostrarTeclado = false; | 691 | $scope.mostrarTeclado = false; |
651 | }); | 692 | }); |
652 | 693 | ||
653 | $scope.selectFocus = function($event) { | 694 | $scope.selectFocus = function($event) { |
654 | // Si el teclado esta en uso no selecciona el valor | 695 | // Si el teclado esta en uso no selecciona el valor |
655 | if($scope.mostrarTeclado) { | 696 | if($scope.mostrarTeclado) { |
656 | return; | 697 | return; |
657 | } | 698 | } |
658 | $event.target.select(); | 699 | $event.target.select(); |
659 | }; | 700 | }; |
660 | 701 | ||
661 | $scope.salir = function() { | 702 | $scope.salir = function() { |
662 | $location.path('/'); | 703 | $location.path('/'); |
663 | }; | 704 | }; |
664 | 705 | ||
665 | $scope.parsearATexto = function(articulo) { | 706 | $scope.parsearATexto = function(articulo) { |
666 | articulo.cantidad = parseFloat(articulo.cantidad); | 707 | articulo.cantidad = parseFloat(articulo.cantidad); |
667 | articulo.precio = parseFloat(articulo.precio); | 708 | articulo.precio = parseFloat(articulo.precio); |
668 | }; | 709 | }; |
669 | 710 | ||
670 | function addArrayCabecera(array) { | 711 | function addArrayCabecera(array) { |
671 | for(var i = 0; i < array.length; i++) { | 712 | for(var i = 0; i < array.length; i++) { |
672 | addCabecera(array[i].label, array[i].valor); | 713 | $scope.$broadcast('addCabecera',{ |
673 | } | 714 | label: array[i].label, |
674 | } | 715 | valor: array[i].valor |
675 | 716 | }); | |
676 | function addCabecera(label, valor) { | ||
677 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | ||
678 | if(propiedad.length === 1) { | ||
679 | propiedad[0].valor = valor; | ||
680 | } else { | ||
681 | $scope.cabecera.push({label: label, valor: valor}); | ||
682 | } | ||
683 | } | ||
684 | |||
685 | function removeCabecera(label) { | ||
686 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | ||
687 | if(propiedad.length === 1) { | ||
688 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | ||
689 | } | 717 | } |
690 | } | 718 | } |
691 | 719 | ||
692 | function rellenar(relleno, longitud) { | 720 | function rellenar(relleno, longitud) { |
693 | relleno = '' + relleno; | 721 | relleno = '' + relleno; |
694 | while (relleno.length < longitud) { | 722 | while (relleno.length < longitud) { |
695 | relleno = '0' + relleno; | 723 | relleno = '0' + relleno; |
696 | } | 724 | } |
697 | 725 |
src/views/nota-pedido.html
1 | <div class="crear-nota-pedido foca-crear row"> | 1 | <div class="crear-nota-pedido foca-crear row"> |
2 | <form name="formCrearNota" ng-submit="crearNotaPedido()" class="mb-0 col-lg-12"> | 2 | <foca-cabecera-facturador |
3 | <div class="row"> | 3 | titulo="'NOTA DE PEDIDO'" |
4 | <div class="col-md-10 col-lg-12"> | 4 | numero="puntoVenta + '-' + comprobante" |
5 | <div class="row panel-informativo"> | 5 | fecha="now" |
6 | <div class="col-12"> | 6 | class="mb-0 col-lg-12" |
7 | <div class="row titulares"> | 7 | busqueda="seleccionarNotaPedido" |
8 | <div class="col-12 col-sm-3 nota-pedido border border-left-0 border-white align-middle"> | 8 | ></foca-cabecera-facturador> |
9 | <h5 class="mb-0">NOTA DE PEDIDO</h5> | ||
10 | </div> | ||
11 | <div class="col-12 col-sm-3 numero-pedido border border-white align-middle" | ||
12 | >Nº {{puntoVenta}}-{{comprobante}} | ||
13 | <button | ||
14 | class="btn btn-xs btn-outline-light float-right" | ||
15 | type="button" | ||
16 | ng-click="seleccionarNotaPedido()" | ||
17 | > | ||
18 | <i class="fa fa-search"></i> | ||
19 | </button> | ||
20 | </div> | ||
21 | <div class="col-7 col-sm-3 border border-white align-middle"> | ||
22 | Fecha:  | ||
23 | <span | ||
24 | ng-show="!datepickerAbierto" | ||
25 | ng-bind="now | date:'dd/MM/yyyy'" | ||
26 | ng-click="datepickerAbierto = true" | ||
27 | > | ||
28 | </span> | ||
29 | <input | ||
30 | ng-show="datepickerAbierto" | ||
31 | type="date" | ||
32 | ng-model="now" | ||
33 | ng-change="datepickerAbierto = false" | ||
34 | ng-blur="datepickerAbierto = false" | ||
35 | class="form-control form-control-sm col-8 float-right" | ||
36 | foca-focus="datepickerAbierto" | ||
37 | hasta-hoy | ||
38 | /> | ||
39 | </div> | ||
40 | <div class="col-5 col-sm-3 border border-white border-right-0 align-middle"> | ||
41 | Hora:  | ||
42 | <span | ||
43 | ng-show="!datepickerAbierto" | ||
44 | ng-bind="now | date:'HH:mm'" | ||
45 | ng-click="datepickerAbierto = true" | ||
46 | > | ||
47 | </span> | ||
48 | </div> | ||
49 | </div> | ||
50 | <div class="row py-2"> | ||
51 | <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> | ||
52 | <span class="label" ng-bind="cab.label"></span> | ||
53 | <span class="valor" ng-bind="cab.valor" ng-if="!isNumber(cab.valor)"></span> | ||
54 | <span class="valor" ng-bind="cab.valor | number:2" ng-if="isNumber(cab.valor)"></span> | ||
55 | </div> | ||
56 | <a | ||
57 | class="btn col-12 btn-secondary d-sm-none" | ||
58 | ng-show="cabecera.length > 0" | ||
59 | ng-click="showCabecera = !showCabecera" | ||
60 | > | ||
61 | <i | ||
62 | class="fa fa-chevron-down" | ||
63 | ng-hide="showCabecera" | ||
64 | aria-hidden="true" | ||
65 | > | ||
66 | </i> | ||
67 | <i | ||
68 | class="fa fa-chevron-up" | ||
69 | ng-show="showCabecera" | ||
70 | aria-hidden="true"> | ||
71 | </i> | ||
72 | </a> | ||
73 | </div> | ||
74 | </div> | ||
75 | </div> | ||
76 | |||
77 | </div> | ||
78 | </div> | ||
79 | </form> | ||
80 | <div class="col-lg-12"> | 9 | <div class="col-lg-12"> |
81 | <div class="row mt-4"> | 10 | <div class="row mt-4"> |
82 | <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"> |
83 | <div class="row px-5 py-2 botonera-secundaria"> | 12 | <div class="row px-5 py-2 botonera-secundaria"> |
84 | <div class="col-12"> | 13 | <div class="col-12"> |
85 | <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> |
86 | </div> | 15 | </div> |
87 | </div> | 16 | </div> |
88 | <!-- PC --> | 17 | <!-- PC --> |
89 | <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"> |
90 | <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"> |
91 | <thead> | 20 | <thead> |
92 | <tr class="d-flex"> | 21 | <tr class="d-flex"> |
93 | <th valign="middle" class="">#</th> | 22 | <th valign="middle" class="">#</th> |
94 | <th valign="middle" class="col">Código</th> | 23 | <th valign="middle" class="col">Código</th> |
95 | <th valign="middle" class="col-4">Descripción</th> | 24 | <th valign="middle" class="col-4">Descripción</th> |
96 | <th valign="middle" class="col text-right">Cantidad</th> | 25 | <th valign="middle" class="col text-right">Cantidad</th> |
97 | <th valign="middle" class="col text-right">Precio Unitario</th> | 26 | <th valign="middle" class="col text-right">Precio Unitario</th> |
98 | <th valign="middle" class="col text-right">SubTotal</th> | 27 | <th valign="middle" class="col text-right">SubTotal</th> |
99 | <th valign="middle" class="text-right"> | 28 | <th valign="middle" class="text-right"> |
100 | <button | 29 | <button |
101 | class="btn btn-outline-light selectable" | 30 | class="btn btn-outline-light selectable" |
102 | ng-click="show = !show; masMenos()" | 31 | ng-click="show = !show; masMenos()" |
103 | > | 32 | > |
104 | <i | 33 | <i |
105 | class="fa fa-chevron-down" | 34 | class="fa fa-chevron-down" |
106 | ng-show="show" | 35 | ng-show="show" |
107 | aria-hidden="true" | 36 | aria-hidden="true" |
108 | > | 37 | > |
109 | </i> | 38 | </i> |
110 | <i | 39 | <i |
111 | class="fa fa-chevron-up" | 40 | class="fa fa-chevron-up" |
112 | ng-hide="show" | 41 | ng-hide="show" |
113 | aria-hidden="true"> | 42 | aria-hidden="true"> |
114 | </i> | 43 | </i> |
115 | </button> | 44 | </button> |
116 | </th> | 45 | </th> |
117 | </tr> | 46 | </tr> |
118 | </thead> | 47 | </thead> |
119 | <tbody class="tabla-articulo-body"> | 48 | <tbody class="tabla-articulo-body"> |
120 | <tr | 49 | <tr |
121 | ng-repeat="(key, articulo) in articulosTabla" | 50 | ng-repeat="(key, articulo) in articulosTabla" |
122 | ng-show="show || key == (articulosTabla.length - 1)" | 51 | ng-show="show || key == (articulosTabla.length - 1)" |
123 | class="d-flex" | 52 | class="d-flex" |
124 | > | 53 | > |
125 | <td ng-bind="key + 1"></td> | 54 | <td ng-bind="key + 1"></td> |
126 | <td | 55 | <td |
127 | class="col" | 56 | class="col" |
128 | ng-bind="articulo.sector + '-' + articulo.codigo" | 57 | ng-bind="articulo.sector + '-' + articulo.codigo" |
129 | ></td> | 58 | ></td> |
130 | <td | 59 | <td |
131 | class="col-4" | 60 | class="col-4" |
132 | ng-bind="articulo.descripcion" | 61 | ng-bind="articulo.descripcion" |
133 | ></td> | 62 | ></td> |
134 | <td class="col text-right"> | 63 | <td class="col text-right"> |
135 | <input | 64 | <input |
136 | ng-show="articulo.editCantidad" | 65 | ng-show="articulo.editCantidad" |
137 | ng-model="articulo.cantidad" | 66 | ng-model="articulo.cantidad" |
138 | class="form-control" | 67 | class="form-control" |
139 | foca-tipo-input | 68 | foca-tipo-input |
140 | min="1" | 69 | min="1" |
141 | step="0.001" | 70 | step="0.001" |
142 | foca-focus="articulo.editCantidad" | 71 | foca-focus="articulo.editCantidad" |
143 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 72 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
144 | ng-focus="selectFocus($event)" | 73 | ng-focus="selectFocus($event)" |
145 | teclado-virtual | 74 | teclado-virtual |
146 | > | 75 | > |
147 | <i | 76 | <i |
148 | class="selectable" | 77 | class="selectable" |
149 | ng-click="cambioEdit(articulo, 'cantidad')" | 78 | ng-click="cambioEdit(articulo, 'cantidad')" |
150 | ng-hide="articulo.editCantidad" | 79 | ng-hide="articulo.editCantidad" |
151 | ng-bind="articulo.cantidad"> | 80 | ng-bind="articulo.cantidad"> |
152 | </i> | 81 | </i> |
153 | </td> | 82 | </td> |
154 | <td class="col text-right"> | 83 | <td class="col text-right"> |
155 | <input | 84 | <input |
156 | ng-show="articulo.editPrecio" | 85 | ng-show="articulo.editPrecio" |
157 | ng-model="articulo.precio" | 86 | ng-model="articulo.precio" |
158 | class="form-control" | 87 | class="form-control" |
159 | foca-tipo-input | 88 | foca-tipo-input |
160 | min="0" | 89 | min="0" |
161 | step="0.0001" | 90 | step="0.0001" |
162 | foca-focus="articulo.editPrecio" | 91 | foca-focus="articulo.editPrecio" |
163 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 92 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
164 | ng-focus="selectFocus($event)" | 93 | ng-focus="selectFocus($event)" |
165 | teclado-virtual | 94 | teclado-virtual |
166 | > | 95 | > |
167 | <i | 96 | <i |
168 | class="selectable" | 97 | class="selectable" |
169 | ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" | 98 | ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" |
170 | ng-hide="articulo.editPrecio" | 99 | ng-hide="articulo.editPrecio" |
171 | ng-bind="articulo.precio | | 100 | ng-bind="articulo.precio | |
172 | currency: notaPedido.moneda.SIMBOLO : 4"> | 101 | currency: notaPedido.moneda.SIMBOLO : 4"> |
173 | </i> | 102 | </i> |
174 | </td> | 103 | </td> |
175 | <td | 104 | <td |
176 | class="col text-right" | 105 | class="col text-right" |
177 | ng-bind="(articulo.precio * articulo.cantidad) | | 106 | ng-bind="(articulo.precio * articulo.cantidad) | |
178 | currency: notaPedido.moneda.SIMBOLO"> | 107 | currency: notaPedido.moneda.SIMBOLO"> |
179 | </td> | 108 | </td> |
180 | <td class="text-center"> | 109 | <td class="text-center"> |
181 | <button | 110 | <button |
182 | ng-show="articulo.editCantidad || articulo.editPrecio" | 111 | ng-show="articulo.editCantidad || articulo.editPrecio" |
183 | class="btn btn-outline-light" | 112 | class="btn btn-outline-light" |
184 | ng-click="editarArticulo(13, articulo)" | 113 | ng-click="editarArticulo(13, articulo)" |
185 | > | 114 | > |
186 | <i class="fa fa-save"></i> | 115 | <i class="fa fa-save"></i> |
187 | </button> | 116 | </button> |
188 | <button | 117 | <button |
189 | class="btn btn-outline-light" | 118 | class="btn btn-outline-light" |
190 | ng-click="quitarArticulo(key)" | 119 | ng-click="quitarArticulo(key)" |
191 | > | 120 | > |
192 | <i class="fa fa-trash"></i> | 121 | <i class="fa fa-trash"></i> |
193 | </button> | 122 | </button> |
194 | </td> | 123 | </td> |
195 | </tr> | 124 | </tr> |
196 | </tbody> | 125 | </tbody> |
197 | <tfoot> | 126 | <tfoot> |
198 | <tr ng-show="!cargando" class="d-flex"> | 127 | <tr ng-show="!cargando" class="d-flex"> |
199 | <td | 128 | <td |
200 | class="align-middle" | 129 | class="align-middle" |
201 | ng-bind="articulosTabla.length + 1" | 130 | ng-bind="articulosTabla.length + 1" |
202 | ></td> | 131 | ></td> |
203 | <td class="col"> | 132 | <td class="col"> |
204 | <input | 133 | <input |
205 | class="form-control" | 134 | class="form-control" |
206 | ng-model="articuloACargar.sectorCodigo" | 135 | ng-model="articuloACargar.sectorCodigo" |
207 | readonly | 136 | readonly |
208 | > | 137 | > |
209 | </td> | 138 | </td> |
210 | <td class="col-4 tabla-articulo-descripcion"> | 139 | <td class="col-4 tabla-articulo-descripcion"> |
211 | <input | 140 | <input |
212 | class="form-control" | 141 | class="form-control" |
213 | ng-model="articuloACargar.descripcion" | 142 | ng-model="articuloACargar.descripcion" |
214 | readonly | 143 | readonly |
215 | > | 144 | > |
216 | </td> | 145 | </td> |
217 | <td class="col text-right"> | 146 | <td class="col text-right"> |
218 | <input | 147 | <input |
219 | class="form-control" | 148 | class="form-control" |
220 | foca-tipo-input | 149 | foca-tipo-input |
221 | min="1" | 150 | min="1" |
222 | step="0.001" | 151 | step="0.001" |
223 | ng-model="articuloACargar.cantidad" | 152 | ng-model="articuloACargar.cantidad" |
224 | foca-focus="!cargando" | 153 | foca-focus="!cargando" |
225 | esc-key="resetFilter()" | 154 | esc-key="resetFilter()" |
226 | ng-keypress="agregarATabla($event.keyCode)" | 155 | ng-keypress="agregarATabla($event.keyCode)" |
227 | teclado-virtual | 156 | teclado-virtual |
228 | > | 157 | > |
229 | </td> | 158 | </td> |
230 | <td class="col text-right"> | 159 | <td class="col text-right"> |
231 | <input | 160 | <input |
232 | class="form-control" | 161 | class="form-control" |
233 | ng-value="articuloACargar.precio | | 162 | ng-value="articuloACargar.precio | |
234 | currency: notaPedido.moneda.SIMBOLO : 4" | 163 | currency: notaPedido.moneda.SIMBOLO : 4" |
235 | ng-show="idLista != -1" | 164 | ng-show="idLista != -1" |
236 | readonly | 165 | readonly |
237 | > | 166 | > |
238 | <input | 167 | <input |
239 | class="form-control" | 168 | class="form-control" |
240 | foca-tipo-input | 169 | foca-tipo-input |
241 | min="0" | 170 | min="0" |
242 | step="0.0001" | 171 | step="0.0001" |
243 | ng-model="articuloACargar.precio" | 172 | ng-model="articuloACargar.precio" |
244 | esc-key="resetFilter()" | 173 | esc-key="resetFilter()" |
245 | ng-keypress="agregarATabla($event.keyCode)" | 174 | ng-keypress="agregarATabla($event.keyCode)" |
246 | ng-show="idLista == -1" | 175 | ng-show="idLista == -1" |
247 | teclado-virtual | 176 | teclado-virtual |
248 | > | 177 | > |
249 | </td> | 178 | </td> |
250 | <td class="col text-right"> | 179 | <td class="col text-right"> |
251 | <input | 180 | <input |
252 | class="form-control" | 181 | class="form-control" |
253 | ng-value="getSubTotal() | currency: notaPedido.moneda.SIMBOLO" | 182 | ng-value="getSubTotal() | currency: notaPedido.moneda.SIMBOLO" |
254 | readonly | 183 | readonly |
255 | ></td> | 184 | ></td> |
256 | <td class="text-center align-middle"> | 185 | <td class="text-center align-middle"> |
257 | <button | 186 | <button |
258 | class="btn btn-outline-light" | 187 | class="btn btn-outline-light" |
259 | ng-click="agregarATabla(13)" | 188 | ng-click="agregarATabla(13)" |
260 | > | 189 | > |
261 | <i class="fa fa-save"></i> | 190 | <i class="fa fa-save"></i> |
262 | </button> | 191 | </button> |
263 | </td> | 192 | </td> |
264 | </tr> | 193 | </tr> |
265 | <tr class="d-flex"> | 194 | <tr class="d-flex"> |
266 | <td colspan="4" class="no-border-top"> | 195 | <td colspan="4" class="no-border-top"> |
267 | <strong>Items:</strong> | 196 | <strong>Items:</strong> |
268 | <a ng-bind="articulosTabla.length"></a> | 197 | <a ng-bind="articulosTabla.length"></a> |
269 | </td> | 198 | </td> |
270 | <td class="text-right ml-auto table-celda-total no-border-top"> | 199 | <td class="text-right ml-auto table-celda-total no-border-top"> |
271 | <h3>Total:</h3> | 200 | <h3>Total:</h3> |
272 | </td> | 201 | </td> |
273 | <td class="table-celda-total text-right no-border-top" colspan="1"> | 202 | <td class="table-celda-total text-right no-border-top" colspan="1"> |
274 | <h3>{{getTotal() | currency: notaPedido.moneda.SIMBOLO}}</h3> | 203 | <h3>{{getTotal() | currency: notaPedido.moneda.SIMBOLO}}</h3> |
275 | </td> | 204 | </td> |
276 | <td class="text-right no-border-top"> | 205 | <td class="text-right no-border-top"> |
277 | <button | 206 | <button |
278 | type="button" | 207 | type="button" |
279 | class="btn btn-default btn-sm" | 208 | class="btn btn-default btn-sm" |
280 | > | 209 | > |
281 | Totales | 210 | Totales |
282 | </button> | 211 | </button> |
283 | </td> | 212 | </td> |
284 | </tr> | 213 | </tr> |
285 | </tfoot> | 214 | </tfoot> |
286 | </table> | 215 | </table> |
287 | </div> | 216 | </div> |
288 | <!-- MOBILE --> | 217 | <!-- MOBILE --> |
289 | <div class="row d-sm-none"> | 218 | <div class="row d-sm-none"> |
290 | <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile"> | 219 | <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile"> |
291 | <thead> | 220 | <thead> |
292 | <tr class="d-flex"> | 221 | <tr class="d-flex"> |
293 | <th class="">#</th> | 222 | <th class="">#</th> |
294 | <th class="col px-0"> | 223 | <th class="col px-0"> |
295 | <div class="d-flex"> | 224 | <div class="d-flex"> |
296 | <div class="col-4 px-1">Código</div> | 225 | <div class="col-4 px-1">Código</div> |
297 | <div class="col-8 px-1">Descripción</div> | 226 | <div class="col-8 px-1">Descripción</div> |
298 | </div> | 227 | </div> |
299 | <div class="d-flex"> | 228 | <div class="d-flex"> |
300 | <div class="col-3 px-1">Cantidad</div> | 229 | <div class="col-3 px-1">Cantidad</div> |
301 | <div class="col px-1 text-right">P. Uni.</div> | 230 | <div class="col px-1 text-right">P. Uni.</div> |
302 | <div class="col px-1 text-right">Subtotal</div> | 231 | <div class="col px-1 text-right">Subtotal</div> |
303 | </div> | 232 | </div> |
304 | </th> | 233 | </th> |
305 | <th class="text-center tamaño-boton"> | 234 | <th class="text-center tamaño-boton"> |
306 | | 235 | |
307 | </th> | 236 | </th> |
308 | </tr> | 237 | </tr> |
309 | </thead> | 238 | </thead> |
310 | <tbody> | 239 | <tbody> |
311 | <tr | 240 | <tr |
312 | ng-repeat="(key, articulo) in articulosTabla" | 241 | ng-repeat="(key, articulo) in articulosTabla" |
313 | ng-show="show || key == articulosTabla.length - 1" | 242 | ng-show="show || key == articulosTabla.length - 1" |
314 | > | 243 | > |
315 | <td class="w-100 align-middle d-flex p-0"> | 244 | <td class="w-100 align-middle d-flex p-0"> |
316 | <div class="align-middle p-1"> | 245 | <div class="align-middle p-1"> |
317 | <span ng-bind="key+1" class="align-middle"></span> | 246 | <span ng-bind="key+1" class="align-middle"></span> |
318 | </div> | 247 | </div> |
319 | <div class="col px-0"> | 248 | <div class="col px-0"> |
320 | <div class="d-flex"> | 249 | <div class="d-flex"> |
321 | <div class="col-4 px-1"> | 250 | <div class="col-4 px-1"> |
322 | <span | 251 | <span |
323 | ng-bind="articulo.sector + '-' + articulo.codigo" | 252 | ng-bind="articulo.sector + '-' + articulo.codigo" |
324 | ></span> | 253 | ></span> |
325 | </div> | 254 | </div> |
326 | <div class="col-8 px-1"> | 255 | <div class="col-8 px-1"> |
327 | <span ng-bind="articulo.descripcion"></span> | 256 | <span ng-bind="articulo.descripcion"></span> |
328 | </div> | 257 | </div> |
329 | </div> | 258 | </div> |
330 | <div class="d-flex"> | 259 | <div class="d-flex"> |
331 | <div class="col-3 px-1"> | 260 | <div class="col-3 px-1"> |
332 | <span | 261 | <span |
333 | ng-bind="'x' + articulo.cantidad" | 262 | ng-bind="'x' + articulo.cantidad" |
334 | ng-hide="articulo.editCantidad" | 263 | ng-hide="articulo.editCantidad" |
335 | ></span> | 264 | ></span> |
336 | <i | 265 | <i |
337 | class="fa fa-pencil text-white-50" | 266 | class="fa fa-pencil text-white-50" |
338 | aria-hidden="true" | 267 | aria-hidden="true" |
339 | ng-hide="articulo.editCantidad" | 268 | ng-hide="articulo.editCantidad" |
340 | ng-click="articulo.editCantidad = true" | 269 | ng-click="articulo.editCantidad = true" |
341 | ></i> | 270 | ></i> |
342 | <input | 271 | <input |
343 | ng-show="articulo.editCantidad" | 272 | ng-show="articulo.editCantidad" |
344 | ng-model="articulo.cantidad" | 273 | ng-model="articulo.cantidad" |
345 | class="form-control" | 274 | class="form-control" |
346 | foca-tipo-input | 275 | foca-tipo-input |
347 | min="1" | 276 | min="1" |
348 | step="0.001" | 277 | step="0.001" |
349 | foca-focus="articulo.editCantidad" | 278 | foca-focus="articulo.editCantidad" |
350 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 279 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
351 | ng-focus="selectFocus($event)" | 280 | ng-focus="selectFocus($event)" |
352 | > | 281 | > |
353 | </div> | 282 | </div> |
354 | <div class="col px-1 text-right"> | 283 | <div class="col px-1 text-right"> |
355 | <span ng-bind="articulo.precio | | 284 | <span ng-bind="articulo.precio | |
356 | currency: notaPedido.moneda.SIMBOLO : 4"></span> | 285 | currency: notaPedido.moneda.SIMBOLO : 4"></span> |
357 | ></span> | 286 | ></span> |
358 | </div> | 287 | </div> |
359 | <div class="col px-1 text-right"> | 288 | <div class="col px-1 text-right"> |
360 | <span | 289 | <span |
361 | ng-bind="(articulo.precio * articulo.cantidad) | | 290 | ng-bind="(articulo.precio * articulo.cantidad) | |
362 | currency: notaPedido.moneda.SIMBOLO" | 291 | currency: notaPedido.moneda.SIMBOLO" |
363 | > | 292 | > |
364 | </span> | 293 | </span> |
365 | </div> | 294 | </div> |
366 | </div> | 295 | </div> |
367 | </div> | 296 | </div> |
368 | <div class="align-middle p-1"> | 297 | <div class="align-middle p-1"> |
369 | <button | 298 | <button |
370 | class="btn btn-outline-light" | 299 | class="btn btn-outline-light" |
371 | ng-click="quitarArticulo(key)" | 300 | ng-click="quitarArticulo(key)" |
372 | > | 301 | > |
373 | <i class="fa fa-trash"></i> | 302 | <i class="fa fa-trash"></i> |
374 | </button> | 303 | </button> |
375 | </div> | 304 | </div> |
376 | </td> | 305 | </td> |
377 | </tr> | 306 | </tr> |
378 | </tbody> | 307 | </tbody> |
379 | <tfoot> | 308 | <tfoot> |
380 | <!-- CARGANDO ITEM --> | 309 | <!-- CARGANDO ITEM --> |
381 | <tr ng-show="!cargando" class="d-flex"> | 310 | <tr ng-show="!cargando" class="d-flex"> |
382 | <td | 311 | <td |
383 | class="align-middle p-1" | 312 | class="align-middle p-1" |
384 | ng-bind="articulosTabla.length + 1" | 313 | ng-bind="articulosTabla.length + 1" |
385 | ></td> | 314 | ></td> |
386 | <td class="col p-0"> | 315 | <td class="col p-0"> |
387 | <div class="d-flex"> | 316 | <div class="d-flex"> |
388 | <div class="col-4 px-1"> | 317 | <div class="col-4 px-1"> |
389 | <span | 318 | <span |
390 | ng-bind="articuloACargar.sectorCodigo" | 319 | ng-bind="articuloACargar.sectorCodigo" |
391 | ></span> | 320 | ></span> |
392 | </div> | 321 | </div> |
393 | <div class="col-8 px-1"> | 322 | <div class="col-8 px-1"> |
394 | <span ng-bind="articuloACargar.descripcion"></span> | 323 | <span ng-bind="articuloACargar.descripcion"></span> |
395 | </div> | 324 | </div> |
396 | </div> | 325 | </div> |
397 | <div class="d-flex"> | 326 | <div class="d-flex"> |
398 | <div class="col-3 px-1 m-1"> | 327 | <div class="col-3 px-1 m-1"> |
399 | <input | 328 | <input |
400 | class="form-control p-1" | 329 | class="form-control p-1" |
401 | foca-tipo-input | 330 | foca-tipo-input |
402 | min="1" | 331 | min="1" |
403 | ng-model="articuloACargar.cantidad" | 332 | ng-model="articuloACargar.cantidad" |
404 | foca-focus="!cargando" | 333 | foca-focus="!cargando" |
405 | ng-keypress="agregarATabla($event.keyCode)" | 334 | ng-keypress="agregarATabla($event.keyCode)" |
406 | style="height: auto; line-height: 1.1em" | 335 | style="height: auto; line-height: 1.1em" |
407 | > | 336 | > |
408 | </div> | 337 | </div> |
409 | <div class="col px-1 text-right"> | 338 | <div class="col px-1 text-right"> |
410 | <span ng-bind="articuloACargar.precio | | 339 | <span ng-bind="articuloACargar.precio | |
411 | currency: notaPedido.moneda.SIMBOLO : 4" | 340 | currency: notaPedido.moneda.SIMBOLO : 4" |
412 | ></span> | 341 | ></span> |
413 | </div> | 342 | </div> |
414 | <div class="col px-1 text-right"> | 343 | <div class="col px-1 text-right"> |
415 | <span | 344 | <span |
416 | ng-bind="getSubTotal() | | 345 | ng-bind="getSubTotal() | |
417 | currency: notaPedido.moneda.SIMBOLO" | 346 | currency: notaPedido.moneda.SIMBOLO" |
418 | > | 347 | > |
419 | </span> | 348 | </span> |
420 | </div> | 349 | </div> |
421 | </div> | 350 | </div> |
422 | </td> | 351 | </td> |
423 | <td class="text-center align-middle"> | 352 | <td class="text-center align-middle"> |
424 | <button | 353 | <button |
425 | class="btn btn-outline-light" | 354 | class="btn btn-outline-light" |
426 | ng-click="agregarATabla(13)" | 355 | ng-click="agregarATabla(13)" |
427 | > | 356 | > |
428 | <i class="fa fa-save"></i> | 357 | <i class="fa fa-save"></i> |
429 | </button> | 358 | </button> |
430 | </td> | 359 | </td> |
431 | </tr> | 360 | </tr> |
432 | <!-- SELECCIONAR PRODUCTO --> | 361 | <!-- SELECCIONAR PRODUCTO --> |
433 | <tr ng-show="cargando" class="d-flex"> | 362 | <tr ng-show="cargando" class="d-flex"> |
434 | <td class="col-12"> | 363 | <td class="col-12"> |
435 | <input | 364 | <input |
436 | placeholder="Seleccione Articulo" | 365 | placeholder="Seleccione Articulo" |
437 | class="form-control form-control-sm" | 366 | class="form-control form-control-sm" |
438 | readonly | 367 | readonly |
439 | ng-click="seleccionarArticulo()" | 368 | ng-click="seleccionarArticulo()" |
440 | /> | 369 | /> |
441 | </td> | 370 | </td> |
442 | </tr> | 371 | </tr> |
443 | <!-- TOOGLE EXPANDIR --> | 372 | <!-- TOOGLE EXPANDIR --> |
444 | <tr> | 373 | <tr> |
445 | <td class="col"> | 374 | <td class="col"> |
446 | <button | 375 | <button |
447 | class="btn btn-outline-light selectable w-100" | 376 | class="btn btn-outline-light selectable w-100" |
448 | ng-click="show = !show; masMenos()" | 377 | ng-click="show = !show; masMenos()" |
449 | ng-show="articulosTabla.length > 0" | 378 | ng-show="articulosTabla.length > 0" |
450 | > | 379 | > |
451 | <i | 380 | <i |
452 | class="fa fa-chevron-down" | 381 | class="fa fa-chevron-down" |
453 | ng-hide="show" | 382 | ng-hide="show" |
454 | aria-hidden="true" | 383 | aria-hidden="true" |
455 | > | 384 | > |
456 | </i> | 385 | </i> |
457 | <i | 386 | <i |
458 | class="fa fa-chevron-up" | 387 | class="fa fa-chevron-up" |
459 | ng-show="show" | 388 | ng-show="show" |
460 | aria-hidden="true"> | 389 | aria-hidden="true"> |
461 | </i> | 390 | </i> |
462 | </button> | 391 | </button> |
463 | </td> | 392 | </td> |
464 | </tr> | 393 | </tr> |
465 | <!-- FOOTER --> | 394 | <!-- FOOTER --> |
466 | <tr class="d-flex"> | 395 | <tr class="d-flex"> |
467 | <td class="align-middle no-border-top" colspan="2"> | 396 | <td class="align-middle no-border-top" colspan="2"> |
468 | <strong>Cantidad Items:</strong> | 397 | <strong>Cantidad Items:</strong> |
469 | <a ng-bind="articulosTabla.length"></a> | 398 | <a ng-bind="articulosTabla.length"></a> |
470 | </td> | 399 | </td> |
471 | <td class="text-right ml-auto table-celda-total no-border-top"> | 400 | <td class="text-right ml-auto table-celda-total no-border-top"> |
472 | <h3>Total:</h3> | 401 | <h3>Total:</h3> |
473 | </td> | 402 | </td> |
474 | <td class="table-celda-total text-right no-border-top"> | 403 | <td class="table-celda-total text-right no-border-top"> |
475 | <h3>{{getTotal() | currency: notaPedido.moneda.SIMBOLO}}</h3> | 404 | <h3>{{getTotal() | currency: notaPedido.moneda.SIMBOLO}}</h3> |
476 | </td> | 405 | </td> |
477 | </tr> | 406 | </tr> |
478 | </tfoot> | 407 | </tfoot> |
479 | </table> | 408 | </table> |
480 | </div> | 409 | </div> |
481 | </div> | 410 | </div> |
482 | <div class="col-auto my-2 col-lg-2 botonera-lateral d-none"> | 411 | <div class="col-auto my-2 col-lg-2 botonera-lateral d-none"> |
483 | <div class="col-12 mt-auto"> | 412 | <div class="col-12 mt-auto"> |
484 | <button | 413 | <button |
485 | ng-click="crearNotaPedido()" | 414 | ng-click="crearNotaPedido()" |
486 | type="submit" | 415 | type="submit" |
487 | title="Crear nota pedido" | 416 | title="Crear nota pedido" |
488 | class="btn btn-default btn-block mb-2 border border-dark" | 417 | class="btn btn-default btn-block mb-2 border border-dark" |
489 | ng-disabled="notaPedido.idRemito || saveLoading" | 418 | ng-disabled="notaPedido.idRemito || saveLoading" |
490 | > | 419 | > |
491 | <strong>GUARDAR</strong> | 420 | <strong>GUARDAR</strong> |
492 | </button> | 421 | </button> |
493 | <!-- AGREGAR FUNCIONALIDAD PAUSAR --> | 422 | <!-- AGREGAR FUNCIONALIDAD PAUSAR --> |
494 | <button | 423 | <button |
495 | type="submit" | 424 | type="submit" |
496 | title="Crear nota pedido" | 425 | title="Crear nota pedido" |
497 | class="btn btn-default btn-block mb-2 border border-dark" | 426 | class="btn btn-default btn-block mb-2 border border-dark" |
498 | > | 427 | > |
499 | <strong>PAUSAR</strong> | 428 | <strong>PAUSAR</strong> |
500 | </button> | 429 | </button> |
501 | <button | 430 | <button |
502 | ng-click="salir()" | 431 | ng-click="salir()" |
503 | type="button" | 432 | type="button" |
504 | title="Salir" | 433 | title="Salir" |
505 | class="btn btn-default btn-block border border-dark"> | 434 | class="btn btn-default btn-block border border-dark"> |
506 | <strong>SALIR</strong> | 435 | <strong>SALIR</strong> |
507 | </button> | 436 | </button> |
508 | </div> | 437 | </div> |
509 | </div> | 438 | </div> |
510 | </div> | 439 | </div> |
511 | </div> | 440 | </div> |
512 | <div class="row d-md-none fixed-bottom"> | 441 | <div class="row d-md-none fixed-bottom"> |
513 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> | 442 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> |
514 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> | 443 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> |
515 | <span | 444 | <span |
516 | class="mr-3 ml-auto" | 445 | class="mr-3 ml-auto" |
517 | ng-class="saveLoading ? 'text-muted' : ''" | 446 | ng-class="saveLoading ? 'text-muted' : ''" |
518 | ng-click="crearNotaPedido()" | 447 | ng-click="crearNotaPedido()" |
519 | ladda="saveLoading" | 448 | ladda="saveLoading" |
520 | data-style="expand-left" | 449 | data-style="expand-left" |
521 | >Guardar</span> | 450 | >Guardar</span> |
522 | </div> | 451 | </div> |
523 | </div> | 452 | </div> |
524 | </div> | 453 | </div> |
525 | 454 |