Commit 95869a524d99fc59fae2dec174bccac956f4b8ba
Exists in
master
Merge branch 'master' into 'develop'
Master(efernandez) See merge request !30
Showing
4 changed files
Show diff stats
src/js/controller.js
1 | angular.module('focaCrearFactura').controller('facturaController', [ | 1 | angular.module('focaCrearFactura').controller('facturaController', [ |
2 | '$scope', '$uibModal', '$location', '$filter', 'crearFacturaService', '$timeout', | 2 | '$scope', '$uibModal', '$location', '$filter', 'crearFacturaService', '$timeout', |
3 | 'focaModalService', 'crearRemitoService', '$rootScope', 'focaBotoneraLateralService', | 3 | 'focaModalService', 'crearRemitoService', '$rootScope', 'focaBotoneraLateralService', |
4 | '$localStorage', 'APP', 'focaLoginService', | 4 | '$localStorage', 'APP', 'focaLoginService', |
5 | function ( | 5 | function ( |
6 | $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService, | 6 | $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService, |
7 | crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP, loginServ) { | 7 | crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP, loginServ) { |
8 | 8 | ||
9 | config(); | 9 | config(); |
10 | 10 | ||
11 | function config() { | 11 | function config() { |
12 | $scope.tmpCantidad = '0'; | 12 | $scope.tmpCantidad = '0'; |
13 | $scope.botonera = crearFacturaService.getBotonera(); | 13 | $scope.botonera = crearFacturaService.getBotonera(); |
14 | $scope.botoneraProductos = []; | 14 | $scope.botoneraProductos = []; |
15 | $scope.isNumber = angular.isNumber; | 15 | $scope.isNumber = angular.isNumber; |
16 | $scope.datepickerAbierto = false; | 16 | $scope.datepickerAbierto = false; |
17 | $scope.show = false; | 17 | $scope.show = false; |
18 | $scope.cargando = true; | 18 | $scope.cargando = true; |
19 | $scope.now = new Date(); | 19 | $scope.now = new Date(); |
20 | $scope.puntoVenta = rellenar(0, 4); | 20 | $scope.puntoVenta = rellenar(0, 4); |
21 | $scope.comprobante = rellenar(0, 8); | 21 | $scope.comprobante = rellenar(0, 8); |
22 | $scope.dateOptions = { | 22 | $scope.dateOptions = { |
23 | maxDate: new Date(), | 23 | maxDate: new Date(), |
24 | minDate: new Date(2010, 0, 1) | 24 | minDate: new Date(2010, 0, 1) |
25 | }; | 25 | }; |
26 | $scope.cabeceras = []; | 26 | $scope.cabeceras = []; |
27 | crearFacturaService.getParametros().then(function (res) { | 27 | crearFacturaService.getParametros().then(function (res) { |
28 | 28 | ||
29 | var parametros = JSON.parse(res.data[0].jsonText); | 29 | var parametros = JSON.parse(res.data[0].jsonText); |
30 | 30 | ||
31 | if ($localStorage.factura) { | 31 | if ($localStorage.factura) { |
32 | 32 | ||
33 | $timeout(function () { getLSFactura(); }); | 33 | $timeout(function () { getLSFactura(); }); |
34 | } else { | 34 | } else { |
35 | 35 | ||
36 | for (var property in parametros) { | 36 | for (var property in parametros) { |
37 | $scope.factura[property] = parametros[property]; | 37 | $scope.factura[property] = parametros[property]; |
38 | $scope.inicial[property] = parametros[property]; | 38 | $scope.inicial[property] = parametros[property]; |
39 | } | 39 | } |
40 | 40 | ||
41 | setearFactura($scope.factura); | 41 | setearFactura($scope.factura); |
42 | } | 42 | } |
43 | 43 | ||
44 | }); | 44 | }); |
45 | 45 | ||
46 | //SETEO BOTONERA LATERAL | 46 | //SETEO BOTONERA LATERAL |
47 | $timeout(function () { | 47 | $timeout(function () { |
48 | focaBotoneraLateralService.showSalir(false); | 48 | focaBotoneraLateralService.showSalir(false); |
49 | focaBotoneraLateralService.showPausar(true); | 49 | focaBotoneraLateralService.showPausar(true); |
50 | focaBotoneraLateralService.showGuardar(true, $scope.seleccionarFormaDePago); | 50 | focaBotoneraLateralService.showGuardar(true, $scope.seleccionarFormaDePago); |
51 | focaBotoneraLateralService.addCustomButton('Salir', $scope.salir); | 51 | focaBotoneraLateralService.addCustomButton('Salir', $scope.salir); |
52 | }); | 52 | }); |
53 | 53 | ||
54 | init(); | 54 | init(); |
55 | 55 | ||
56 | } | 56 | } |
57 | 57 | ||
58 | function init() { | 58 | function init() { |
59 | 59 | ||
60 | $scope.$broadcast('cleanCabecera'); | 60 | $scope.$broadcast('cleanCabecera'); |
61 | 61 | ||
62 | $scope.factura = { | 62 | $scope.factura = { |
63 | id: 0, | 63 | id: 0, |
64 | estado: 0, | 64 | estado: 0, |
65 | vendedor: {}, | 65 | vendedor: {}, |
66 | cliente: {}, | 66 | cliente: {}, |
67 | proveedor: {}, | 67 | proveedor: {}, |
68 | domicilio: { dom: '' }, | 68 | domicilio: { dom: '' }, |
69 | moneda: {}, | 69 | moneda: {}, |
70 | formaPago: 1, // Por defecto paga contado | 70 | formaPago: 1, // Por defecto paga contado |
71 | cotizacion: $scope.cotizacionPorDefecto || {}, | 71 | cotizacion: $scope.cotizacionPorDefecto || {}, |
72 | articulosFactura: [], | 72 | articulosFactura: [], |
73 | despachos: [] | 73 | despachos: [] |
74 | }; | 74 | }; |
75 | 75 | ||
76 | $scope.factura.articulosFactura = []; | 76 | $scope.factura.articulosFactura = []; |
77 | $scope.idLista = undefined; | 77 | $scope.idLista = undefined; |
78 | 78 | ||
79 | crearRemitoService.getNumeroRemito().then( | 79 | crearRemitoService.getNumeroRemito().then( |
80 | function (res) { | 80 | function (res) { |
81 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 81 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
82 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); | 82 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); |
83 | }, | 83 | }, |
84 | function (err) { | 84 | function (err) { |
85 | focaModalService.alert('La terminal no esta configurada correctamente'); | 85 | focaModalService.alert('La terminal no esta configurada correctamente'); |
86 | console.info(err); | 86 | console.info(err); |
87 | } | 87 | } |
88 | ); | 88 | ); |
89 | 89 | ||
90 | $scope.inicial = angular.copy($scope.factura); | 90 | $scope.inicial = angular.copy($scope.factura); |
91 | 91 | ||
92 | if (APP == 'facturador') { | 92 | if (APP == 'facturador') { |
93 | crearFacturaService | 93 | crearFacturaService |
94 | .getVendedorPlayaById(loginServ.getLoginData().vendedorPlaya) | 94 | .getVendedorPlayaById(loginServ.getLoginData().vendedorPlaya) |
95 | .then(function (res) { | 95 | .then(function (res) { |
96 | 96 | ||
97 | validarPlanillaVendedor(res.data) | 97 | validarPlanillaVendedor(res.data) |
98 | .then(function () { | 98 | .then(function () { |
99 | 99 | ||
100 | $scope.$broadcast('addCabecera', { | 100 | $scope.$broadcast('addCabecera', { |
101 | label: 'Vendedor:', | 101 | label: 'Vendedor:', |
102 | valor: $filter('rellenarDigitos')(res.data.CodVen, 3) + | 102 | valor: $filter('rellenarDigitos')(res.data.CodVen, 3) + |
103 | ' - ' + | 103 | ' - ' + |
104 | res.data.NomVen | 104 | res.data.NomVen |
105 | }); | 105 | }); |
106 | $scope.$broadcast('addCabecera', { | 106 | $scope.$broadcast('addCabecera', { |
107 | label: 'Planilla:', | 107 | label: 'Planilla:', |
108 | valor: res.data.NplVen | 108 | valor: res.data.NplVen |
109 | }); | 109 | }); |
110 | 110 | ||
111 | $scope.factura.vendedor = res.data; | 111 | $scope.factura.vendedor = res.data; |
112 | $scope.inicial.vendedor = res.data; | 112 | $scope.inicial.vendedor = res.data; |
113 | 113 | ||
114 | getProductosByPlanilla(res.data.NplVen); | 114 | getProductosByPlanilla(res.data.NplVen); |
115 | }) | 115 | }) |
116 | .catch(function (err) { | 116 | .catch(function (err) { |
117 | console.log(err); | 117 | console.log(err); |
118 | focaModalService.alert('Ocurrió un error al intentar recuperar' + | 118 | focaModalService.alert('Ocurrió un error al intentar recuperar' + |
119 | 'el vendedor logeado'); | 119 | 'el vendedor logeado'); |
120 | }); | 120 | }); |
121 | }) | 121 | }) |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
125 | $scope.$watch('factura', function (newValue) { | 125 | $scope.$watch('factura', function (newValue) { |
126 | focaBotoneraLateralService.setPausarData({ | 126 | focaBotoneraLateralService.setPausarData({ |
127 | label: 'factura', | 127 | label: 'factura', |
128 | val: newValue | 128 | val: newValue |
129 | }); | 129 | }); |
130 | }, true); | 130 | }, true); |
131 | 131 | ||
132 | $scope.seleccionarFormaDePago = function () { | 132 | $scope.seleccionarFormaDePago = function () { |
133 | 133 | ||
134 | if (!validarGuardar()) return; | 134 | if (!validarGuardar()) return; |
135 | 135 | ||
136 | if ($scope.factura.formaPago == 2) { | 136 | if ($scope.factura.formaPago == 2) { |
137 | $scope.crearFactura(); | 137 | $scope.crearFactura(); |
138 | return; | 138 | return; |
139 | } | 139 | } |
140 | 140 | ||
141 | var modalInstance = $uibModal.open( | 141 | var modalInstance = $uibModal.open( |
142 | { | 142 | { |
143 | templateUrl: 'modal-forma-pago.html', | 143 | templateUrl: 'modal-forma-pago.html', |
144 | controller: 'focaModalFormaPagoController', | 144 | controller: 'focaModalFormaPagoController', |
145 | resolve: { | 145 | resolve: { |
146 | parametros: function () { | 146 | parametros: function () { |
147 | return { | 147 | return { |
148 | importe: $scope.getTotal() | 148 | importe: $scope.getTotal() |
149 | }; | 149 | }; |
150 | }, | 150 | }, |
151 | }, | 151 | }, |
152 | size: 'lg', | 152 | size: 'lg', |
153 | } | 153 | } |
154 | ); | 154 | ); |
155 | modalInstance.result | 155 | modalInstance.result |
156 | .then(function (data) { | 156 | .then(function (data) { |
157 | 157 | ||
158 | if (data.tipo == 'tarjeta') { | 158 | if (data.tipo == 'tarjeta') { |
159 | $scope.factura.formaPago = 4; | 159 | $scope.factura.formaPago = 4; |
160 | } else { | 160 | } else { |
161 | $scope.factura.formaPago = 1; | 161 | $scope.factura.formaPago = 1; |
162 | } | 162 | } |
163 | 163 | ||
164 | $scope.crearFactura(data); | 164 | $scope.crearFactura(data); |
165 | }) | 165 | }) |
166 | .catch(function (e) { console.error(e); }); | 166 | .catch(function (e) { console.error(e); }); |
167 | }; | 167 | }; |
168 | 168 | ||
169 | $scope.crearFactura = function (formaPago) { | 169 | $scope.crearFactura = function (formaPago) { |
170 | 170 | ||
171 | var save = { | 171 | var save = { |
172 | factura: { | 172 | factura: { |
173 | 173 | ||
174 | BONIF: 0, | 174 | BONIF: 0, |
175 | CLI: $scope.factura.cliente.cod, | 175 | CLI: $scope.factura.cliente.cod, |
176 | CUI: $scope.factura.cliente.cuit, | 176 | CUI: $scope.factura.cliente.cuit, |
177 | CTA: $scope.factura.cliente.cod, | 177 | CTA: $scope.factura.cliente.cod, |
178 | DC1: '', | 178 | DC1: '', |
179 | DC2: '', | 179 | DC2: '', |
180 | DE1: '', | 180 | DE1: '', |
181 | DOM: $scope.factura.cliente.DOM, | 181 | DOM: $scope.factura.cliente.DOM, |
182 | FACAUT: 0, | 182 | FACAUT: 0, |
183 | DTO: 0, | 183 | DTO: 0, |
184 | FEC: $filter('date')($scope.now, 'yyyy-MM-dd HH:mm:ss'), | 184 | FEC: $filter('date')($scope.now, 'yyyy-MM-dd HH:mm:ss'), |
185 | FEC_ANT: '19000101', | 185 | FEC_ANT: '19000101', |
186 | FPA: $scope.factura.formaPago, | 186 | FPA: $scope.factura.formaPago, |
187 | IDEXCEPCION: 0, | 187 | IDEXCEPCION: 0, |
188 | IDLP: $scope.factura.cliente.mod.trim() || 0, | 188 | IDLP: $scope.factura.cliente.mod.trim() || 0, |
189 | IDPERSONERIA: 0, | 189 | IDPERSONERIA: 0, |
190 | IMI: getImporte('IMI'), | 190 | IMI: getImporte('IMI'), |
191 | IMI2: getImporte('IMI2'), | 191 | IMI2: getImporte('IMI2'), |
192 | IMI3: getImporte('IMI3'), | 192 | IMI3: getImporte('IMI3'), |
193 | IMP_LEY: 0, | 193 | IMP_LEY: 0, |
194 | IRI: getImporte('IVA'), | 194 | IRI: getImporte('IVA'), |
195 | IRS: 0, | 195 | IRS: 0, |
196 | LEG: '', | 196 | LEG: '', |
197 | LUG: $scope.factura.vendedor.LugVen, | 197 | LUG: $scope.factura.vendedor.LugVen, |
198 | MK_M: 0, | 198 | MK_M: 0, |
199 | NEE: getImporte('NEX'), | 199 | NEE: getImporte('NEX'), |
200 | NET: getImporte('NET'), | 200 | NET: getImporte('NET'), |
201 | NFI: '', | 201 | NFI: '', |
202 | NNP: 0, | 202 | NNP: 0, |
203 | NOM: $scope.factura.cliente.nom, | 203 | NOM: $scope.factura.cliente.nom, |
204 | OPE: $scope.factura.vendedor.CodVen, | 204 | OPE: $scope.factura.vendedor.CodVen, |
205 | PAG: $scope.getTotal(), | 205 | PAG: $scope.getTotal(), |
206 | PER: 0, | 206 | PER: 0, |
207 | PER_IVA: 0, | 207 | PER_IVA: 0, |
208 | PLA: $scope.factura.vendedor.NplVen, | 208 | PLA: $scope.factura.vendedor.NplVen, |
209 | PRO: '', | 209 | PRO: '', |
210 | REC_ANT: 0, | 210 | REC_ANT: 0, |
211 | SUC: parseInt($scope.puntoVenta), | 211 | SUC: parseInt($scope.puntoVenta), |
212 | TCA: 1, | 212 | TCA: 1, |
213 | TCO: 'FT', | 213 | TCO: 'FT', |
214 | TFI: '', | 214 | TFI: '', |
215 | TIP: $scope.factura.cliente.tipoFactura, | 215 | TIP: $scope.factura.cliente.tipoFactura, |
216 | TIV: $scope.factura.cliente.iva, | 216 | TIV: $scope.factura.cliente.iva, |
217 | TOT: $scope.getTotal(), | 217 | TOT: $scope.getTotal(), |
218 | TUR: $scope.factura.vendedor.TurVen, | 218 | TUR: $scope.factura.vendedor.TurVen, |
219 | VEN: $scope.factura.vendedor.CodVen, | 219 | VEN: $scope.factura.vendedor.CodVen, |
220 | VTO_CLI: '', | 220 | VTO_CLI: '', |
221 | ZON: 1, // TODO: ZON DE APAREMP | 221 | ZON: 1, // TODO: ZON DE APAREMP |
222 | OBSERVACIONES: $scope.factura.observaciones | 222 | OBSERVACIONES: $scope.factura.observaciones |
223 | }, | 223 | }, |
224 | cuerpo: $scope.articulosFiltro(), | 224 | cuerpo: $scope.articulosFiltro(), |
225 | despachos: $scope.factura.despachos, | 225 | despachos: $scope.factura.despachos, |
226 | formaPago: formaPago | 226 | formaPago: formaPago |
227 | }; | 227 | }; |
228 | 228 | ||
229 | crearFacturaService.guardarFactura(save).then(function (res) { | 229 | crearFacturaService.guardarFactura(save).then(function (res) { |
230 | 230 | ||
231 | focaBotoneraLateralService.endGuardar(true); | 231 | focaBotoneraLateralService.endGuardar(true); |
232 | 232 | ||
233 | focaModalService.alert('Comprobante guardado con éxito'); | 233 | focaModalService.alert('Comprobante guardado con éxito'); |
234 | 234 | ||
235 | config(); | 235 | config(); |
236 | 236 | ||
237 | }).catch(function (err) { | 237 | }).catch(function (err) { |
238 | focaModalService.alert('Hubo un error al guardar la factura'); | 238 | focaModalService.alert('Hubo un error al guardar la factura'); |
239 | console.error(err); | 239 | console.error(err); |
240 | }); | 240 | }); |
241 | 241 | ||
242 | }; | 242 | }; |
243 | 243 | ||
244 | $scope.seleccionarCliente = function () { | 244 | $scope.seleccionarCliente = function () { |
245 | 245 | ||
246 | var modalInstance = $uibModal.open( | 246 | var modalInstance = $uibModal.open( |
247 | { | 247 | { |
248 | ariaLabelledBy: 'Busqueda de Cliente', | 248 | ariaLabelledBy: 'Busqueda de Cliente', |
249 | templateUrl: 'foca-busqueda-cliente-modal.html', | 249 | templateUrl: 'foca-busqueda-cliente-modal.html', |
250 | controller: 'focaBusquedaClienteModalController', | 250 | controller: 'focaBusquedaClienteModalController', |
251 | resolve: { | 251 | resolve: { |
252 | vendedor: function () { return null; }, | 252 | vendedor: function () { return null; }, |
253 | cobrador: function () { return null; } | 253 | cobrador: function () { return null; } |
254 | }, | 254 | }, |
255 | size: 'lg' | 255 | size: 'lg' |
256 | } | 256 | } |
257 | ); | 257 | ); |
258 | modalInstance.result.then( | 258 | modalInstance.result.then( |
259 | function (cliente) { | 259 | function (cliente) { |
260 | var modalInstance = $uibModal.open( | 260 | var modalInstance = $uibModal.open( |
261 | { | 261 | { |
262 | templateUrl: 'modal-estado-cuenta.html', | 262 | templateUrl: 'modal-estado-cuenta.html', |
263 | controller: 'focaModalEstadoCuentaController', | 263 | controller: 'focaModalEstadoCuentaController', |
264 | size: 'lg', | 264 | size: 'lg', |
265 | resolve: { | 265 | resolve: { |
266 | parametros: function () { | 266 | parametros: function () { |
267 | return { | 267 | return { |
268 | idCliente: cliente.cod, | 268 | idCliente: cliente.cod, |
269 | nombreCliente: cliente.nom | 269 | nombreCliente: cliente.nom |
270 | }; | 270 | }; |
271 | }, | 271 | }, |
272 | } | 272 | } |
273 | } | 273 | } |
274 | ); | 274 | ); |
275 | modalInstance.result | 275 | modalInstance.result |
276 | .then(function (data) { | 276 | .then(function (data) { |
277 | 277 | ||
278 | $scope.factura.formaPago = data.formaDePago; | 278 | $scope.factura.formaPago = data.formaDePago; |
279 | 279 | ||
280 | $scope.factura.cliente = cliente; | 280 | $scope.factura.cliente = cliente; |
281 | 281 | ||
282 | $scope.$broadcast('addCabecera', { | 282 | $scope.$broadcast('addCabecera', { |
283 | label: 'Cliente:', | 283 | label: 'Cliente:', |
284 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + | 284 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + |
285 | ' - ' + cliente.nom | 285 | ' - ' + cliente.nom |
286 | }); | 286 | }); |
287 | 287 | ||
288 | $filter('filter')($scope.botonera, | 288 | $filter('filter')($scope.botonera, |
289 | { label: 'Cliente' })[0].checked = true; | 289 | { label: 'Cliente' })[0].checked = true; |
290 | 290 | ||
291 | $scope.$broadcast('addCabecera', { | 291 | $scope.$broadcast('addCabecera', { |
292 | label: 'Tipo de pago: ', | 292 | label: 'Tipo de pago: ', |
293 | valor: data.tipo | 293 | valor: data.tipo |
294 | }); | 294 | }); |
295 | }) | 295 | }) |
296 | .catch(function () { | 296 | .catch(function () { |
297 | 297 | ||
298 | $scope.seleccionarCliente(); | 298 | $scope.seleccionarCliente(); |
299 | }); | 299 | }); |
300 | 300 | ||
301 | }, function () { | 301 | }, function () { |
302 | } | 302 | } |
303 | ); | 303 | ); |
304 | 304 | ||
305 | }; | 305 | }; |
306 | 306 | ||
307 | $scope.seleccionarVendedor = function () { | 307 | $scope.seleccionarVendedor = function () { |
308 | var parametrosModal = { | 308 | var parametrosModal = { |
309 | titulo: 'Búsqueda vendedores', | 309 | titulo: 'Búsqueda vendedores', |
310 | query: '/vendedor-playa', | 310 | query: '/vendedor-playa', |
311 | columnas: [ | 311 | columnas: [ |
312 | { | 312 | { |
313 | propiedad: 'CodVen', | 313 | propiedad: 'CodVen', |
314 | nombre: 'Código', | 314 | nombre: 'Código', |
315 | filtro: { | 315 | filtro: { |
316 | nombre: 'rellenarDigitos', | 316 | nombre: 'rellenarDigitos', |
317 | parametro: 3 | 317 | parametro: 3 |
318 | } | 318 | } |
319 | }, | 319 | }, |
320 | { | 320 | { |
321 | propiedad: 'NomVen', | 321 | propiedad: 'NomVen', |
322 | nombre: 'Nombre' | 322 | nombre: 'Nombre' |
323 | } | 323 | } |
324 | ], | 324 | ], |
325 | size: 'md' | 325 | size: 'md' |
326 | }; | 326 | }; |
327 | focaModalService.modal(parametrosModal).then( | 327 | focaModalService.modal(parametrosModal).then( |
328 | function (vendedor) { | 328 | function (vendedor) { |
329 | 329 | ||
330 | indicarPassword(vendedor) | 330 | indicarPassword(vendedor) |
331 | .then(function () { | 331 | .then(function () { |
332 | validarPlanillaVendedor(vendedor) | 332 | validarPlanillaVendedor(vendedor) |
333 | .then(function () { | 333 | .then(function () { |
334 | 334 | ||
335 | $filter('filter')($scope.botonera, { | 335 | $filter('filter')($scope.botonera, { |
336 | label: 'Vendedor' | 336 | label: 'Vendedor' |
337 | })[0].checked = true; | 337 | })[0].checked = true; |
338 | 338 | ||
339 | $scope.$broadcast('addCabecera', { | 339 | $scope.$broadcast('addCabecera', { |
340 | label: 'Vendedor:', | 340 | label: 'Vendedor:', |
341 | valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + | 341 | valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + |
342 | ' - ' + | 342 | ' - ' + |
343 | vendedor.NomVen | 343 | vendedor.NomVen |
344 | }); | 344 | }); |
345 | $scope.$broadcast('addCabecera', { | 345 | $scope.$broadcast('addCabecera', { |
346 | label: 'Planilla:', | 346 | label: 'Planilla:', |
347 | valor: vendedor.NplVen | 347 | valor: vendedor.NplVen |
348 | }); | 348 | }); |
349 | 349 | ||
350 | $scope.factura.vendedor = vendedor; | 350 | $scope.factura.vendedor = vendedor; |
351 | 351 | ||
352 | getProductosByPlanilla(vendedor.NplVen); | 352 | getProductosByPlanilla(vendedor.NplVen); |
353 | }) | 353 | }) |
354 | .catch($scope.seleccionarVendedor); | 354 | .catch($scope.seleccionarVendedor); |
355 | }) | 355 | }) |
356 | .catch(function (err) { | 356 | .catch(function (err) { |
357 | console.error(err); | 357 | console.error(err); |
358 | }); | 358 | }); |
359 | 359 | ||
360 | }, function () { } | 360 | }, function () { } |
361 | ); | 361 | ); |
362 | }; | 362 | }; |
363 | 363 | ||
364 | $scope.seleccionarMoneda = function () { | 364 | $scope.seleccionarMoneda = function () { |
365 | 365 | ||
366 | var parametrosModal = { | 366 | var parametrosModal = { |
367 | titulo: 'Búsqueda de monedas', | 367 | titulo: 'Búsqueda de monedas', |
368 | query: '/moneda', | 368 | query: '/moneda', |
369 | columnas: [ | 369 | columnas: [ |
370 | { | 370 | { |
371 | propiedad: 'DETALLE', | 371 | propiedad: 'DETALLE', |
372 | nombre: 'Nombre' | 372 | nombre: 'Nombre' |
373 | }, | 373 | }, |
374 | { | 374 | { |
375 | propiedad: 'SIMBOLO', | 375 | propiedad: 'SIMBOLO', |
376 | nombre: 'Símbolo' | 376 | nombre: 'Símbolo' |
377 | } | 377 | } |
378 | ], | 378 | ], |
379 | size: 'md' | 379 | size: 'md' |
380 | }; | 380 | }; |
381 | focaModalService.modal(parametrosModal).then( | 381 | focaModalService.modal(parametrosModal).then( |
382 | function (moneda) { | 382 | function (moneda) { |
383 | 383 | ||
384 | if (moneda.ID !== 1) { | 384 | if (moneda.ID !== 1) { |
385 | $scope.abrirModalCotizacion(moneda); | 385 | $scope.abrirModalCotizacion(moneda); |
386 | return; | 386 | return; |
387 | } | 387 | } |
388 | 388 | ||
389 | crearRemitoService.getCotizacionByIdMoneda(1) | 389 | crearRemitoService.getCotizacionByIdMoneda(1) |
390 | .then(function (res) { | 390 | .then(function (res) { |
391 | 391 | ||
392 | var cotizacionPArgentino = res.data[0].cotizaciones[0]; | 392 | var cotizacionPArgentino = res.data[0].cotizaciones[0]; |
393 | cotizacionPArgentino.moneda = moneda; | 393 | cotizacionPArgentino.moneda = moneda; |
394 | 394 | ||
395 | actualizarCabeceraMoneda(cotizacionPArgentino); | 395 | actualizarCabeceraMoneda(cotizacionPArgentino); |
396 | 396 | ||
397 | $scope.remito.cotizacion = cotizacionPArgentino; | 397 | $scope.remito.cotizacion = cotizacionPArgentino; |
398 | }); | 398 | }); |
399 | }, function () { | 399 | }, function () { |
400 | 400 | ||
401 | } | 401 | } |
402 | ); | 402 | ); |
403 | }; | 403 | }; |
404 | 404 | ||
405 | $scope.abrirModalCotizacion = function (moneda) { | 405 | $scope.abrirModalCotizacion = function (moneda) { |
406 | var modalInstance = $uibModal.open( | 406 | var modalInstance = $uibModal.open( |
407 | { | 407 | { |
408 | ariaLabelledBy: 'Busqueda de Cotización', | 408 | ariaLabelledBy: 'Busqueda de Cotización', |
409 | templateUrl: 'modal-cotizacion.html', | 409 | templateUrl: 'modal-cotizacion.html', |
410 | controller: 'focaModalCotizacionController', | 410 | controller: 'focaModalCotizacionController', |
411 | size: 'lg', | 411 | size: 'lg', |
412 | resolve: { idMoneda: function () { return moneda.ID; } } | 412 | resolve: { idMoneda: function () { return moneda.ID; } } |
413 | } | 413 | } |
414 | ); | 414 | ); |
415 | modalInstance.result.then( | 415 | modalInstance.result.then( |
416 | function (cotizacion) { | 416 | function (cotizacion) { |
417 | 417 | ||
418 | cotizacion.moneda = moneda; | 418 | cotizacion.moneda = moneda; |
419 | actualizarCabeceraMoneda(cotizacion); | 419 | actualizarCabeceraMoneda(cotizacion); |
420 | $scope.factura.cotizacion = cotizacion; | 420 | $scope.factura.cotizacion = cotizacion; |
421 | 421 | ||
422 | }, function () { | 422 | }, function () { |
423 | 423 | ||
424 | } | 424 | } |
425 | ); | 425 | ); |
426 | }; | 426 | }; |
427 | 427 | ||
428 | $scope.seleccionarObservaciones = function () { | 428 | $scope.seleccionarObservaciones = function () { |
429 | var observacion = { | 429 | var observacion = { |
430 | titulo: 'Ingrese Observaciones', | 430 | titulo: 'Ingrese Observaciones', |
431 | value: $scope.factura.observaciones, | 431 | value: $scope.factura.observaciones, |
432 | maxlength: 155, | 432 | maxlength: 155, |
433 | textarea: true | 433 | textarea: true |
434 | }; | 434 | }; |
435 | 435 | ||
436 | focaModalService | 436 | focaModalService |
437 | .prompt(observacion) | 437 | .prompt(observacion) |
438 | .then(function (observaciones) { | 438 | .then(function (observaciones) { |
439 | $scope.factura.observaciones = observaciones; | 439 | $scope.factura.observaciones = observaciones; |
440 | }); | 440 | }); |
441 | }; | 441 | }; |
442 | 442 | ||
443 | $scope.articulosFiltro = function () { | 443 | $scope.articulosFiltro = function () { |
444 | return $scope.factura.articulosFactura.filter(function (articulo) { | 444 | return $scope.factura.articulosFactura.filter(function (articulo) { |
445 | return !articulo.desactivado; | 445 | return !articulo.desactivado; |
446 | }); | 446 | }); |
447 | }; | 447 | }; |
448 | 448 | ||
449 | $scope.getTotal = function () { | 449 | $scope.getTotal = function () { |
450 | 450 | ||
451 | var total = 0; | 451 | var total = 0; |
452 | 452 | ||
453 | $scope.articulosFiltro().forEach(function (articulo) { | 453 | $scope.articulosFiltro().forEach(function (articulo) { |
454 | total += articulo.PUN * articulo.CAN; | 454 | total += articulo.PUN * articulo.CAN; |
455 | }); | 455 | }); |
456 | 456 | ||
457 | return parseFloat(total.toFixed(2)); | 457 | return parseFloat(total.toFixed(2)); |
458 | }; | 458 | }; |
459 | 459 | ||
460 | $scope.quitarDespacho = function (articulo, index) { | 460 | $scope.quitarDespacho = function (articulo, index) { |
461 | 461 | ||
462 | if (articulo.SUR == 0) { | 462 | if (articulo.SUR == 0) { |
463 | articulo.desactivado = true; | 463 | articulo.desactivado = true; |
464 | return; | 464 | return; |
465 | } | 465 | } |
466 | 466 | ||
467 | crearFacturaService | 467 | crearFacturaService |
468 | .setearDespachoDesocupado({ | 468 | .setearDespachoDesocupado({ |
469 | surtidor: $scope.factura.despachos[index].SUR, | 469 | surtidor: $scope.factura.despachos[index].SUR, |
470 | producto: $scope.factura.despachos[index].PRO, | 470 | producto: $scope.factura.despachos[index].PRO, |
471 | carga: $scope.factura.despachos[index].CAR, | 471 | carga: $scope.factura.despachos[index].CAR, |
472 | planilla: $scope.factura.despachos[index].PLA | 472 | planilla: $scope.factura.despachos[index].PLA |
473 | }) | 473 | }) |
474 | .then(function () { | 474 | .then(function () { |
475 | articulo.desactivado = true; | 475 | articulo.desactivado = true; |
476 | $scope.factura.despachos.splice(index, 1); | 476 | $scope.factura.despachos.splice(index, 1); |
477 | }) | 477 | }) |
478 | .catch(function () { | 478 | .catch(function () { |
479 | focaModalService.alert('Hubo un error al desasociar este despacho'); | 479 | focaModalService.alert('Hubo un error al desasociar este despacho'); |
480 | }); | 480 | }); |
481 | }; | 481 | }; |
482 | 482 | ||
483 | //Recibe aviso si el teclado está en uso | 483 | //Recibe aviso si el teclado está en uso |
484 | $rootScope.$on('usarTeclado', function (event, data) { | 484 | $rootScope.$on('usarTeclado', function (event, data) { |
485 | if (data) { | 485 | if (data) { |
486 | $scope.mostrarTeclado = true; | 486 | $scope.mostrarTeclado = true; |
487 | return; | 487 | return; |
488 | } | 488 | } |
489 | $scope.mostrarTeclado = false; | 489 | $scope.mostrarTeclado = false; |
490 | }); | 490 | }); |
491 | 491 | ||
492 | $scope.selectFocus = function ($event) { | 492 | $scope.selectFocus = function ($event) { |
493 | // Si el teclado esta en uso no selecciona el valor | 493 | // Si el teclado esta en uso no selecciona el valor |
494 | if ($scope.mostrarTeclado) { | 494 | if ($scope.mostrarTeclado) { |
495 | return; | 495 | return; |
496 | } | 496 | } |
497 | $event.target.select(); | 497 | $event.target.select(); |
498 | }; | 498 | }; |
499 | 499 | ||
500 | 500 | ||
501 | function getProductosByPlanilla(numeroPlanilla) { | 501 | function getProductosByPlanilla(numeroPlanilla) { |
502 | 502 | ||
503 | crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function (res) { | 503 | crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function (res) { |
504 | 504 | ||
505 | if (!res.data.length) { | 505 | if (!res.data.length) { |
506 | 506 | ||
507 | focaModalService.alert('No hay despachos disponibles por el momento'); | 507 | focaModalService.alert('No hay despachos disponibles por el momento'); |
508 | return; | 508 | return; |
509 | } | 509 | } |
510 | 510 | ||
511 | $scope.botoneraProductos.length = 0; | 511 | $scope.botoneraProductos.length = 0; |
512 | res.data.forEach(function (producto) { | 512 | res.data.forEach(function (producto) { |
513 | 513 | ||
514 | $scope.botoneraProductos.push({ | 514 | $scope.botoneraProductos.push({ |
515 | label: producto.DetArt, | 515 | label: producto.DetArt, |
516 | image: producto.nombreImagen, | 516 | image: producto.nombreImagen, |
517 | imageDefault: 'productoDefault.png' | 517 | imageDefault: 'productoDefault.png' |
518 | }); | 518 | }); |
519 | 519 | ||
520 | crearFuncionesProductos(producto); | 520 | crearFuncionesProductos(producto); |
521 | }); | 521 | }); |
522 | |||
523 | $scope.botoneraProductos.push({ | ||
524 | label: 'Ultimos despachos', | ||
525 | image: 'ultimos-despachos.png', | ||
526 | imageDefault: 'productoDefault.png' | ||
527 | }); | ||
522 | }); | 528 | }); |
523 | } | 529 | } |
524 | 530 | ||
525 | $scope.seleccionarBusquedaProductos = function () { | 531 | $scope.seleccionarBusquedaProductos = function () { |
526 | 532 | ||
527 | if (angular.equals({}, $scope.factura.vendedor)) { | 533 | if (angular.equals({}, $scope.factura.vendedor)) { |
528 | 534 | ||
529 | focaModalService.alert('Seleccione Vendedor'); | 535 | focaModalService.alert('Seleccione Vendedor'); |
530 | return false; | 536 | return false; |
531 | } | 537 | } |
532 | 538 | ||
533 | var modalInstance = $uibModal.open( | 539 | var modalInstance = $uibModal.open( |
534 | { | 540 | { |
535 | ariaLabelledBy: 'Busqueda de Productos', | 541 | ariaLabelledBy: 'Busqueda de Productos', |
536 | templateUrl: 'modal-busqueda-productos.html', | 542 | templateUrl: 'modal-busqueda-productos.html', |
537 | controller: 'modalBusquedaProductosCtrl', | 543 | controller: 'modalBusquedaProductosCtrl', |
538 | resolve: { | 544 | resolve: { |
539 | parametroProducto: { | 545 | parametroProducto: { |
540 | idLista: null, | 546 | idLista: null, |
541 | cotizacion: $scope.factura.cotizacion.VENDEDOR, | 547 | cotizacion: $scope.factura.cotizacion.VENDEDOR, |
542 | simbolo: $scope.factura.cotizacion.moneda.SIMBOLO, | 548 | simbolo: $scope.factura.cotizacion.moneda.SIMBOLO, |
543 | buscarTodos: true | 549 | buscarTodos: true |
544 | } | 550 | } |
545 | }, | 551 | }, |
546 | size: 'lg' | 552 | size: 'lg' |
547 | } | 553 | } |
548 | ); | 554 | ); |
549 | 555 | ||
550 | modalInstance.result | 556 | modalInstance.result |
551 | .then(function (producto) { | 557 | .then(function (producto) { |
552 | 558 | ||
553 | var articulo = { | 559 | var articulo = { |
554 | TIP: $scope.factura.cliente.tipoFactura, | 560 | TIP: $scope.factura.cliente.tipoFactura, |
555 | TCO: 'FT', | 561 | TCO: 'FT', |
556 | SUC: parseInt($scope.puntoVenta), | 562 | SUC: parseInt($scope.puntoVenta), |
557 | ORD: $scope.articulosFiltro().length + 1, | 563 | ORD: $scope.articulosFiltro().length + 1, |
558 | SEC: producto.sector, | 564 | SEC: producto.sector, |
559 | ART: producto.codigo, | 565 | ART: producto.codigo, |
560 | RUB: producto.CodRub, | 566 | RUB: producto.CodRub, |
561 | DES: producto.descripcionLarga, | 567 | DES: producto.descripcionLarga, |
562 | PUN: producto.precio, | 568 | PUN: producto.precio, |
563 | IVA: producto.IMPIVA, | 569 | IVA: producto.IMPIVA, |
564 | NET: producto.IvaCO != 0 ? parseFloat(producto.neto) : 0, | 570 | NET: producto.IvaCO != 0 ? parseFloat(producto.neto) : 0, |
565 | NEX: producto.IvaCO == 0 ? parseFloat(producto.neto) : 0, | 571 | NEX: producto.IvaCO == 0 ? parseFloat(producto.neto) : 0, |
566 | IMI: producto.ImpInt, | 572 | IMI: producto.ImpInt, |
567 | IMI2: producto.ImpInt2, | 573 | IMI2: producto.ImpInt2, |
568 | IMI3: producto.ImpInt3, | 574 | IMI3: producto.ImpInt3, |
569 | PUT: producto.precio, | 575 | PUT: producto.precio, |
570 | SUR: 0, | 576 | SUR: 0, |
571 | PLA: $scope.factura.vendedor.NplVen, | 577 | PLA: $scope.factura.vendedor.NplVen, |
572 | LUG: $scope.factura.vendedor.LugVen, | 578 | LUG: $scope.factura.vendedor.LugVen, |
573 | LEG: $scope.factura.vendedor.CodVen, | 579 | LEG: $scope.factura.vendedor.CodVen, |
574 | TUR: $scope.factura.vendedor.TurVen, | 580 | TUR: $scope.factura.vendedor.TurVen, |
575 | ORDEN_PRECOMPRA: '', | 581 | ORDEN_PRECOMPRA: '', |
576 | ESC: producto.tipoFactura === 'L' ? 1 : 0, | 582 | ESC: producto.tipoFactura === 'L' ? 1 : 0, |
577 | CMF: 0, | 583 | CMF: 0, |
578 | PTA: 0, | 584 | PTA: 0, |
579 | IVS: 0, | 585 | IVS: 0, |
580 | TIVA: 0, | 586 | TIVA: 0, |
581 | CON: 0, | 587 | CON: 0, |
582 | SINO: '', | 588 | SINO: '', |
583 | ORD_TRA: 0, | 589 | ORD_TRA: 0, |
584 | IMP_DESP: 0, | 590 | IMP_DESP: 0, |
585 | PCD: 0, | 591 | PCD: 0, |
586 | RTO: '', | 592 | RTO: '', |
587 | }; | 593 | }; |
588 | 594 | ||
589 | $scope.factura.articulosFactura.push(articulo); | 595 | $scope.factura.articulosFactura.push(articulo); |
590 | $scope.cambioEdit(articulo, 'cantidad'); | 596 | $scope.cambioEdit(articulo, 'cantidad'); |
591 | 597 | ||
592 | }) | 598 | }) |
593 | .catch(function (e) { console.error(e); }); | 599 | .catch(function (e) { console.error(e); }); |
594 | }; | 600 | }; |
595 | 601 | ||
602 | $scope.seleccionarUltimosDespachos = function () { | ||
603 | |||
604 | if (angular.equals($scope.factura.cliente, {})) { | ||
605 | focaModalService.alert('Seleccione cliente'); | ||
606 | return; | ||
607 | } | ||
608 | |||
609 | var modalInstance = $uibModal.open( | ||
610 | { | ||
611 | templateUrl: 'modal-ultimos-despachos.html', | ||
612 | controller: 'ultimosDespachosController', | ||
613 | resolve: { | ||
614 | parametros: function () { | ||
615 | return { | ||
616 | planilla: $scope.factura.vendedor.NplVen, | ||
617 | }; | ||
618 | } | ||
619 | }, | ||
620 | size: 'md' | ||
621 | } | ||
622 | ); | ||
623 | |||
624 | modalInstance.result.then(function (despacho) { | ||
625 | |||
626 | var articulo = { | ||
627 | TIP: $scope.factura.cliente.tipoFactura, | ||
628 | TCO: 'FT', | ||
629 | SUC: parseInt($scope.puntoVenta), | ||
630 | ORD: $scope.articulosFiltro().length + 1, | ||
631 | SEC: despacho.SEC, | ||
632 | ART: despacho.PRO, | ||
633 | RUB: producto.CodRub, | ||
634 | DES: producto.DetArt, | ||
635 | CAN: despacho.LTS, | ||
636 | PUN: producto.PreVen, | ||
637 | IVA: producto.IMPIVA, | ||
638 | NET: producto.IvaCO != 0 ? producto.PreNet : 0, | ||
639 | NEX: producto.IvaCO == 0 ? producto.PreNet : 0, | ||
640 | IMI: producto.ImpInt, | ||
641 | IMI2: producto.ImpInt2, | ||
642 | IMI3: producto.ImpInt3, | ||
643 | PUT: producto.PreVen, | ||
644 | SUR: despacho.SUR, | ||
645 | PLA: despacho.PLA, | ||
646 | LUG: despacho.LUG, | ||
647 | LEG: $scope.factura.vendedor.CodVen, | ||
648 | TUR: $scope.factura.vendedor.TurVen, | ||
649 | ORDEN_PRECOMPRA: '', | ||
650 | ESC: producto.tipoFactura === 'L' ? 1 : 0, | ||
651 | CMF: 0, | ||
652 | PTA: 0, | ||
653 | IVS: 0, | ||
654 | TIVA: 21, // TODO traer POR de la tabla ACODIVA where ID = IvaCO | ||
655 | CON: 0, | ||
656 | SINO: '', | ||
657 | ORD_TRA: 0, | ||
658 | IMP_DESP: 0, | ||
659 | PCD: 0, | ||
660 | RTO: '', | ||
661 | }; | ||
662 | |||
663 | crearFacturaService.setearDespachoOcupado({ | ||
664 | surtidor: despacho.SUR, | ||
665 | producto: despacho.PRO, | ||
666 | carga: despacho.CAR | ||
667 | }) | ||
668 | .then(function () { | ||
669 | $scope.factura.articulosFactura.push(articulo); | ||
670 | $scope.factura.despachos.push(despacho); | ||
671 | }) | ||
672 | .catch(function (err) { | ||
673 | |||
674 | console.error(err); | ||
675 | focaModalService.alert('El despacho esta en uso'); | ||
676 | }); | ||
677 | |||
678 | }) | ||
679 | .catch(function (err) { | ||
680 | console.error(err); | ||
681 | }); | ||
682 | |||
683 | }; | ||
684 | |||
596 | function crearFuncionesProductos(producto) { | 685 | function crearFuncionesProductos(producto) { |
597 | 686 | ||
598 | $scope[nombreFuncion(producto.DetArt)] = function () { | 687 | $scope[nombreFuncion(producto.DetArt)] = function () { |
599 | 688 | ||
600 | if (angular.equals($scope.factura.cliente, {})) { | 689 | if (angular.equals($scope.factura.cliente, {})) { |
601 | focaModalService.alert('Seleccione cliente'); | 690 | focaModalService.alert('Seleccione cliente'); |
602 | return; | 691 | return; |
603 | } | 692 | } |
604 | 693 | ||
605 | var modalInstance = $uibModal.open( | 694 | var modalInstance = $uibModal.open( |
606 | { | 695 | { |
607 | templateUrl: 'modal-combustibles.html', | 696 | templateUrl: 'modal-combustibles.html', |
608 | controller: 'focaModalCombustiblesController', | 697 | controller: 'focaModalCombustiblesController', |
609 | resolve: { | 698 | resolve: { |
610 | parametros: function () { | 699 | parametros: function () { |
611 | return { | 700 | return { |
612 | despachos: producto.despachos, | 701 | despachos: producto.despachos, |
613 | nombreProducto: producto.DetArt | 702 | nombreProducto: producto.DetArt |
614 | }; | 703 | }; |
615 | } | 704 | } |
616 | }, | 705 | }, |
617 | size: 'md' | 706 | size: 'md' |
618 | } | 707 | } |
619 | ); | 708 | ); |
620 | 709 | ||
621 | modalInstance.result.then(function (despacho) { | 710 | modalInstance.result.then(function (despacho) { |
622 | 711 | ||
623 | var articulo = { | 712 | var articulo = { |
624 | TIP: $scope.factura.cliente.tipoFactura, | 713 | TIP: $scope.factura.cliente.tipoFactura, |
625 | TCO: 'FT', | 714 | TCO: 'FT', |
626 | SUC: parseInt($scope.puntoVenta), | 715 | SUC: parseInt($scope.puntoVenta), |
627 | ORD: $scope.articulosFiltro().length + 1, | 716 | ORD: $scope.articulosFiltro().length + 1, |
628 | SEC: despacho.SEC, | 717 | SEC: despacho.SEC, |
629 | ART: despacho.PRO, | 718 | ART: despacho.PRO, |
630 | RUB: producto.CodRub, | 719 | RUB: producto.CodRub, |
631 | DES: producto.DetArt, | 720 | DES: producto.DetArt, |
632 | CAN: despacho.LTS, | 721 | CAN: despacho.LTS, |
633 | PUN: producto.PreVen, | 722 | PUN: producto.PreVen, |
634 | IVA: producto.IMPIVA, | 723 | IVA: producto.IMPIVA, |
635 | NET: producto.IvaCO != 0 ? producto.PreNet : 0, | 724 | NET: producto.IvaCO != 0 ? producto.PreNet : 0, |
636 | NEX: producto.IvaCO == 0 ? producto.PreNet : 0, | 725 | NEX: producto.IvaCO == 0 ? producto.PreNet : 0, |
637 | IMI: producto.ImpInt, | 726 | IMI: producto.ImpInt, |
638 | IMI2: producto.ImpInt2, | 727 | IMI2: producto.ImpInt2, |
639 | IMI3: producto.ImpInt3, | 728 | IMI3: producto.ImpInt3, |
640 | PUT: producto.PreVen, | 729 | PUT: producto.PreVen, |
641 | SUR: despacho.SUR, | 730 | SUR: despacho.SUR, |
642 | PLA: despacho.PLA, | 731 | PLA: despacho.PLA, |
643 | LUG: despacho.LUG, | 732 | LUG: despacho.LUG, |
644 | LEG: $scope.factura.vendedor.CodVen, | 733 | LEG: $scope.factura.vendedor.CodVen, |
645 | TUR: $scope.factura.vendedor.TurVen, | 734 | TUR: $scope.factura.vendedor.TurVen, |
646 | ORDEN_PRECOMPRA: '', | 735 | ORDEN_PRECOMPRA: '', |
647 | ESC: producto.tipoFactura === 'L' ? 1 : 0, | 736 | ESC: producto.tipoFactura === 'L' ? 1 : 0, |
648 | CMF: 0, | 737 | CMF: 0, |
649 | PTA: 0, | 738 | PTA: 0, |
650 | IVS: 0, | 739 | IVS: 0, |
651 | TIVA: 21, // TODO traer POR de la tabla ACODIVA where ID = IvaCO | 740 | TIVA: 21, // TODO traer POR de la tabla ACODIVA where ID = IvaCO |
652 | CON: 0, | 741 | CON: 0, |
653 | SINO: '', | 742 | SINO: '', |
654 | ORD_TRA: 0, | 743 | ORD_TRA: 0, |
655 | IMP_DESP: 0, | 744 | IMP_DESP: 0, |
656 | PCD: 0, | 745 | PCD: 0, |
657 | RTO: '', | 746 | RTO: '', |
658 | }; | 747 | }; |
659 | 748 | ||
660 | crearFacturaService.setearDespachoOcupado({ | 749 | crearFacturaService.setearDespachoOcupado({ |
661 | surtidor: despacho.SUR, | 750 | surtidor: despacho.SUR, |
662 | producto: despacho.PRO, | 751 | producto: despacho.PRO, |
663 | carga: despacho.CAR | 752 | carga: despacho.CAR |
664 | }) | 753 | }) |
665 | .then(function () { | 754 | .then(function () { |
666 | $scope.factura.articulosFactura.push(articulo); | 755 | $scope.factura.articulosFactura.push(articulo); |
667 | $scope.factura.despachos.push(despacho); | 756 | $scope.factura.despachos.push(despacho); |
668 | }) | 757 | }) |
669 | .catch(function (err) { | 758 | .catch(function (err) { |
670 | 759 | ||
671 | console.error(err); | 760 | console.error(err); |
672 | focaModalService.alert('El despacho esta en uso'); | 761 | focaModalService.alert('El despacho esta en uso'); |
673 | }); | 762 | }); |
674 | 763 | ||
675 | }) | 764 | }) |
676 | .catch(function (err) { | 765 | .catch(function (err) { |
677 | console.error(err); | 766 | console.error(err); |
678 | }); | 767 | }); |
679 | 768 | ||
680 | }; | 769 | }; |
681 | } | 770 | } |
682 | 771 | ||
683 | function nombreFuncion(string) { | 772 | function nombreFuncion(string) { |
684 | var texto = 'seleccionar'; | 773 | var texto = 'seleccionar'; |
685 | var arr = string.split(' '); | 774 | var arr = string.split(' '); |
686 | arr.forEach(function (palabra) { | 775 | arr.forEach(function (palabra) { |
687 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); | 776 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); |
688 | texto += palabra; | 777 | texto += palabra; |
689 | }); | 778 | }); |
690 | return texto; | 779 | return texto; |
691 | } | 780 | } |
692 | 781 | ||
693 | function indicarPassword(vendedor) { | 782 | function indicarPassword(vendedor) { |
694 | 783 | ||
695 | return new Promise(function (resolve, reject) { | 784 | return new Promise(function (resolve, reject) { |
696 | 785 | ||
697 | function openPrompt() { | 786 | function openPrompt() { |
698 | return focaModalService | 787 | return focaModalService |
699 | .prompt({ | 788 | .prompt({ |
700 | titulo: 'Indique Contraseña', | 789 | titulo: 'Indique Contraseña', |
701 | value: '', | 790 | value: '', |
702 | tipo: 'password' | 791 | tipo: 'password' |
703 | }) | 792 | }) |
704 | .then(function (contraseña) { | 793 | .then(function (contraseña) { |
705 | 794 | ||
706 | if (contraseña !== vendedor.ClaVen.trim()) { | 795 | if (contraseña !== vendedor.ClaVen.trim()) { |
707 | 796 | ||
708 | focaModalService.alert('Clave incorrecta').then(function () { | 797 | focaModalService.alert('Clave incorrecta').then(function () { |
709 | openPrompt(vendedor); | 798 | openPrompt(vendedor); |
710 | }); | 799 | }); |
711 | } else { | 800 | } else { |
712 | resolve(); | 801 | resolve(); |
713 | } | 802 | } |
714 | }) | 803 | }) |
715 | .catch(reject); | 804 | .catch(reject); |
716 | } | 805 | } |
717 | 806 | ||
718 | openPrompt(); | 807 | openPrompt(); |
719 | }); | 808 | }); |
720 | } | 809 | } |
721 | 810 | ||
722 | function validarPlanillaVendedor(vendedor) { | 811 | function validarPlanillaVendedor(vendedor) { |
723 | 812 | ||
724 | return new Promise(function (resolve, reject) { | 813 | return new Promise(function (resolve, reject) { |
725 | 814 | ||
726 | crearFacturaService | 815 | crearFacturaService |
727 | .validarPlanillaVendedor(vendedor.CodVen.toString().trim()) | 816 | .validarPlanillaVendedor(vendedor.CodVen.toString().trim()) |
728 | .then(function (res) { | 817 | .then(function (res) { |
729 | 818 | ||
730 | if (!res.data.length) { | 819 | if (!res.data.length) { |
731 | 820 | ||
732 | focaModalService | 821 | focaModalService |
733 | .alert('No se encontró planilla abierta para el vendedor') | 822 | .alert('No se encontró planilla abierta para el vendedor') |
734 | .then(reject); | 823 | .then(reject); |
735 | 824 | ||
736 | } else { | 825 | } else { |
737 | resolve(); | 826 | resolve(); |
738 | } | 827 | } |
739 | 828 | ||
740 | }) | 829 | }) |
741 | .catch(function (err) { | 830 | .catch(function (err) { |
742 | console.log(err) | 831 | console.log(err) |
743 | reject(); | 832 | reject(); |
744 | }); | 833 | }); |
745 | }); | 834 | }); |
746 | } | 835 | } |
747 | 836 | ||
748 | function rellenar(relleno, longitud) { | 837 | function rellenar(relleno, longitud) { |
749 | relleno = '' + relleno; | 838 | relleno = '' + relleno; |
750 | while (relleno.length < longitud) { | 839 | while (relleno.length < longitud) { |
751 | relleno = '0' + relleno; | 840 | relleno = '0' + relleno; |
752 | } | 841 | } |
753 | return relleno; | 842 | return relleno; |
754 | } | 843 | } |
755 | 844 | ||
756 | $scope.salir = function () { | 845 | $scope.salir = function () { |
757 | var confirmacion = false; | 846 | var confirmacion = false; |
758 | 847 | ||
759 | if (!angular.equals($scope.factura, $scope.inicial)) { | 848 | if (!angular.equals($scope.factura, $scope.inicial)) { |
760 | confirmacion = true; | 849 | confirmacion = true; |
761 | } | 850 | } |
762 | 851 | ||
763 | if (confirmacion) { | 852 | if (confirmacion) { |
764 | focaModalService.confirm( | 853 | focaModalService.confirm( |
765 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 854 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
766 | ).then(function (data) { | 855 | ).then(function (data) { |
767 | if (data) { | 856 | if (data) { |
768 | $location.path('/'); | 857 | $location.path('/'); |
769 | } | 858 | } |
770 | }); | 859 | }); |
771 | } else { | 860 | } else { |
772 | $location.path('/'); | 861 | $location.path('/'); |
773 | } | 862 | } |
774 | } | 863 | } |
775 | 864 | ||
776 | function setearFactura(factura) { | 865 | function setearFactura(factura) { |
777 | 866 | ||
778 | $scope.$broadcast('cleanCabecera'); | 867 | $scope.$broadcast('cleanCabecera'); |
779 | 868 | ||
780 | $scope.cabeceras = []; | 869 | $scope.cabeceras = []; |
781 | 870 | ||
782 | if (factura.cotizacion && factura.cotizacion.moneda.CODIGO_AFIP !== 'PES') { | 871 | if (factura.cotizacion && factura.cotizacion.moneda.CODIGO_AFIP !== 'PES') { |
783 | $scope.cabeceras.push({ | 872 | $scope.cabeceras.push({ |
784 | label: 'Moneda:', | 873 | label: 'Moneda:', |
785 | valor: factura.cotizacion.moneda.DETALLE | 874 | valor: factura.cotizacion.moneda.DETALLE |
786 | }); | 875 | }); |
787 | $scope.cabeceras.push({ | 876 | $scope.cabeceras.push({ |
788 | label: 'Fecha cotizacion:', | 877 | label: 'Fecha cotizacion:', |
789 | valor: $filter('date')(factura.cotizacion.FECHA, | 878 | valor: $filter('date')(factura.cotizacion.FECHA, |
790 | 'dd/MM/yyyy') | 879 | 'dd/MM/yyyy') |
791 | }); | 880 | }); |
792 | $scope.cabeceras.push({ | 881 | $scope.cabeceras.push({ |
793 | label: 'Cotizacion:', | 882 | label: 'Cotizacion:', |
794 | valor: $filter('number')(factura.cotizacion.VENDEDOR, | 883 | valor: $filter('number')(factura.cotizacion.VENDEDOR, |
795 | '2') | 884 | '2') |
796 | }); | 885 | }); |
797 | } | 886 | } |
798 | 887 | ||
799 | if (factura.cotizacion && factura.cotizacion.moneda) { | 888 | if (factura.cotizacion && factura.cotizacion.moneda) { |
800 | // $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; | 889 | // $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; |
801 | } | 890 | } |
802 | 891 | ||
803 | if (factura.cliente && factura.cliente.cod) { | 892 | if (factura.cliente && factura.cliente.cod) { |
804 | $scope.cabeceras.push({ | 893 | $scope.cabeceras.push({ |
805 | label: 'Cliente:', | 894 | label: 'Cliente:', |
806 | valor: $filter('rellenarDigitos')(factura.cliente.cod, 3) + ' - ' + | 895 | valor: $filter('rellenarDigitos')(factura.cliente.cod, 3) + ' - ' + |
807 | factura.cliente.nom | 896 | factura.cliente.nom |
808 | }); | 897 | }); |
809 | 898 | ||
810 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; | 899 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; |
811 | } | 900 | } |
812 | 901 | ||
813 | $scope.puntoVenta = rellenar(factura.sucursal, 4); | 902 | $scope.puntoVenta = rellenar(factura.sucursal, 4); |
814 | $scope.comprobante = rellenar(factura.numerofactura, 8); | 903 | $scope.comprobante = rellenar(factura.numerofactura, 8); |
815 | $scope.factura = factura; | 904 | $scope.factura = factura; |
816 | 905 | ||
817 | addArrayCabecera($scope.cabeceras); | 906 | addArrayCabecera($scope.cabeceras); |
818 | } | 907 | } |
819 | 908 | ||
820 | function getLSFactura() { | 909 | function getLSFactura() { |
821 | var factura = JSON.parse($localStorage.factura || null); | 910 | var factura = JSON.parse($localStorage.factura || null); |
822 | if (factura) { | 911 | if (factura) { |
823 | setearFactura(factura); | 912 | setearFactura(factura); |
824 | delete $localStorage.factura; | 913 | delete $localStorage.factura; |
825 | } | 914 | } |
826 | } | 915 | } |
827 | 916 | ||
828 | function addArrayCabecera(array) { | 917 | function addArrayCabecera(array) { |
829 | for (var i = 0; i < array.length; i++) { | 918 | for (var i = 0; i < array.length; i++) { |
830 | $scope.$broadcast('addCabecera', { | 919 | $scope.$broadcast('addCabecera', { |
831 | label: array[i].label, | 920 | label: array[i].label, |
832 | valor: array[i].valor | 921 | valor: array[i].valor |
833 | }); | 922 | }); |
834 | } | 923 | } |
835 | } | 924 | } |
836 | 925 | ||
837 | $scope.cambioEdit = function (articulo, propiedad) { | 926 | $scope.cambioEdit = function (articulo, propiedad) { |
838 | if (propiedad === 'cantidad' && articulo.SUR == 0) { | 927 | if (propiedad === 'cantidad' && articulo.SUR == 0) { |
839 | articulo.editCantidad = true; | 928 | articulo.editCantidad = true; |
840 | } | 929 | } |
841 | }; | 930 | }; |
842 | 931 | ||
843 | $scope.editarArticulo = function (key, articulo, tmpCantidad) { | 932 | $scope.editarArticulo = function (key, articulo, tmpCantidad) { |
844 | if (key === 13) { | 933 | if (key === 13) { |
845 | if (!articulo.cantidad && tmpCantidad.length === 0) { | 934 | if (!articulo.cantidad && tmpCantidad.length === 0) { |
846 | focaModalService.alert('Los valores deben ser al menos 1'); | 935 | focaModalService.alert('Los valores deben ser al menos 1'); |
847 | return; | 936 | return; |
848 | } else if (tmpCantidad === '0') { | 937 | } else if (tmpCantidad === '0') { |
849 | focaModalService.alert('Esta ingresando un producto con valor 0'); | 938 | focaModalService.alert('Esta ingresando un producto con valor 0'); |
850 | return; | 939 | return; |
851 | } else if (parseInt(tmpCantidad) < 0) { | 940 | } else if (parseInt(tmpCantidad) < 0) { |
852 | focaModalService.alert('Los valores no pueden ser negativos'); | 941 | focaModalService.alert('Los valores no pueden ser negativos'); |
853 | return; | 942 | return; |
854 | } | 943 | } |
855 | articulo.CAN = parseInt(tmpCantidad); | 944 | articulo.CAN = parseInt(tmpCantidad); |
856 | $scope.getTotal(); | 945 | $scope.getTotal(); |
857 | articulo.editCantidad = false; | 946 | articulo.editCantidad = false; |
858 | } | 947 | } |
859 | }; | 948 | }; |
860 | 949 | ||
861 | $scope.cancelarEditar = function (articulo) { | 950 | $scope.cancelarEditar = function (articulo) { |
862 | $scope.tmpCantidad = articulo.CAN; | 951 | $scope.tmpCantidad = articulo.CAN; |
863 | articulo.editCantidad = false; | 952 | articulo.editCantidad = false; |
864 | }; | 953 | }; |
865 | 954 | ||
866 | function actualizarCabeceraMoneda(cotizacion) { | 955 | function actualizarCabeceraMoneda(cotizacion) { |
867 | 956 | ||
868 | $scope.factura.articulosFactura.forEach(function (art) { | 957 | $scope.factura.articulosFactura.forEach(function (art) { |
869 | art.PUN = (art.PUN * $scope.factura.cotizacion.VENDEDOR).toFixed(4); | 958 | art.PUN = (art.PUN * $scope.factura.cotizacion.VENDEDOR).toFixed(4); |
870 | art.PUN = (art.PUN / cotizacion.VENDEDOR).toFixed(4); | 959 | art.PUN = (art.PUN / cotizacion.VENDEDOR).toFixed(4); |
871 | }); | 960 | }); |
872 | 961 | ||
873 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { | 962 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { |
874 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 963 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
875 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 964 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
876 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 965 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
877 | } else { | 966 | } else { |
878 | $scope.$broadcast('addCabecera', { | 967 | $scope.$broadcast('addCabecera', { |
879 | label: 'Moneda:', | 968 | label: 'Moneda:', |
880 | valor: cotizacion.moneda.DETALLE | 969 | valor: cotizacion.moneda.DETALLE |
881 | }); | 970 | }); |
882 | $scope.$broadcast('addCabecera', { | 971 | $scope.$broadcast('addCabecera', { |
883 | label: 'Fecha cotizacion:', | 972 | label: 'Fecha cotizacion:', |
884 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 973 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
885 | }); | 974 | }); |
886 | $scope.$broadcast('addCabecera', { | 975 | $scope.$broadcast('addCabecera', { |
887 | label: 'Cotizacion:', | 976 | label: 'Cotizacion:', |
888 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 977 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
889 | }); | 978 | }); |
890 | } | 979 | } |
891 | } | 980 | } |
892 | 981 | ||
893 | function validarGuardar() { | 982 | function validarGuardar() { |
894 | 983 | ||
895 | if (angular.equals({}, $scope.factura.vendedor)) { | 984 | if (angular.equals({}, $scope.factura.vendedor)) { |
896 | 985 | ||
897 | focaModalService.alert('Seleccione Vendedor'); | 986 | focaModalService.alert('Seleccione Vendedor'); |
898 | return false; | 987 | return false; |
899 | } else if (angular.equals({}, $scope.factura.cliente)) { | 988 | } else if (angular.equals({}, $scope.factura.cliente)) { |
900 | 989 | ||
901 | focaModalService.alert('Seleccione Cliente'); | 990 | focaModalService.alert('Seleccione Cliente'); |
902 | return false; | 991 | return false; |
903 | } else if (!$scope.articulosFiltro().length) { | 992 | } else if (!$scope.articulosFiltro().length) { |
904 | 993 | ||
905 | focaModalService.alert('Seleccione al menos un Articulo'); | 994 | focaModalService.alert('Seleccione al menos un Articulo'); |
906 | return false; | 995 | return false; |
907 | } | 996 | } |
908 | 997 | ||
909 | return true; | 998 | return true; |
910 | } | 999 | } |
911 | 1000 | ||
912 | //recibo la propiedad por la cual quiero obtener el valor | 1001 | //recibo la propiedad por la cual quiero obtener el valor |
913 | function getImporte(propiedad) { | 1002 | function getImporte(propiedad) { |
914 | var importe = 0; | 1003 | var importe = 0; |
915 | 1004 | ||
916 | $scope.articulosFiltro().forEach(function (articulo) { | 1005 | $scope.articulosFiltro().forEach(function (articulo) { |
917 | 1006 | ||
918 | if (articulo[propiedad]) { | 1007 | if (articulo[propiedad]) { |
919 | importe += articulo[propiedad] * articulo.CAN; | 1008 | importe += articulo[propiedad] * articulo.CAN; |
920 | } | 1009 | } |
921 | return; | 1010 | return; |
922 | 1011 | ||
923 | }); | 1012 | }); |
924 | 1013 | ||
925 | return importe; | 1014 | return importe; |
926 | } | 1015 | } |
927 | } | 1016 | } |
928 | ]); | 1017 | ]); |
929 | 1018 |
src/js/controllerUltimosDespachos.js
File was created | 1 | angular.module('focaCrearFactura') | |
2 | .controller('ultimosDespachosController', [ | ||
3 | '$filter', | ||
4 | '$scope', | ||
5 | '$uibModalInstance', | ||
6 | 'crearFacturaService', | ||
7 | 'parametros', | ||
8 | function ($filter, $scope, $uibModalInstance, crearFacturaService, parametros) { | ||
9 | |||
10 | $scope.colorTexto = { color: 'black' }; | ||
11 | |||
12 | config(); | ||
13 | |||
14 | function config() { | ||
15 | |||
16 | crearFacturaService.getUltimosDespachos(parametros.planilla).then(function (res) { | ||
17 | $scope.productos = res.data; | ||
18 | }); | ||
19 | } | ||
20 | |||
21 | $scope.aceptar = function (despacho) { | ||
22 | $uibModalInstance.close(despacho); | ||
23 | }; | ||
24 | |||
25 | $scope.cancel = function () { | ||
26 | $uibModalInstance.dismiss('cancel'); | ||
27 | }; | ||
28 | |||
29 | //TODO: Cambiar switch case con los casos de nombres de productos axion | ||
30 | function setColorNombreProducto() { | ||
31 | |||
32 | // Diesel #FF852E | Euro+Diesel #6C389A | Premium #00A857 | Super #175AA5 | ||
33 | switch ($scope.nombreProducto) { | ||
34 | case 'NAFTA SUPER XXI': | ||
35 | $scope.colorTexto = { color: '#FF852E' }; | ||
36 | break; | ||
37 | case 'GO-INFINIA DIESEL': | ||
38 | $scope.colorTexto = { color: '#6C389A' }; | ||
39 | break; | ||
40 | case 'ULTRADIESEL XXI - RED': | ||
41 | $scope.colorTexto = { color: '#00A857' }; | ||
42 | break; | ||
43 | case 'NAFTA INFINIA': | ||
44 | $scope.colorTexto = { color: '#175AA5' }; | ||
45 | break; | ||
46 | default: | ||
47 | $scope.colorTexto = { color: 'black' }; | ||
48 | break; | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | ]); | ||
53 |
src/js/service.js
1 | angular.module('focaCrearFactura') | 1 | angular.module('focaCrearFactura') |
2 | .service('crearFacturaService', ['$http', 'API_ENDPOINT', 'APP', | 2 | .service('crearFacturaService', ['$http', 'API_ENDPOINT', 'APP', |
3 | function ($http, API_ENDPOINT, APP) { | 3 | function ($http, API_ENDPOINT, APP) { |
4 | var route = API_ENDPOINT.URL; | 4 | var route = API_ENDPOINT.URL; |
5 | return { | 5 | return { |
6 | guardarFactura: function (factura) { | 6 | guardarFactura: function (factura) { |
7 | return $http.post(route + '/factura/guardar', factura); | 7 | return $http.post(route + '/factura/guardar', factura); |
8 | }, | 8 | }, |
9 | getParametros: function () { | 9 | getParametros: function () { |
10 | return $http.get(API_ENDPOINT.URL + '/parametros/factura'); | 10 | return $http.get(API_ENDPOINT.URL + '/parametros/factura'); |
11 | }, | 11 | }, |
12 | validarPlanillaVendedor: function (idVendedor) { | 12 | validarPlanillaVendedor: function (idVendedor) { |
13 | return $http.get(route + '/turnos/validar-planilla/' + idVendedor); | 13 | return $http.get(route + '/turnos/validar-planilla/' + idVendedor); |
14 | }, | 14 | }, |
15 | getProductosByPlanilla: function (numeroPlanilla) { | 15 | getProductosByPlanilla: function (numeroPlanilla) { |
16 | return $http.get(route + '/turnos/productos/' + numeroPlanilla); | 16 | return $http.get(route + '/turnos/productos/' + numeroPlanilla); |
17 | }, | 17 | }, |
18 | getUltimosDespachos: function (numeroPlanilla) { | ||
19 | return $http.get(route + '/turnos/productos/' + numeroPlanilla + '/true'); | ||
20 | }, | ||
18 | setearDespachoOcupado: function (parametros) { | 21 | setearDespachoOcupado: function (parametros) { |
19 | return $http.post(route + '/turnos/despacho-en-uso', parametros); | 22 | return $http.post(route + '/turnos/despacho-en-uso', parametros); |
20 | }, | 23 | }, |
21 | setearDespachoDesocupado: function (parametros) { | 24 | setearDespachoDesocupado: function (parametros) { |
22 | return $http.post(route + '/turnos/depacho-sin-uso', parametros); | 25 | return $http.post(route + '/turnos/depacho-sin-uso', parametros); |
23 | }, | 26 | }, |
24 | getResumenCuenta: function (idCliente) { | 27 | getResumenCuenta: function (idCliente) { |
25 | return $http.get(route + '/cliente/resumen-cuenta/' + idCliente); | 28 | return $http.get(route + '/cliente/resumen-cuenta/' + idCliente); |
26 | }, | 29 | }, |
27 | getVendedorPlayaById: function (id) { | 30 | getVendedorPlayaById: function (id) { |
28 | return $http.get(route + '/vendedor-playa/' + id); | 31 | return $http.get(route + '/vendedor-playa/' + id); |
29 | }, | 32 | }, |
30 | getBotonera: function () { | 33 | getBotonera: function () { |
31 | var vendedor = { | 34 | var vendedor = { |
32 | label: 'Vendedor', | 35 | label: 'Vendedor', |
33 | image: 'vendedor.png' | 36 | image: 'vendedor.png' |
34 | }; | 37 | }; |
35 | // $scope.botoneraProductos.push({ | 38 | // $scope.botoneraProductos.push({ |
36 | // label: 'Busqueda Productos', | 39 | // label: 'Busqueda Productos', |
37 | // image: 'buscarProductos.png', | 40 | // image: 'buscarProductos.png', |
38 | // imageDefault: 'productoDefault.png' | 41 | // imageDefault: 'productoDefault.png' |
39 | // }); | 42 | // }); |
40 | var botones = [ | 43 | var botones = [ |
41 | { | 44 | { |
42 | label: 'Cliente', | 45 | label: 'Cliente', |
43 | image: 'cliente.png' | 46 | image: 'cliente.png' |
44 | }, | 47 | }, |
45 | { | 48 | { |
46 | label: 'Busqueda Productos', | 49 | label: 'Busqueda Productos', |
47 | image: 'productos.png' | 50 | image: 'productos.png' |
48 | } | 51 | } |
49 | // { | 52 | // { |
50 | // label: 'Moneda', | 53 | // label: 'Moneda', |
51 | // image: 'moneda.png' | 54 | // image: 'moneda.png' |
52 | // }, | 55 | // }, |
53 | // { | 56 | // { |
54 | // label: 'Observaciones', | 57 | // label: 'Observaciones', |
55 | // image: 'botonObservaciones.png' | 58 | // image: 'botonObservaciones.png' |
56 | // } | 59 | // } |
57 | ]; | 60 | ]; |
58 | 61 | ||
59 | if (APP !== 'facturador') { | 62 | if (APP !== 'facturador') { |
60 | botones.unshift(vendedor); | 63 | botones.unshift(vendedor); |
61 | } | 64 | } |
62 | 65 | ||
63 | return botones; | 66 | return botones; |
64 | } | 67 | } |
65 | }; | 68 | }; |
66 | } | 69 | } |
67 | ]); | 70 | ]); |
68 | 71 |
src/views/modal-ultimos-despachos.html
File was created | 1 | <div class="modal-header py-1"> | |
2 | <div class="row w-100"> | ||
3 | <div class="col-lg-6"> | ||
4 | <h5 class="modal-title my-1"><b>Despachos Disponibles</b></h5> | ||
5 | </div> | ||
6 | </div> | ||
7 | </div> | ||
8 | <div class="modal-body" id="modal-body"> | ||
9 | <div ng-repeat="(key, producto) in productos"> | ||
10 | <div class="row my-2"> | ||
11 | <div class="col"> | ||
12 | <label> | ||
13 | <img class="w-50" ng-src="./img/surtidor.png" alt=""> | ||
14 | {{manguera.csu}} | ||
15 | </label> | ||
16 | <button | ||
17 | type="button" | ||
18 | class="btn p-1 text-secondary float-right border" | ||
19 | ng-click="manguera.show = !manguera.show"> | ||
20 | <i ng-show="manguera.show" class="fa fa-minus px-1"></i> | ||
21 | <i ng-show="!manguera.show" class="fa fa-plus px-1"></i> | ||
22 | </button> | ||
23 | <table class="table table-sm table-striped" ng-show="manguera.show"> | ||
24 | <tbody> | ||
25 | <tr ng-repeat="(key, despacho) in manguera.despachos"> | ||
26 | <td class="py-2 py-sm-1" ng-bind="despacho.FEC | date:'dd/MM/yyyy hh:MM:ss'"></td> | ||
27 | <td class="py-2 py-sm-1" ng-bind="despacho.LTS"></td> | ||
28 | <td class="py-2 py-sm-1" ng-bind="despacho.IMP | currency: '$'"></td> | ||
29 | <td class="py-2 py-sm-1"> | ||
30 | <button | ||
31 | type="button" | ||
32 | class="btn btn-default btn-xs p-1 float-right" | ||
33 | title="Seleccionar" | ||
34 | ng-click="aceptar(despacho)" | ||
35 | ><i class="fa fa-circle-thin" aria-hidden="true"></i> | ||
36 | </button> | ||
37 | </td> | ||
38 | </tr> | ||
39 | </tbody> | ||
40 | </table> | ||
41 | </div> | ||
42 | </div> | ||
43 | </div> | ||
44 | |||
45 | </div> | ||
46 | <div class="modal-footer py-2"> | ||
47 | <nav ng-show="currentPageProveedores.length > 0 && primerBusqueda" class="mr-auto"> | ||
48 | <ul class="pagination pagination-sm mb-0"> | ||
49 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | ||
50 | <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage - 1)"> | ||
51 | <span aria-hidden="true">«</span> | ||
52 | <span class="sr-only">Anterior</span> | ||
53 | </a> | ||
54 | </li> | ||
55 | <li | ||
56 | class="page-item" | ||
57 | ng-repeat="pagina in paginas" | ||
58 | ng-class="{'active': pagina == currentPage}" | ||
59 | > | ||
60 | <a | ||
61 | class="page-link" | ||
62 | href="javascript:void();" | ||
63 | ng-click="selectPage(pagina)" | ||
64 | ng-bind="pagina" | ||
65 | ></a> | ||
66 | </li> | ||
67 | <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | ||
68 | <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage + 1)"> | ||
69 | <span aria-hidden="true">»</span> | ||
70 | <span class="sr-only">Siguiente</span> | ||
71 | </a> | ||
72 | </li> | ||
73 | </ul> | ||
74 | </nav> | ||
75 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | ||
76 | </div> | ||
77 |