Commit 14d7ad88947803858dfee0d4997fea08a3bf169a
Exists in
master
and in
1 other branch
Merge branch 'develop' into 'master'
Develop See merge request !65
Showing
7 changed files
Show diff stats
gulpfile.js
1 | const templateCache = require('gulp-angular-templatecache'); | 1 | const templateCache = require('gulp-angular-templatecache'); |
2 | const clean = require('gulp-clean'); | 2 | const clean = require('gulp-clean'); |
3 | const concat = require('gulp-concat'); | 3 | const concat = require('gulp-concat'); |
4 | const htmlmin = require('gulp-htmlmin'); | 4 | const htmlmin = require('gulp-htmlmin'); |
5 | const rename = require('gulp-rename'); | 5 | const rename = require('gulp-rename'); |
6 | const uglify = require('gulp-uglify'); | 6 | const uglify = require('gulp-uglify'); |
7 | const gulp = require('gulp'); | 7 | const gulp = require('gulp'); |
8 | const pump = require('pump'); | 8 | const pump = require('pump'); |
9 | const jshint = require('gulp-jshint'); | 9 | const jshint = require('gulp-jshint'); |
10 | const replace = require('gulp-replace'); | 10 | const replace = require('gulp-replace'); |
11 | const connect = require('gulp-connect'); | 11 | const connect = require('gulp-connect'); |
12 | const header = require('gulp-header'); | 12 | const header = require('gulp-header'); |
13 | const footer = require('gulp-footer'); | 13 | const footer = require('gulp-footer'); |
14 | const gulpSequence = require('gulp-sequence'); | 14 | const gulpSequence = require('gulp-sequence'); |
15 | 15 | ||
16 | var paths = { | 16 | var paths = { |
17 | srcJS: 'src/js/*.js', | 17 | srcJS: 'src/js/*.js', |
18 | srcViews: 'src/views/*.html', | 18 | srcViews: 'src/views/*.html', |
19 | specs: 'spec/*.js', | 19 | specs: 'spec/*.js', |
20 | tmp: 'tmp', | 20 | tmp: 'tmp', |
21 | dist: 'dist/' | 21 | dist: 'dist/' |
22 | }; | 22 | }; |
23 | 23 | ||
24 | gulp.task('uglify', gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')); | 24 | gulp.task('uglify', function(callback) { |
25 | gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')(callback); | ||
26 | }); | ||
25 | 27 | ||
26 | gulp.task('templates', ['clean'], function() { | 28 | gulp.task('templates', function() { |
27 | return pump( | 29 | return pump( |
28 | [ | 30 | [ |
29 | gulp.src(paths.srcViews), | 31 | gulp.src(paths.srcViews), |
30 | htmlmin(), | 32 | htmlmin(), |
31 | templateCache('views.js', { | 33 | templateCache('views.js', { |
32 | module: 'focaCrearRemito', | 34 | module: 'focaCrearRemito', |
33 | root: '' | 35 | root: '' |
34 | }), | 36 | }), |
35 | gulp.dest(paths.tmp) | 37 | gulp.dest(paths.tmp) |
36 | ] | 38 | ] |
37 | ); | 39 | ); |
38 | }); | 40 | }); |
39 | 41 | ||
40 | gulp.task('uglify-app', function() { | 42 | gulp.task('uglify-app', function() { |
41 | return pump( | 43 | return pump( |
42 | [ | 44 | [ |
43 | gulp.src([ | 45 | gulp.src([ |
44 | paths.srcJS, | 46 | paths.srcJS, |
45 | 'tmp/views.js' | 47 | 'tmp/views.js' |
46 | ]), | 48 | ]), |
47 | concat('foca-crear-remito.js'), | 49 | concat('foca-crear-remito.js'), |
48 | replace('src/views/', ''), | 50 | replace('src/views/', ''), |
49 | gulp.dest(paths.tmp), | 51 | gulp.dest(paths.tmp), |
50 | rename('foca-crear-remito.min.js'), | 52 | rename('foca-crear-remito.min.js'), |
51 | uglify(), | 53 | uglify(), |
52 | gulp.dest(paths.dist) | 54 | gulp.dest(paths.dist) |
53 | ] | 55 | ] |
54 | ); | 56 | ); |
55 | }); | 57 | }); |
56 | 58 | ||
57 | gulp.task('uglify-spec', function() { | 59 | gulp.task('uglify-spec', function() { |
58 | return pump( | 60 | return pump( |
59 | [ | 61 | [ |
60 | gulp.src(paths.specs), | 62 | gulp.src(paths.specs), |
61 | concat('foca-crear-remito.spec.js'), | 63 | concat('foca-crear-remito.spec.js'), |
62 | replace('src/views/', ''), | 64 | replace('src/views/', ''), |
63 | header("describe('Módulo foca-crear-remito', function() { \n"), | 65 | header("describe('Módulo foca-crear-remito', function() { \n"), |
64 | footer("});"), | 66 | footer("});"), |
65 | gulp.dest(paths.dist) | 67 | gulp.dest(paths.dist) |
66 | ] | 68 | ] |
67 | ); | 69 | ); |
68 | }); | 70 | }); |
69 | 71 | ||
70 | gulp.task('clean', function() { | 72 | gulp.task('clean', function() { |
71 | return gulp.src(['tmp', 'dist'], {read: false}) | 73 | return gulp.src(['tmp', 'dist'], {read: false}).pipe(clean()); |
72 | .pipe(clean()); | ||
73 | }); | 74 | }); |
74 | 75 | ||
75 | gulp.task('pre-commit', function() { | 76 | gulp.task('pre-commit', function() { |
76 | return pump( | 77 | return pump( |
77 | [ | 78 | [ |
78 | gulp.src([paths.srcJS, paths.specs]), | 79 | gulp.src([paths.srcJS, paths.specs]), |
79 | jshint('.jshintrc'), | 80 | jshint('.jshintrc'), |
80 | jshint.reporter('default'), | 81 | jshint.reporter('default'), |
81 | jshint.reporter('fail') | 82 | jshint.reporter('fail') |
82 | ] | 83 | ] |
83 | ); | 84 | ); |
84 | 85 | ||
85 | gulp.start('uglify'); | 86 | gulp.start('uglify'); |
86 | }); | 87 | }); |
87 | 88 | ||
88 | gulp.task('webserver', function() { | 89 | gulp.task('webserver', function() { |
89 | pump [ | 90 | pump [ |
90 | connect.server({port: 3300, host: '0.0.0.0'}) | 91 | connect.server({port: 3300, host: '0.0.0.0'}) |
91 | ] | 92 | ] |
92 | }); | 93 | }); |
93 | 94 | ||
94 | gulp.task('clean-post-install', function() { | 95 | gulp.task('clean-post-install', function() { |
95 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 96 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
96 | 'index.html'], {read: false}) | 97 | 'index.html'], {read: false}) |
97 | .pipe(clean()); | 98 | .pipe(clean()); |
98 | }); | 99 | }); |
99 | 100 | ||
100 | gulp.task('default', ['webserver']); | 101 | gulp.task('default', ['webserver']); |
101 | 102 | ||
102 | gulp.task('watch', function() { | 103 | gulp.task('watch', function() { |
103 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | 104 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); |
104 | }); | 105 | }); |
105 | 106 | ||
106 | gulp.task('copy', ['uglify'], function() { | 107 | gulp.task('copy', ['uglify'], function() { |
107 | return gulp.src('dist/*.js') | 108 | return gulp.src('dist/*.js') |
108 | .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-crear-remito/dist/')); | 109 | .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-crear-remito/dist/')); |
109 | }); | 110 | }); |
110 | 111 | ||
111 | gulp.task('watchAndCopy', function() { | 112 | gulp.task('watchAndCopy', function() { |
112 | return gulp.watch([paths.srcJS, paths.srcViews], ['copy']); | 113 | return gulp.watch([paths.srcJS, paths.srcViews], ['copy']); |
113 | }); | 114 | }); |
src/js/businessService.js
1 | angular.module('focaCrearRemito') | 1 | angular.module('focaCrearRemito') |
2 | .factory('remitoBusinessService', [ | 2 | .factory('remitoBusinessService', [ |
3 | 'crearRemitoService', | 3 | 'crearRemitoService', |
4 | function(crearRemitoService) { | 4 | function(crearRemitoService) { |
5 | return { | 5 | return { |
6 | addArticulos: function(articulosRemito, idRemito, cotizacion) { | 6 | addArticulos: function(articulosRemito, idRemito, cotizacion) { |
7 | for(var i = 0; i < articulosRemito.length; i++) { | 7 | for(var i = 0; i < articulosRemito.length; i++) { |
8 | delete articulosRemito[i].editCantidad; | 8 | delete articulosRemito[i].editCantidad; |
9 | delete articulosRemito[i].editPrecio; | 9 | delete articulosRemito[i].editPrecio; |
10 | articulosRemito[i].idRemito = idRemito; | 10 | articulosRemito[i].idRemito = articulosRemito[i].idRemito !== -1 ? |
11 | idRemito : articulosRemito[i].idRemito; | ||
11 | articulosRemito[i].precio = articulosRemito[i].precio * cotizacion; | 12 | articulosRemito[i].precio = articulosRemito[i].precio * cotizacion; |
12 | delete articulosRemito[i].idNotaPedido; | 13 | delete articulosRemito[i].idNotaPedido; |
13 | crearRemitoService.crearArticulosParaRemito(articulosRemito[i]); | 14 | crearRemitoService.crearArticulosParaRemito(articulosRemito[i]); |
14 | } | 15 | } |
15 | }, | 16 | }, |
16 | addEstado: function(idRemito, idVendedor) { | 17 | addEstado: function(idRemito, idVendedor) { |
17 | var date = new Date(); | 18 | var date = new Date(); |
18 | var estado = { | 19 | var estado = { |
19 | idRemito: idRemito, | 20 | idRemito: idRemito, |
20 | fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 21 | fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
21 | .toISOString().slice(0, 19).replace('T', ' '), | 22 | .toISOString().slice(0, 19).replace('T', ' '), |
22 | estado: 0, | 23 | estado: 0, |
23 | idVendedor: idVendedor | 24 | idVendedor: idVendedor |
24 | }; | 25 | }; |
25 | crearRemitoService.crearEstadoParaRemito(estado); | 26 | crearRemitoService.crearEstadoParaRemito(estado); |
26 | }, | 27 | }, |
27 | calcularArticulos: function(articulos, cotizacion) { | 28 | calcularArticulos: function(articulos, cotizacion) { |
28 | for(var i = 0; i < articulos.length; i++) { | 29 | for(var i = 0; i < articulos.length; i++) { |
29 | articulos[i].precio = articulos[i].precio / cotizacion; | 30 | articulos[i].precio = articulos[i].precio / cotizacion; |
30 | } | 31 | } |
31 | }, | 32 | }, |
32 | plazoToString: function(plazos) { | 33 | plazoToString: function(plazos) { |
33 | var result = ''; | 34 | var result = ''; |
34 | for(var i = 0; i < plazos.length; i++) { | 35 | for(var i = 0; i < plazos.length; i++) { |
35 | result += plazos[i].dias + ' '; | 36 | result += plazos[i].dias + ' '; |
36 | } | 37 | } |
37 | return result.trim(); | 38 | return result.trim(); |
38 | } | 39 | } |
39 | }; | 40 | }; |
40 | }]); | 41 | }]); |
41 | 42 |
src/js/controller.js
1 | angular.module('focaCrearRemito') .controller('remitoController', | 1 | angular.module('focaCrearRemito') .controller('remitoController', |
2 | [ | 2 | [ |
3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout', |
4 | 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', | 4 | 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', |
5 | '$localStorage', | 5 | '$localStorage', |
6 | function( | 6 | function( |
7 | $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService, | 7 | $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService, |
8 | remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) | 8 | remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) |
9 | { | 9 | { |
10 | config(); | 10 | config(); |
11 | 11 | ||
12 | function config() { | 12 | function config() { |
13 | $scope.tmpCantidad = Number; | ||
14 | $scope.tmpPrecio = Number; | ||
13 | $scope.botonera = crearRemitoService.getBotonera(); | 15 | $scope.botonera = crearRemitoService.getBotonera(); |
14 | $scope.isNumber = angular.isNumber; | 16 | $scope.isNumber = angular.isNumber; |
15 | $scope.datepickerAbierto = false; | 17 | $scope.datepickerAbierto = false; |
16 | $scope.show = false; | 18 | $scope.show = false; |
17 | $scope.cargando = true; | 19 | $scope.cargando = true; |
18 | $scope.now = new Date(); | 20 | $scope.now = new Date(); |
19 | $scope.puntoVenta = rellenar(0, 4); | 21 | $scope.puntoVenta = rellenar(0, 4); |
20 | $scope.comprobante = rellenar(0, 8); | 22 | $scope.comprobante = rellenar(0, 8); |
21 | $scope.dateOptions = { | 23 | $scope.dateOptions = { |
22 | maxDate: new Date(), | 24 | maxDate: new Date(), |
23 | minDate: new Date(2010, 0, 1) | 25 | minDate: new Date(2010, 0, 1) |
24 | }; | 26 | }; |
25 | 27 | ||
26 | var monedaPorDefecto; | 28 | var monedaPorDefecto; |
27 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 29 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
28 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { | 30 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { |
29 | monedaPorDefecto = res.data[0]; | 31 | monedaPorDefecto = res.data[0]; |
30 | 32 | ||
31 | $scope.remito.cotizacion = Object.assign( | 33 | $scope.remito.cotizacion = Object.assign( |
32 | {moneda: monedaPorDefecto}, monedaPorDefecto.cotizaciones[0] | 34 | {moneda: monedaPorDefecto}, monedaPorDefecto.cotizaciones[0] |
33 | ); | 35 | ); |
34 | $scope.inicial.cotizacion = $scope.remito.cotizacion; | 36 | $scope.inicial.cotizacion = $scope.remito.cotizacion; |
35 | $scope.cotizacionPorDefecto = angular.copy($scope.remito.cotizacion); | 37 | $scope.cotizacionPorDefecto = angular.copy($scope.remito.cotizacion); |
38 | |||
39 | $timeout(function() { getLSRemito(); }); | ||
36 | }); | 40 | }); |
37 | 41 | ||
38 | //SETEO BOTONERA LATERAL | 42 | //SETEO BOTONERA LATERAL |
39 | $timeout(function() { | 43 | $timeout(function() { |
40 | focaBotoneraLateralService.showSalir(false); | 44 | focaBotoneraLateralService.showSalir(false); |
41 | focaBotoneraLateralService.showPausar(true); | 45 | focaBotoneraLateralService.showPausar(true); |
42 | focaBotoneraLateralService.showGuardar(true, $scope.crearRemito); | 46 | focaBotoneraLateralService.showGuardar(true, $scope.crearRemito); |
43 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 47 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
44 | }); | 48 | }); |
45 | 49 | ||
46 | init(); | 50 | init(); |
47 | $timeout(function() {getLSRemito();}); | ||
48 | } | 51 | } |
49 | 52 | ||
50 | function init() { | 53 | function init() { |
51 | $scope.$broadcast('cleanCabecera'); | 54 | $scope.$broadcast('cleanCabecera'); |
52 | 55 | ||
53 | $scope.remito = { | 56 | $scope.remito = { |
54 | id: 0, | 57 | id: 0, |
55 | estado: 0, | 58 | estado: 0, |
56 | vendedor: {}, | 59 | vendedor: {}, |
57 | cliente: {}, | 60 | cliente: {}, |
58 | proveedor: {}, | 61 | proveedor: {}, |
59 | domicilio: {dom: ''}, | 62 | domicilio: {dom: ''}, |
60 | moneda: {}, | 63 | moneda: {}, |
61 | cotizacion: $scope.cotizacionPorDefecto || {}, | 64 | cotizacion: $scope.cotizacionPorDefecto || {}, |
62 | articulosRemito: [] | 65 | articulosRemito: [] |
63 | }; | 66 | }; |
64 | 67 | ||
65 | $scope.notaPedido = { | 68 | $scope.notaPedido = { |
66 | id: 0 | 69 | id: 0 |
67 | }; | 70 | }; |
68 | 71 | ||
69 | $scope.remito.articulosRemito = []; | 72 | $scope.remito.articulosRemito = []; |
70 | $scope.idLista = undefined; | 73 | $scope.idLista = undefined; |
71 | 74 | ||
72 | crearRemitoService.getNumeroRemito().then( | 75 | crearRemitoService.getNumeroRemito().then( |
73 | function(res) { | 76 | function(res) { |
74 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 77 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
75 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); | 78 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); |
76 | }, | 79 | }, |
77 | function(err) { | 80 | function(err) { |
78 | focaModalService.alert('La terminal no esta configurada correctamente'); | 81 | focaModalService.alert('La terminal no esta configurada correctamente'); |
79 | console.info(err); | 82 | console.info(err); |
80 | } | 83 | } |
81 | ); | 84 | ); |
82 | 85 | ||
83 | $scope.inicial = angular.copy($scope.remito); | 86 | $scope.inicial = angular.copy($scope.remito); |
84 | } | 87 | } |
85 | 88 | ||
86 | $scope.$watch('remito', function(newValue) { | 89 | $scope.$watch('remito', function(newValue) { |
87 | focaBotoneraLateralService.setPausarData({ | 90 | focaBotoneraLateralService.setPausarData({ |
88 | label: 'remito', | 91 | label: 'remito', |
89 | val: newValue | 92 | val: newValue |
90 | }); | 93 | }); |
91 | }, true); | 94 | }, true); |
92 | 95 | ||
93 | $scope.seleccionarNotaPedido = function() { | 96 | $scope.seleccionarNotaPedido = function() { |
94 | if(varlidarRemitoFacturado()) { | 97 | if (varlidarRemitoFacturado()) { |
95 | var modalInstance = $uibModal.open( | 98 | var modalInstance = $uibModal.open( |
96 | { | 99 | { |
97 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 100 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
98 | templateUrl: 'foca-modal-nota-pedido.html', | 101 | templateUrl: 'foca-modal-nota-pedido.html', |
99 | controller: 'focaModalNotaPedidoController', | 102 | controller: 'focaModalNotaPedidoController', |
100 | size: 'lg', | 103 | size: 'lg', |
101 | resolve: { | 104 | resolve: { |
102 | usadoPor: function() { return 'remito'; }, | 105 | usadoPor: function() { return 'remito'; }, |
103 | idVendedor: function() { return null; } | 106 | idVendedor: function() { return null; } |
104 | } | 107 | } |
105 | } | 108 | } |
106 | ); | 109 | ); |
107 | modalInstance.result.then( | 110 | modalInstance.result.then( |
108 | function(notaPedido) { | 111 | function(notaPedido) { |
109 | //añado cabeceras | 112 | //añado cabeceras |
110 | $scope.notaPedido.id = notaPedido.id; | 113 | $scope.notaPedido.id = notaPedido.id; |
111 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 114 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
112 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 115 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
113 | var cabeceras = [ | 116 | var cabeceras = [ |
114 | { | 117 | { |
115 | label: 'Moneda:', | 118 | label: 'Moneda:', |
116 | valor: notaPedido.cotizacion.moneda.DETALLE | 119 | valor: notaPedido.cotizacion.moneda.DETALLE |
117 | }, | 120 | }, |
118 | { | 121 | { |
119 | label: 'Fecha cotizacion:', | 122 | label: 'Fecha cotizacion:', |
120 | valor: $filter('date')(notaPedido.cotizacion.FECHA, | 123 | valor: $filter('date')(notaPedido.cotizacion.FECHA, |
121 | 'dd/MM/yyyy') | 124 | 'dd/MM/yyyy') |
122 | }, | 125 | }, |
123 | { | 126 | { |
124 | label: 'Cotizacion:', | 127 | label: 'Cotizacion:', |
125 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, | 128 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, |
126 | '2') | 129 | '2') |
127 | }, | 130 | }, |
128 | { | 131 | { |
129 | label: 'Cliente:', | 132 | label: 'Cliente:', |
130 | valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + | 133 | valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + |
131 | ' - ' + notaPedido.cliente.NOM | 134 | ' - ' + notaPedido.cliente.NOM |
132 | }, | 135 | }, |
133 | { | 136 | { |
134 | label: 'Domicilio:', | 137 | label: 'Domicilio:', |
135 | valor: notaPedido.domicilioStamp | 138 | valor: notaPedido.domicilioStamp |
136 | }, | 139 | }, |
137 | { | 140 | { |
138 | label: 'Vendedor:', | 141 | label: 'Vendedor:', |
139 | valor: $filter('rellenarDigitos')( | 142 | valor: $filter('rellenarDigitos')( |
140 | notaPedido.vendedor.NUM, 3 | 143 | notaPedido.vendedor.NUM, 3 |
141 | ) + ' - ' + notaPedido.vendedor.NOM | 144 | ) + ' - ' + notaPedido.vendedor.NOM |
142 | }, | 145 | }, |
143 | { | 146 | { |
144 | label: 'Proveedor:', | 147 | label: 'Proveedor:', |
145 | valor: $filter('rellenarDigitos') | 148 | valor: $filter('rellenarDigitos') |
146 | (notaPedido.proveedor.COD, 5) + ' - ' + | 149 | (notaPedido.proveedor.COD, 5) + ' - ' + |
147 | notaPedido.proveedor.NOM | 150 | notaPedido.proveedor.NOM |
148 | }, | 151 | }, |
149 | { | 152 | { |
150 | label: 'Precio condicion:', | 153 | label: 'Precio condicion:', |
151 | valor: valorPrecioCondicion() + ' ' + | 154 | valor: valorPrecioCondicion() + ' ' + |
152 | remitoBusinessService | 155 | remitoBusinessService |
153 | .plazoToString(notaPedido.notaPedidoPlazo) | 156 | .plazoToString(notaPedido.notaPedidoPlazo) |
154 | }, | 157 | }, |
155 | { | 158 | { |
156 | label: 'Flete:', | 159 | label: 'Flete:', |
157 | valor: notaPedido.fob === 1 ? 'FOB' : ( | 160 | valor: notaPedido.fob === 1 ? 'FOB' : ( |
158 | notaPedido.flete === 1 ? 'Si' : 'No') | 161 | notaPedido.flete === 1 ? 'Si' : 'No') |
159 | } | 162 | } |
160 | ]; | 163 | ]; |
161 | 164 | ||
162 | if (notaPedido.observaciones) { | ||
163 | cabeceras.push({ | ||
164 | label: 'Observaciones:', | ||
165 | valor: notaPedido.observaciones | ||
166 | }); | ||
167 | } | ||
168 | |||
169 | function valorPrecioCondicion() { | 165 | function valorPrecioCondicion() { |
170 | if (notaPedido.idPrecioCondicion > 0) { | 166 | if (notaPedido.idPrecioCondicion > 0) { |
171 | return notaPedido.precioCondicion.nombre; | 167 | return notaPedido.precioCondicion.nombre; |
172 | } else { | 168 | } else { |
173 | return 'Ingreso Manual'; | 169 | return 'Ingreso Manual'; |
174 | } | 170 | } |
175 | } | 171 | } |
176 | 172 | ||
177 | if (notaPedido.flete === 1) { | 173 | if (notaPedido.flete === 1) { |
178 | var cabeceraBomba = { | 174 | var cabeceraBomba = { |
179 | label: 'Bomba:', | 175 | label: 'Bomba:', |
180 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 176 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
181 | }; | 177 | }; |
182 | if (notaPedido.kilometros) { | 178 | if (notaPedido.kilometros) { |
183 | var cabeceraKilometros = { | 179 | var cabeceraKilometros = { |
184 | label: 'Kilometros:', | 180 | label: 'Kilometros:', |
185 | valor: notaPedido.kilometros | 181 | valor: notaPedido.kilometros |
186 | }; | 182 | }; |
187 | cabeceras.push(cabeceraKilometros); | 183 | cabeceras.push(cabeceraKilometros); |
188 | } | 184 | } |
189 | cabeceras.push(cabeceraBomba); | 185 | cabeceras.push(cabeceraBomba); |
190 | } | 186 | } |
191 | 187 | ||
192 | delete notaPedido.id; | 188 | delete notaPedido.id; |
193 | $scope.remito = notaPedido; | 189 | $scope.remito = notaPedido; |
194 | $scope.remito.id = 0; | 190 | $scope.remito.id = 0; |
195 | $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; | 191 | $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; |
196 | 192 | ||
197 | for(var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) { | 193 | for(var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) { |
198 | notaPedido.articulosNotaPedido[i].id = 0; | 194 | notaPedido.articulosNotaPedido[i].id = 0; |
195 | notaPedido.articulosNotaPedido[i].idRemito = 0; | ||
199 | } | 196 | } |
200 | 197 | ||
201 | $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; | 198 | $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; |
202 | remitoBusinessService.calcularArticulos($scope.remito.articulosRemito, | ||
203 | notaPedido.cotizacion.VENDEDOR); | ||
204 | 199 | ||
205 | if(notaPedido.idPrecioCondicion > 0) { | 200 | if (notaPedido.idPrecioCondicion > 0) { |
206 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | 201 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; |
207 | }else { | 202 | } else { |
208 | $scope.idLista = -1; | 203 | $scope.idLista = -1; |
209 | } | 204 | } |
210 | 205 | ||
211 | enableObservaciones(notaPedido.observaciones ? true : false); | 206 | enableObservaciones(notaPedido.observaciones ? true : false); |
212 | addArrayCabecera(cabeceras); | 207 | addArrayCabecera(cabeceras); |
213 | 208 | ||
214 | }, function() { | 209 | }, function() { |
215 | // funcion ejecutada cuando se cancela el modal | 210 | // funcion ejecutada cuando se cancela el modal |
216 | } | 211 | } |
217 | ); | 212 | ); |
218 | } | 213 | } |
219 | }; | 214 | }; |
220 | 215 | ||
221 | $scope.seleccionarRemito = function() { | 216 | $scope.seleccionarRemito = function() { |
222 | var modalInstance = $uibModal.open( | 217 | var modalInstance = $uibModal.open( |
223 | { | 218 | { |
224 | ariaLabelledBy: 'Busqueda de Remito', | 219 | ariaLabelledBy: 'Busqueda de Remito', |
225 | templateUrl: 'foca-modal-remito.html', | 220 | templateUrl: 'foca-modal-remito.html', |
226 | controller: 'focaModalRemitoController', | 221 | controller: 'focaModalRemitoController', |
227 | size: 'lg', | 222 | size: 'lg', |
228 | resolve: {usadoPor: function() {return 'remito';}} | 223 | resolve: {usadoPor: function() {return 'remito';}} |
229 | } | 224 | } |
230 | ); | 225 | ); |
231 | modalInstance.result.then( | 226 | modalInstance.result.then( |
232 | setearRemito, function() { | 227 | setearRemito, function() { |
233 | // funcion ejecutada cuando se cancela el modal | 228 | // funcion ejecutada cuando se cancela el modal |
234 | } | 229 | } |
235 | ); | 230 | ); |
236 | }; | 231 | }; |
237 | 232 | ||
238 | //validacion por domicilio y por plazo pago | 233 | //validacion por domicilio y por plazo pago |
239 | $scope.crearRemito = function() { | 234 | $scope.crearRemito = function() { |
240 | if (!$scope.remito.vendedor.NUM) { | 235 | if (!$scope.remito.vendedor.NUM) { |
241 | focaModalService.alert('Ingrese Vendedor'); | 236 | focaModalService.alert('Ingrese Vendedor'); |
242 | return; | 237 | return; |
243 | } else if (!$scope.remito.cliente.COD) { | 238 | } else if (!$scope.remito.cliente.COD) { |
244 | focaModalService.alert('Ingrese Cliente'); | 239 | focaModalService.alert('Ingrese Cliente'); |
245 | return; | 240 | return; |
246 | } else if (!$scope.remito.proveedor) { | 241 | } else if (!$scope.remito.proveedor) { |
247 | focaModalService.alert('Ingrese Proveedor'); | 242 | focaModalService.alert('Ingrese Proveedor'); |
248 | return; | 243 | return; |
249 | } else if (!$scope.remito.cotizacion.moneda.id && | 244 | } else if (!$scope.remito.cotizacion.moneda.id && |
250 | !$scope.remito.cotizacion.moneda.ID) | 245 | !$scope.remito.cotizacion.moneda.ID){ |
251 | { | ||
252 | focaModalService.alert('Ingrese Moneda'); | 246 | focaModalService.alert('Ingrese Moneda'); |
253 | return; | 247 | return; |
254 | } else if (!$scope.remito.cotizacion.ID) { | 248 | } else if (!$scope.remito.cotizacion.ID) { |
255 | focaModalService.alert('Ingrese Cotización'); | 249 | focaModalService.alert('Ingrese Cotización'); |
256 | return; | 250 | return; |
257 | } else if ( | 251 | } else if ($scope.remito.flete === undefined || $scope.remito.flete === null){ |
258 | $scope.remito.flete === undefined || $scope.remito.flete === null) | ||
259 | { | ||
260 | focaModalService.alert('Ingrese Flete'); | 252 | focaModalService.alert('Ingrese Flete'); |
261 | return; | 253 | return; |
262 | } else if ($scope.remito.articulosRemito.length === 0) { | 254 | } else if ($scope.articulosFiltro().length === 0) { |
263 | focaModalService.alert('Debe cargar al menos un articulo'); | 255 | focaModalService.alert('Debe cargar al menos un articulo'); |
264 | return; | 256 | return; |
265 | } | 257 | } |
266 | focaBotoneraLateralService.startGuardar(); | 258 | focaBotoneraLateralService.startGuardar(); |
267 | $scope.saveLoading = true; | 259 | $scope.saveLoading = true; |
268 | var save = { | 260 | var save = { |
269 | remito: { | 261 | remito: { |
270 | id: $scope.remito.id, | 262 | id: $scope.remito.id, |
271 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | 263 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), |
272 | idCliente: $scope.remito.cliente.COD, | 264 | idCliente: $scope.remito.cliente.COD, |
273 | nombreCliente: $scope.remito.cliente.NOM, | 265 | nombreCliente: $scope.remito.cliente.NOM, |
274 | cuitCliente: $scope.remito.cliente.CUIT, | 266 | cuitCliente: $scope.remito.cliente.CUIT, |
275 | responsabilidadIvaCliente: 0,//TODO, | 267 | responsabilidadIvaCliente: 0,//TODO, |
276 | descuento: 0,//TODO, | 268 | descuento: 0,//TODO, |
277 | importeNeto: 0,//TODO | 269 | importeNeto: 0,//TODO |
278 | importeExento: 0,//TODO | 270 | importeExento: 0,//TODO |
279 | importeIva: 0,//TODO | 271 | importeIva: 0,//TODO |
280 | importeIvaServicios: 0,//TODO | 272 | importeIvaServicios: 0,//TODO |
281 | importeImpuestoInterno: 0,//TODO | 273 | importeImpuestoInterno: 0,//TODO |
282 | importeImpuestoInterno1: 0,//TODO | 274 | importeImpuestoInterno1: 0,//TODO |
283 | importeImpuestoInterno2: 0,//TODO | 275 | importeImpuestoInterno2: 0,//TODO |
284 | percepcion: 0,//TODO | 276 | percepcion: 0,//TODO |
285 | percepcionIva: 0,//TODO | 277 | percepcionIva: 0,//TODO |
286 | redondeo: 0,//TODO | 278 | redondeo: 0,//TODO |
287 | total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR, | 279 | total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR, |
288 | numeroNotaPedido: $scope.remito.numeroNotaPedido, | 280 | numeroNotaPedido: $scope.remito.numeroNotaPedido, |
289 | anulado: false, | 281 | anulado: false, |
290 | planilla: 0,//TODO | 282 | planilla: 0,//TODO |
291 | lugar: 0,//TODO | 283 | lugar: 0,//TODO |
292 | cuentaMadre: 0,// | 284 | cuentaMadre: 0,// |
293 | cuentaContable: 0,//TODO | 285 | cuentaContable: 0,//TODO |
294 | asiento: 0,//TODO | 286 | asiento: 0,//TODO |
295 | e_hd: '',//TODO | 287 | e_hd: '',//TODO |
296 | c_hd: '', | 288 | c_hd: '', |
297 | numeroLiquidoProducto: 0,//TODO | 289 | numeroLiquidoProducto: 0,//TODO |
298 | idVendedor: $scope.remito.idVendedor, | 290 | idVendedor: $scope.remito.idVendedor, |
299 | idProveedor: $scope.remito.idProveedor, | 291 | idProveedor: $scope.remito.idProveedor, |
300 | idDomicilio: $scope.remito.idDomicilio, | 292 | idDomicilio: $scope.remito.idDomicilio, |
301 | idCotizacion: $scope.remito.cotizacion.ID, | 293 | idCotizacion: $scope.remito.cotizacion.ID, |
302 | idPrecioCondicion: $scope.remito.idPrecioCondicion, | 294 | idPrecioCondicion: $scope.remito.idPrecioCondicion, |
303 | flete: $scope.remito.flete, | 295 | flete: $scope.remito.flete, |
304 | fob: $scope.remito.fob, | 296 | fob: $scope.remito.fob, |
305 | bomba: $scope.remito.bomba, | 297 | bomba: $scope.remito.bomba, |
306 | kilometros: $scope.remito.kilometros, | 298 | kilometros: $scope.remito.kilometros, |
307 | domicilioStamp: $scope.remito.domicilioStamp, | 299 | domicilioStamp: $scope.remito.domicilioStamp, |
308 | estado: 0,//TODO | 300 | estado: 0,//TODO |
309 | destinoVenta: 0,//TODO | 301 | destinoVenta: 0,//TODO |
310 | operacionTipo: 0//TODO | 302 | operacionTipo: 0, //TODO |
303 | observaciones: $scope.remito.observaciones, | ||
304 | numeroRemito: parseInt($scope.comprobante), | ||
305 | sucursal: parseInt($scope.puntoVenta) | ||
311 | }, | 306 | }, |
312 | notaPedido: $scope.notaPedido | 307 | notaPedido: $scope.notaPedido |
313 | }; | 308 | }; |
314 | 309 | ||
315 | crearRemitoService.crearRemito(save).then( | 310 | crearRemitoService.crearRemito(save).then( |
316 | function(data) { | 311 | function(data) { |
317 | remitoBusinessService.addArticulos($scope.remito.articulosRemito, | ||
318 | data.data.id, $scope.remito.cotizacion.COTIZACION); | ||
319 | 312 | ||
320 | focaBotoneraLateralService.endGuardar(true); | 313 | focaBotoneraLateralService.endGuardar(true); |
321 | $scope.saveLoading = false; | 314 | $scope.saveLoading = false; |
322 | 315 | ||
323 | //TODO: updatear plazos | 316 | $scope.remito.id = data.data.id; |
324 | if($scope.remito.id === 0) { | 317 | $scope.remito.numeroRemito = data.data.numero; |
318 | |||
319 | remitoBusinessService.addArticulos($scope.remito.articulosRemito, | ||
320 | $scope.remito.id, $scope.remito.cotizacion.VENDEDOR); | ||
321 | |||
322 | if(data.status === 500) { | ||
323 | focaModalService.alert(data.data); | ||
324 | return; | ||
325 | } | ||
326 | |||
327 | // TODO: updatear plazos | ||
328 | if ($scope.remito.id === 0) { | ||
325 | var plazos = $scope.remito.remitoPlazo; | 329 | var plazos = $scope.remito.remitoPlazo; |
326 | 330 | ||
327 | for(var j = 0; j < plazos.length; j++) { | 331 | for(var j = 0; j < plazos.length; j++) { |
328 | var json = { | 332 | var json = { |
329 | idRemito: $scope.remito.id, | 333 | idRemito: $scope.remito.id, |
330 | dias: plazos[j].dias | 334 | dias: plazos[j].dias |
331 | }; | 335 | }; |
332 | crearRemitoService.crearPlazosParaRemito(json); | 336 | crearRemitoService.crearPlazosParaRemito(json); |
333 | } | 337 | } |
334 | } | 338 | } |
335 | 339 | ||
336 | $uibModal.open({ | 340 | abrirModalMail($scope.remito.id, |
337 | templateUrl: 'remito-comprobante.html', | 341 | $scope.remito.cliente, |
338 | controller: 'focaRemitoComprobanteController', | 342 | $filter('comprobante')([ |
339 | resolve: { | 343 | $scope.puntoVenta, |
340 | parametros: { | 344 | $scope.remito.numeroRemito |
341 | idRemito: data.data.id | 345 | ]) |
342 | } | 346 | ); |
343 | } | ||
344 | }); | ||
345 | 347 | ||
346 | init(); | 348 | init(); |
347 | 349 | ||
348 | }, function(error) { | 350 | }, function(error) { |
349 | focaModalService.alert('Hubo un error al crear el remito'); | 351 | focaModalService.alert(error.data || 'Hubo un error al crear el remito'); |
350 | focaBotoneraLateralService.endGuardar(); | 352 | focaBotoneraLateralService.endGuardar(); |
351 | $scope.saveLoading = false; | 353 | $scope.saveLoading = false; |
352 | console.info(error); | 354 | console.info(error); |
353 | } | 355 | } |
354 | ); | 356 | ); |
355 | }; | 357 | }; |
356 | 358 | ||
357 | $scope.seleccionarProductos = function() { | 359 | $scope.seleccionarProductos = function() { |
358 | if($scope.idLista === undefined) { | 360 | if ($scope.idLista === undefined) { |
359 | focaModalService.alert( | 361 | focaModalService.alert( |
360 | 'Primero seleccione una lista de precio y condicion'); | 362 | 'Primero seleccione una lista de precio y condicion'); |
361 | return; | 363 | return; |
362 | } | 364 | } |
363 | var modalInstance = $uibModal.open( | 365 | var modalInstance = $uibModal.open( |
364 | { | 366 | { |
365 | ariaLabelledBy: 'Busqueda de Productos', | 367 | ariaLabelledBy: 'Busqueda de Productos', |
366 | templateUrl: 'modal-busqueda-productos.html', | 368 | templateUrl: 'modal-busqueda-productos.html', |
367 | controller: 'modalBusquedaProductosCtrl', | 369 | controller: 'modalBusquedaProductosCtrl', |
368 | resolve: { | 370 | resolve: { |
369 | parametroProducto: { | 371 | parametroProducto: { |
370 | idLista: $scope.idLista, | 372 | idLista: $scope.idLista, |
371 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 373 | cotizacion: $scope.remito.cotizacion.VENDEDOR, |
372 | simbolo: $scope.remito.cotizacion.moneda.simbolo | 374 | simbolo: $scope.remito.cotizacion.moneda.SIMBOLO |
373 | } | 375 | } |
374 | }, | 376 | }, |
375 | size: 'lg' | 377 | size: 'lg' |
376 | } | 378 | } |
377 | ); | 379 | ); |
378 | modalInstance.result.then( | 380 | modalInstance.result.then( |
379 | function(producto) { | 381 | function(producto) { |
380 | var newArt = | 382 | var newArt = |
381 | { | 383 | { |
382 | id: 0, | 384 | id: 0, |
385 | idRemito: 0, | ||
383 | codigo: producto.codigo, | 386 | codigo: producto.codigo, |
384 | sector: producto.sector, | 387 | sector: producto.sector, |
385 | sectorCodigo: producto.sector + '-' + producto.codigo, | 388 | sectorCodigo: producto.sector + '-' + producto.codigo, |
386 | descripcion: producto.descripcion, | 389 | descripcion: producto.descripcion, |
387 | item: $scope.remito.articulosRemito.length + 1, | 390 | item: $scope.remito.articulosRemito.length + 1, |
388 | nombre: producto.descripcion, | 391 | nombre: producto.descripcion, |
389 | precio: parseFloat(producto.precio.toFixed(4)), | 392 | precio: parseFloat(producto.precio.toFixed(4)), |
390 | costoUnitario: producto.costo, | 393 | costoUnitario: producto.costo, |
391 | editCantidad: false, | 394 | editCantidad: false, |
392 | editPrecio: false, | 395 | editPrecio: false, |
393 | rubro: producto.CodRub, | 396 | rubro: producto.CodRub, |
394 | exentoUnitario: producto.precio, | 397 | exentoUnitario: producto.precio, |
395 | ivaUnitario: producto.IMPIVA, | 398 | ivaUnitario: producto.IMPIVA, |
396 | impuestoInternoUnitario: producto.ImpInt, | 399 | impuestoInternoUnitario: producto.ImpInt, |
397 | impuestoInterno1Unitario: producto.ImpInt2, | 400 | impuestoInterno1Unitario: producto.ImpInt2, |
398 | impuestoInterno2Unitario: producto.ImpInt3, | 401 | impuestoInterno2Unitario: producto.ImpInt3, |
399 | precioLista: producto.precio, | 402 | precioLista: producto.precio, |
400 | combustible: 1, | 403 | combustible: 1, |
401 | facturado: 0 | 404 | facturado: 0 |
402 | }; | 405 | }; |
403 | $scope.articuloACargar = newArt; | 406 | $scope.articuloACargar = newArt; |
404 | $scope.cargando = false; | 407 | $scope.cargando = false; |
405 | }, function() { | 408 | }, function() { |
406 | // funcion ejecutada cuando se cancela el modal | 409 | // funcion ejecutada cuando se cancela el modal |
407 | } | 410 | } |
408 | ); | 411 | ); |
409 | }; | 412 | }; |
410 | 413 | ||
411 | $scope.seleccionarPuntosDeDescarga = function() { | 414 | $scope.seleccionarPuntosDeDescarga = function() { |
412 | if(!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { | 415 | if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { |
413 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 416 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
414 | return; | 417 | return; |
415 | }else { | 418 | } else { |
416 | var modalInstance = $uibModal.open( | 419 | var modalInstance = $uibModal.open( |
417 | { | 420 | { |
418 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', | 421 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
419 | templateUrl: 'modal-punto-descarga.html', | 422 | templateUrl: 'modal-punto-descarga.html', |
420 | controller: 'focaModalPuntoDescargaController', | 423 | controller: 'focaModalPuntoDescargaController', |
421 | size: 'lg', | 424 | size: 'lg', |
422 | resolve: { | 425 | resolve: { |
423 | filters: { | 426 | filters: { |
424 | idDomicilio: $scope.remito.domicilio.id, | 427 | idDomicilio: $scope.remito.domicilio.id, |
425 | idCliente: $scope.remito.cliente.COD, | 428 | idCliente: $scope.remito.cliente.COD, |
426 | articulos: $scope.remito.articulosRemito, | 429 | articulos: $scope.remito.articulosRemito, |
427 | puntosDescarga: $scope.remito.domicilio.puntosDescarga | 430 | puntosDescarga: $scope.remito.domicilio.puntosDescarga, |
431 | domicilio: $scope.remito.domicilio | ||
428 | } | 432 | } |
429 | } | 433 | } |
430 | } | 434 | } |
431 | ); | 435 | ); |
432 | modalInstance.result.then( | 436 | modalInstance.result.then( |
433 | function(puntosDescarga) { | 437 | function(puntosDescarga) { |
434 | $scope.remito.puntosDescarga = puntosDescarga; | 438 | $scope.remito.domicilio.puntosDescarga = puntosDescarga; |
435 | |||
436 | //AGREGO PUNTOS DE DESCARGA A CABECERA | ||
437 | var puntosStamp = ''; | ||
438 | puntosDescarga.forEach(function(punto, idx, arr) { | ||
439 | puntosStamp += punto.descripcion; | ||
440 | if((idx + 1) !== arr.length) puntosStamp += ', '; | ||
441 | }); | ||
442 | 439 | ||
443 | $scope.$broadcast('addCabecera', { | 440 | $scope.$broadcast('addCabecera', { |
444 | label: 'Puntos de descarga:', | 441 | label: 'Puntos de descarga:', |
445 | valor: puntosStamp | 442 | valor: getCabeceraPuntoDescarga($scope.remito.domicilio.puntosDescarga) |
446 | }); | 443 | }); |
447 | }, function() { | 444 | }, function() { |
448 | $scope.abrirModalDomicilios($scope.cliente); | 445 | $scope.abrirModalDomicilios($scope.cliente); |
449 | } | 446 | } |
450 | ); | 447 | ); |
451 | } | 448 | } |
452 | }; | 449 | }; |
453 | 450 | ||
454 | $scope.seleccionarVendedor = function(callback, ocultarVendedor) { | 451 | $scope.seleccionarVendedor = function(callback, ocultarVendedor) { |
455 | if (ocultarVendedor) { | 452 | if (ocultarVendedor) { |
456 | callback(); | 453 | callback(); |
457 | return; | 454 | return; |
458 | } | 455 | } |
459 | 456 | ||
460 | if(varlidarRemitoFacturado()) { | 457 | if (varlidarRemitoFacturado()) { |
461 | var parametrosModal = { | 458 | var parametrosModal = { |
462 | titulo: 'Búsqueda vendedores', | 459 | titulo: 'Búsqueda vendedores', |
463 | query: '/vendedor', | 460 | query: '/vendedor', |
464 | columnas: [ | 461 | columnas: [ |
465 | { | 462 | { |
466 | propiedad: 'NUM', | 463 | propiedad: 'NUM', |
467 | nombre: 'Código', | 464 | nombre: 'Código', |
468 | filtro: { | 465 | filtro: { |
469 | nombre: 'rellenarDigitos', | 466 | nombre: 'rellenarDigitos', |
470 | parametro: 3 | 467 | parametro: 3 |
471 | } | 468 | } |
472 | }, | 469 | }, |
473 | { | 470 | { |
474 | propiedad: 'NOM', | 471 | propiedad: 'NOM', |
475 | nombre: 'Nombre' | 472 | nombre: 'Nombre' |
476 | } | 473 | } |
477 | ], | 474 | ], |
478 | size: 'md' | 475 | size: 'md' |
479 | }; | 476 | }; |
480 | focaModalService.modal(parametrosModal).then( | 477 | focaModalService.modal(parametrosModal).then( |
481 | function(vendedor) { | 478 | function(vendedor) { |
482 | $scope.$broadcast('addCabecera',{ | 479 | $scope.$broadcast('addCabecera',{ |
483 | label: 'Vendedor:', | 480 | label: 'Vendedor:', |
484 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 481 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
485 | vendedor.NOM | 482 | vendedor.NOM |
486 | }); | 483 | }); |
487 | $scope.remito.idVendedor = vendedor.id; | 484 | $scope.remito.idVendedor = vendedor.id; |
488 | $scope.remito.vendedor = vendedor; | 485 | $scope.remito.vendedor = vendedor; |
489 | deleteCliente(); | 486 | deleteCliente(); |
490 | callback(); | 487 | callback(); |
491 | }, function() { | 488 | }, function() { |
492 | 489 | ||
493 | } | 490 | } |
494 | ); | 491 | ); |
495 | } | 492 | } |
496 | }; | 493 | }; |
497 | 494 | ||
498 | $scope.seleccionarCliente = function(ocultarVendedor) { | 495 | $scope.seleccionarCliente = function(ocultarVendedor) { |
499 | 496 | ||
500 | $scope.seleccionarVendedor(function() { | 497 | $scope.seleccionarVendedor(function() { |
501 | if (varlidarRemitoFacturado()) { | 498 | if (varlidarRemitoFacturado()) { |
502 | var modalInstance = $uibModal.open( | 499 | var modalInstance = $uibModal.open( |
503 | { | 500 | { |
504 | ariaLabelledBy: 'Busqueda de Cliente', | 501 | ariaLabelledBy: 'Busqueda de Cliente', |
505 | templateUrl: 'foca-busqueda-cliente-modal.html', | 502 | templateUrl: 'foca-busqueda-cliente-modal.html', |
506 | controller: 'focaBusquedaClienteModalController', | 503 | controller: 'focaBusquedaClienteModalController', |
507 | resolve: { | 504 | resolve: { |
508 | vendedor: function() { return $scope.remito.vendedor; }, | 505 | vendedor: function() { return $scope.remito.vendedor; }, |
509 | cobrador: function() { return null; } | 506 | cobrador: function() { return null; } |
510 | }, | 507 | }, |
511 | size: 'lg' | 508 | size: 'lg' |
512 | } | 509 | } |
513 | ); | 510 | ); |
514 | modalInstance.result.then( | 511 | modalInstance.result.then( |
515 | function(cliente) { | 512 | function(cliente) { |
516 | $scope.abrirModalDomicilios(cliente); | 513 | $scope.abrirModalDomicilios(cliente); |
517 | $scope.cliente = cliente; | 514 | $scope.cliente = cliente; |
518 | }, function() { | 515 | }, function() { |
519 | $scope.seleccionarCliente(); | 516 | $scope.seleccionarCliente(); |
520 | } | 517 | } |
521 | ); | 518 | ); |
522 | } | 519 | } |
523 | }, ocultarVendedor); | 520 | }, ocultarVendedor); |
524 | }; | 521 | }; |
525 | 522 | ||
526 | $scope.seleccionarProveedor = function(callback) { | 523 | $scope.seleccionarProveedor = function() { |
527 | if(varlidarRemitoFacturado()) { | 524 | if (varlidarRemitoFacturado()) { |
528 | var parametrosModal = { | 525 | var parametrosModal = { |
529 | titulo: 'Búsqueda de Proveedor', | 526 | titulo: 'Búsqueda de Proveedor', |
530 | query: '/proveedor', | 527 | query: '/proveedor', |
531 | columnas: [ | 528 | columnas: [ |
532 | { | 529 | { |
533 | nombre: 'Código', | 530 | nombre: 'Código', |
534 | propiedad: 'COD', | 531 | propiedad: 'COD', |
535 | filtro: { | 532 | filtro: { |
536 | nombre: 'rellenarDigitos', | 533 | nombre: 'rellenarDigitos', |
537 | parametro: 5 | 534 | parametro: 5 |
538 | } | 535 | } |
539 | }, | 536 | }, |
540 | { | 537 | { |
541 | nombre: 'Nombre', | 538 | nombre: 'Nombre', |
542 | propiedad: 'NOM' | 539 | propiedad: 'NOM' |
543 | }, | 540 | }, |
544 | { | 541 | { |
545 | nombre: 'CUIT', | 542 | nombre: 'CUIT', |
546 | propiedad: 'CUIT' | 543 | propiedad: 'CUIT' |
547 | } | 544 | } |
548 | ], | 545 | ], |
549 | tipo: 'POST', | 546 | tipo: 'POST', |
550 | json: {razonCuitCod: ''} | 547 | json: {razonCuitCod: ''} |
551 | }; | 548 | }; |
552 | focaModalService.modal(parametrosModal).then( | 549 | focaModalService.modal(parametrosModal).then( |
553 | function(proveedor) { | 550 | function(proveedor) { |
554 | $scope.remito.proveedor = proveedor; | 551 | $scope.seleccionarFlete(proveedor); |
555 | $scope.remito.idProveedor = proveedor.COD; | ||
556 | |||
557 | $scope.$broadcast('addCabecera',{ | ||
558 | label: 'Proveedor:', | ||
559 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | ||
560 | proveedor.NOM | ||
561 | }); | ||
562 | callback(); | ||
563 | }, function() { } | 552 | }, function() { } |
564 | ); | 553 | ); |
565 | } | 554 | } |
566 | }; | 555 | }; |
567 | 556 | ||
568 | $scope.abrirModalDomicilios = function(cliente) { | 557 | $scope.abrirModalDomicilios = function(cliente) { |
569 | var modalInstanceDomicilio = $uibModal.open( | 558 | var modalInstanceDomicilio = $uibModal.open( |
570 | { | 559 | { |
571 | ariaLabelledBy: 'Busqueda de Domicilios', | 560 | ariaLabelledBy: 'Busqueda de Domicilios', |
572 | templateUrl: 'modal-domicilio.html', | 561 | templateUrl: 'modal-domicilio.html', |
573 | controller: 'focaModalDomicilioController', | 562 | controller: 'focaModalDomicilioController', |
574 | size: 'lg', | 563 | size: 'lg', |
575 | resolve: { | 564 | resolve: { |
576 | idCliente: function() { return cliente.cod; }, | 565 | idCliente: function() { return cliente.cod; }, |
577 | esNuevo: function() { return cliente.esNuevo; } | 566 | esNuevo: function() { return cliente.esNuevo; } |
578 | } | 567 | } |
579 | } | 568 | } |
580 | ); | 569 | ); |
581 | modalInstanceDomicilio.result.then( | 570 | modalInstanceDomicilio.result.then( |
582 | function(domicilio) { | 571 | function(domicilio) { |
583 | $scope.remito.domicilio = domicilio; | 572 | $scope.remito.domicilio = domicilio; |
584 | $scope.remito.cliente = { | 573 | $scope.remito.cliente = { |
585 | COD: cliente.cod, | 574 | COD: cliente.cod, |
586 | CUIT: cliente.cuit, | 575 | CUIT: cliente.cuit, |
587 | NOM: cliente.nom, | 576 | NOM: cliente.nom, |
588 | MAIL: cliente.mail, | 577 | MAIL: cliente.mail, |
589 | MOD: cliente.mod | 578 | MOD: cliente.mod |
590 | }; | 579 | }; |
591 | 580 | ||
592 | |||
593 | var domicilioStamp = | 581 | var domicilioStamp = |
594 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 582 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
595 | domicilio.Localidad + ', ' + domicilio.Provincia; | 583 | domicilio.Localidad + ', ' + domicilio.Provincia; |
596 | $scope.remito.domicilioStamp = domicilioStamp; | 584 | $scope.remito.domicilioStamp = domicilioStamp; |
597 | |||
598 | $scope.$broadcast('addCabecera',{ | 585 | $scope.$broadcast('addCabecera',{ |
599 | label: 'Cliente:', | 586 | label: 'Cliente:', |
600 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom | 587 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom |
601 | }); | 588 | }); |
602 | $scope.$broadcast('addCabecera',{ | 589 | $scope.$broadcast('addCabecera',{ |
603 | label: 'Domicilio:', | 590 | label: 'Domicilio:', |
604 | valor: domicilioStamp | 591 | valor: domicilioStamp |
605 | }); | 592 | }); |
606 | 593 | ||
607 | if(domicilio.verPuntos) { | 594 | if (domicilio.verPuntos) { |
608 | delete $scope.remito.domicilio.verPuntos; | 595 | delete $scope.remito.domicilio.verPuntos; |
609 | $scope.seleccionarPuntosDeDescarga(); | 596 | $scope.seleccionarPuntosDeDescarga(); |
610 | }else { | 597 | } else { |
611 | crearRemitoService | 598 | crearRemitoService |
612 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | 599 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
613 | .then(function(res) { | 600 | .then(function(res) { |
614 | if(res.data.length) $scope.seleccionarPuntosDeDescarga(); | 601 | if (res.data.length) $scope.seleccionarPuntosDeDescarga(); |
615 | }); | 602 | }); |
616 | } | 603 | } |
617 | }, function() { | 604 | }, function() { |
618 | $scope.seleccionarCliente(true); | 605 | $scope.seleccionarCliente(true); |
619 | return; | 606 | return; |
620 | } | 607 | } |
621 | ); | 608 | ); |
622 | }; | 609 | }; |
623 | 610 | ||
624 | $scope.getTotal = function() { | 611 | $scope.getTotal = function() { |
625 | var total = 0; | 612 | var total = 0; |
626 | var arrayTempArticulos = $scope.remito.articulosRemito; | 613 | var arrayTempArticulos = $scope.articulosFiltro(); |
627 | for(var i = 0; i < arrayTempArticulos.length; i++) { | 614 | for(var i = 0; i < arrayTempArticulos.length; i++) { |
628 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 615 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
629 | } | 616 | } |
630 | return parseFloat(total.toFixed(2)); | 617 | return parseFloat(total.toFixed(2)); |
631 | }; | 618 | }; |
632 | 619 | ||
633 | $scope.getSubTotal = function() { | 620 | $scope.getSubTotal = function() { |
634 | if($scope.articuloACargar) { | 621 | if ($scope.articuloACargar) { |
635 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 622 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
636 | } | 623 | } |
637 | }; | 624 | }; |
638 | 625 | ||
639 | $scope.seleccionarPreciosYCondiciones = function() { | 626 | $scope.seleccionarPreciosYCondiciones = function() { |
640 | if (!$scope.remito.cliente.COD) { | 627 | if (!$scope.remito.cliente.COD) { |
641 | focaModalService.alert('Primero seleccione un cliente'); | 628 | focaModalService.alert('Primero seleccione un cliente'); |
642 | return; | 629 | return; |
643 | } | 630 | } |
644 | if(varlidarRemitoFacturado()) { | 631 | if (varlidarRemitoFacturado()) { |
645 | var modalInstance = $uibModal.open( | 632 | var modalInstance = $uibModal.open( |
646 | { | 633 | { |
647 | ariaLabelledBy: 'Busqueda de Precio Condición', | 634 | ariaLabelledBy: 'Busqueda de Precio Condición', |
648 | templateUrl: 'modal-precio-condicion.html', | 635 | templateUrl: 'modal-precio-condicion.html', |
649 | controller: 'focaModalPrecioCondicionController', | 636 | controller: 'focaModalPrecioCondicionController', |
650 | size: 'lg', | 637 | size: 'lg', |
651 | resolve: { | 638 | resolve: { |
652 | idListaPrecio: function() { | 639 | idListaPrecio: function() { |
653 | return $scope.remito.cliente.MOD || null; | 640 | return $scope.remito.cliente.MOD || null; |
654 | } | 641 | } |
655 | } | 642 | } |
656 | } | 643 | } |
657 | ); | 644 | ); |
658 | modalInstance.result.then( | 645 | modalInstance.result.then( |
659 | function(precioCondicion) { | 646 | function(precioCondicion) { |
660 | var cabecera = ''; | 647 | var cabecera = ''; |
661 | var plazosConcat = ''; | 648 | var plazosConcat = ''; |
662 | if(!Array.isArray(precioCondicion)) { | 649 | if (!Array.isArray(precioCondicion)) { |
663 | $scope.remito.idPrecioCondicion = precioCondicion.id; | 650 | $scope.remito.idPrecioCondicion = precioCondicion.id; |
664 | $scope.remito.remitoPlazo = precioCondicion.plazoPago; | 651 | $scope.remito.remitoPlazo = precioCondicion.plazoPago; |
665 | $scope.idLista = precioCondicion.idListaPrecio; | 652 | $scope.idLista = precioCondicion.idListaPrecio; |
666 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 653 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
667 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 654 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
668 | } | 655 | } |
669 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + | 656 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + |
670 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); | 657 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); |
671 | }else { //Cuando se ingresan los plazos manualmente | 658 | } else { //Cuando se ingresan los plazos manualmente |
672 | $scope.remito.idPrecioCondicion = 0; | 659 | $scope.remito.idPrecioCondicion = 0; |
673 | //-1, el modal productos busca todos los productos | 660 | //-1, el modal productos busca todos los productos |
674 | $scope.idLista = -1; | 661 | $scope.idLista = -1; |
675 | $scope.remito.remitoPlazo = precioCondicion; | 662 | $scope.remito.remitoPlazo = precioCondicion; |
676 | for(var j = 0; j < precioCondicion.length; j++) { | 663 | for(var j = 0; j < precioCondicion.length; j++) { |
677 | plazosConcat += precioCondicion[j].dias + ' '; | 664 | plazosConcat += precioCondicion[j].dias + ' '; |
678 | } | 665 | } |
679 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 666 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
680 | } | 667 | } |
681 | $scope.remito.articulosRemito = []; | 668 | $scope.remito.articulosRemito = []; |
682 | $scope.$broadcast('addCabecera',{ | 669 | $scope.$broadcast('addCabecera',{ |
683 | label: 'Precios y condiciones:', | 670 | label: 'Precios y condiciones:', |
684 | valor: cabecera | 671 | valor: cabecera |
685 | }); | 672 | }); |
686 | |||
687 | $scope.remito.precioCondicion = precioCondicion; | 673 | $scope.remito.precioCondicion = precioCondicion; |
688 | }, function() { | 674 | }, function() { |
689 | 675 | ||
690 | } | 676 | } |
691 | ); | 677 | ); |
692 | } | 678 | } |
693 | }; | 679 | }; |
694 | 680 | ||
695 | $scope.seleccionarTransportista = function() { | 681 | $scope.seleccionarFlete = function(proveedor) { |
696 | $scope.seleccionarProveedor(function() { | 682 | if (varlidarRemitoFacturado()) { |
697 | if (varlidarRemitoFacturado()) { | 683 | var modalInstance = $uibModal.open( |
698 | var modalInstance = $uibModal.open( | 684 | { |
699 | { | 685 | ariaLabelledBy: 'Busqueda de Flete', |
700 | ariaLabelledBy: 'Busqueda de Flete', | 686 | templateUrl: 'modal-flete.html', |
701 | templateUrl: 'modal-flete.html', | 687 | controller: 'focaModalFleteController', |
702 | controller: 'focaModalFleteController', | 688 | size: 'lg', |
703 | size: 'lg', | 689 | resolve: { |
704 | resolve: { | 690 | parametrosFlete: |
705 | parametrosFlete: | 691 | function() { |
706 | function() { | 692 | return { |
707 | return { | 693 | flete: $scope.remito.flete ? '1' : |
708 | flete: $scope.remito.flete ? '1' : | 694 | ($scope.remito.fob ? 'FOB' : |
709 | ($scope.remito.fob ? 'FOB' : | 695 | ($scope.remito.flete === undefined ? |
710 | ($scope.remito.flete === undefined ? | 696 | null : '0')), |
711 | null : '0')), | 697 | bomba: $scope.remito.bomba ? '1' : |
712 | bomba: $scope.remito.bomba ? '1' : | 698 | ($scope.remito.bomba === undefined ? |
713 | ($scope.remito.bomba === undefined ? | 699 | null : '0'), |
714 | null : '0'), | 700 | kilometros: $scope.remito.kilometros |
715 | kilometros: $scope.remito.kilometros | 701 | }; |
716 | }; | 702 | } |
717 | } | ||
718 | } | ||
719 | } | 703 | } |
720 | ); | 704 | } |
721 | modalInstance.result.then( | 705 | ); |
722 | function(datos) { | 706 | modalInstance.result.then( |
723 | $scope.remito.flete = datos.flete; | 707 | function(datos) { |
724 | $scope.remito.fob = datos.FOB; | 708 | |
725 | $scope.remito.bomba = datos.bomba; | 709 | $scope.remito.proveedor = proveedor; |
726 | $scope.remito.kilometros = datos.kilometros; | 710 | $scope.remito.idProveedor = proveedor.COD; |
727 | 711 | $scope.$broadcast('addCabecera',{ | |
712 | label: 'Proveedor:', | ||
713 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | ||
714 | proveedor.NOM | ||
715 | }); | ||
716 | |||
717 | $scope.remito.flete = datos.flete; | ||
718 | $scope.remito.fob = datos.FOB; | ||
719 | $scope.remito.bomba = datos.bomba; | ||
720 | $scope.remito.kilometros = datos.kilometros; | ||
721 | |||
722 | $scope.$broadcast('addCabecera',{ | ||
723 | label: 'Flete:', | ||
724 | valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') | ||
725 | }); | ||
726 | if (datos.flete) { | ||
728 | $scope.$broadcast('addCabecera',{ | 727 | $scope.$broadcast('addCabecera',{ |
729 | label: 'Flete:', | 728 | label: 'Bomba:', |
730 | valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') | 729 | valor: datos.bomba ? 'Si' : 'No' |
731 | }); | 730 | }); |
732 | if (datos.flete) { | 731 | $scope.$broadcast('addCabecera',{ |
733 | $scope.$broadcast('addCabecera',{ | 732 | label: 'Kilometros:', |
734 | label: 'Bomba:', | 733 | valor: datos.kilometros |
735 | valor: datos.bomba ? 'Si' : 'No' | 734 | }); |
736 | }); | 735 | } else { |
737 | $scope.$broadcast('addCabecera',{ | 736 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
738 | label: 'Kilometros:', | 737 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
739 | valor: datos.kilometros | 738 | $scope.remito.bomba = false; |
740 | }); | 739 | $scope.remito.kilometros = null; |
741 | } else { | ||
742 | $scope.$broadcast('removeCabecera', 'Bomba:'); | ||
743 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | ||
744 | $scope.remito.fob = false; | ||
745 | $scope.remito.bomba = false; | ||
746 | $scope.remito.kilometros = null; | ||
747 | } | ||
748 | }, function() { | ||
749 | $scope.seleccionarTransportista(); | ||
750 | } | 740 | } |
751 | ); | 741 | }, function() { |
752 | } | 742 | $scope.seleccionarTransportista(); |
753 | }); | 743 | } |
744 | ); | ||
745 | } | ||
754 | }; | 746 | }; |
755 | 747 | ||
756 | $scope.seleccionarMoneda = function() { | 748 | $scope.seleccionarMoneda = function() { |
757 | if(varlidarRemitoFacturado()) { | 749 | if (varlidarRemitoFacturado()) { |
758 | var parametrosModal = { | 750 | var parametrosModal = { |
759 | titulo: 'Búsqueda de monedas', | 751 | titulo: 'Búsqueda de monedas', |
760 | query: '/moneda', | 752 | query: '/moneda', |
761 | columnas: [ | 753 | columnas: [ |
762 | { | 754 | { |
763 | propiedad: 'DETALLE', | 755 | propiedad: 'DETALLE', |
764 | nombre: 'Nombre' | 756 | nombre: 'Nombre' |
765 | }, | 757 | }, |
766 | { | 758 | { |
767 | propiedad: 'SIMBOLO', | 759 | propiedad: 'SIMBOLO', |
768 | nombre: 'Símbolo' | 760 | nombre: 'Símbolo' |
769 | } | 761 | } |
770 | ], | 762 | ], |
771 | size: 'md' | 763 | size: 'md' |
772 | }; | 764 | }; |
773 | focaModalService.modal(parametrosModal).then( | 765 | focaModalService.modal(parametrosModal).then( |
774 | function(moneda) { | 766 | function(moneda) { |
775 | $scope.abrirModalCotizacion(moneda); | 767 | $scope.abrirModalCotizacion(moneda); |
776 | }, function() { | 768 | }, function() { |
777 | 769 | ||
778 | } | 770 | } |
779 | ); | 771 | ); |
780 | } | 772 | } |
781 | }; | 773 | }; |
782 | 774 | ||
783 | $scope.seleccionarObservaciones = function() { | 775 | $scope.seleccionarObservaciones = function() { |
784 | focaModalService | 776 | focaModalService |
785 | .prompt({ | 777 | .prompt({ |
786 | titulo: 'Observaciones', | 778 | titulo: 'Observaciones', |
787 | value: $scope.remito.observaciones, | 779 | value: $scope.remito.observaciones, |
788 | textarea: true, | 780 | textarea: true, |
789 | readonly: true | 781 | readonly: true |
790 | }) | 782 | }) |
791 | .then(function(observaciones) { | 783 | .then(function(observaciones) { |
792 | $scope.remito.observaciones = observaciones; | 784 | $scope.remito.observaciones = observaciones; |
793 | }); | 785 | }); |
794 | }; | 786 | }; |
795 | 787 | ||
796 | $scope.abrirModalCotizacion = function(moneda) { | 788 | $scope.abrirModalCotizacion = function(moneda) { |
797 | var modalInstance = $uibModal.open( | 789 | var modalInstance = $uibModal.open( |
798 | { | 790 | { |
799 | ariaLabelledBy: 'Busqueda de Cotización', | 791 | ariaLabelledBy: 'Busqueda de Cotización', |
800 | templateUrl: 'modal-cotizacion.html', | 792 | templateUrl: 'modal-cotizacion.html', |
801 | controller: 'focaModalCotizacionController', | 793 | controller: 'focaModalCotizacionController', |
802 | size: 'lg', | 794 | size: 'lg', |
803 | resolve: {idMoneda: function() {return moneda.ID;}} | 795 | resolve: {idMoneda: function() {return moneda.ID;}} |
804 | } | 796 | } |
805 | ); | 797 | ); |
806 | modalInstance.result.then( | 798 | modalInstance.result.then( |
807 | function(cotizacion) { | 799 | function(cotizacion) { |
808 | var articulosTablaTemp = $scope.remito.articulosRemito; | 800 | var articulosTablaTemp = $scope.remito.articulosRemito; |
809 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 801 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
810 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 802 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
811 | $scope.remito.cotizacion.COTIZACION; | 803 | $scope.remito.cotizacion.VENDEDOR; |
812 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 804 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
813 | cotizacion.COTIZACION; | 805 | cotizacion.VENDEDOR; |
814 | } | 806 | } |
815 | $scope.remito.articulosRemito = articulosTablaTemp; | 807 | $scope.remito.articulosRemito = articulosTablaTemp; |
816 | $scope.remito.cotizacion.moneda = moneda; | ||
817 | $scope.remito.cotizacion = cotizacion; | 808 | $scope.remito.cotizacion = cotizacion; |
818 | if(moneda.DETALLE === 'PESOS ARGENTINOS') { | 809 | $scope.remito.cotizacion.moneda = moneda; |
810 | if (moneda.DETALLE === 'PESOS ARGENTINOS') { | ||
819 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 811 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
820 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 812 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
821 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 813 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
822 | }else { | 814 | } else { |
823 | $scope.$broadcast('addCabecera',{ | 815 | $scope.$broadcast('addCabecera',{ |
824 | label: 'Moneda:', | 816 | label: 'Moneda:', |
825 | valor: moneda.DETALLE | 817 | valor: moneda.DETALLE |
826 | }); | 818 | }); |
827 | $scope.$broadcast('addCabecera',{ | 819 | $scope.$broadcast('addCabecera',{ |
828 | label: 'Fecha cotizacion:', | 820 | label: 'Fecha cotizacion:', |
829 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 821 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
830 | }); | 822 | }); |
831 | $scope.$broadcast('addCabecera',{ | 823 | $scope.$broadcast('addCabecera',{ |
832 | label: 'Cotizacion:', | 824 | label: 'Cotizacion:', |
833 | valor: $filter('number')(cotizacion.COTIZACION, '2') | 825 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
834 | }); | 826 | }); |
835 | } | 827 | } |
836 | }, function() { | 828 | }, function() { |
837 | 829 | ||
838 | } | 830 | } |
839 | ); | 831 | ); |
840 | }; | 832 | }; |
841 | 833 | ||
842 | $scope.agregarATabla = function(key) { | 834 | $scope.agregarATabla = function(key) { |
843 | if(key === 13) { | 835 | if (key === 13) { |
844 | if($scope.articuloACargar.cantidad === undefined || | 836 | if ($scope.articuloACargar.cantidad === undefined || |
845 | $scope.articuloACargar.cantidad === 0 || | 837 | $scope.articuloACargar.cantidad === 0 || |
846 | $scope.articuloACargar.cantidad === null ) { | 838 | $scope.articuloACargar.cantidad === null ) { |
847 | focaModalService.alert('El valor debe ser al menos 1'); | 839 | focaModalService.alert('El valor debe ser al menos 1'); |
848 | return; | 840 | return; |
849 | } | 841 | } |
850 | delete $scope.articuloACargar.sectorCodigo; | 842 | delete $scope.articuloACargar.sectorCodigo; |
851 | $scope.remito.articulosRemito.push($scope.articuloACargar); | 843 | $scope.remito.articulosRemito.push($scope.articuloACargar); |
852 | $scope.cargando = true; | 844 | $scope.cargando = true; |
853 | } | 845 | } |
854 | }; | 846 | }; |
855 | 847 | ||
856 | $scope.quitarArticulo = function(key) { | 848 | $scope.quitarArticulo = function(articulo) { |
857 | $scope.remito.articulosRemito.splice(key, 1); | 849 | articulo.idRemito = -1; |
858 | }; | 850 | }; |
859 | 851 | ||
860 | $scope.editarArticulo = function(key, articulo) { | 852 | $scope.articulosFiltro = function() { |
853 | |||
854 | var result = $scope.remito.articulosRemito.filter(function(articulo) { | ||
855 | return articulo.idRemito >= 0; | ||
856 | }); | ||
857 | return result; | ||
858 | }; | ||
859 | |||
860 | $scope.editarArticulo = function(key, articulo, tmpCantidad, tmpPrecio) { | ||
861 | if (key === 13) { | 861 | if (key === 13) { |
862 | if (!articulo.cantidad || !articulo.precio) { | 862 | if (!articulo.cantidad || !articulo.precio) { |
863 | focaModalService.alert('Los valores deben ser al menos 1'); | 863 | focaModalService.alert('Los valores deben ser al menos 1'); |
864 | return; | 864 | return; |
865 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { | 865 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { |
866 | focaModalService.alert('Los valores no pueden ser negativos'); | 866 | focaModalService.alert('Los valores no pueden ser negativos'); |
867 | return; | 867 | return; |
868 | } | 868 | } |
869 | articulo.cantidad = tmpCantidad; | ||
870 | articulo.precio = tmpPrecio; | ||
871 | $scope.getTotal(); | ||
869 | articulo.editCantidad = articulo.editPrecio = false; | 872 | articulo.editCantidad = articulo.editPrecio = false; |
870 | } | 873 | } |
871 | }; | 874 | }; |
872 | 875 | ||
876 | $scope.cancelarEditar = function(articulo) { | ||
877 | $scope.tmpCantidad = articulo.cantidad; | ||
878 | $scope.tmpPrecio = articulo.precio; | ||
879 | articulo.editCantidad = articulo.editPrecio = false; | ||
880 | }; | ||
881 | |||
873 | $scope.cambioEdit = function(articulo, propiedad) { | 882 | $scope.cambioEdit = function(articulo, propiedad) { |
874 | if(propiedad === 'cantidad') { | 883 | if (propiedad === 'cantidad') { |
875 | articulo.editCantidad = true; | 884 | articulo.editCantidad = true; |
876 | }else if(propiedad === 'precio') { | 885 | } else if (propiedad === 'precio') { |
877 | articulo.editPrecio = true; | 886 | articulo.editPrecio = true; |
878 | } | 887 | } |
879 | }; | 888 | }; |
880 | 889 | ||
881 | $scope.resetFilter = function() { | 890 | $scope.resetFilter = function() { |
882 | $scope.articuloACargar = {}; | 891 | $scope.articuloACargar = {}; |
883 | $scope.cargando = true; | 892 | $scope.cargando = true; |
884 | }; | 893 | }; |
885 | //Recibe aviso si el teclado está en uso | 894 | //Recibe aviso si el teclado está en uso |
886 | $rootScope.$on('usarTeclado', function(event, data) { | 895 | $rootScope.$on('usarTeclado', function(event, data) { |
887 | if(data) { | 896 | if (data) { |
888 | $scope.mostrarTeclado = true; | 897 | $scope.mostrarTeclado = true; |
889 | return; | 898 | return; |
890 | } | 899 | } |
891 | $scope.mostrarTeclado = false; | 900 | $scope.mostrarTeclado = false; |
892 | }); | 901 | }); |
893 | 902 | ||
894 | $scope.selectFocus = function($event) { | 903 | $scope.selectFocus = function($event) { |
895 | // Si el teclado esta en uso no selecciona el valor | 904 | // Si el teclado esta en uso no selecciona el valor |
896 | if($scope.mostrarTeclado) { | 905 | if ($scope.mostrarTeclado) { |
897 | return; | 906 | return; |
898 | } | 907 | } |
899 | $event.target.select(); | 908 | $event.target.select(); |
900 | }; | 909 | }; |
901 | 910 | ||
902 | function addArrayCabecera(array) { | 911 | function addArrayCabecera(array) { |
903 | for(var i = 0; i < array.length; i++) { | 912 | for (var i = 0; i < array.length; i++) { |
904 | $scope.$broadcast('addCabecera',{ | 913 | $scope.$broadcast('addCabecera',{ |
905 | label: array[i].label, | 914 | label: array[i].label, |
906 | valor: array[i].valor | 915 | valor: array[i].valor |
907 | }); | 916 | }); |
908 | } | 917 | } |
909 | } | 918 | } |
910 | 919 | ||
911 | function rellenar(relleno, longitud) { | 920 | function rellenar(relleno, longitud) { |
912 | relleno = '' + relleno; | 921 | relleno = '' + relleno; |
913 | while (relleno.length < longitud) { | 922 | while (relleno.length < longitud) { |
914 | relleno = '0' + relleno; | 923 | relleno = '0' + relleno; |
915 | } | 924 | } |
916 | |||
917 | return relleno; | 925 | return relleno; |
918 | } | 926 | } |
919 | 927 | ||
920 | function varlidarRemitoFacturado() { | 928 | function varlidarRemitoFacturado() { |
921 | if($scope.remito.estado !== 5) { | 929 | if ($scope.remito.estado !== 5) { |
922 | return true; | 930 | return true; |
923 | }else { | 931 | } else { |
924 | focaModalService.alert('No se puede editar un remito facturado'); | 932 | focaModalService.alert('No se puede editar un remito facturado'); |
925 | return false(); | 933 | return false(); |
926 | } | 934 | } |
927 | } | 935 | } |
928 | 936 | ||
929 | function salir() { | 937 | function salir() { |
930 | var confirmacion = false; | 938 | var confirmacion = false; |
931 | 939 | ||
932 | if (!angular.equals($scope.remito, $scope.inicial)) { | 940 | if (!angular.equals($scope.remito, $scope.inicial)) { |
933 | confirmacion = true; | 941 | confirmacion = true; |
934 | } | 942 | } |
935 | 943 | ||
936 | if (confirmacion) { | 944 | if (confirmacion) { |
937 | focaModalService.confirm( | 945 | focaModalService.confirm( |
938 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 946 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
939 | ).then(function(data) { | 947 | ).then(function(data) { |
940 | if (data) { | 948 | if (data) { |
941 | $location.path('/'); | 949 | $location.path('/'); |
942 | } | 950 | } |
943 | }); | 951 | }); |
944 | } else { | 952 | } else { |
945 | $location.path('/'); | 953 | $location.path('/'); |
946 | } | 954 | } |
947 | } | 955 | } |
948 | 956 | ||
949 | function enableObservaciones(val) { | 957 | function enableObservaciones(val) { |
950 | var boton = $scope.botonera.filter(function(botonObs) { | 958 | var boton = $scope.botonera.filter(function(botonObs) { |
951 | return botonObs.label === 'Observaciones'; | 959 | return botonObs.label === 'Observaciones'; |
952 | }); | 960 | }); |
953 | |||
954 | boton[0].disable = !val; | 961 | boton[0].disable = !val; |
955 | } | 962 | } |
956 | 963 | ||
957 | function setearRemito(remito) { | 964 | function setearRemito(remito) { |
958 | //añado cabeceras | 965 | //añado cabeceras |
959 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 966 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
960 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 967 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
961 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 968 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
962 | 969 | ||
963 | var cabeceras = []; | 970 | var cabeceras = []; |
964 | 971 | ||
965 | if (remito.cotizacion.ID) { | 972 | if (remito.cotizacion.moneda.CODIGO_AFIP !== 'PES') { |
966 | cabeceras.push({ | 973 | cabeceras.push({ |
967 | label: 'Moneda:', | 974 | label: 'Moneda:', |
968 | valor: remito.cotizacion.moneda.DETALLE | 975 | valor: remito.cotizacion.moneda.DETALLE |
969 | }); | 976 | }); |
970 | cabeceras.push({ | 977 | cabeceras.push({ |
971 | label: 'Fecha cotizacion:', | 978 | label: 'Fecha cotizacion:', |
972 | valor: $filter('date')(remito.cotizacion.FECHA, | 979 | valor: $filter('date')(remito.cotizacion.FECHA, |
973 | 'dd/MM/yyyy') | 980 | 'dd/MM/yyyy') |
974 | }); | 981 | }); |
975 | cabeceras.push({ | 982 | cabeceras.push({ |
976 | label: 'Cotizacion:', | 983 | label: 'Cotizacion:', |
977 | valor: $filter('number')(remito.cotizacion.VENDEDOR, | 984 | valor: $filter('number')(remito.cotizacion.VENDEDOR, |
978 | '2') | 985 | '2') |
979 | }); | 986 | }); |
980 | } | 987 | } |
981 | if (remito.cliente.COD) { | 988 | if (remito.cliente.COD) { |
982 | cabeceras.push({ | 989 | cabeceras.push({ |
983 | label: 'Cliente:', | 990 | label: 'Cliente:', |
984 | valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + | 991 | valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + |
985 | remito.cliente.NOM | 992 | remito.cliente.NOM |
986 | }); | 993 | }); |
987 | cabeceras.push({ | 994 | cabeceras.push({ |
988 | label: 'Domicilio:', | 995 | label: 'Domicilio:', |
989 | valor: remito.domicilioStamp | 996 | valor: remito.domicilioStamp |
990 | }); | 997 | }); |
991 | } | 998 | } |
992 | if (remito.vendedor.NUM) { | 999 | if (remito.vendedor.NUM) { |
993 | cabeceras.push({ | 1000 | cabeceras.push({ |
994 | label: 'Vendedor:', | 1001 | label: 'Vendedor:', |
995 | valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + | 1002 | valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + |
996 | ' - ' + remito.vendedor.NOM | 1003 | ' - ' + remito.vendedor.NOM |
997 | }); | 1004 | }); |
998 | } | 1005 | } |
999 | if (remito.proveedor.COD) { | 1006 | if (remito.proveedor.COD) { |
1000 | cabeceras.push({ | 1007 | cabeceras.push({ |
1001 | label: 'Proveedor:', | 1008 | label: 'Proveedor:', |
1002 | valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + | 1009 | valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + |
1003 | ' - ' + remito.proveedor.NOM | 1010 | ' - ' + remito.proveedor.NOM |
1004 | }); | 1011 | }); |
1005 | } | 1012 | } |
1006 | if (remito.flete !== undefined) { | 1013 | if (remito.flete !== undefined && remito.fob !== undefined) { |
1007 | cabeceras.push({ | 1014 | cabeceras.push({ |
1008 | label: 'Flete:', | 1015 | label: 'Flete:', |
1009 | valor: remito.fob === 1 ? 'FOB' : ( | 1016 | valor: remito.fob ? 'FOB' : ( |
1010 | remito.flete === 1 ? 'Si' : 'No') | 1017 | remito.flete ? 'Si' : 'No') |
1011 | }); | 1018 | }); |
1012 | } | 1019 | } |
1013 | if (remito.remitoPlazo) { | 1020 | if (remito.remitoPlazo) { |
1014 | cabeceras.push({ | 1021 | cabeceras.push({ |
1015 | label: 'Precio condicion:', | 1022 | label: 'Precio condicion:', |
1016 | valor: valorPrecioCondicion() + ' ' + | 1023 | valor: valorPrecioCondicion() + ' ' + |
1017 | remitoBusinessService.plazoToString(remito.remitoPlazo) | 1024 | remitoBusinessService.plazoToString(remito.remitoPlazo) |
1018 | }); | 1025 | }); |
1019 | } | 1026 | } |
1020 | |||
1021 | function valorPrecioCondicion() { | 1027 | function valorPrecioCondicion() { |
1022 | if (remito.idPrecioCondicion > 0) { | 1028 | if (remito.idPrecioCondicion > 0) { |
1023 | return remito.precioCondicion.nombre; | 1029 | return remito.precioCondicion.nombre; |
1024 | } else { | 1030 | } else { |
1025 | return 'Ingreso Manual'; | 1031 | return 'Ingreso Manual'; |
1026 | } | 1032 | } |
1027 | } | 1033 | } |
1028 | |||
1029 | if (remito.flete === 1) { | 1034 | if (remito.flete === 1) { |
1030 | var cabeceraBomba = { | 1035 | var cabeceraBomba = { |
1031 | label: 'Bomba', | 1036 | label: 'Bomba', |
1032 | valor: remito.bomba === 1 ? 'Si' : 'No' | 1037 | valor: remito.bomba === 1 ? 'Si' : 'No' |
1033 | }; | 1038 | }; |
1034 | if (remito.kilometros) { | 1039 | if (remito.kilometros) { |
1035 | var cabeceraKilometros = { | 1040 | var cabeceraKilometros = { |
1036 | label: 'Kilometros', | 1041 | label: 'Kilometros', |
1037 | valor: remito.kilometros | 1042 | valor: remito.kilometros |
1038 | }; | 1043 | }; |
1039 | cabeceras.push(cabeceraKilometros); | 1044 | cabeceras.push(cabeceraKilometros); |
1040 | } | 1045 | } |
1041 | cabeceras.push(cabeceraBomba); | 1046 | cabeceras.push(cabeceraBomba); |
1042 | } | 1047 | } |
1043 | $scope.remito.articulosRemito = remito.articulosRemito; | 1048 | |
1044 | remitoBusinessService.calcularArticulos($scope.remito.articulosRemito, | ||
1045 | remito.cotizacion.VENDEDOR); | ||
1046 | if (remito.idPrecioCondicion > 0) { | 1049 | if (remito.idPrecioCondicion > 0) { |
1047 | $scope.idLista = remito.precioCondicion.idListaPrecio; | 1050 | $scope.idLista = remito.precioCondicion.idListaPrecio; |
1048 | } else { | 1051 | } else { |
1049 | $scope.idLista = -1; | 1052 | $scope.idLista = -1; |
1050 | } | 1053 | } |
1051 | $scope.puntoVenta = rellenar(remito.sucursal, 4); | 1054 | $scope.puntoVenta = rellenar(remito.sucursal, 4); |
1052 | $scope.comprobante = rellenar(remito.numeroRemito, 8); | 1055 | $scope.comprobante = rellenar(remito.numeroRemito, 8); |
1053 | $scope.remito = remito; | 1056 | $scope.remito = remito; |
1057 | if ($scope.remito.puntosDescarga) { | ||
1058 | var puntosDescarga = $scope.remito.puntosDescarga; | ||
1059 | cabeceras.push({ | ||
1060 | label: 'Puntos de descarga: ', | ||
1061 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntosDescarga)) | ||
1062 | }); | ||
1063 | } | ||
1054 | addArrayCabecera(cabeceras); | 1064 | addArrayCabecera(cabeceras); |
1055 | } | 1065 | } |
1056 | 1066 | ||
1057 | function getLSRemito() { | 1067 | function getLSRemito() { |
1058 | var remito = JSON.parse($localStorage.remito || null); | 1068 | var remito = JSON.parse($localStorage.remito || null); |
src/js/controllerComprobante.js
1 | angular.module('focaCrearRemito') | File was deleted | |
2 | .controller('focaRemitoComprobanteController', [ | ||
3 | '$scope', | ||
4 | '$uibModalInstance', | ||
5 | 'crearRemitoService', | ||
6 | '$filter', | ||
7 | 'parametros', | ||
8 | 'FileSaver', | ||
9 | 'Blob', | ||
10 | function( | ||
11 | $scope, $uibModalInstance, crearRemitoService, $filter, | ||
12 | parametros, FileSaver, Blob | ||
13 | ) { | ||
14 | crearRemitoService.getRemitoById(parametros.idRemito).then(function(res) { | ||
15 | |||
16 | $scope.remito = res.data; | ||
17 | }); | ||
18 | $scope.correoEnviado = false; | ||
19 | $scope.correoNoEnviado = false; | ||
20 | $scope.esperando = false; | ||
21 | |||
22 | $scope.aceptar = function() { | ||
23 | $uibModalInstance.close(); | ||
24 | }; | ||
25 | |||
26 | $scope.imprimir = function () { | ||
27 | $scope.esperando = true; | ||
28 | crearRemitoService.imprimirRemitoByIdRemito($scope.remito.id).then( | ||
29 | function(res) { | ||
30 | var data = new Blob([res.data], {type: 'application/pdf'}); | ||
31 | |||
32 | FileSaver.saveAs( | ||
33 | data, | ||
34 | 'RE-R-' + $filter('comprobante')([ | ||
35 | $scope.remito.sucursal, | ||
36 | $scope.remito.numeroRemito | ||
37 | ]) + '.pdf' | ||
38 | ); | ||
39 | $scope.esperando = false; | ||
40 | } | ||
41 | ); | ||
42 | }; | ||
43 | |||
44 | $scope.enviarCorreo = function(key) { | ||
45 | if(key !== 13) return; | ||
46 | $scope.esperando = true; | ||
47 | var options = { | ||
48 | para: $scope.remito.cliente.MAIL, | ||
49 | remito: $scope.remito.id | ||
50 | }; | ||
51 | |||
52 | crearRemitoService.enviarCorreo(options).then(function() { | ||
53 | $scope.correoEnviado = true; | ||
54 | $scope.esperando = false; | ||
55 | }, function() { | ||
56 | $scope.esperando = false; | ||
57 | $scope.correoNoEnviado = true; | ||
58 | }); | ||
59 | }; | ||
60 | } | ||
61 | ]); | ||
62 | 1 | angular.module('focaCrearRemito') |
src/js/service.js
1 | angular.module('focaCrearRemito') | 1 | angular.module('focaCrearRemito') |
2 | .service('crearRemitoService', ['$http', 'API_ENDPOINT', | 2 | .service('crearRemitoService', ['$http', 'API_ENDPOINT', |
3 | function($http, API_ENDPOINT) { | 3 | function($http, API_ENDPOINT) { |
4 | var route = API_ENDPOINT.URL; | 4 | var route = API_ENDPOINT.URL; |
5 | return { | 5 | return { |
6 | crearRemito: function(remito) { | 6 | crearRemito: function(remito) { |
7 | // TODO: Cambiar para usar el servicio /remito | 7 | // TODO: Cambiar para usar el servicio /remito |
8 | return $http.post(route + '/remito', remito); | 8 | return $http.post(route + '/remito', remito); |
9 | }, | 9 | }, |
10 | getRemitoById: function(id) { | 10 | getRemitoById: function(id) { |
11 | return $http.get(route + '/remito/obtener/' + id); | 11 | return $http.get(route + '/remito/obtener/' + id); |
12 | }, | 12 | }, |
13 | obtenerRemito: function() { | 13 | obtenerRemito: function() { |
14 | return $http.get(route +'/nota-pedido'); | 14 | return $http.get(route +'/nota-pedido'); |
15 | }, | 15 | }, |
16 | setRemito: function(remito) { | 16 | setRemito: function(remito) { |
17 | this.remito = remito; | 17 | this.remito = remito; |
18 | }, | 18 | }, |
19 | clearRemito: function() { | 19 | clearRemito: function() { |
20 | this.remito = undefined; | 20 | this.remito = undefined; |
21 | }, | 21 | }, |
22 | getRemito: function() { | 22 | getRemito: function() { |
23 | return this.remito; | 23 | return this.remito; |
24 | }, | 24 | }, |
25 | getArticulosByIdRemito: function(id) { | 25 | getArticulosByIdRemito: function(id) { |
26 | return $http.get(route+'/articulos/nota-pedido/'+id); | 26 | return $http.get(route+'/articulos/nota-pedido/'+id); |
27 | }, | 27 | }, |
28 | crearArticulosParaRemito: function(articuloRemito) { | 28 | crearArticulosParaRemito: function(articuloRemito) { |
29 | return $http.post(route + '/articulos/remito', | 29 | return $http.post(route + '/articulos/remito', |
30 | {articuloRemito: articuloRemito}); | 30 | {articuloRemito: articuloRemito}); |
31 | }, | 31 | }, |
32 | getDomiciliosByIdRemito: function(id) { | 32 | getDomiciliosByIdRemito: function(id) { |
33 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); | 33 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); |
34 | }, | 34 | }, |
35 | getDomiciliosByIdCliente: function(id) { | 35 | getDomiciliosByIdCliente: function(id) { |
36 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) | 36 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) |
37 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); | 37 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); |
38 | }, | 38 | }, |
39 | getPrecioCondicion: function() { | 39 | getPrecioCondicion: function() { |
40 | return $http.get(route + '/precio-condicion'); | 40 | return $http.get(route + '/precio-condicion'); |
41 | }, | 41 | }, |
42 | getPrecioCondicionById: function(id) { | 42 | getPrecioCondicionById: function(id) { |
43 | return $http.get(route + '/precio-condicion/' + id); | 43 | return $http.get(route + '/precio-condicion/' + id); |
44 | }, | 44 | }, |
45 | getPlazoPagoByPrecioCondicion: function(id) { | 45 | getPlazoPagoByPrecioCondicion: function(id) { |
46 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); | 46 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); |
47 | }, | 47 | }, |
48 | crearFlete: function(flete) { | 48 | crearFlete: function(flete) { |
49 | return $http.post(route + '/flete', {flete : flete}); | 49 | return $http.post(route + '/flete', {flete : flete}); |
50 | }, | 50 | }, |
51 | crearPlazosParaRemito: function(plazos) { | 51 | crearPlazosParaRemito: function(plazos) { |
52 | return $http.post(route + '/plazo-pago/remito', plazos); | 52 | return $http.post(route + '/plazo-pago/remito', plazos); |
53 | }, | 53 | }, |
54 | getCotizacionByIdMoneda: function(id) { | 54 | getCotizacionByIdMoneda: function(id) { |
55 | return $http.get(route + '/moneda/' + id); | 55 | return $http.get(route + '/moneda/' + id); |
56 | }, | 56 | }, |
57 | crearEstadoParaRemito: function(estado) { | 57 | crearEstadoParaRemito: function(estado) { |
58 | return $http.post(route + '/estado', {estado: estado}); | 58 | return $http.post(route + '/estado', {estado: estado}); |
59 | }, | 59 | }, |
60 | getNumeroRemito: function() { | 60 | getNumeroRemito: function() { |
61 | return $http.get(route + '/remito/numero-siguiente'); | 61 | return $http.get(route + '/remito/numero-siguiente'); |
62 | }, | 62 | }, |
63 | imprimirRemitoByIdRemito: function(idRemito, original) { | 63 | imprimirRemitoByIdRemito: function(idRemito) { |
64 | var tipo = original ? '/original' : ''; | 64 | return $http.get(route + '/remito/comprobante/' + idRemito , { |
65 | return $http.get(route + '/remito/comprobante/' + idRemito + tipo, { | ||
66 | responseType: 'arraybuffer' | 65 | responseType: 'arraybuffer' |
67 | }); | 66 | }); |
68 | }, | 67 | }, |
69 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { | 68 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { |
70 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + | 69 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + |
71 | idDomicilio + '/' + idCliente); | 70 | idDomicilio + '/' + idCliente); |
72 | }, | 71 | }, |
73 | enviarCorreo: function(options) { | 72 | enviarCorreo: function(options) { |
74 | return $http.post(API_ENDPOINT.URL + '/remito/mail', options); | 73 | return $http.post(API_ENDPOINT.URL + '/remito/mail', options); |
75 | }, | 74 | }, |
76 | getBotonera: function() { | 75 | getBotonera: function() { |
77 | return [ | 76 | return [ |
78 | { | 77 | { |
79 | label: 'Nota pedido', | 78 | label: 'Nota pedido', |
80 | image: 'notaDePedido.png' | 79 | image: 'notaDePedido.png' |
81 | }, | 80 | }, |
82 | { | 81 | { |
83 | label: 'Cliente', | 82 | label: 'Cliente', |
84 | image: 'cliente.png' | 83 | image: 'cliente.png' |
85 | }, | 84 | }, |
86 | { | 85 | { |
87 | label: 'Transportista', | 86 | label: 'Proveedor', |
88 | image: 'proveedor.png' | 87 | image: 'proveedor.png' |
89 | }, | 88 | }, |
90 | { | 89 | { |
91 | label: 'Moneda', | 90 | label: 'Moneda', |
92 | image: 'moneda.png' | 91 | image: 'moneda.png' |
93 | }, | 92 | }, |
94 | { | 93 | { |
95 | label: 'Precios y condiciones', | 94 | label: 'Precios y condiciones', |
96 | image: 'precios-condiciones.png' | 95 | image: 'precios-condiciones.png' |
97 | }, | 96 | }, |
98 | { | 97 | { |
99 | label: 'Productos', | 98 | label: 'Productos', |
100 | image: 'productos.png' | 99 | image: 'productos.png' |
101 | }, | 100 | }, |
102 | { | 101 | { |
103 | label: 'Observaciones', | 102 | label: 'Observaciones', |
104 | image: 'botonObservaciones.png', | 103 | image: 'botonObservaciones.png', |
105 | disable: true | 104 | disable: true |
106 | } | 105 | } |
107 | ]; | 106 | ]; |
108 | } | 107 | } |
109 | }; | 108 | }; |
110 | }]); | 109 | }]); |
111 | 110 |
src/views/remito-comprobante.html
1 | <div class="modal-header"> | File was deleted | |
2 | <h5>Comprobante de remito Nº | ||
3 | <span | ||
4 | ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"> | ||
5 | </span> | ||
6 | </h5> | ||
7 | </div> | ||
8 | <div class="modal-body"> | ||
9 | <div class="col-12"> | ||
10 | <label | ||
11 | class="col-12 bg-success text-white" | ||
12 | ng-show="correoEnviado">Correo enviado con éxito</label> | ||
13 | <label | ||
14 | class="col-12 bg-danger text-white" | ||
15 | ng-show="correoNoEnviado">Hubo un error al enviar el correo</label> | ||
16 | <label>Enviar correo a </label> | ||
17 | <input | ||
18 | class="form-control" | ||
19 | ng-model="remito.cliente.MAIL" | ||
20 | ng-click="enviarCorreo($event.keyCode)"/> | ||
21 | </div> | ||
22 | </div> | ||
23 | <div class="modal-footer"> | ||
24 | <button | ||
25 | type="button" | ||
26 | class="btn btn-info" | ||
27 | ng-click="imprimir()" | ||
28 | ladda="esperando" | ||
29 | >Imprimir</button> | ||
30 | <button | ||
31 | type="button" | ||
32 | class="btn btn-primary" | ||
33 | ng-click="aceptar()" | ||
34 | ladda="esperando" | ||
35 | >Aceptar</button> | ||
36 | <button | ||
37 | type="button" | ||
38 | class="btn btn-primary" | ||
39 | ng-click="enviarCorreo(13)" | ||
40 | ladda="esperando" | ||
41 | >Enviar</button> | ||
42 | </div> | ||
43 | 1 | <div class="modal-header"> |
src/views/remito.html
1 | <div class="crear-nota-remito foca-crear row"> | 1 | <div class="crear-nota-remito foca-crear row"> |
2 | <foca-cabecera-facturador | 2 | <foca-cabecera-facturador |
3 | titulo="'Remito'" | 3 | titulo="'Remito'" |
4 | numero="puntoVenta + '-' + comprobante" | 4 | numero="puntoVenta + '-' + comprobante" |
5 | fecha="now" | 5 | fecha="now" |
6 | class="mb-0 col-lg-12" | 6 | class="mb-0 col-lg-12" |
7 | busqueda="seleccionarRemito" | 7 | busqueda="seleccionarRemito" |
8 | ></foca-cabecera-facturador> | 8 | ></foca-cabecera-facturador> |
9 | <marquee | ||
10 | bgcolor="#FF9900" | ||
11 | behavior="scroll" | ||
12 | direction="left" | ||
13 | ng-bind="remito.observaciones" | ||
14 | ></marquee> | ||
9 | <div class="col-lg-12"> | 15 | <div class="col-lg-12"> |
10 | <div class="row mt-4"> | 16 | <div class="row mt-4"> |
11 | <div class="col-12 col-md-10 col-lg-10 border border-light rounded"> | 17 | <div class="col-12 col-md-10 col-lg-10 border border-light rounded"> |
12 | <div class="row p-1 botonera-secundaria px-5 py-2"> | 18 | <div class="row p-1 botonera-secundaria px-5 py-2"> |
13 | <div class="col-12"> | 19 | <div class="col-12"> |
14 | <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador> | 20 | <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador> |
15 | </div> | 21 | </div> |
16 | </div> | 22 | </div> |
17 | <!-- PC --> | 23 | <!-- PC --> |
18 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> | 24 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> |
19 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> | 25 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> |
20 | <thead> | 26 | <thead> |
21 | <tr class="d-flex"> | 27 | <tr class="d-flex"> |
22 | <th class="">#</th> | 28 | <th class="">#</th> |
23 | <th class="col">Código</th> | 29 | <th class="col">Código</th> |
24 | <th class="col-4">Descripción</th> | 30 | <th class="col-4">Descripción</th> |
25 | <th class="col text-right">Cantidad</th> | 31 | <th class="col text-right">Cantidad</th> |
26 | <th class="col text-right">Precio Unitario</th> | 32 | <th class="col text-right">Precio Unitario</th> |
27 | <th class="col text-right">SubTotal</th> | 33 | <th class="col text-right">SubTotal</th> |
28 | <th class="text-right"> | 34 | <th class="text-right"> |
29 | <button | 35 | <button |
30 | class="btn btn-outline-light selectable" | 36 | class="btn btn-outline-light selectable" |
31 | ng-click="show = !show; masMenos()" | 37 | ng-click="show = !show; masMenos()" |
32 | > | 38 | > |
33 | <i | 39 | <i |
34 | class="fa fa-chevron-down" | 40 | class="fa fa-chevron-down" |
35 | ng-show="show" | 41 | ng-show="show" |
36 | aria-hidden="true" | 42 | aria-hidden="true" |
37 | > | 43 | > |
38 | </i> | 44 | </i> |
39 | <i | 45 | <i |
40 | class="fa fa-chevron-up" | 46 | class="fa fa-chevron-up" |
41 | ng-hide="show" | 47 | ng-hide="show" |
42 | aria-hidden="true"> | 48 | aria-hidden="true"> |
43 | </i> | 49 | </i> |
44 | </button> | 50 | </button> |
45 | </th> | 51 | </th> |
46 | </tr> | 52 | </tr> |
47 | </thead> | 53 | </thead> |
48 | <tbody class="tabla-articulo-body"> | 54 | <tbody class="tabla-articulo-body"> |
49 | <tr | 55 | <tr |
50 | ng-repeat="(key, articulo) in remito.articulosRemito" | 56 | ng-repeat="(key, articulo) in articulosFiltro()" |
51 | ng-show="show || key == (remito.articulosRemito.length - 1)" | 57 | ng-show="show || key == (articulosFiltro().length - 1)" |
52 | class="d-flex" | 58 | class="d-flex" |
53 | > | 59 | > |
54 | <td ng-bind="key + 1"></td> | 60 | <td ng-bind="key + 1"></td> |
55 | <td | 61 | <td |
56 | class="col" | 62 | class="col" |
57 | ng-bind="articulo.sector + '-' + articulo.codigo" | 63 | ng-bind="articulo.sector + '-' + articulo.codigo" |
58 | ></td> | 64 | ></td> |
59 | <td | 65 | <td |
60 | class="col-4" | 66 | class="col-4" |
61 | ng-bind="articulo.descripcion" | 67 | ng-bind="articulo.descripcion" |
62 | ></td> | 68 | ></td> |
63 | <td class="col text-right"> | 69 | <td class="col text-right"> |
64 | <input | 70 | <input |
65 | ng-show="articulo.editCantidad" | 71 | ng-show="articulo.editCantidad" |
66 | ng-model="articulo.cantidad" | 72 | ng-model="tmpCantidad" |
67 | class="form-control" | 73 | class="form-control" |
68 | foca-tipo-input | 74 | foca-tipo-input |
69 | min="1" | 75 | min="1" |
70 | foca-focus="articulo.editCantidad" | 76 | foca-focus="articulo.editCantidad" |
71 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 77 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" |
72 | ng-focus="selectFocus($event)" | 78 | esc-key="cancelarEditar(articulo)" |
79 | ng-focus="selectFocus($event); | ||
80 | tmpCantidad = articulo.cantidad; | ||
81 | tmpPrecio = articulo.precio" | ||
73 | teclado-virtual | 82 | teclado-virtual |
74 | > | 83 | > |
75 | <i | 84 | <i |
76 | class="selectable" | 85 | class="selectable" |
77 | ng-click="cambioEdit(articulo, 'cantidad')" | 86 | ng-click="cambioEdit(articulo, 'cantidad')" |
78 | ng-hide="articulo.editCantidad" | 87 | ng-hide="articulo.editCantidad" |
79 | ng-bind="articulo.cantidad"> | 88 | ng-bind="articulo.cantidad"> |
80 | </i> | 89 | </i> |
81 | </td> | 90 | </td> |
82 | <td class="col text-right"> | 91 | <td class="col text-right"> |
83 | <input | 92 | <input |
84 | ng-show="articulo.editPrecio" | 93 | ng-show="articulo.editPrecio" |
85 | ng-model="articulo.precio" | 94 | ng-model="tmpPrecio" |
86 | class="form-control" | 95 | class="form-control" |
87 | foca-tipo-input | 96 | foca-tipo-input |
88 | min="1" | 97 | min="1" |
89 | step="0.0001" | 98 | step="0.0001" |
90 | foca-focus="articulo.editPrecio" | 99 | foca-focus="articulo.editPrecio" |
91 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 100 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" |
92 | ng-focus="selectFocus($event)" | 101 | esc-key="cancelarEditar(articulo)" |
102 | ng-focus="selectFocus($event); | ||
103 | tmpCantidad = articulo.cantidad; | ||
104 | tmpPrecio = articulo.precio" | ||
93 | teclado-virtual | 105 | teclado-virtual |
94 | > | 106 | > |
95 | <i | 107 | <i |
96 | class="selectable" | 108 | class="selectable" |
97 | ng-click="cambioEdit(articulo, 'precio')" | 109 | ng-click="cambioEdit(articulo, 'precio')" |
98 | ng-hide="articulo.editPrecio" | 110 | ng-hide="articulo.editPrecio" |
99 | ng-bind="articulo.precio | number: 4"> | 111 | ng-bind="articulo.precio | number: 4"> |
100 | </i> | 112 | </i> |
101 | </td> | 113 | </td> |
102 | <td | 114 | <td |
103 | class="col text-right" | 115 | class="col text-right" |
104 | ng-bind="(articulo.precio * articulo.cantidad) | number: 2"> | 116 | ng-bind="(articulo.precio * articulo.cantidad) | number: 2"> |
105 | </td> | 117 | </td> |
106 | <td class="text-center"> | 118 | <td class="text-center"> |
107 | <button | 119 | <button |
108 | class="btn btn-outline-light" | 120 | class="btn btn-outline-light" |
109 | ng-click="quitarArticulo(key)" | 121 | ng-click="quitarArticulo(articulo)" |
110 | > | 122 | > |
111 | <i class="fa fa-trash"></i> | 123 | <i class="fa fa-trash"></i> |
112 | </button> | 124 | </button> |
113 | <button | 125 | <button |
114 | class="btn btn-outline-light" | 126 | class="btn btn-outline-light" |
115 | ng-click="editarArticulo(13, articulo)" | 127 | ng-click="editarArticulo(13, articulo)" |
116 | ng-show="articulo.editCantidad || articulo.editPrecio" | 128 | ng-show="articulo.editCantidad || articulo.editPrecio" |
117 | > | 129 | > |
118 | <i class="fa fa-save"></i> | 130 | <i class="fa fa-save"></i> |
119 | </button> | 131 | </button> |
120 | </td> | 132 | </td> |
121 | </tr> | 133 | </tr> |
122 | </tbody> | 134 | </tbody> |
123 | <tfoot> | 135 | <tfoot> |
124 | <tr ng-show="!cargando" class="d-flex"> | 136 | <tr ng-show="!cargando" class="d-flex"> |
125 | <td | 137 | <td |
126 | class="align-middle" | 138 | class="align-middle" |
127 | ng-bind="remito.articulosRemito.length + 1" | 139 | ng-bind="articulosFiltro().length + 1" |
128 | ></td> | 140 | ></td> |
129 | <td class="col"> | 141 | <td class="col"> |
130 | <input | 142 | <input |
131 | class="form-control" | 143 | class="form-control" |
132 | ng-model="articuloACargar.sectorCodigo" | 144 | ng-model="articuloACargar.sectorCodigo" |
133 | readonly | 145 | readonly |
134 | > | 146 | > |
135 | </td> | 147 | </td> |
136 | <td class="col-4 tabla-articulo-descripcion"> | 148 | <td class="col-4 tabla-articulo-descripcion"> |
137 | <input | 149 | <input |
138 | class="form-control" | 150 | class="form-control" |
139 | ng-model="articuloACargar.descripcion" | 151 | ng-model="articuloACargar.descripcion" |
140 | readonly | 152 | readonly |
141 | > | 153 | > |
142 | </td> | 154 | </td> |
143 | <td class="col text-right"> | 155 | <td class="col text-right"> |
144 | <input | 156 | <input |
145 | class="form-control" | 157 | class="form-control" |
146 | foca-tipo-input | 158 | foca-tipo-input |
147 | min="1" | 159 | min="1" |
148 | ng-model="articuloACargar.cantidad" | 160 | ng-model="articuloACargar.cantidad" |
149 | foca-focus="!cargando" | 161 | foca-focus="!cargando" |
150 | esc-key="resetFilter()" | 162 | esc-key="resetFilter()" |
151 | ng-keypress="agregarATabla($event.keyCode)" | 163 | ng-keypress="agregarATabla($event.keyCode)" |
152 | teclado-virtual | 164 | teclado-virtual |
153 | > | 165 | > |
154 | </td> | 166 | </td> |
155 | <td class="col text-right"> | 167 | <td class="col text-right"> |
156 | <input | 168 | <input |
157 | class="form-control" | 169 | class="form-control" |
158 | ng-model="articuloACargar.precio" | 170 | ng-model="articuloACargar.precio" |
159 | ng-show="idLista != -1" | 171 | ng-show="idLista != -1" |
160 | ng-keypress="agregarATabla($event.keyCode)" | 172 | ng-keypress="agregarATabla($event.keyCode)" |
161 | > | 173 | > |
162 | <input | 174 | <input |
163 | class="form-control" | 175 | class="form-control" |
164 | foca-tipo-input | 176 | foca-tipo-input |
165 | step="0.0001" | 177 | step="0.0001" |
166 | ng-model="articuloACargar.precio" | 178 | ng-model="articuloACargar.precio" |
167 | esc-key="resetFilter()" | 179 | esc-key="resetFilter()" |
168 | ng-keypress="agregarATabla($event.keyCode)" | 180 | ng-keypress="agregarATabla($event.keyCode)" |
169 | ng-show="idLista == -1" | 181 | ng-show="idLista == -1" |
170 | teclado-virtual | 182 | teclado-virtual |
171 | > | 183 | > |
172 | </td> | 184 | </td> |
173 | <td class="col text-right"> | 185 | <td class="col text-right"> |
174 | <input | 186 | <input |
175 | class="form-control" | 187 | class="form-control" |
176 | ng-value="getSubTotal() | number: 2" | 188 | ng-value="getSubTotal() | number: 2" |
177 | readonly | 189 | readonly |
178 | ></td> | 190 | ></td> |
179 | <td class="text-center align-middle"> | 191 | <td class="text-center align-middle"> |
180 | <button | 192 | <button |
181 | class="btn btn-outline-light" | 193 | class="btn btn-outline-light" |
182 | ng-click="agregarATabla(13)" | 194 | ng-click="agregarATabla(13)" |
183 | > | 195 | > |
184 | <i class="fa fa-save"></i> | 196 | <i class="fa fa-save"></i> |
185 | </button> | 197 | </button> |
186 | </td> | 198 | </td> |
187 | </tr> | 199 | </tr> |
188 | 200 | ||
189 | <tr class="d-flex"> | 201 | <tr class="d-flex"> |
190 | <td colspan="4" class="no-border-top"> | 202 | <td colspan="4" class="no-border-top"> |
191 | <strong>Items:</strong> | 203 | <strong>Items:</strong> |
192 | <a ng-bind="remito.articulosRemito.length"></a> | 204 | <a ng-bind="articulosFiltro().length"></a> |
193 | </td> | 205 | </td> |
194 | <td class="text-right ml-auto table-celda-total no-border-top"> | 206 | <td class="text-right ml-auto table-celda-total no-border-top"> |
195 | <h3>Total:</h3> | 207 | <h3>Total:</h3> |
196 | </td> | 208 | </td> |
197 | <td class="table-celda-total text-right no-border-top" colspan="1"> | 209 | <td class="table-celda-total text-right no-border-top" colspan="1"> |
198 | <h3>{{getTotal() | currency: remito.moneda.SIMBOLO}}</h3> | 210 | <h3>{{getTotal() | currency: remito.cotizacion.moneda.SIMBOLO}}</h3> |
199 | </td> | 211 | </td> |
200 | <td class="text-right no-border-top"> | 212 | <td class="text-right no-border-top"> |
201 | <button | 213 | <button |
202 | type="button" | 214 | type="button" |
203 | class="btn btn-default btn-sm" | 215 | class="btn btn-default btn-sm" |
204 | > | 216 | > |
205 | Totales | 217 | Totales |
206 | </button> | 218 | </button> |
207 | </td> | 219 | </td> |
208 | </tr> | 220 | </tr> |
209 | </tfoot> | 221 | </tfoot> |
210 | </table> | 222 | </table> |
211 | </div> | 223 | </div> |
212 | |||
213 | <!-- MOBILE --> | ||
214 | <div class="row d-sm-none"> | ||
215 | <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile"> | ||
216 | <thead> | ||
217 | <tr class="d-flex"> | ||
218 | <th class="">#</th> | ||
219 | <th class="col px-0"> | ||
220 | <div class="d-flex"> | ||
221 | <div class="col-4 px-1">Código</div> | ||
222 | <div class="col-8 px-1">Descripción</div> | ||
223 | </div> | ||
224 | <div class="d-flex"> | ||
225 | <div class="col-3 px-1">Cantidad</div> | ||
226 | <div class="col px-1 text-right">P. Uni.</div> | ||
227 | <div class="col px-1 text-right">Subtotal</div> | ||
228 | </div> | ||
229 | </th> | ||
230 | <th class="text-center tamaño-boton"> | ||
231 | | ||
232 | </th> | ||
233 | </tr> | ||
234 | </thead> | ||
235 | <tbody> | ||
236 | <tr | ||
237 | ng-repeat="(key, articulo) in remito.articulosRemito" | ||
238 | ng-show="show || key == remito.articulosRemito.length - 1" | ||
239 | > | ||
240 | <td class="w-100 align-middle d-flex p-0"> | ||
241 | <div class="align-middle p-1"> | ||
242 | <span ng-bind="key+1" class="align-middle"></span> | ||
243 | </div> | ||
244 | <div class="col px-0"> | ||
245 | <div class="d-flex"> | ||
246 | <div class="col-4 px-1"> | ||
247 | <span | ||
248 | ng-bind="articulo.sector + '-' + articulo.codigo" | ||
249 | ></span> | ||
250 | </div> | ||
251 | <div class="col-8 px-1"> | ||
252 | <span | ||
253 | ng-bind="'x' + articulo.cantidad" | ||
254 | ng-hide="articulo.editCantidad" | ||
255 | ></span> | ||
256 | <i | ||
257 | class="fa fa-pencil text-white-50" | ||
258 | aria-hidden="true" | ||
259 | ng-hide="articulo.editCantidad" | ||
260 | ng-click="articulo.editCantidad = true" | ||
261 | ></i> | ||
262 | <input | ||
263 | ng-show="articulo.editCantidad" | ||
264 | ng-model="articulo.cantidad" | ||
265 | class="form-control" | ||
266 | foca-tipo-input | ||
267 | min="1" | ||
268 | step="0.001" | ||
269 | foca-focus="articulo.editCantidad" | ||
270 | ng-keypress="editarArticulo($event.keyCode, articulo)" | ||
271 | ng-focus="selectFocus($event)" | ||
272 | > | ||
273 | </div> | ||
274 | </div> | ||
275 | <div class="d-flex"> | ||
276 | <div class="col-3 px-1"> | ||
277 | <span ng-bind="'x' + articulo.cantidad"></span> | ||
278 | </div> | ||
279 | <div class="col px-1 text-right"> | ||
280 | <span ng-bind="articulo.precio | currency: remito.moneda.SIMBOLO : 4"></span> | ||
281 | </div> | ||
282 | <div class="col px-1 text-right"> | ||
283 | <span | ||
284 | ng-bind="(articulo.precio * articulo.cantidad) | currency: remito.moneda.SIMBOLO" | ||
285 | > | ||
286 | </span> | ||
287 | </div> | ||
288 | </div> | ||
289 | </div> | ||
290 | <div class="align-middle p-1"> | ||
291 | <button | ||
292 | class="btn btn-outline-light" | ||
293 | ng-click="quitarArticulo(key)" | ||
294 | > | ||
295 | <i class="fa fa-trash"></i> | ||
296 | </button> | ||
297 | </div> | ||
298 | </td> | ||
299 | </tr> | ||
300 | </tbody> | ||
301 | <tfoot> | ||
302 | <!-- CARGANDO ITEM --> | ||
303 | <tr ng-show="!cargando" class="d-flex"> | ||
304 | <td | ||
305 | class="align-middle p-1" | ||
306 | ng-bind="remito.articulosRemito.length + 1" | ||
307 | ></td> | ||
308 | <td class="col p-0"> | ||
309 | <div class="d-flex"> | ||
310 | <div class="col-4 px-1"> | ||
311 | <span | ||
312 | ng-bind="articuloACargar.sectorCodigo" | ||
313 | ></span> | ||
314 | </div> | ||
315 | <div class="col-8 px-1"> | ||
316 | <span ng-bind="articuloACargar.descripcion"></span> | ||
317 | </div> | ||
318 | </div> | ||
319 | <div class="d-flex"> | ||
320 | <div class="col-3 px-1 m-1"> | ||
321 | <input | ||
322 | class="form-control p-1" | ||
323 | foca-tipo-input | ||
324 | min="1" | ||
325 | ng-model="articuloACargar.cantidad" | ||
326 | foca-focus="!cargando" | ||
327 | ng-keypress="agregarATabla($event.keyCode)" | ||
328 | style="height: auto; line-height: 1.1em" | ||
329 | > | ||
330 | </div> | ||
331 | <div class="col px-1 text-right"> | ||
332 | <span ng-bind="articuloACargar.precio | currency: remito.moneda.SIMBOLO : 4"></span> | ||
333 | </div> | ||
334 | <div class="col px-1 text-right"> | ||
335 | <span | ||
336 | ng-bind="getSubTotal() | currency: remito.moneda.SIMBOLO" | ||
337 | > | ||
338 | </span> | ||
339 | </div> | ||
340 | </div> | ||
341 | </td> | ||
342 | <td class="text-center align-middle"> | ||
343 | <button | ||
344 | class="btn btn-outline-light" | ||
345 | ng-click="agregarATabla(13)" | ||
346 | > | ||
347 | <i class="fa fa-save"></i> | ||
348 | </button> | ||
349 | </td> | ||
350 | </tr> | ||
351 | <!-- TOOGLE EXPANDIR --> | ||
352 | <tr> | ||
353 | <td class="col"> | ||
354 | <button | ||
355 | class="btn btn-outline-light selectable w-100" | ||
356 | ng-click="show = !show; masMenos()" | ||
357 | ng-show="remito.articulosRemito.length > 0" | ||
358 | > | ||
359 | <i | ||
360 | class="fa fa-chevron-down" | ||
361 | ng-hide="show" | ||
362 | aria-hidden="true" | ||
363 | > | ||
364 | </i> | ||
365 | <i | ||
366 | class="fa fa-chevron-up" | ||
367 | ng-show="show" | ||
368 | aria-hidden="true"> | ||
369 | </i> | ||
370 | </button> | ||
371 | </td> | ||
372 | </tr> | ||
373 | <!-- FOOTER --> | ||
374 | <tr class="d-flex"> | ||
375 | <td class="align-middle no-border-top" colspan="2"> | ||
376 | <strong>Cantidad Items:</strong> | ||
377 | <a ng-bind="remito.articulosRemito.length"></a> | ||
378 | </td> | ||
379 | <td class="text-right ml-auto table-celda-total no-border-top"> | ||
380 | <h3>Total:</h3> | ||
381 | </td> | ||
382 | <td class="table-celda-total text-right no-border-top"> | ||
383 | <h3>{{getTotal() | currency: remito.moneda.SIMBOLO}}</h3> | ||
384 | </td> | ||
385 | </tr> | ||
386 | </tfoot> | ||
387 | </table> | ||
388 | </div> | ||
389 | </div> | 224 | </div> |
390 | </div> | 225 | </div> |
391 | </div> | 226 | </div> |
392 | <div class="row d-md-none fixed-bottom"> | 227 | <div class="row d-md-none fixed-bottom"> |
393 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> | 228 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> |