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