Commit 844610fb5768738fb98f08fae49e1f30467cb210

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'master'

Master

See merge request !1
File was created 1 /node_modules
2 /dist
3 /tmp
4 package-lock\.json
5 src/etc/develop.js
6
File was created 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 }
65
File was created 1 const templateCache = require('gulp-angular-templatecache');
2 const concat = require('gulp-concat');
3 const htmlmin = require('gulp-htmlmin');
4 const rename = require('gulp-rename');
5 const uglify = require('gulp-uglify-es').default;
6 const gulp = require('gulp');
7 const pump = require('pump');
8 const jshint = require('gulp-jshint');
9 const replace = require('gulp-replace');
10 const connect = require('gulp-connect');
11 const clean = require('gulp-clean');
12 const header = require('gulp-header');
13 const footer =require('gulp-footer');
14
15 var paths = {
16 srcJS: 'src/js/*.js',
17 srcViews: 'src/views/*.html',
18 specs: 'spec/*.js',
19 tmp: 'tmp',
20 dist: 'dist/'
21 };
22
23 gulp.task('templates', function() {
24 return pump(
25 [
26 gulp.src(paths.srcViews),
27 replace('views/', ''),
28 htmlmin(),
29 templateCache('views.js', {
30 module: 'focaAbmCliente',
31 root: ''
32 }),
33 gulp.dest(paths.tmp)
34 ]
35 );
36 });
37
38 gulp.task('uglify', ['templates', 'uglify-spec'], function() {
39 return pump(
40 [
41 gulp.src([
42 paths.srcJS,
43 'tmp/views.js'
44 ]),
45 concat('foca-abm-cliente.js'),
46 replace("src/views/", ''),
47 gulp.dest(paths.tmp),
48 rename('foca-abm-cliente.min.js'),
49 uglify(),
50 gulp.dest(paths.dist)
51 ]
52 );
53 });
54
55 gulp.task('uglify-spec', function() {
56 return pump([
57 gulp.src(paths.specs),
58 concat('foca-abm-cliente.spec.js'),
59 replace("src/views/", ''),
60 header("describe('Módulo foca-abm-cliente', function() { \n"),
61 footer("});"),
62 gulp.dest(paths.dist)
63 ]);
64 });
65
66 gulp.task('clean', function() {
67 return gulp.src(['tmp', 'dist'], {read: false})
68 .pipe(clean());
69 });
70
71 gulp.task('pre-commit', function() {
72 pump(
73 [
74 gulp.src([paths.srcJS, paths.specs]),
75 jshint('.jshintrc'),
76 jshint.reporter('default'),
77 jshint.reporter('fail')
78 ]
79 );
80
81 gulp.start('uglify');
82 });
83
84 gulp.task('clean-post-install', function() {
85 return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js',
86 'index.html', 'spec', 'test.html'], {read: false})
87 .pipe(clean());
88 });
89
90 gulp.task('compile', ['templates', 'uglify']);
91
92 gulp.task('watch', function() {
93 gulp.watch([paths.srcJS, paths.srcViews], ['uglify']);
94 });
95
96 gulp.task('webserver', function() {
97 pump [
98 connect.server({port: 3000})
99 ]
100 });
101
102 gulp.task('default', ['webserver']);
103
File was created 1 {
2 "name": "foca-abm-cliente",
3 "version": "0.0.1",
4 "description": "Abm de cliente",
5 "main": "index.html",
6 "scripts": {
7 "test": "test.html",
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 angular bootstrap ui-bootstrap4 font-awesome jquery gulp gulp-connect jasmine-core pre-commit gulp-angular-templatecache gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-uglify gulp-clean jshint pump git+http://git.focasoftware.com/npm/foca-modal.git"
12 },
13 "pre-commit": [
14 "gulp-pre-commit"
15 ],
16 "repository": {
17 "type": "git",
18 "url": "http://git.focasoftware.com/npm/foca-abm-cliente.git"
19 },
20 "author": "Foca Software",
21 "license": "ISC",
22 "peerDependencies": {
23 "angular": "^1.7.x",
24 "angular-route": "^1.7.x",
25 "bootstrap": "^4.1.x",
26 "jquery": "^3.3.x",
27 "font-awesome": "^4.7.x",
28 "gulp": "^3.9.x",
29 "gulp-concat": "2.6.x",
30 "gulp-jshint": "^2.1.x",
31 "gulp-rename": "^1.4.x",
32 "gulp-replace": "^1.0.x",
33 "gulp-uglify-es": "^1.0.x",
34 "jshint": "^2.9.x",
35 "pump": "^3.0.x"
36 },
37 "devDependencies": {
38 "angular": "^1.7.8",
39 "angular-mocks": "^1.7.8",
40 "angular-route": "^1.7.8",
41 "bootstrap": "^4.2.1",
42 "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git",
43 "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git",
44 "font-awesome": "^4.7.0",
45 "gulp": "^3.9.1",
46 "gulp-angular-templatecache": "^2.2.7",
47 "gulp-clean": "^0.4.0",
48 "gulp-connect": "^5.7.0",
49 "gulp-header": "^2.0.7",
50 "gulp-htmlmin": "^5.0.1",
51 "gulp-jshint": "^2.1.0",
52 "gulp-rename": "^1.4.0",
53 "gulp-replace": "^1.0.0",
54 "gulp-uglify": "^3.0.1",
55 "gulp-uglify-es": "^1.0.4",
56 "jasmine-core": "^3.4.0",
57 "jquery": "^3.4.1",
58 "jshint": "^2.10.2",
59 "pre-commit": "^1.2.2",
60 "pump": "^3.0.0",
61 "ui-bootstrap4": "^3.0.6"
62 }
63 }
64
src/etc/develop.js.ejemplo
File was created 1 angular.module('focaAbmCliente')
2 .constant("API_ENDPOINT", {
3 'URL': '//127.0.0.1:9000'
4 });
5
File was created 1 angular.module('focaAbmCliente', ['ngRoute']);
2
src/js/controller.js
File was created 1 angular.module('focaAbmCliente')
2 .controller('focaAbmClienteController', [
3 '$scope', 'focaBotoneraLateralService', '$timeout', '$uibModal','focaModalService',
4 'focaAbmClienteService','$filter',
5 function($scope, focaBotoneraLateralService, $timeout, $uibModal,focaModalService,
6 focaAbmClienteService, $filter) {
7 $scope.cliente= {
8 NOM: undefined,
9 COD: undefined
10 };
11 $scope.vendedor = {};
12
13 $scope.botonCliente = [{
14 label: 'Cliente',
15 image: 'cliente.png'
16 }];
17
18 $scope.botonera = [
19 {
20 label: 'Datos Cliente',
21 image: 'datoscliente.png',
22 },
23 {
24 label: 'Domicilios de entrega',
25 image: 'dimiciliodeentrega.png'
26 },
27 {
28 label: 'Precio y Condiciones',
29 image: 'precios-condiciones.png'
30 }
31 ];
32
33 //SETEO BOTONERA LATERAL
34 $timeout(function() {
35 focaBotoneraLateralService.showSalir(true);
36 focaBotoneraLateralService.showPausar(false);
37 focaBotoneraLateralService.showCancelar(false);
38 focaBotoneraLateralService.showGuardar(false);
39 });
40
41 $scope.seleccionarCliente = function() {
42 var datos = null;
43 focaAbmClienteService.getAllClientes()
44 .then(function (res) {
45 datos = res.data;
46 focaModalService.modal({
47 titulo: 'Clientes',
48 data: datos,
49 size: 'md',
50 columnas: [
51 {
52 propiedad: 'COD',
53 nombre: 'Codigo'
54 },
55 {
56 propiedad: 'NOM',
57 nombre: 'Nombre'
58 },
59 {
60 propiedad: 'CUIT',
61 nombre: 'CUIT'
62 }
63 ],
64 }).then(function (res) {
65 $scope.cliente.NOM = res.NOM;
66 $scope.cliente.COD = res.COD;
67 $scope.$broadcast('addCabecera', {
68 label: 'Cliente:',
69 valor: $filter('rellenarDigitos')
70 ($scope.cliente.COD, 5) + ' - ' + $scope.cliente.NOM
71 });
72 }).catch(function (e) {
73 console.log(e);
74 });
75 });
76 };
77
78 $scope.seleccionarDatosCliente = function () {
79 if ($scope.cliente.NOM === undefined || $scope.cliente.COD === undefined) {
80 focaModalService.alert('Seleccione cliente');
81 return;
82 } else {
83 var modalInstanceCliente = $uibModal.open(
84 {
85 ariaLabelledBy: '',
86 templateUrl: 'foca-modal-cliente.html',
87 controller: 'focaModalClienteController',
88 resolve: {
89 idCliente: function () { return $scope.cliente.COD; },
90 },
91 size: 'lg',
92 }
93 );
94 modalInstanceCliente.result
95 .then( function(data) {
96 if (data) {
97 $scope.cliente.NOM = data.NOM;
98 $scope.$broadcast('cleanCabecera');
99 $scope.$broadcast('addCabecera', {
100 label: 'Cliente:',
101 valor: $filter('rellenarDigitos')($scope.cliente.NOM)
102 });
103 }
104 });
105 }
106 };
107
108 $scope.seleccionarDomiciliosDeEntrega = function () {
109 if ($scope.cliente.NOM === undefined || $scope.cliente.COD === undefined) {
110 focaModalService.alert('Seleccione un cliente');
111 return;
112 }
113 var modalInstanceDomicilio = $uibModal.open(
114 {
115 ariaLabelledBy: 'Busqueda de Domicilios',
116 templateUrl: 'modal-domicilio.html',
117 controller: 'focaModalDomicilioController',
118 resolve: {
119 idCliente: function () { return $scope.cliente.COD; },
120 esNuevo: function () { return $scope.cliente.esNuevo; }
121 },
122 size: 'lg',
123 }
124 );
125 modalInstanceDomicilio.result.then( function(data) {
126 if (data) {
127 $scope.$broadcast('addCabecera', {
128 label: 'Domicilio:',
129 valor: data.Calle + ' ' + data.Numero + ' - ' + data.Localidad +
130 ' - ' + data.Provincia
131 });
132 }
133 });
134 };
135
136 $scope.seleccionarPrecioYCondiciones = function () {
137
138 if ($scope.cliente.NOM === undefined || $scope.cliente.COD === undefined) {
139 focaModalService.alert('Seleccione cliente');
140 return;
141 }
142 var modalInstance = $uibModal.open(
143 {
144 ariaLabelledBy: 'Busqueda de Precio Condición',
145 templateUrl: 'modal-precio-condicion.html',
146 controller: 'focaModalPrecioCondicionController',
147 size: 'lg',
148 resolve: {
149 idListaPrecio: function () {
150 return $scope.cliente.MOD || null;
151 }
152 }
153 }
154 );
155
156 modalInstance.result.then( function (data) {
157 if (data) {
158 console.log('Data: ', data);
159 }
160
161 }, function () {
162
163 }
164 );
165 };
166
167
168 }
169 ]);
170
src/js/controllerCliente.js
File was created 1 angular.module('focaAbmCliente')
2 .controller('focaModalClienteController', [
3 '$scope', '$timeout', '$uibModalInstance', 'focaModalService',
4 'focaAbmClienteService', 'idCliente',
5 function ($scope, $timeout, $uibModalInstance, focaModalService,
6 focaAbmClienteService, idCliente) {
7 $scope.cliente = {
8 provincia: {},
9 localidad: {},
10 zona: {},
11 actividad: {},
12 cobrador: {},
13 vendedor: {},
14 iva: {},
15 tipoFactura: {},
16 tipoComprobante: {},
17 formaPago: {}
18 };
19 $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/);
20 $scope.vendedor = {};
21
22 focaAbmClienteService.obtenerClientePorCodigo(idCliente)
23 .then(function (res) {
24 var data = res.data[0];
25 $scope.cliente.codigo = data.COD;
26 $scope.cliente.DOM = data.DOM;
27 $scope.cliente.NOM = data.NOM;
28 $scope.cliente.CPO = data.CPO;
29 $scope.cliente.provincia.ID = data.PCX;
30 $scope.cliente.provincia.NOMBRE = data.PCI;
31 $scope.cliente.localidad.ID = data.LOX;
32 $scope.cliente.localidad.NOMBRE = data.LOC;
33 $scope.cliente.zona.ID = data.zona.ID;
34 $scope.cliente.zona.NOM = data.zona.NOM;
35 $scope.cliente.actividad.NOM = data.actividad.NOM;
36 $scope.cliente.actividad.ID = data.actividad.ID;
37 $scope.cliente.cobrador.NOM = data.cobrador ? data.cobrador.NOM : '';
38 $scope.cliente.cobrador.NUM = data.cobrador ? data.cobrador.NUM : undefined;
39 $scope.cliente.cobrador.ID = data.cobrador ? data.cobrador.id : undefined;
40 $scope.vendedor.NOM = data.vendedor.NOM;
41 $scope.vendedor.id = data.vendedor.id;
42 $scope.cliente.MAIL = data.MAIL;
43 $scope.cliente.TEL = data.TEL;
44 $scope.cliente.iva.NOMBRE = data.iva.NOMBRE;
45 $scope.cliente.tipoFactura.NOMBRE = data.tipoFactura.NOMBRE;
46 $scope.cliente.tipoFactura.ID = data.tipoFactura.ID;
47 var cuit = data.CUIT.split('-');
48 $scope.cliente.cuit1 = cuit[0];
49 $scope.cliente.cuit2 = cuit[1];
50 $scope.cliente.cuit3 = cuit[2];
51 $scope.cliente.tipoComprobante.NOMBRE = data.tipoComprobante.NOMBRE;
52 $scope.cliente.tipoComprobante.ID = data.tipoComprobante.ID;
53 $scope.cliente.formaPago.NOMBRE = data.formaPago.NOMBRE;
54 $scope.cliente.formaPago.ID = data.formaPago.ID;
55 $scope.cliente.ES_PROS = data.ES_PROS;
56 $scope.cliente.ES_MAY = data.ES_MAY;
57 $scope.editando = true;
58 })
59 .catch(function (e) { console.log(e); });
60
61 $scope.cancel = function () {
62 $uibModalInstance.dismiss('cancel');
63 };
64
65 $scope.guardar = function () {
66 if (!$scope.cliente.NOM) {
67 focaModalService.alert('Ingrese Nombre');
68 return;
69 } else if (!$scope.cliente.CPO) {
70 focaModalService.alert('Ingrese Codigo Postal');
71 return;
72 } else if (!$scope.cliente.provincia.NOMBRE) {
73 focaModalService.alert('Seleccione una provincia');
74 return;
75 } else if (!$scope.cliente.DOM) {
76 focaModalService.alert('Ingrese Domicilio');
77 return;
78 } else if (!$scope.cliente.localidad.NOMBRE) {
79 focaModalService.alert('Seleccione una localidad');
80 return;
81 } else if (!$scope.cliente.zona.NOM) {
82 focaModalService.alert('Seleccione una zona');
83 return;
84 } else if (!$scope.cliente.actividad.NOM) {
85 focaModalService.alert('Seleccione actividad');
86 return;
87 } else if (!$scope.cliente.cobrador.NUM) {
88 focaModalService.alert('Seleccione un cobrador');
89 return;
90 } else if (!$scope.vendedor.NOM) {
91 focaModalService.alert('Seleccione un vendedor');
92 return;
93 } else if ($scope.cliente.MAIL && !validateEmails($scope.cliente.MAIL)) {
94 focaModalService.alert('Ingrese un formato de email válido');
95 return;
96 } else if (!$scope.cliente.TEL) {
97 focaModalService.alert('Ingrese un numero de telefono');
98 return;
99 } else if (!$scope.cliente.iva.NOMBRE) {
100 focaModalService.alert('Seleccione responsabilidad ante el IVA');
101 return;
102 } else if (!$scope.cliente.tipoFactura.NOMBRE) {
103 focaModalService.alert('Seleccione tipo de Factura');
104 return;
105 } else if (!$scope.cliente.cuit1 && !$scope.cliente.cuit2 && !$scope.cliente.cuit3) {
106 focaModalService.alert('Ingrese CUIT');
107 return;
108 } else if (!$scope.cliente.cuit1 || !$scope.cliente.cuit2 || !$scope.cliente.cuit3) {
109 focaModalService.alert('Ingrese CUIT válido');
110 return;
111 } else if (!$scope.regexCuit.test($scope.cliente.cuit1 + $scope.cliente.cuit2 + $scope.cliente.cuit3)) {
112 focaModalService.alert('Ingrese CUIT con formato: XX-XXXXXXXX-X');
113 return;
114 } else if (!$scope.cliente.tipoComprobante.NOMBRE) {
115 focaModalService.alert('Seleccione un Comprobante');
116 return;
117 } else if (!$scope.cliente.formaPago.NOMBRE) {
118 focaModalService.alert('Seleccione una forma de pago');
119 return;
120 }
121 $scope.cliente.actividad.ID = parseInt($scope.cliente.actividad.ID);
122 var cliente = crearCopia();
123 focaAbmClienteService
124 .guardarCliente(cliente)
125 .then(function () {
126 $uibModalInstance.close(cliente);
127 })
128 .catch(function (e) {
129 console.log(e);
130 });
131 };
132 $scope.seleccionarProvincia = function (key) {
133 if (key === 13) {
134 var parametrosModal = {
135 searchText: $scope.cliente.provincia.NOMBRE,
136 query: '/provincia',
137 columnas: [
138 {
139 propiedad: 'ID',
140 nombre: 'Codigo',
141 filtro: {
142 nombre: 'rellenarDigitos',
143 parametro: 3
144 }
145 },
146 {
147 propiedad: 'NOMBRE',
148 nombre: 'Nombre'
149 }
150 ],
151 titulo: 'Búsqueda de provincias',
152 size: 'md'
153 };
154 focaModalService.modal(parametrosModal).then(function (provincia) {
155 $scope.cliente.provincia = provincia;
156 $timeout(function () {
157 $scope.focused = 4;
158 });
159 }, function () {
160 //TODO: función llamada cuando cancela el modal
161 });
162 }
163 };
164 $scope.seleccionarLocalidad = function (key) {
165 if ($scope.cliente.provincia.ID === undefined) {
166 focaModalService.alert('Seleccione una provincia');
167 return;
168 }
169 if (key === 13) {
170 var parametrosModal = {
171 searchText: $scope.cliente.localidad.NOMBRE,
172 query: '/localidad/' + parseInt($scope.cliente.provincia.ID),
173 columnas: [
174 {
175 propiedad: 'ID',
176 nombre: 'Código',
177 },
178 {
179 propiedad: 'NOMBRE',
180 nombre: 'Nombre'
181 }
182 ],
183 titulo: 'Búsqueda de localidades',
184 size: 'md'
185 };
186 focaModalService.modal(parametrosModal).then(function (localidad) {
187 $scope.cliente.localidad = localidad;
188 $timeout(function () {
189 $scope.focused = 5;
190 });
191 }, function () {
192 //TODO: función llamada cuando cancela el modal
193 });
194 }
195 };
196 $scope.seleccionarZona = function (key) {
197 if (key === 13) {
198 var parametrosModal = {
199 searchText: $scope.cliente.zona.NOM,
200 query: '/zona',
201 columnas: [
202 {
203 propiedad: 'ID',
204 nombre: 'Código',
205 filtro: {
206 nombre: 'rellenarDigitos',
207 parametro: 3
208 }
209 },
210 {
211 propiedad: 'NOM',
212 nombre: 'Nombre'
213 }
214 ],
215 titulo: 'Búsqueda de zonas',
216 size: 'md'
217 };
218 focaModalService.modal(parametrosModal).then(
219 function (zona) {
220 $scope.cliente.zona = zona;
221 $timeout(function () {
222 $scope.focused = 6;
223 });
224 }, function () {
225 // funcion ejecutada cuando se cancela el modal
226 });
227 }
228 };
229 $scope.seleccionarActividad = function (key) {
230 if (key === 13) {
231 var parametrosModal = {
232 searchText: $scope.cliente.actividad.NOM,
233 query: '/actividad',
234 columnas: [
235 {
236 propiedad: 'ID',
237 nombre: 'Código',
238 filtro: {
239 nombre: 'rellenarDigitos',
240 parametro: 3
241 }
242 },
243 {
244 propiedad: 'NOM',
245 nombre: 'Nombre'
246 }
247 ],
248 titulo: 'Búsqueda de actividades',
249 size: 'md'
250 };
251 focaModalService.modal(parametrosModal).then(
252 function (actividad) {
253 $scope.cliente.actividad = actividad;
254 $timeout(function () {
255 $scope.focused = 7;
256 });
257 }, function () {
258 // funcion ejecutada cuando se cancela el modal
259 });
260 }
261 };
262 $scope.seleccionarCobrador = function (key) {
263 if (key === 13) {
264 var parametrosModal = {
265 searchText: $scope.cliente.cobrador.NOM,
266 query: '/cobrador',
267 columnas: [
268 {
269 propiedad: 'NUM',
270 nombre: 'Código'
271 },
272 {
273 propiedad: 'NOM',
274 nombre: 'Nombre'
275 }
276 ],
277 titulo: 'Búsqueda de cobradores',
278 size: 'md'
279 };
280 focaModalService.modal(parametrosModal).then(
281 function (cobrador) {
282 $scope.cliente.cobrador = cobrador;
283 }, function () {
284 // funcion ejecutada cuando se cancela el modal
285 });
286 }
287 };
288 $scope.seleccionarVendedor = function (key) {
289 if (key === 13) {
290 var parametrosModal = {
291 titulo: 'Búsqueda vendedores',
292 query: '/vendedor',
293 columnas: [
294 {
295 propiedad: 'NUM',
296 nombre: 'Código',
297 filtro: {
298 nombre: 'rellenarDigitos',
299 parametro: 3
300 }
301 },
302 {
303 propiedad: 'NOM',
304 nombre: 'Nombre'
305 }
306 ],
307 size: 'md'
308 };
309 focaModalService.modal(parametrosModal).then(
310 function (vendedor) {
311 $scope.vendedor = vendedor;
312 }, function () {
313 // funcion ejecutada cuando se cancela el modal
314 });
315 }
316 };
317 $scope.seleccionarIva = function (key) {
318 if (key === 13) {
319 var parametrosModal = {
320 query: '/iva',
321 searchText: $scope.cliente.iva.NOMBRE,
322 columnas: [
323 {
324 propiedad: 'ID',
325 nombre: 'Código',
326 filtro: {
327 nombre: 'rellenarDigitos',
328 parametro: 3
329 }
330 },
331 {
332 propiedad: 'NOMBRE',
333 nombre: 'Nombre'
334 }
335 ],
336 titulo: 'Búsqueda de responsabilidad ante el IVA',
337 size: 'md'
338 };
339 focaModalService.modal(parametrosModal).then(
340 function (iva) {
341 if (iva) {
342 delete $scope.cliente.tipoFactura.NOMBRE;
343 }
344 $scope.cliente.iva = iva;
345 $timeout(function () {
346 $scope.focused = 12;
347 });
348 }, function () {
349 // funcion ejecutada cuando se cancela el modal
350 });
351 }
352 };
353 $scope.seleccionarTipoFactura = function (key) {
354
355 if ($scope.cliente.iva.NOMBRE == '') {
356 focaModalService.alert('Seleccione una responsabilidad ante el IVA');
357 return;
358 }
359
360 if (key === 13) {
361 var datos;
362 if ($scope.cliente.iva.ID == 1) {
363 datos = [
364 {
365 ID: 'A',
366 NOMBRE: 'Factura A'
367 },
368 {
369 ID: 'M',
370 NOMBRE: 'Factura M'
371 },
372 {
373 ID: 'R',
374 NOMBRE: 'Remito'
375 }
376 ];
377 } else {
378 datos = [
379 {
380 ID: 'B',
381 NOMBRE: 'Factura B'
382 },
383 {
384 ID: 'R',
385 NOMBRE: 'Remito'
386 }
387 ];
388 }
389 focaModalService.modal({
390 titulo: 'Seleccionar Factura',
391 data: datos,
392 size: 'md',
393 columnas: [
394 {
395 propiedad: 'ID',
396 NOMBRE: 'Codigo'
397 },
398 {
399 propiedad: 'NOMBRE',
400 NOMBRE: 'Factura'
401 }
402 ],
403 }).then(function (res) {
404 $scope.cliente.tipoFactura = res;
405 });
406 }
407 };
408 $scope.pasarCampoCuit = function (numeroCuit) {
409 if (numeroCuit === 1 && $scope.cliente.cuit1.length === 2) {
410 $scope.cuitActivo = 2;
411 } else if (numeroCuit === 2 && $scope.cliente.cuit2.length === 8) {
412 $scope.cuitActivo = 3;
413 }
414 };
415 $scope.seleccionarTipoComprobante = function (key) {
416 if (key === 13) {
417 var parametrosModal = {
418 searchText: $scope.cliente.tipoComprobante.NOMBRE,
419 query: '/tipo-comprobante',
420 columnas: [
421 {
422 propiedad: 'ID',
423 nombre: 'Código'
424 },
425 {
426 propiedad: 'NOMBRE',
427 nombre: 'Nombre'
428 }
429 ],
430 titulo: 'Búsqueda de tipos de comprobante',
431 size: 'md'
432 };
433 focaModalService.modal(parametrosModal).then(
434 function (tipoComprobante) {
435 $scope.cliente.tipoComprobante = tipoComprobante;
436 $timeout(function () {
437 $scope.focused = 17;
438 });
439 }, function () {
440 // funcion ejecutada cuando se cancela el modal
441 });
442 }
443 };
444 $scope.seleccionarFormaPago = function (key) {
445 if (key === 13) {
446 var parametrosModal = {
447 searchText: $scope.cliente.formaPago.NOMBRE,
448 query: '/forma-pago',
449 columnas: [
450 {
451 propiedad: 'ID',
452 nombre: 'Código',
453 filtro: {
454 nombre: 'rellenarDigitos',
455 parametro: 3
456 }
457 },
458 {
459 propiedad: 'NOMBRE',
460 nombre: 'Nombre'
461 }
462 ],
463 titulo: 'Búsqueda de formas de pago',
464 size: 'md'
465 };
466 focaModalService.modal(parametrosModal).then(
467 function (formaPago) {
468 $scope.cliente.formaPago = formaPago;
469 }, function () {
470 // funcion ejecutada cuando se cancela el modal
471 });
472 }
473 };
474
475 function crearCopia() {
476 var cliente = angular.copy($scope.cliente);
477 cliente.COD = cliente.codigo;
478 cliente.CPO = cliente.CPO;
479 cliente.PCX = parseInt(cliente.provincia.ID);
480 cliente.LOX = parseInt(cliente.localidad.ID);
481 cliente.LOC = cliente.localidad.NOMBRE;
482 cliente.PCI = cliente.provincia.NOMBRE;
483 cliente.IVA = cliente.iva.ID;
484 cliente.ACT = cliente.actividad.ID;
485 cliente.ZON = (parseInt(cliente.zona.ID)).toString();
486 cliente.TIP = cliente.tipoFactura.ID;
487 cliente.TCO = cliente.tipoComprobante.ID;
488 cliente.FPA = cliente.formaPago.ID;
489 cliente.VEN = $scope.vendedor.id;
490 cliente.CUIT = `${cliente.cuit1}-${cliente.cuit2}-${cliente.cuit3}`;
491 cliente.idCobrador = cliente.cobrador.ID;
492
493 delete cliente.codigo;
494 delete cliente.provincia;
495 delete cliente.localidad;
496 delete cliente.iva;
497 delete cliente.actividad;
498 delete cliente.zona;
499 delete cliente.tipoFactura;
500 delete cliente.tipoComprobante;
501 delete cliente.formaPago;
502 delete cliente.cobrador;
503 delete cliente.cuit1;
504 delete cliente.cuit2;
505 delete cliente.cuit3;
506 delete cliente.vendedor;
507
508 return cliente;
509 }
510 function validateEmails(emails) {
511 var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
512 var arr = emails.split(',');
513 var result = true;
514 arr.forEach(function (email) {
515 var val = String(email).trim().toLowerCase();
516 if (!re.test(val)) result = false;
517 });
518 return result;
519 }
520 }
521 ]);
522
File was created 1 angular.module('focaAbmCliente')
2 .config([
3 '$routeProvider',
4 function($routeProvider) {
5 $routeProvider.when('/cliente', {
6 controller: 'focaAbmClienteController',
7 templateUrl: 'src/views/foca-abm-cliente.html'
8 });
9 }
10 ]);
11
12
File was created 1 angular.module('focaAbmCliente')
2 .factory('focaAbmClienteService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) {
3 return {
4 getAllClientes: function () {
5 return $http.get(API_ENDPOINT.URL + '/cliente');
6 },
7 obtenerClientePorCodigo: function (cod) {
8 return $http.get(API_ENDPOINT.URL + '/cliente-codigo/' + cod );
9 },
10 guardarCliente: function (cliente) {
11 return $http.post(API_ENDPOINT.URL + '/cliente', { cliente: cliente });
12 }
13 };
14 }]);
15
src/views/foca-abm-cliente.html
File was created 1 <div class="row">
2 <foca-cabecera-facturador
3 titulo="'Cliente'"
4 fecha="now"
5 class="mb-0 col-lg-12"
6 ></foca-cabecera-facturador>
7 </div>
8 <div class="row">
9 <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded">
10 <div class="row px-5 py-2 botonera-secundaria">
11 <div class="col-12">
12 <foca-botonera-facturador
13 botones="botonCliente"
14 max="1"
15 class="row"
16 >
17 </foca-botonera-facturador>
18 </div>
19 </div>
20 <div class="col-12 col-md-12 p-0 border border-white rounded">
21 <div class="row px-5 py-2 botonera-secundaria">
22 <div class="col-12">
23 <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador>
24 </div>
25 </div>
26 </div>
27 </div>
28
src/views/foca-modal-cliente.html
File was created 1 <div class="modal-header py-1">
2 <div class="row w-100">
3 <div class="col-lg-4 col-7">
4 <h5 class="modal-title my-1">Editar Cliente</h5>
5 </div>
6 <div class="col-lg-6 col-5 front-index">
7 <div class="custom-control custom-checkbox mt-2">
8 <input
9 type="checkbox"
10 class="custom-control-input"
11 id="checkProspecto"
12 ng-model="cliente.ES_PROS">
13 <label class="custom-control-label" for="checkProspecto">¿Es prospecto?</label>
14 </div>
15 </div>
16 </div>
17 </div>
18 <div class="modal-body" id="modal-body">
19 <form name="formCliente">
20 <fieldset>
21 <uib-tabset class="tabs-right">
22 <uib-tab heading="Datos cliente">
23 <div class="row">
24 <div class="col-3 mt-2">
25 <label>Código</label>
26 <input
27 type="text"
28 class="form-control form-control-sm"
29 ng-model="cliente.codigo"
30 readonly
31 />
32 </div>
33 <div class="col-9 mt-2">
34 <label>Nombre</label>
35 <input
36 type="text"
37 class="form-control form-control-sm"
38 ng-model="cliente.NOM"
39 teclado-virtual
40 placeholder="Ingrese nombre"
41 ng-required="true"
42 foca-focus="focused == 1"
43 ng-focus="focus(1)"
44 ng-keypress="next($event.keyCode)"
45 />
46 </div>
47 </div>
48 <div class="row">
49 <div class="col-md-9 col-12 mt-2">
50 <label>Domicilio</label>
51 <input
52 type="text"
53 class="form-control form-control-sm"
54 ng-model="cliente.DOM"
55 teclado-virtual
56 placeholder="Ingrese domicilio"
57 ng-required="true"
58 ng-focus="focus(2)"
59 foca-focus="focused == 2"
60 ng-keypress="next($event.keyCode)"
61 />
62 </div>
63 <div class="col-md-3 col-12 mt-2">
64 <label>Código postal</label>
65 <input
66 type="text"
67 class="form-control form-control-sm"
68 ng-model="cliente.CPO"
69 placeholder="Ingrese CP"
70 ng-required="true"
71 ng-focus="focus(3)"
72 foca-focus="focused == 3"
73 ng-keypress="next($event.keyCode)"
74 teclado-virtual
75 />
76 </div>
77 </div>
78 <div class="row">
79 <div class="col-md-6 col-12 mt-2">
80 <label>Provincia</label>
81 <div class="input-group">
82 <input
83 type="text"
84 class="form-control form-control-sm"
85 ng-model="cliente.provincia.NOMBRE"
86 ng-keypress="seleccionarProvincia($event.keyCode)"
87 placeholder="Seleccione provincia"
88 ng-required="true"
89 ng-focus="focus(4)"
90 foca-focus="focused == 4"
91 teclado-virtual
92 />
93 <button
94 ng-show="cliente.provincia.NOMBRE !== ''"
95 type="button"
96 class="clear-input"
97 ng-click=
98 "cliente.provincia.NOMBRE = '';
99 cliente.provincia.ID = undefined"
100 ><i class="fa fa-times"></i>
101 </button>
102 <div class="input-group-append">
103 <button
104 ladda="searchLoading"
105 class="btn btn-outline-secondary"
106 type="button"
107 ng-click="seleccionarProvincia(13)"
108 ><i class="fa fa-search" aria-hidden="true"></i>
109 </button>
110 </div>
111 </div>
112 </div>
113 <div class="col-md-6 col-12 mt-2">
114 <label>Localidad</label>
115 <div class="input-group">
116 <input
117 type="text"
118 class="form-control form-control-sm"
119 ng-model="cliente.localidad.NOMBRE"
120 ng-keypress="seleccionarLocalidad($event.keyCode)"
121 placeholder="Seleccione localidad"
122 ng-required="true"
123 foca-focus="focused == 5"
124 ng-focus="focus(5)"
125 teclado-virtual
126 />
127 <button
128 ng-show="cliente.localidad.NOMBRE !== ''"
129 type="button"
130 class="clear-input"
131 ng-click="cliente.localidad.NOMBRE = ''"
132 ><i class="fa fa-times"></i>
133 </button>
134 <div class="input-group-append">
135 <button
136 ladda="searchLoading"
137 class="btn btn-outline-secondary"
138 type="button"
139 ng-click="seleccionarLocalidad(13)"
140 ><i class="fa fa-search" aria-hidden="true"></i>
141 </button>
142 </div>
143 </div>
144 </div>
145 </div>
146 <div class="row">
147 <div class="col-md-6 col-12 mt-2">
148 <label>Zona</label>
149 <div class="input-group">
150 <input
151 type="text"
152 class="form-control form-control-sm"
153 ng-model="cliente.zona.NOM"
154 ng-keypress="seleccionarZona($event.keyCode)"
155 placeholder="Seleccione zona"
156 ng-required="true"
157 ng-focus="focus(6)"
158 foca-focus="focused == 6"
159 teclado-virtual
160 />
161 <button
162 ng-show="cliente.zona.NOM !== ''"
163 type="button"
164 class="clear-input"
165 ng-click="cliente.zona.NOM = ''"
166 ><i class="fa fa-times"></i>
167 </button>
168 <div class="input-group-append">
169 <button
170 ladda="searchLoading"
171 class="btn btn-outline-secondary"
172 type="button"
173 ng-click="seleccionarZona(13)"
174 ><i class="fa fa-search" aria-hidden="true"></i>
175 </button>
176 </div>
177 </div>
178 </div>
179 <div class="col-md-6 col-12 mt-2">
180 <label> Actividad </label>
181 <div class="input-group">
182 <input
183 type="text"
184 class="form-control form-control-sm"
185 ng-model="cliente.actividad.NOM"
186 ng-keypress="seleccionarActividad($event.keyCode)"
187 placeholder="Seleccione actividad"
188 ng-required="true"
189 ng-focus="focus(7)"
190 foca-focus="focused == 7"
191 teclado-virtual
192 />
193 <button
194 ng-show="cliente.actividad.NOM !== ''"
195 type="button"
196 class="clear-input"
197 ng-click="cliente.actividad.NOM = ''"
198 ><i class="fa fa-times"></i>
199 </button>
200 <div class="input-group-append">
201 <button
202 ladda="searchLoading"
203 class="btn btn-outline-secondary"
204 type="button"
205 ng-click="seleccionarActividad(13)"
206 ><i class="fa fa-search" aria-hidden="true"></i>
207 </button>
208 </div>
209 </div>
210 </div>
211 </div>
212 <div class="row">
213 <div class="col-md-6 col-12 mt-2">
214 <label>Cobrador</label>
215 <div class="input-group">
216 <input
217 type="text"
218 class="form-control form-control-sm"
219 ng-model="cliente.cobrador.NOM"
220 ng-keypress="seleccionarCobrador($event.keyCode)"
221 placeholder="Seleccione cobrador"
222 ng-focus="focus(8)"
223 foca-focus="focused == 8"
224 teclado-virtual
225 />
226 <button
227 ng-show="cliente.cobrador.NOM !== ''"
228 type="button"
229 class="clear-input"
230 ng-click="cliente.cobrador.NOM = ''"
231 ><i class="fa fa-times"></i>
232 </button>
233 <div class="input-group-append">
234 <button
235 ladda="searchLoading"
236 class="btn btn-outline-secondary"
237 type="button"
238 ng-click="seleccionarCobrador(13)"
239 ><i class="fa fa-search" aria-hidden="true"></i>
240 </button>
241 </div>
242 </div>
243 </div>
244 <div class="col-md-6 col-12 mt-2">
245 <label>Vendedor</label>
246 <div class="input-group">
247 <input
248 type="text"
249 class="form-control form-control-sm"
250 ng-model="vendedor.NOM"
251 ng-keypress="seleccionarVendedor($event.keyCode)"
252 placeholder="Seleccione vendedor"
253 ng-focus="focus(9)"
254 foca-focus="focused == 9"
255 teclado-virtual
256 />
257 <button
258 ng-show="vendedor.NOM !== ''"
259 type="button"
260 class="clear-input"
261 ng-click="vendedor.NOM = ''"
262 ><i class="fa fa-times"></i>
263 </button>
264 <div class="input-group-append">
265 <button
266 ladda="searchLoading"
267 class="btn btn-outline-secondary"
268 type="button"
269 ng-click="seleccionarVendedor(13)"
270 ><i class="fa fa-search" aria-hidden="true"></i>
271 </button>
272 </div>
273 </div>
274 </div>
275 <div class="col-md-6 col-12 mt-2">
276 <label>Email</label>
277 <div class="input-group">
278 <input
279 type="text"
280 class="form-control form-control-sm"
281 placeholder="Ingrese Email"
282 ng-model="cliente.MAIL"
283 ng-required="true"
284 ng-keypress="next($event.keyCode)"
285 ng-focus="focus(10)"
286 foca-focus="focused == 10"
287 teclado-virtual>
288 </div>
289 </div>
290 <div class="col-md-6 col-12 mt-2">
291 <label>Telefono</label>
292 <div class="input-group">
293 <input
294 foca-tipo-input
295 limite-numeros-max="20"
296 class="form-control form-control-sm"
297 placeholder="Ingrese Telefono"
298 ng-model="cliente.TEL"
299 ng-required="true"
300 ng-keypress="next($event.keyCode)"
301 ng-focus="focus(11)"
302 foca-focus="focused == 11"
303 teclado-virtual>
304 </div>
305 </div>
306 </div>
307 <div class="row">
308 <div class="col-6 d-flex mt-3">
309 <div class="custom-control custom-checkbox mt-auto">
310 <input
311 type="checkbox"
312 class="custom-control-input"
313 id="checkDistribuidor"
314 ng-model="cliente.ES_MAY"
315 checked
316 disabled="disabled">
317 <label class="custom-control-label" for="checkDistribuidor">¿Este cliente es distribuidor?</label>
318 </div>
319 </div>
320 </div>
321 </uib-tab>
322 <uib-tab heading="Datos impositivos">
323 <div class="row">
324 <div class="col-md-7 col-12 mt-2">
325 <label>Responsabilidad ante el IVA</label>
326 <div class="input-group">
327 <input
328 type="text"
329 class="form-control form-control-sm"
330 placeholder="Seleccione responsabilidad ante el IVA"
331 ng-model="cliente.iva.NOMBRE"
332 ng-keypress="seleccionarIva($event.keyCode)"
333 ng-required="true"
334 ng-focus="focus(12)"
335 foca-focus="focused == 12"
336 teclado-virtual
337 />
338 <button
339 ng-show="cliente.iva.NOMBRE !== ''"
340 type="button"
341 class="clear-input"
342 ng-click="cliente.iva.NOMBRE = ''"
343 ><i class="fa fa-times"></i>
344 </button>
345 <div class="input-group-append">
346 <button
347 ladda="searchLoading"
348 class="btn btn-outline-secondary"
349 type="button"
350 ng-click="seleccionarIva(13)"
351 ><i class="fa fa-search" aria-hidden="true"></i>
352 </button>
353 </div>
354 </div>
355 </div>
356 <div class="col-md-5 col-12 mt-2">
357 <label>Factura que emite</label>
358 <div class="input-group">
359 <input
360 type="text"
361 class="form-control form-control-sm"
362 placeholder="Seleccione factura que emite"
363 ng-model="cliente.tipoFactura.NOMBRE"
364 ng-required="true"
365 ng-keypress="seleccionarTipoFactura(13)"
366 ng-focus="focus(13)"
367 foca-focus="focused == 13"
368 teclado-virtual>
369 <button
370 ng-show="cliente.tipoFactura.NOMBRE !== ''"
371 type="button"
372 class="clear-input"
373 ng-click="cliente.tipoFactura.NOMBRE = ''"
374 ><i class="fa fa-times"></i>
375 </button>
376 <div class="input-group-append">
377 <button
378 ladda="searchLoading"
379 class="btn btn-outline-secondary"
380 type="button"
381 ng-click="seleccionarTipoFactura(13)"
382 ><i class="fa fa-search" aria-hidden="true"></i>
383 </button>
384 </div>
385 </div>
386 </div>
387 </div>
388 <div class="row">
389 <div class= "col-md-4 col-12 mt-2">
390 <label>CUIT</label>
391 <div class="d-flex">
392 <input
393 type="text"
394 class="text-center form-control form-control-sm col-2"
395 limite-numeros-max="2"
396 ng-model="cliente.cuit1"
397 ng-required="true"
398 ng-keypress="pasarCampoCuit(1)"
399 ng-focus="focus(14)"
400 foca-focus="focused == 14"
401 teclado-virtual
402 foca-tipo-input
403 >
404 <span class="m-1"> - </span>
405 <input
406 type="text"
407 class="text-center form-control form-control-sm col-5"
408 maxlength="8"
409 limite-numeros-max="8"
410 ng-keypress="pasarCampoCuit(2)"
411 ng-model="cliente.cuit2"
412 ng-required="true"
413 ng-focus="focus(15)"
414 foca-focus="cuitActivo == 2 || focused == 15"
415 teclado-virtual
416 foca-tipo-input
417 >
418 <span class="m-1"> - </span>
419 <input
420 type="text"
421 class="text-center form-control form-control-sm col-2"
422 maxlength="1"
423 limite-numeros-max="1"
424 ng-keypress="pasarCampoCuit(3)"
425 ng-model="cliente.cuit3"
426 ng-required="true"
427 ng-focus="focus(16)"
428 foca-focus="cuitActivo == 3 || focused == 16"
429 teclado-virtual
430 foca-tipo-input
431 >
432 </div>
433 </div>
434 <div class="col-md-4 col-12 mt-2">
435 <label>Clase de comprobante</label>
436 <div class="input-group">
437 <input
438 type="text"
439 class="form-control form-control-sm"
440 placeholder="Seleccione clase de comprobante"
441 ng-keypress="seleccionarTipoComprobante($event.keyCode)"
442 ng-model="cliente.tipoComprobante.NOMBRE"
443 ng-required="true"
444 ng-focus="focus(17)"
445 foca-focus="focused == 17"
446 teclado-virtual>
447 <button
448 ng-show="cliente.tipoComprobante.NOMBRE !== ''"
449 type="button"
450 class="clear-input"
451 ng-click="cliente.tipoComprobante.NOMBRE = ''"
452 ><i class="fa fa-times"></i>
453 </button>
454 <div class="input-group-append">
455 <button
456 ladda="searchLoading"
457 class="btn btn-outline-secondary"
458 type="button"
459 ng-click="seleccionarTipoComprobante(13)"
460 ><i class="fa fa-search" aria-hidden="true"></i>
461 </button>
462 </div>
463 </div>
464 </div>
465 <div class="col-md-4 col-12 mt-2">
466 <label>Forma de pago</label>
467 <div class="input-group">
468 <input
469 type="text"
470 class="form-control form-control-sm"
471 placeholder="Seleccione forma de pago"
472 ng-model="cliente.formaPago.NOMBRE"
473 ng-required="true"
474 ng-keypress="seleccionarFormaPago($event.keyCode)"
475 ng-focus="focus(18)"
476 foca-focus="focused == 18"
477 teclado-virtual>
478 <button
479 ng-show="cliente.formaPago.NOMBRE !== ''"
480 type="button"
481 class="clear-input"
482 ng-click="cliente.formaPago.NOMBRE = ''"
483 ><i class="fa fa-times"></i>
484 </button>
485 <div class="input-group-append">
486 <button
487 ladda="searchLoading"
488 class="btn btn-outline-secondary"
489 type="button"
490 ng-click="seleccionarFormaPago(13)"
491 ><i class="fa fa-search" aria-hidden="true"></i>
492 </button>
493 </div>
494 </div>
495 </div>
496 </div>
497 </uib-tab>
498 </uib-tabset>
499 </fieldset>
500 </form>
501 </div>
502 <div class="modal-footer py-1">
503 <button
504 class="btn btn-sm btn-secondary"
505 type="button"
506 data-dismiss="modal"
507 ng-click="cancel()">Cancelar
508 </button>
509 <button
510 class="btn btn-sm btn-primary"
511 type="button"
512 ng-click="guardar()"
513 >Guardar
514 </button>
515 </div>
516