Commit 79eab61a57cd4d7df87c0cf067b1c2b167df3dca
1 parent
9294a45076
Exists in
master
and in
1 other branch
primera versión estable2
Showing
10 changed files
with
975 additions
and
0 deletions
Show diff stats
.gitignore
.jshintrc
... | ... | @@ -0,0 +1,64 @@ |
1 | +{ | |
2 | + /* | |
3 | + * ENVIRONMENTS | |
4 | + * ================= | |
5 | + */ | |
6 | + | |
7 | + // Define globals exposed by modern browsers. | |
8 | + "browser": true, | |
9 | + | |
10 | + // Define globals exposed by jQuery. | |
11 | + "jquery": true, | |
12 | + | |
13 | + // Define globals exposed by Node.js. | |
14 | + "node": true, | |
15 | + | |
16 | + // Allow ES6. | |
17 | + "esversion": 6, | |
18 | + | |
19 | + /* | |
20 | + * ENFORCING OPTIONS | |
21 | + * ================= | |
22 | + */ | |
23 | + | |
24 | + // Force all variable names to use either camelCase style or UPPER_CASE | |
25 | + // with underscores. | |
26 | + "camelcase": true, | |
27 | + | |
28 | + // Prohibit use of == and != in favor of === and !==. | |
29 | + "eqeqeq": true, | |
30 | + | |
31 | + // Enforce tab width of 2 spaces. | |
32 | + "indent": 4, | |
33 | + | |
34 | + // Prohibit use of a variable before it is defined. | |
35 | + "latedef": false, | |
36 | + | |
37 | + // Enforce line length to 100 characters | |
38 | + "maxlen": 100, | |
39 | + | |
40 | + // Require capitalized names for constructor functions. | |
41 | + "newcap": true, | |
42 | + | |
43 | + // Enforce use of single quotation marks for strings. | |
44 | + "quotmark": "single", | |
45 | + | |
46 | + // Enforce placing 'use strict' at the top function scope | |
47 | + "strict": false, | |
48 | + | |
49 | + // Prohibit use of explicitly undeclared variables. | |
50 | + "undef": true, | |
51 | + | |
52 | + // Warn when variables are defined but never used. | |
53 | + "unused": true, | |
54 | + | |
55 | + // Para que funcione en angular | |
56 | + "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], | |
57 | + /* | |
58 | + * RELAXING OPTIONS | |
59 | + * ================= | |
60 | + */ | |
61 | + | |
62 | + // Suppress warnings about == null comparisons. | |
63 | + "eqnull": true | |
64 | +} |
gulpfile.js
... | ... | @@ -0,0 +1,86 @@ |
1 | +const templateCache = require('gulp-angular-templatecache'); | |
2 | +const clean = require('gulp-clean'); | |
3 | +const concat = require('gulp-concat'); | |
4 | +const htmlmin = require('gulp-htmlmin'); | |
5 | +const rename = require('gulp-rename'); | |
6 | +const uglify = require('gulp-uglify'); | |
7 | +const gulp = require('gulp'); | |
8 | +const pump = require('pump'); | |
9 | +const jshint = require('gulp-jshint'); | |
10 | +const replace = require('gulp-replace'); | |
11 | +const connect = require('gulp-connect'); | |
12 | + | |
13 | +var paths = { | |
14 | + srcJS: 'src/js/*.js', | |
15 | + srcViews: 'src/views/*.html', | |
16 | + tmp: 'tmp', | |
17 | + dist: 'dist/' | |
18 | +}; | |
19 | + | |
20 | +gulp.task('templates', ['clean'], function() { | |
21 | + return pump( | |
22 | + [ | |
23 | + gulp.src(paths.srcViews), | |
24 | + htmlmin(), | |
25 | + templateCache('views.js', { | |
26 | + module: 'focaParametros', | |
27 | + root: '' | |
28 | + }), | |
29 | + gulp.dest(paths.tmp) | |
30 | + ] | |
31 | + ); | |
32 | +}); | |
33 | + | |
34 | +gulp.task('uglify', ['templates'], function() { | |
35 | + return pump( | |
36 | + [ | |
37 | + gulp.src([ | |
38 | + paths.srcJS, | |
39 | + 'tmp/views.js' | |
40 | + ]), | |
41 | + concat('foca-parametros.js'), | |
42 | + replace('src/views/', ''), | |
43 | + replace("'ngRoute'", ''), | |
44 | + gulp.dest(paths.tmp), | |
45 | + rename('foca-parametros.min.js'), | |
46 | + uglify(), | |
47 | + gulp.dest(paths.dist) | |
48 | + ] | |
49 | + ); | |
50 | +}); | |
51 | + | |
52 | +gulp.task('clean', function() { | |
53 | + return gulp.src(['tmp', 'dist'], {read: false}) | |
54 | + .pipe(clean()); | |
55 | +}); | |
56 | + | |
57 | +gulp.task('pre-commit', function() { | |
58 | + return pump( | |
59 | + [ | |
60 | + gulp.src(paths.srcJS), | |
61 | + jshint('.jshintrc'), | |
62 | + jshint.reporter('default'), | |
63 | + jshint.reporter('fail') | |
64 | + ] | |
65 | + ); | |
66 | + | |
67 | + gulp.start('uglify'); | |
68 | +}); | |
69 | + | |
70 | +gulp.task('webserver', function() { | |
71 | + pump [ | |
72 | + connect.server({port: 3300, host: '0.0.0.0'}) | |
73 | + ] | |
74 | +}); | |
75 | + | |
76 | +gulp.task('clean-post-install', function() { | |
77 | + return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | |
78 | + 'index.html'], {read: false}) | |
79 | + .pipe(clean()); | |
80 | +}); | |
81 | + | |
82 | +gulp.task('default', ['webserver']); | |
83 | + | |
84 | +gulp.task('watch', function() { | |
85 | + gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | |
86 | +}); |
package.json
... | ... | @@ -0,0 +1,50 @@ |
1 | +{ | |
2 | + "name": "foca-autorizar-nota-pedido", | |
3 | + "version": "0.0.1", | |
4 | + "description": "foca-autorizar-nota-pedido", | |
5 | + "main": "index.js", | |
6 | + "scripts": { | |
7 | + "test": "echo \"Error: no test specified\" && exit 1", | |
8 | + "compile": "gulp uglify", | |
9 | + "gulp-pre-commit": "gulp pre-commit", | |
10 | + "postinstall": "npm run compile && gulp clean-post-install", | |
11 | + "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-remito.git" | |
12 | + }, | |
13 | + "pre-commit": [ | |
14 | + "gulp-pre-commit" | |
15 | + ], | |
16 | + "repository": { | |
17 | + "type": "git", | |
18 | + "url": "git+http://git.focasoftware.com/npm/foca-autorizar-nota-pedido.git" | |
19 | + }, | |
20 | + "author": "Foca Software", | |
21 | + "license": "ISC", | |
22 | + "devDependencies": { | |
23 | + "angular": "^1.7.8", | |
24 | + "angular-ladda": "^0.4.3", | |
25 | + "angular-route": "^1.7.8", | |
26 | + "bootstrap": "^4.3.1", | |
27 | + "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | |
28 | + "foca-modal-remito": "git+http://git.focasoftware.com/npm/foca-modal-remito.git", | |
29 | + "font-awesome": "^4.7.0", | |
30 | + "gulp": "^3.9.1", | |
31 | + "gulp-angular-templatecache": "^2.2.6", | |
32 | + "gulp-clean": "^0.4.0", | |
33 | + "gulp-concat": "^2.6.1", | |
34 | + "gulp-connect": "^5.7.0", | |
35 | + "gulp-htmlmin": "^5.0.1", | |
36 | + "gulp-jshint": "^2.1.0", | |
37 | + "gulp-rename": "^1.4.0", | |
38 | + "gulp-replace": "^1.0.0", | |
39 | + "gulp-sequence": "^1.0.0", | |
40 | + "gulp-uglify": "^3.0.2", | |
41 | + "gulp-uglify-es": "^1.0.4", | |
42 | + "jasmine-core": "^3.4.0", | |
43 | + "jquery": "^3.4.0", | |
44 | + "jshint": "^2.10.2", | |
45 | + "ladda": "^1.0.6", | |
46 | + "pre-commit": "^1.2.2", | |
47 | + "pump": "^3.0.0", | |
48 | + "ui-bootstrap4": "^3.0.6" | |
49 | + } | |
50 | +} |
src/etc/develop.js.ejemplo
src/js/app.js
... | ... | @@ -0,0 +1 @@ |
1 | +angular.module('focaParametros', []); |
src/js/controller.js
... | ... | @@ -0,0 +1,642 @@ |
1 | +angular.module('focaParametros') | |
2 | + .controller('focaParametrosCtrl', [ | |
3 | + '$scope', | |
4 | + 'focaParametrosService', | |
5 | + 'focaBotoneraLateralService', | |
6 | + '$filter', | |
7 | + 'focaModalService', | |
8 | + '$timeout', | |
9 | + '$uibModal', | |
10 | + function($scope, focaParametrosService, focaBotoneraLateralService, $filter, | |
11 | + focaModalService, $timeout, $uibModal) | |
12 | + { | |
13 | + | |
14 | + $scope.botonera = []; | |
15 | + $scope.now = new Date(); | |
16 | + | |
17 | + $scope.botoneraPrincipal = focaParametrosService.getBotonesPrincipal; | |
18 | + | |
19 | + $timeout(function() { | |
20 | + focaBotoneraLateralService.showSalir(true); | |
21 | + focaBotoneraLateralService.showGuardar(true, $scope.guardar); | |
22 | + }); | |
23 | + | |
24 | + focaParametrosService.getParametros().then(function(res) { | |
25 | + | |
26 | + $scope.$broadcast('cleanCabecera'); | |
27 | + res.data.forEach(function(entidad) { | |
28 | + | |
29 | + setearEntidad(entidad); | |
30 | + }); | |
31 | + }); | |
32 | + | |
33 | + $scope.guardar = function() { | |
34 | + | |
35 | + focaParametrosService.saveParametros(getObjGuardar()).then(function() { | |
36 | + focaModalService.alert('Parámetros guardados con éxito'); | |
37 | + }); | |
38 | + }; | |
39 | + | |
40 | + $scope.seleccionarPuntosDeDescarga = function() { | |
41 | + if (!$scope[getModulo()].cliente.COD || !$scope[getModulo()].domicilio.id) { | |
42 | + focaModalService.alert('Primero seleccione un cliente y un domicilio'); | |
43 | + return; | |
44 | + } else { | |
45 | + var modalInstance = $uibModal.open( | |
46 | + { | |
47 | + ariaLabelledBy: 'Búsqueda de Puntos de descarga', | |
48 | + templateUrl: 'modal-punto-descarga.html', | |
49 | + controller: 'focaModalPuntoDescargaController', | |
50 | + size: 'lg', | |
51 | + resolve: { | |
52 | + filters: { | |
53 | + idDomicilio: $scope[getModulo()].domicilio.id, | |
54 | + idCliente: $scope[getModulo()].cliente.COD, | |
55 | + articulos: $scope[getModulo()].articulosNotaPedido || [], | |
56 | + puntoDescarga: $scope[getModulo()].notaPedidoPuntoDescarga, | |
57 | + domicilio: $scope[getModulo()].domicilio | |
58 | + } | |
59 | + } | |
60 | + } | |
61 | + ); | |
62 | + modalInstance.result.then( | |
63 | + function(puntoDescarga) { | |
64 | + $scope[getModulo()].notaPedidoPuntoDescarga = puntoDescarga; | |
65 | + | |
66 | + $scope.$broadcast('addCabecera', { | |
67 | + label: 'Puntos de descarga:', | |
68 | + seccion: getModulo('label'), | |
69 | + valor: getCabeceraPuntoDescarga(puntoDescarga) | |
70 | + }); | |
71 | + }, function() { | |
72 | + $scope.abrirModalDomicilios($scope.cliente); | |
73 | + } | |
74 | + ); | |
75 | + } | |
76 | + }; | |
77 | + | |
78 | + $scope.seleccionarFlete = function() { | |
79 | + | |
80 | + if ($scope[getModulo()].flete === undefined) { | |
81 | + $scope[getModulo()].fob = undefined; | |
82 | + $scope[getModulo()].bomba = undefined; | |
83 | + $scope[getModulo()].kilometros = undefined; | |
84 | + | |
85 | + } | |
86 | + | |
87 | + var modalInstance = $uibModal.open( | |
88 | + { | |
89 | + ariaLabelledBy: 'Busqueda de Flete', | |
90 | + templateUrl: 'modal-flete.html', | |
91 | + controller: 'focaModalFleteController', | |
92 | + size: 'lg', | |
93 | + resolve: { | |
94 | + parametrosFlete: | |
95 | + function() { | |
96 | + return { | |
97 | + flete: $scope[getModulo()].fob ? 'FOB' : | |
98 | + ( $scope[getModulo()].flete ? '1' : | |
99 | + ($scope[getModulo()].flete === undefined ? | |
100 | + null : '0')), | |
101 | + bomba: $scope[getModulo()].bomba ? '1' : | |
102 | + ($scope[getModulo()].bomba === undefined ? | |
103 | + null : '0'), | |
104 | + kilometros: $scope[getModulo()].kilometros | |
105 | + }; | |
106 | + } | |
107 | + } | |
108 | + } | |
109 | + ); | |
110 | + modalInstance.result.then( | |
111 | + function(datos) { | |
112 | + $scope[getModulo()].flete = datos.flete; | |
113 | + $scope[getModulo()].fob = datos.FOB; | |
114 | + $scope[getModulo()].bomba = datos.bomba; | |
115 | + $scope[getModulo()].kilometros = datos.kilometros; | |
116 | + $scope.$broadcast('addCabecera', { | |
117 | + label: 'Flete:', | |
118 | + seccion: getModulo('label'), | |
119 | + valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') | |
120 | + }); | |
121 | + if (datos.flete) { | |
122 | + $scope.$broadcast('addCabecera', { | |
123 | + label: 'Bomba:', | |
124 | + seccion: getModulo('label'), | |
125 | + valor: datos.bomba ? 'Si' : 'No' | |
126 | + }); | |
127 | + $scope.$broadcast('addCabecera', { | |
128 | + label: 'Kilometros:', | |
129 | + seccion: getModulo('label'), | |
130 | + valor: datos.kilometros | |
131 | + }); | |
132 | + } else { | |
133 | + $scope.$broadcast('removeCabecera', 'Bomba:'); | |
134 | + $scope.$broadcast('removeCabecera', 'Kilometros:'); | |
135 | + $scope[getModulo()].bomba = false; | |
136 | + $scope[getModulo()].kilometros = null; | |
137 | + } | |
138 | + }, function() { | |
139 | + } | |
140 | + ); | |
141 | + }; | |
142 | + | |
143 | + $scope.seleccionarVendedor = function() { | |
144 | + | |
145 | + var parametrosModal = { | |
146 | + titulo: 'Búsqueda vendedores', | |
147 | + query: '/vendedor', | |
148 | + columnas: [ | |
149 | + { | |
150 | + propiedad: 'NUM', | |
151 | + nombre: 'Código', | |
152 | + filtro: { | |
153 | + nombre: 'rellenarDigitos', | |
154 | + parametro: 3 | |
155 | + } | |
156 | + }, | |
157 | + { | |
158 | + propiedad: 'NOM', | |
159 | + nombre: 'Nombre' | |
160 | + } | |
161 | + ], | |
162 | + size: 'md' | |
163 | + }; | |
164 | + focaModalService.modal(parametrosModal).then( | |
165 | + function(vendedor) { | |
166 | + $scope.$broadcast('addCabecera', { | |
167 | + label: 'Vendedor:', | |
168 | + seccion: getModulo('label'), | |
169 | + valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | |
170 | + vendedor.NOM | |
171 | + }); | |
172 | + $scope[getModulo()].vendedor = vendedor; | |
173 | + }, function() {} | |
174 | + ); | |
175 | + }; | |
176 | + | |
177 | + $scope.seleccionarCliente = function() { | |
178 | + | |
179 | + if (!$scope[getModulo()].vendedor) { | |
180 | + focaModalService.alert('Seleccione Vendedor'); | |
181 | + return; | |
182 | + } | |
183 | + | |
184 | + var modalInstance = $uibModal.open( | |
185 | + { | |
186 | + ariaLabelledBy: 'Busqueda de Cliente', | |
187 | + templateUrl: 'foca-busqueda-cliente-modal.html', | |
188 | + controller: 'focaBusquedaClienteModalController', | |
189 | + resolve: { | |
190 | + vendedor: function() { return $scope.notaPedido.vendedor; }, | |
191 | + cobrador: function() { return null; } | |
192 | + }, | |
193 | + size: 'lg' | |
194 | + } | |
195 | + ); | |
196 | + modalInstance.result.then( | |
197 | + function(cliente) { | |
198 | + $scope.abrirModalDomicilios(cliente); | |
199 | + }, function() { } | |
200 | + ); | |
201 | + }; | |
202 | + | |
203 | + $scope.seleccionarProveedor = function() { | |
204 | + | |
205 | + var parametrosModal = { | |
206 | + titulo: 'Búsqueda de Proveedor', | |
207 | + query: '/proveedor', | |
208 | + columnas: [ | |
209 | + { | |
210 | + nombre: 'Código', | |
211 | + propiedad: 'COD', | |
212 | + filtro: { | |
213 | + nombre: 'rellenarDigitos', | |
214 | + parametro: 5 | |
215 | + } | |
216 | + }, | |
217 | + { | |
218 | + nombre: 'Nombre', | |
219 | + propiedad: 'NOM' | |
220 | + }, | |
221 | + { | |
222 | + nombre: 'CUIT', | |
223 | + propiedad: 'CUIT' | |
224 | + } | |
225 | + ], | |
226 | + tipo: 'POST', | |
227 | + json: {razonCuitCod: ''} | |
228 | + }; | |
229 | + focaModalService.modal(parametrosModal).then( | |
230 | + function(proveedor) { | |
231 | + $scope[getModulo()].proveedor = proveedor; | |
232 | + $scope.$broadcast('addCabecera', { | |
233 | + label: 'Proveedor:', | |
234 | + seccion: getModulo('label'), | |
235 | + valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | |
236 | + proveedor.NOM | |
237 | + }); | |
238 | + }, function() { | |
239 | + } | |
240 | + ); | |
241 | + | |
242 | + }; | |
243 | + | |
244 | + $scope.abrirModalDomicilios = function(cliente) { | |
245 | + var modalInstanceDomicilio = $uibModal.open( | |
246 | + { | |
247 | + ariaLabelledBy: 'Busqueda de Domicilios', | |
248 | + templateUrl: 'modal-domicilio.html', | |
249 | + controller: 'focaModalDomicilioController', | |
250 | + resolve: { | |
251 | + idCliente: function() { return cliente.cod; }, | |
252 | + esNuevo: function() { return cliente.esNuevo; } | |
253 | + }, | |
254 | + size: 'lg', | |
255 | + } | |
256 | + ); | |
257 | + modalInstanceDomicilio.result.then( | |
258 | + function(domicilio) { | |
259 | + | |
260 | + $scope[getModulo()].domicilio = domicilio; | |
261 | + | |
262 | + $scope[getModulo()].cliente = { | |
263 | + COD: cliente.cod, | |
264 | + CUIT: cliente.cuit, | |
265 | + NOM: cliente.nom, | |
266 | + MOD: cliente.mod | |
267 | + }; | |
268 | + | |
269 | + var domicilioStamp = | |
270 | + domicilio.Calle + ' ' + domicilio.Numero + ', ' + | |
271 | + domicilio.Localidad + ', ' + domicilio.Provincia; | |
272 | + $scope[getModulo()].domicilioStamp = domicilioStamp; | |
273 | + | |
274 | + $scope[getModulo()].notaPedidoPuntoDescarga = domicilio.puntoDescarga; | |
275 | + | |
276 | + $scope.$broadcast('addCabecera', { | |
277 | + label: 'Cliente:', | |
278 | + seccion: getModulo('label'), | |
279 | + valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom | |
280 | + }); | |
281 | + $scope.$broadcast('addCabecera', { | |
282 | + label: 'Domicilio:', | |
283 | + seccion: getModulo('label'), | |
284 | + valor: domicilioStamp | |
285 | + }); | |
286 | + if (domicilio.verPuntos) { | |
287 | + delete $scope[getModulo()].domicilio.verPuntos; | |
288 | + $scope.seleccionarPuntosDeDescarga(); | |
289 | + } else { | |
290 | + focaParametrosService | |
291 | + .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | |
292 | + .then(function(res) { | |
293 | + if (res.data.length) $scope.seleccionarPuntosDeDescarga(); | |
294 | + }); | |
295 | + } | |
296 | + }, function() { | |
297 | + $scope.seleccionarCliente(true); | |
298 | + return; | |
299 | + } | |
300 | + ); | |
301 | + }; | |
302 | + | |
303 | + $scope.seleccionarMoneda = function() { | |
304 | + | |
305 | + var parametrosModal = { | |
306 | + titulo: 'Búsqueda de monedas', | |
307 | + query: '/moneda', | |
308 | + columnas: [ | |
309 | + { | |
310 | + propiedad: 'DETALLE', | |
311 | + nombre: 'Nombre' | |
312 | + }, | |
313 | + { | |
314 | + propiedad: 'SIMBOLO', | |
315 | + nombre: 'Símbolo' | |
316 | + } | |
317 | + ], | |
318 | + size: 'md' | |
319 | + }; | |
320 | + focaModalService.modal(parametrosModal).then( | |
321 | + function(moneda) { | |
322 | + $scope.abrirModalCotizacion(moneda); | |
323 | + }, function() { | |
324 | + } | |
325 | + ); | |
326 | + | |
327 | + }; | |
328 | + | |
329 | + $scope.abrirModalCotizacion = function(moneda) { | |
330 | + var modalInstance = $uibModal.open( | |
331 | + { | |
332 | + ariaLabelledBy: 'Busqueda de Cotización', | |
333 | + templateUrl: 'modal-cotizacion.html', | |
334 | + controller: 'focaModalCotizacionController', | |
335 | + size: 'lg', | |
336 | + resolve: { | |
337 | + idMoneda: function() { | |
338 | + return moneda.ID; | |
339 | + } | |
340 | + } | |
341 | + } | |
342 | + ); | |
343 | + modalInstance.result.then( | |
344 | + function(cotizacion) { | |
345 | + // var articulosTablaTemp = $scope.notaPedido.articulosNotaPedido || []; | |
346 | + // for (var i = 0; i < articulosTablaTemp.length; i++) { | |
347 | + // articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | |
348 | + // $scope.notaPedido.cotizacion.VENDEDOR; | |
349 | + // articulosTablaTemp[i].precio = (articulosTablaTemp[i].precio / | |
350 | + // cotizacion.VENDEDOR).toFixed(4); | |
351 | + // } | |
352 | + // $scope[getModulo()].articulosNotaPedido = articulosTablaTemp; | |
353 | + $scope[getModulo()].cotizacion = cotizacion; | |
354 | + $scope[getModulo()].cotizacion.moneda = moneda; | |
355 | + | |
356 | + $scope.$broadcast('addCabecera', { | |
357 | + label: 'Moneda:', | |
358 | + seccion: getModulo('label'), | |
359 | + valor: moneda.DETALLE | |
360 | + }); | |
361 | + $scope.$broadcast('addCabecera', { | |
362 | + label: 'Fecha cotizacion:', | |
363 | + seccion: getModulo('label'), | |
364 | + valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | |
365 | + }); | |
366 | + $scope.$broadcast('addCabecera', { | |
367 | + label: 'Cotizacion:', | |
368 | + seccion: getModulo('label'), | |
369 | + valor: $filter('number')(cotizacion.VENDEDOR, '2') | |
370 | + }); | |
371 | + | |
372 | + }, function() { | |
373 | + | |
374 | + } | |
375 | + ); | |
376 | + }; | |
377 | + | |
378 | + $scope.seleccionarObservaciones = function() { | |
379 | + var observacion = { | |
380 | + titulo: 'Ingrese Observaciones', | |
381 | + value: $scope[getModulo()].observaciones, | |
382 | + maxlength: 155, | |
383 | + textarea: true | |
384 | + }; | |
385 | + | |
386 | + focaModalService | |
387 | + .prompt(observacion) | |
388 | + .then(function(observaciones) { | |
389 | + $scope[getModulo()].observaciones = observaciones; | |
390 | + $scope.$broadcast('addCabecera', { | |
391 | + label: 'Observaciones:', | |
392 | + valor: observaciones | |
393 | + }); | |
394 | + }); | |
395 | + }; | |
396 | + | |
397 | + $scope.$watch('botonera', function() { | |
398 | + | |
399 | + // Creo el string en donde guardo el objeto parseado | |
400 | + $scope[getModulo()] = $scope[getModulo()] || {}; | |
401 | + | |
402 | + getCheckeds(); | |
403 | + }, true); | |
404 | + | |
405 | + $scope.botoneraPrincipal.forEach(function(botonPincipal) { | |
406 | + | |
407 | + // watch en objetos principales para ir guardando los valores | |
408 | + $scope.$watch(botonPincipal.variable, function() { | |
409 | + | |
410 | + $scope[botonPincipal.variable + 'String'] = { | |
411 | + jsonText: JSON.stringify($scope[botonPincipal.variable]), | |
412 | + modulo: botonPincipal.variable, | |
413 | + id: $scope[botonPincipal.variable] ? | |
414 | + $scope[botonPincipal.variable].id : null | |
415 | + }; | |
416 | + | |
417 | + getCheckeds(); | |
418 | + }, true); | |
419 | + | |
420 | + // creo las funciones para seleccionar boton principal | |
421 | + $scope[nombreFuncion(botonPincipal.label)] = function() { | |
422 | + | |
423 | + $scope.botoneraPrincipal.filter(function(boton) { | |
424 | + boton.checked = false; | |
425 | + }); | |
426 | + | |
427 | + botonPincipal.checked = true; | |
428 | + $scope.botonera = focaParametrosService.getBotones(botonPincipal.modulo); | |
429 | + }; | |
430 | + | |
431 | + }); | |
432 | + | |
433 | + function nombreFuncion(string) { | |
434 | + var texto = 'seleccionar'; | |
435 | + var arr = string.split(' '); | |
436 | + arr.forEach(function(palabra) { | |
437 | + palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); | |
438 | + texto += palabra; | |
439 | + }); | |
440 | + return texto; | |
441 | + } | |
442 | + | |
443 | + function getModulo(propiedad) { | |
444 | + var nombre = ''; | |
445 | + | |
446 | + $scope.botoneraPrincipal.filter(function(boton) { | |
447 | + if (boton.checked) { | |
448 | + if(!propiedad) { | |
449 | + nombre = boton.variable; | |
450 | + } else { | |
451 | + nombre = boton[propiedad]; | |
452 | + } | |
453 | + } | |
454 | + }); | |
455 | + return nombre; | |
456 | + } | |
457 | + | |
458 | + function getCheckeds() { | |
459 | + | |
460 | + $scope.botonera.forEach(function(boton) { | |
461 | + | |
462 | + if ($scope[getModulo()][boton.variable] !== undefined) { | |
463 | + | |
464 | + boton.checked = true; | |
465 | + | |
466 | + //Creo la función para limpiar obj | |
467 | + $scope['clean' + boton.variable] = function() { | |
468 | + | |
469 | + focaModalService.alert('Esta seguro que desea eliminar el parámetro?') | |
470 | + .then(function() { | |
471 | + delete $scope[getModulo()][boton.variable]; | |
472 | + $scope.$broadcast('cleanCabecera', { | |
473 | + seccion: getModulo('label') | |
474 | + }); | |
475 | + setearEntidad({ | |
476 | + jsonText: JSON.stringify($scope[getModulo()]), | |
477 | + modulo: getModulo(), | |
478 | + id: $scope[getModulo()].id | |
479 | + }); | |
480 | + }); | |
481 | + }; | |
482 | + | |
483 | + } else { | |
484 | + boton.checked = false; | |
485 | + } | |
486 | + }); | |
487 | + } | |
488 | + | |
489 | + function getCabeceraPuntoDescarga(puntoDescarga) { | |
490 | + var puntosStamp = ''; | |
491 | + puntoDescarga.forEach(function(punto, idx, arr) { | |
492 | + puntosStamp += punto.descripcion; | |
493 | + if ((idx + 1) !== arr.length) puntosStamp += ', '; | |
494 | + }); | |
495 | + return puntosStamp; | |
496 | + } | |
497 | + | |
498 | + function setearEntidad(entidad) { | |
499 | + | |
500 | + $scope[entidad.modulo] = JSON.parse(entidad.jsonText) || {}; | |
501 | + $scope[entidad.modulo].id = entidad.id; | |
502 | + | |
503 | + if (!$scope[entidad.modulo].domicilio) { | |
504 | + $scope[entidad.modulo].domicilio = { | |
505 | + id: $scope[entidad.modulo].idDomicilio | |
506 | + }; | |
507 | + } | |
508 | + | |
509 | + var cabeceras = []; | |
510 | + | |
511 | + if ($scope[entidad.modulo].cotizacion && | |
512 | + $scope[entidad.modulo].cotizacion.moneda.CODIGO_AFIP !== 'PES') | |
513 | + { | |
514 | + cabeceras.push({ | |
515 | + label: 'Moneda:', | |
516 | + valor: $scope[entidad.modulo].cotizacion.moneda.DETALLE | |
517 | + }); | |
518 | + cabeceras.push({ | |
519 | + label: 'Fecha cotizacion:', | |
520 | + valor: $filter('date')($scope[entidad.modulo].cotizacion.FECHA, | |
521 | + 'dd/MM/yyyy') | |
522 | + }); | |
523 | + cabeceras.push({ | |
524 | + label: 'Cotizacion:', | |
525 | + valor: $filter('number')($scope[entidad.modulo].cotizacion.VENDEDOR, | |
526 | + '2') | |
527 | + }); | |
528 | + } | |
529 | + | |
530 | + if ($scope[entidad.modulo].vendedor && $scope[entidad.modulo].vendedor.NUM) { | |
531 | + cabeceras.push({ | |
532 | + label: 'Vendedor:', | |
533 | + valor: $filter('rellenarDigitos')($scope[entidad.modulo].vendedor.NUM, 3) + | |
534 | + ' - ' + $scope[entidad.modulo].vendedor.NOM | |
535 | + }); | |
536 | + } | |
537 | + | |
538 | + if ($scope[entidad.modulo].cliente && $scope[entidad.modulo].cliente.COD) { | |
539 | + cabeceras.push({ | |
540 | + label: 'Cliente:', | |
541 | + valor: $scope[entidad.modulo].cliente.NOM | |
542 | + }); | |
543 | + cabeceras.push({ | |
544 | + label: 'Domicilio:', | |
545 | + valor: $scope[entidad.modulo].domicilioStamp | |
546 | + }); | |
547 | + } | |
548 | + | |
549 | + if ($scope[entidad.modulo].proveedor && $scope[entidad.modulo].proveedor.COD) { | |
550 | + cabeceras.push({ | |
551 | + label: 'Proveedor:', | |
552 | + valor: $filter('rellenarDigitos')($scope[entidad.modulo].proveedor.COD, 5) + | |
553 | + ' - ' + $scope[entidad.modulo].proveedor.NOM | |
554 | + }); | |
555 | + } | |
556 | + | |
557 | + if ($scope[entidad.modulo][entidad + 'Plazo'] && | |
558 | + $scope[entidad.modulo][entidad + 'Plazo'].length) | |
559 | + { | |
560 | + cabeceras.push({ | |
561 | + label: 'Precios y condiciones:', | |
562 | + valor: valorPrecioCondicion() + ' ' + | |
563 | + focaParametrosService.plazoToString( | |
564 | + $scope[entidad.modulo][entidad.modulo + 'Plazo']) | |
565 | + }); | |
566 | + } | |
567 | + | |
568 | + if ($scope[entidad.modulo].flete !== undefined) { | |
569 | + cabeceras.push({ | |
570 | + label: 'Flete:', | |
571 | + valor: $scope[entidad.modulo].fob === 1 ? 'FOB' : ( | |
572 | + $scope[entidad.modulo].flete === 1 ? 'Si' : 'No') | |
573 | + }); | |
574 | + } | |
575 | + | |
576 | + function valorPrecioCondicion() { | |
577 | + if ($scope[entidad.modulo].idPrecioCondicion > 0) { | |
578 | + return $scope[entidad.modulo].precioCondicion.nombre; | |
579 | + } else { | |
580 | + return 'Ingreso Manual'; | |
581 | + } | |
582 | + } | |
583 | + | |
584 | + if ($scope[entidad.modulo].flete === 1) { | |
585 | + var cabeceraBomba = { | |
586 | + label: 'Bomba:', | |
587 | + valor: $scope[entidad.modulo].bomba === 1 ? 'Si' : 'No' | |
588 | + }; | |
589 | + if ($scope[entidad.modulo].kilometros) { | |
590 | + var cabeceraKilometros = { | |
591 | + label: 'Kilometros:', | |
592 | + valor: $scope[entidad.modulo].kilometros | |
593 | + }; | |
594 | + cabeceras.push(cabeceraKilometros); | |
595 | + } | |
596 | + cabeceras.push(cabeceraBomba); | |
597 | + } | |
598 | + | |
599 | + if ($scope[entidad.modulo].idPrecioCondicion > 0) { | |
600 | + $scope.idLista = $scope[entidad.modulo].precioCondicion.idListaPrecio; | |
601 | + } else { | |
602 | + $scope.idLista = -1; | |
603 | + } | |
604 | + | |
605 | + if ($scope[entidad.modulo][entidad.modulo + 'PuntoDescarga']) { | |
606 | + var puntos = []; | |
607 | + $scope[entidad.modulo][entidad + 'PuntoDescarga'] | |
608 | + .forEach(function(entidadPuntoDescarga) { | |
609 | + puntos.push(entidadPuntoDescarga); | |
610 | + }); | |
611 | + cabeceras.push({ | |
612 | + label: 'Puntos de descarga: ', | |
613 | + valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) | |
614 | + }); | |
615 | + } | |
616 | + | |
617 | + addArrayCabecera(cabeceras, entidad.modulo); | |
618 | + | |
619 | + } | |
620 | + | |
621 | + function addArrayCabecera(array, entidad) { | |
622 | + for (var i = 0; i < array.length; i++) { | |
623 | + $scope.$broadcast('addCabecera', { | |
624 | + label: array[i].label, | |
625 | + valor: array[i].valor, | |
626 | + seccion: $filter('filter') | |
627 | + ($scope.botoneraPrincipal, {variable: entidad}, true)[0].label | |
628 | + }); | |
629 | + } | |
630 | + } | |
631 | + | |
632 | + function getObjGuardar() { | |
633 | + var guardar = []; | |
634 | + $scope.botoneraPrincipal.forEach(function(botonPincipal) { | |
635 | + if (!botonPincipal || !$scope[botonPincipal.variable + 'String']) return; | |
636 | + guardar.push($scope[botonPincipal.variable + 'String']); | |
637 | + }); | |
638 | + | |
639 | + return guardar; | |
640 | + } | |
641 | + | |
642 | + }]); |
src/js/route.js
src/js/service.js
... | ... | @@ -0,0 +1,94 @@ |
1 | +angular.module('focaParametros') | |
2 | + .factory('focaParametrosService', ['$http', 'API_ENDPOINT', function ($http, API_ENDPOINT) { | |
3 | + return { | |
4 | + getNotasPedido: function (fechaDesde, fechaHasta) { | |
5 | + return $http.get(API_ENDPOINT.URL + '/nota-pedido/listar/' + fechaDesde + '/' + | |
6 | + fechaHasta + '/sin-remito'); | |
7 | + }, | |
8 | + getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { | |
9 | + return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + | |
10 | + idDomicilio + '/' + idCliente); | |
11 | + }, | |
12 | + saveParametros: function(parametros) { | |
13 | + return $http.post(API_ENDPOINT.URL + '/parametros', parametros); | |
14 | + }, | |
15 | + getParametros: function() { | |
16 | + return $http.get(API_ENDPOINT.URL + '/parametros'); | |
17 | + }, | |
18 | + plazoToString: function(plazos) { | |
19 | + | |
20 | + var result = ''; | |
21 | + | |
22 | + for(var i = 0; i < plazos.length; i++) { | |
23 | + result += plazos[i].dias + ' '; | |
24 | + } | |
25 | + | |
26 | + return result.trim(); | |
27 | + }, | |
28 | + getBotones: function (modulo) { | |
29 | + var botones = [ | |
30 | + { | |
31 | + label: 'Vendedor', | |
32 | + variable: 'vendedor', | |
33 | + image: 'vendedor.png', | |
34 | + modulo: [1, 2] | |
35 | + }, | |
36 | + { | |
37 | + label: 'Cliente', | |
38 | + image: 'cliente.png', | |
39 | + variable: 'cliente', | |
40 | + modulo: [1, 2] | |
41 | + }, | |
42 | + { | |
43 | + label: 'Proveedor', | |
44 | + image: 'proveedor.png', | |
45 | + variable: 'proveedor', | |
46 | + modulo: [1, 2] | |
47 | + }, | |
48 | + { | |
49 | + label: 'Flete', | |
50 | + image: 'flete.png', | |
51 | + variable: 'flete', | |
52 | + modulo: [1, 2] | |
53 | + }, | |
54 | + { | |
55 | + label: 'Moneda', | |
56 | + image: 'moneda.png', | |
57 | + variable: 'cotizacion', | |
58 | + modulo: [1, 2] | |
59 | + }, | |
60 | + { | |
61 | + label: 'Precios y condiciones', | |
62 | + image: 'precios-condiciones.png', | |
63 | + modulo: [1, 2] | |
64 | + }, | |
65 | + { | |
66 | + label: 'Observaciones', | |
67 | + image: 'botonObservaciones.png', | |
68 | + variable: 'observaciones', | |
69 | + modulo: [1] | |
70 | + } | |
71 | + ]; | |
72 | + | |
73 | + // Devuelvo solo los botones correspondietes | |
74 | + // Modulo 1 = nota de pedido, 2 remito, 3 ambos | |
75 | + return botones.filter(function (p) { | |
76 | + return p.modulo.includes(modulo); | |
77 | + }); | |
78 | + }, | |
79 | + getBotonesPrincipal: [ | |
80 | + { | |
81 | + label: 'Nota de Pedido', | |
82 | + image: 'notaPedido.png', | |
83 | + modulo: 1, | |
84 | + variable: 'notaPedido' | |
85 | + }, | |
86 | + { | |
87 | + label: 'Remito', | |
88 | + image: 'remito.png', | |
89 | + modulo: 2, | |
90 | + variable: 'remito' | |
91 | + } | |
92 | + ] | |
93 | + }; | |
94 | + }]); |
src/views/foca-parametros.html
... | ... | @@ -0,0 +1,21 @@ |
1 | +<div class="row"> | |
2 | + <foca-cabecera-facturador | |
3 | + titulo="'Parametros'" | |
4 | + fecha="now" | |
5 | + class="mb-0 col-lg-12" | |
6 | + ></foca-cabecera-facturador> | |
7 | +</div> | |
8 | +<div class="col-10"> | |
9 | + | |
10 | + <div class="row py-2 botonera-secundaria border border-light rounded mb-5"> | |
11 | + <div class="col-12 foca-facturador-px"> | |
12 | + <foca-botonera-facturador botones="botoneraPrincipal" max="6" class="row"></foca-botonera-facturador> | |
13 | + </div> | |
14 | + </div> | |
15 | + | |
16 | + <div class="row py-2 botonera-secundaria border border-light rounded"> | |
17 | + <div class="col-12 foca-facturador-px"> | |
18 | + <foca-botonera-facturador botones="botonera" max="18" class="row"></foca-botonera-facturador> | |
19 | + </div> | |
20 | + </div> | |
21 | +</div> |