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