Commit dc10f0eefed91e15601f1d23fcf9bcc4b8e8eab2
1 parent
39a9112fe4
Exists in
master
Code styling.
Showing
2 changed files
with
4 additions
and
4 deletions
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 | replace('"ngRoute","ui.bootstrap","focaModalVendedores","focaBusquedaProductos",'+ | 46 | replace('"ngRoute","ui.bootstrap","focaModalVendedores","focaBusquedaProductos",'+ |
47 | '"focaModalProveedor","focaBusquedaCliente","focaModalPrecioCondicion",'+ | 47 | '"focaModalProveedor","focaBusquedaCliente","focaModalPrecioCondicion",'+ |
48 | '"focaModalFlete","focaDirectivas","focaModal","focaModalDomicilio",'+ | 48 | '"focaModalFlete","focaDirectivas","focaModal","focaModalDomicilio",'+ |
49 | '"focaModalMoneda","focaModalCotizacion","focaSeguimiento","angular-ladda",'+ | 49 | '"focaModalMoneda","focaModalCotizacion","focaSeguimiento","angular-ladda",'+ |
50 | '"cordovaGeolocationModule"', ''), | 50 | '"cordovaGeolocationModule"', ''), |
51 | gulp.dest(paths.dist) | 51 | gulp.dest(paths.dist) |
52 | ] | 52 | ] |
53 | ); | 53 | ); |
54 | }); | 54 | }); |
55 | 55 | ||
56 | gulp.task('clean', function(){ | 56 | gulp.task('clean', function() { |
57 | return gulp.src(['tmp', 'dist'], {read: false}) | 57 | return gulp.src(['tmp', 'dist'], {read: false}) |
58 | .pipe(clean()); | 58 | .pipe(clean()); |
59 | }); | 59 | }); |
60 | 60 | ||
61 | gulp.task('pre-commit', function() { | 61 | gulp.task('pre-commit', function() { |
62 | return pump( | 62 | return pump( |
63 | [ | 63 | [ |
64 | gulp.src(paths.srcJS), | 64 | gulp.src(paths.srcJS), |
65 | jshint('.jshintrc'), | 65 | jshint('.jshintrc'), |
66 | jshint.reporter('default'), | 66 | jshint.reporter('default'), |
67 | jshint.reporter('fail') | 67 | jshint.reporter('fail') |
68 | ] | 68 | ] |
69 | ); | 69 | ); |
70 | 70 | ||
71 | gulp.start('uglify'); | 71 | gulp.start('uglify'); |
72 | }); | 72 | }); |
73 | 73 | ||
74 | gulp.task('webserver', function() { | 74 | gulp.task('webserver', function() { |
75 | pump [ | 75 | pump [ |
76 | connect.server({port: 3300, host: '0.0.0.0'}) | 76 | connect.server({port: 3300, host: '0.0.0.0'}) |
77 | ] | 77 | ] |
78 | }); | 78 | }); |
79 | 79 | ||
80 | gulp.task('clean-post-install', function() { | 80 | gulp.task('clean-post-install', function() { |
81 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 81 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
82 | 'index.html'], {read: false}) | 82 | 'index.html'], {read: false}) |
83 | .pipe(clean()); | 83 | .pipe(clean()); |
84 | }); | 84 | }); |
85 | 85 | ||
86 | gulp.task('default', ['webserver']); | 86 | gulp.task('default', ['webserver']); |
87 | 87 | ||
88 | gulp.task('watch', function() { | 88 | gulp.task('watch', function() { |
89 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | 89 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); |
90 | }); | 90 | }); |
91 | 91 | ||
92 | gulp.task('copy', ['uglify'], function() { | 92 | gulp.task('copy', ['uglify'], function() { |
93 | return gulp.src('dist/*.js') | 93 | return gulp.src('dist/*.js') |
94 | .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-crear-remito/dist/')); | 94 | .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-crear-remito/dist/')); |
95 | }); | 95 | }); |
96 | 96 | ||
97 | gulp.task('watchAndCopy', function() { | 97 | gulp.task('watchAndCopy', function() { |
98 | return gulp.watch([paths.srcJS, paths.srcViews], ['copy']); | 98 | return gulp.watch([paths.srcJS, paths.srcViews], ['copy']); |
99 | }); | 99 | }); |
100 | 100 |
src/js/controller.js
1 | angular.module('focaCrearRemito') .controller('remitoController', | 1 | angular.module('focaCrearRemito') .controller('remitoController', |
2 | [ | 2 | [ |
3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', |
4 | 'focaModalService', 'focaSeguimientoService', 'remitoBusinessService', | 4 | 'focaModalService', 'focaSeguimientoService', 'remitoBusinessService', |
5 | function( | 5 | function( |
6 | $scope, $uibModal, $location, $filter, crearRemitoService, focaModalService, | 6 | $scope, $uibModal, $location, $filter, crearRemitoService, focaModalService, |
7 | focaSeguimientoService, remitoBusinessService | 7 | focaSeguimientoService, remitoBusinessService |
8 | ) { | 8 | ) { |
9 | $scope.botonera = [ | 9 | $scope.botonera = [ |
10 | {texto: 'Nota Pedido', accion: function() {$scope.seleccionarNotaPedido();}}, | 10 | {texto: 'Nota Pedido', accion: function() {$scope.seleccionarNotaPedido();}}, |
11 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, | 11 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, |
12 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | 12 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
13 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, | 13 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, |
14 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | 14 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, |
15 | { | 15 | { |
16 | texto: 'Precios y condiciones', | 16 | texto: 'Precios y condiciones', |
17 | accion: function() {$scope.abrirModalListaPrecio();}}, | 17 | accion: function() {$scope.abrirModalListaPrecio();}}, |
18 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | 18 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, |
19 | {texto: '', accion: function() {}} | 19 | {texto: '', accion: function() {}} |
20 | ]; | 20 | ]; |
21 | $scope.datepickerAbierto = false; | 21 | $scope.datepickerAbierto = false; |
22 | 22 | ||
23 | $scope.show = false; | 23 | $scope.show = false; |
24 | $scope.cargando = true; | 24 | $scope.cargando = true; |
25 | $scope.dateOptions = { | 25 | $scope.dateOptions = { |
26 | maxDate: new Date(), | 26 | maxDate: new Date(), |
27 | minDate: new Date(2010, 0, 1) | 27 | minDate: new Date(2010, 0, 1) |
28 | }; | 28 | }; |
29 | 29 | ||
30 | $scope.remito = { | 30 | $scope.remito = { |
31 | vendedor: {}, | 31 | vendedor: {}, |
32 | cliente: {}, | 32 | cliente: {}, |
33 | proveedor: {}, | 33 | proveedor: {}, |
34 | domicilio: {dom: ''}, | 34 | domicilio: {dom: ''}, |
35 | moneda: {}, | 35 | moneda: {}, |
36 | cotizacion: {} | 36 | cotizacion: {} |
37 | }; | 37 | }; |
38 | var monedaPorDefecto; | 38 | var monedaPorDefecto; |
39 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 39 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
40 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { | 40 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { |
41 | monedaPorDefecto = { | 41 | monedaPorDefecto = { |
42 | id: res.data[0].ID, | 42 | id: res.data[0].ID, |
43 | detalle: res.data[0].DETALLE, | 43 | detalle: res.data[0].DETALLE, |
44 | simbolo: res.data[0].SIMBOLO, | 44 | simbolo: res.data[0].SIMBOLO, |
45 | cotizaciones: res.data[0].cotizaciones | 45 | cotizaciones: res.data[0].cotizaciones |
46 | }; | 46 | }; |
47 | addCabecera('Moneda:', monedaPorDefecto.detalle); | 47 | addCabecera('Moneda:', monedaPorDefecto.detalle); |
48 | addCabecera('Fecha cotizacion:', | 48 | addCabecera('Fecha cotizacion:', |
49 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | 49 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); |
50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); | 50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); |
51 | $scope.remito.moneda = monedaPorDefecto; | 51 | $scope.remito.moneda = monedaPorDefecto; |
52 | $scope.remito.cotizacion = monedaPorDefecto.cotizaciones[0]; | 52 | $scope.remito.cotizacion = monedaPorDefecto.cotizaciones[0]; |
53 | }); | 53 | }); |
54 | 54 | ||
55 | $scope.cabecera = []; | 55 | $scope.cabecera = []; |
56 | $scope.showCabecera = true; | 56 | $scope.showCabecera = true; |
57 | 57 | ||
58 | $scope.now = new Date(); | 58 | $scope.now = new Date(); |
59 | $scope.puntoVenta = Math.round(Math.random() * 10000); | 59 | $scope.puntoVenta = Math.round(Math.random() * 10000); |
60 | $scope.comprobante = Math.round(Math.random() * 1000000); | 60 | $scope.comprobante = Math.round(Math.random() * 1000000); |
61 | 61 | ||
62 | $scope.articulosTabla = []; | 62 | $scope.articulosTabla = []; |
63 | $scope.idLista = undefined; | 63 | $scope.idLista = undefined; |
64 | //La pantalla solo se usa para cargar remitos | 64 | //La pantalla solo se usa para cargar remitos |
65 | //var remitoTemp = crearRemitoService.getRemito(); | 65 | //var remitoTemp = crearRemitoService.getRemito(); |
66 | 66 | ||
67 | crearRemitoService.getPrecioCondicion().then( | 67 | crearRemitoService.getPrecioCondicion().then( |
68 | function(res) { | 68 | function(res) { |
69 | $scope.precioCondiciones = res.data; | 69 | $scope.precioCondiciones = res.data; |
70 | } | 70 | } |
71 | ); | 71 | ); |
72 | $scope.seleccionarNotaPedido = function() { | 72 | $scope.seleccionarNotaPedido = function() { |
73 | var modalInstance = $uibModal.open( | 73 | var modalInstance = $uibModal.open( |
74 | { | 74 | { |
75 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 75 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
76 | templateUrl: 'foca-modal-nota-pedido.html', | 76 | templateUrl: 'foca-modal-nota-pedido.html', |
77 | controller: 'focaModalNotaPedidoController', | 77 | controller: 'focaModalNotaPedidoController', |
78 | resolve: { | 78 | resolve: { |
79 | parametroNotaPedido: { | 79 | parametroNotaPedido: { |
80 | idLista: $scope.idLista, | 80 | idLista: $scope.idLista, |
81 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 81 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
82 | simbolo: $scope.remito.moneda.simbolo | 82 | simbolo: $scope.remito.moneda.simbolo |
83 | } | 83 | } |
84 | }, | 84 | }, |
85 | size: 'lg' | 85 | size: 'lg' |
86 | } | 86 | } |
87 | ); | 87 | ); |
88 | modalInstance.result.then( | 88 | modalInstance.result.then( |
89 | function(producto) { | 89 | function(producto) { |
90 | var newArt = | 90 | var newArt = |
91 | { | 91 | { |
92 | id: 0, | 92 | id: 0, |
93 | codigo: producto.codigo, | 93 | codigo: producto.codigo, |
94 | sector: producto.sector, | 94 | sector: producto.sector, |
95 | sectorCodigo: producto.sector + '-' + producto.codigo, | 95 | sectorCodigo: producto.sector + '-' + producto.codigo, |
96 | descripcion: producto.descripcion, | 96 | descripcion: producto.descripcion, |
97 | item: $scope.articulosTabla.length + 1, | 97 | item: $scope.articulosTabla.length + 1, |
98 | nombre: producto.descripcion, | 98 | nombre: producto.descripcion, |
99 | precio: parseFloat(producto.precio.toFixed(4)), | 99 | precio: parseFloat(producto.precio.toFixed(4)), |
100 | costoUnitario: producto.costo, | 100 | costoUnitario: producto.costo, |
101 | editCantidad: false, | 101 | editCantidad: false, |
102 | editPrecio: false | 102 | editPrecio: false |
103 | }; | 103 | }; |
104 | $scope.articuloACargar = newArt; | 104 | $scope.articuloACargar = newArt; |
105 | $scope.cargando = false; | 105 | $scope.cargando = false; |
106 | }, function() { | 106 | }, function() { |
107 | // funcion ejecutada cuando se cancela el modal | 107 | // funcion ejecutada cuando se cancela el modal |
108 | } | 108 | } |
109 | ); | 109 | ); |
110 | } | 110 | } |
111 | $scope.seleccionarRemito = function() { | 111 | $scope.seleccionarRemito = function() { |
112 | var modalInstance = $uibModal.open( | 112 | var modalInstance = $uibModal.open( |
113 | { | 113 | { |
114 | ariaLabelledBy: 'Busqueda de Remito', | 114 | ariaLabelledBy: 'Busqueda de Remito', |
115 | templateUrl: 'foca-modal-remito.html', | 115 | templateUrl: 'foca-modal-remito.html', |
116 | controller: 'focaModalRemitoController', | 116 | controller: 'focaModalRemitoController', |
117 | resolve: { | 117 | resolve: { |
118 | parametroRemito: { | 118 | parametroRemito: { |
119 | idLista: $scope.idLista, | 119 | idLista: $scope.idLista, |
120 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 120 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
121 | simbolo: $scope.remito.moneda.simbolo | 121 | simbolo: $scope.remito.moneda.simbolo |
122 | } | 122 | } |
123 | }, | 123 | }, |
124 | size: 'lg' | 124 | size: 'lg' |
125 | } | 125 | } |
126 | ); | 126 | ); |
127 | modalInstance.result.then( | 127 | modalInstance.result.then( |
128 | function(producto) { | 128 | function(producto) { |
129 | var newArt = | 129 | var newArt = |
130 | { | 130 | { |
131 | id: 0, | 131 | id: 0, |
132 | codigo: producto.codigo, | 132 | codigo: producto.codigo, |
133 | sector: producto.sector, | 133 | sector: producto.sector, |
134 | sectorCodigo: producto.sector + '-' + producto.codigo, | 134 | sectorCodigo: producto.sector + '-' + producto.codigo, |
135 | descripcion: producto.descripcion, | 135 | descripcion: producto.descripcion, |
136 | item: $scope.articulosTabla.length + 1, | 136 | item: $scope.articulosTabla.length + 1, |
137 | nombre: producto.descripcion, | 137 | nombre: producto.descripcion, |
138 | precio: parseFloat(producto.precio.toFixed(4)), | 138 | precio: parseFloat(producto.precio.toFixed(4)), |
139 | costoUnitario: producto.costo, | 139 | costoUnitario: producto.costo, |
140 | editCantidad: false, | 140 | editCantidad: false, |
141 | editPrecio: false | 141 | editPrecio: false |
142 | }; | 142 | }; |
143 | $scope.articuloACargar = newArt; | 143 | $scope.articuloACargar = newArt; |
144 | $scope.cargando = false; | 144 | $scope.cargando = false; |
145 | }, function() { | 145 | }, function() { |
146 | // funcion ejecutada cuando se cancela el modal | 146 | // funcion ejecutada cuando se cancela el modal |
147 | } | 147 | } |
148 | ); | 148 | ); |
149 | } | 149 | } |
150 | //La pantalla solo se usa para cargar remitos | 150 | //La pantalla solo se usa para cargar remitos |
151 | // if (remitoTemp !== undefined) { | 151 | // if (remitoTemp !== undefined) { |
152 | // remitoTemp.fechaCarga = new Date(remitoTemp.fechaCarga); | 152 | // remitoTemp.fechaCarga = new Date(remitoTemp.fechaCarga); |
153 | // $scope.remito = remitoTemp; | 153 | // $scope.remito = remitoTemp; |
154 | // $scope.remito.flete = ($scope.remito.flete).toString(); | 154 | // $scope.remito.flete = ($scope.remito.flete).toString(); |
155 | // $scope.remito.bomba = ($scope.remito.bomba).toString(); | 155 | // $scope.remito.bomba = ($scope.remito.bomba).toString(); |
156 | // $scope.idLista = $scope.remito.precioCondicion; | 156 | // $scope.idLista = $scope.remito.precioCondicion; |
157 | // crearRemitoService | 157 | // crearRemitoService |
158 | // .getArticulosByIdRemito($scope.remito.id).then( | 158 | // .getArticulosByIdRemito($scope.remito.id).then( |
159 | // function(res) { | 159 | // function(res) { |
160 | // $scope.articulosTabla = res.data; | 160 | // $scope.articulosTabla = res.data; |
161 | // } | 161 | // } |
162 | // ); | 162 | // ); |
163 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR REMITO | 163 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR REMITO |
164 | //(NO REQUERIDO EN ESTA VERSION) | 164 | //(NO REQUERIDO EN ESTA VERSION) |
165 | // crearRemitoService.getDomiciliosByIdRemito($scope.remito.id).then( | 165 | // crearRemitoService.getDomiciliosByIdRemito($scope.remito.id).then( |
166 | // function(res) { | 166 | // function(res) { |
167 | // $scope.remito.domicilio = res.data; | 167 | // $scope.remito.domicilio = res.data; |
168 | // } | 168 | // } |
169 | // ); | 169 | // ); |
170 | // } else { | 170 | // } else { |
171 | // $scope.remito.fechaCarga = new Date(); | 171 | // $scope.remito.fechaCarga = new Date(); |
172 | // $scope.remito.bomba = '0'; | 172 | // $scope.remito.bomba = '0'; |
173 | // $scope.remito.flete = '0'; | 173 | // $scope.remito.flete = '0'; |
174 | // $scope.idLista = undefined; | 174 | // $scope.idLista = undefined; |
175 | // } | 175 | // } |
176 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 176 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
177 | // $scope.addNewDom = function() { | 177 | // $scope.addNewDom = function() { |
178 | // $scope.remito.domicilio.push({ 'id': 0 }); | 178 | // $scope.remito.domicilio.push({ 'id': 0 }); |
179 | // }; | 179 | // }; |
180 | // $scope.removeNewChoice = function(choice) { | 180 | // $scope.removeNewChoice = function(choice) { |
181 | // if ($scope.remito.domicilio.length > 1) { | 181 | // if ($scope.remito.domicilio.length > 1) { |
182 | // $scope.remito.domicilio.splice($scope.remito.domicilio.findIndex( | 182 | // $scope.remito.domicilio.splice($scope.remito.domicilio.findIndex( |
183 | // function(c) { | 183 | // function(c) { |
184 | // return c.$$hashKey === choice.$$hashKey; | 184 | // return c.$$hashKey === choice.$$hashKey; |
185 | // } | 185 | // } |
186 | // ), 1); | 186 | // ), 1); |
187 | // } | 187 | // } |
188 | // }; | 188 | // }; |
189 | 189 | ||
190 | $scope.crearRemito = function() { | 190 | $scope.crearRemito = function() { |
191 | if(!$scope.remito.vendedor.codigo) { | 191 | if(!$scope.remito.vendedor.codigo) { |
192 | focaModalService.alert('Ingrese Vendedor'); | 192 | focaModalService.alert('Ingrese Vendedor'); |
193 | return; | 193 | return; |
194 | } else if(!$scope.remito.cliente.cod) { | 194 | } else if(!$scope.remito.cliente.cod) { |
195 | focaModalService.alert('Ingrese Cliente'); | 195 | focaModalService.alert('Ingrese Cliente'); |
196 | return; | 196 | return; |
197 | } else if(!$scope.remito.proveedor.codigo) { | 197 | } else if(!$scope.remito.proveedor.codigo) { |
198 | focaModalService.alert('Ingrese Proveedor'); | 198 | focaModalService.alert('Ingrese Proveedor'); |
199 | return; | 199 | return; |
200 | } else if(!$scope.remito.moneda.id) { | 200 | } else if(!$scope.remito.moneda.id) { |
201 | focaModalService.alert('Ingrese Moneda'); | 201 | focaModalService.alert('Ingrese Moneda'); |
202 | return; | 202 | return; |
203 | } else if(!$scope.remito.cotizacion.ID) { | 203 | } else if(!$scope.remito.cotizacion.ID) { |
204 | focaModalService.alert('Ingrese Cotización'); | 204 | focaModalService.alert('Ingrese Cotización'); |
205 | return; | 205 | return; |
206 | } else if(!$scope.plazosPagos) { | 206 | } else if(!$scope.plazosPagos) { |
207 | focaModalService.alert('Ingrese Precios y Condiciones'); | 207 | focaModalService.alert('Ingrese Precios y Condiciones'); |
208 | return; | 208 | return; |
209 | } else if( | 209 | } else if( |
210 | $scope.remito.flete === undefined || $scope.remito.flete === null) | 210 | $scope.remito.flete === undefined || $scope.remito.flete === null) |
211 | { | 211 | { |
212 | focaModalService.alert('Ingrese Flete'); | 212 | focaModalService.alert('Ingrese Flete'); |
213 | return; | 213 | return; |
214 | } else if(!$scope.remito.domicilio.id) { | 214 | } else if(!$scope.remito.domicilio.id) { |
215 | focaModalService.alert('Ingrese Domicilio'); | 215 | focaModalService.alert('Ingrese Domicilio'); |
216 | return; | 216 | return; |
217 | } else if($scope.articulosTabla.length === 0) { | 217 | } else if($scope.articulosTabla.length === 0) { |
218 | focaModalService.alert('Debe cargar al menos un articulo'); | 218 | focaModalService.alert('Debe cargar al menos un articulo'); |
219 | return; | 219 | return; |
220 | } | 220 | } |
221 | var date = new Date(); | 221 | var date = new Date(); |
222 | var remito = { | 222 | var remito = { |
223 | id: 0, | 223 | id: 0, |
224 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 224 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
225 | .toISOString().slice(0, 19).replace('T', ' '), | 225 | .toISOString().slice(0, 19).replace('T', ' '), |
226 | idVendedor: $scope.remito.vendedor.codigo, | 226 | idVendedor: $scope.remito.vendedor.codigo, |
227 | idCliente: $scope.remito.cliente.cod, | 227 | idCliente: $scope.remito.cliente.cod, |
228 | nombreCliente: $scope.remito.cliente.nom, | 228 | nombreCliente: $scope.remito.cliente.nom, |
229 | cuitCliente: $scope.remito.cliente.cuit, | 229 | cuitCliente: $scope.remito.cliente.cuit, |
230 | idProveedor: $scope.remito.proveedor.codigo, | 230 | idProveedor: $scope.remito.proveedor.codigo, |
231 | idDomicilio: $scope.remito.domicilio.id, | 231 | idDomicilio: $scope.remito.domicilio.id, |
232 | idCotizacion: $scope.remito.cotizacion.ID, | 232 | idCotizacion: $scope.remito.cotizacion.ID, |
233 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 233 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
234 | flete: $scope.remito.flete, | 234 | flete: $scope.remito.flete, |
235 | fob: $scope.remito.fob, | 235 | fob: $scope.remito.fob, |
236 | bomba: $scope.remito.bomba, | 236 | bomba: $scope.remito.bomba, |
237 | kilometros: $scope.remito.kilometros, | 237 | kilometros: $scope.remito.kilometros, |
238 | estado: 0, | 238 | estado: 0, |
239 | total: $scope.getTotal() | 239 | total: $scope.getTotal() |
240 | }; | 240 | }; |
241 | crearRemitoService.crearRemito(remito).then( | 241 | crearRemitoService.crearRemito(remito).then( |
242 | function(data) { | 242 | function(data) { |
243 | remitoBusinessService.addArticulos($scope.articulosTabla, | 243 | remitoBusinessService.addArticulos($scope.articulosTabla, |
244 | data.data.id, $scope.remito.cotizacion.COTIZACION); | 244 | data.data.id, $scope.remito.cotizacion.COTIZACION); |
245 | focaSeguimientoService.guardarPosicion('crear nota remito', ''); | 245 | focaSeguimientoService.guardarPosicion('crear nota remito', ''); |
246 | var plazos = $scope.plazosPagos; | 246 | var plazos = $scope.plazosPagos; |
247 | for(var j = 0; j < plazos.length; j++) { | 247 | for(var j = 0; j < plazos.length; j++) { |
248 | var json = { | 248 | var json = { |
249 | idRemito: data.data.id, | 249 | idRemito: data.data.id, |
250 | dias: plazos[j].dias | 250 | dias: plazos[j].dias |
251 | }; | 251 | }; |
252 | crearRemitoService.crearPlazosParaRemito(json); | 252 | crearRemitoService.crearPlazosParaRemito(json); |
253 | } | 253 | } |
254 | remitoBusinessService.addEstado(data.data.id, | 254 | remitoBusinessService.addEstado(data.data.id, |
255 | $scope.remito.vendedor.codigo); | 255 | $scope.remito.vendedor.codigo); |
256 | 256 | ||
257 | focaModalService.alert('Nota remito creada'); | 257 | focaModalService.alert('Nota remito creada'); |
258 | $scope.cabecera = []; | 258 | $scope.cabecera = []; |
259 | addCabecera('Moneda:', $scope.remito.moneda.detalle); | 259 | addCabecera('Moneda:', $scope.remito.moneda.detalle); |
260 | addCabecera( | 260 | addCabecera( |
261 | 'Fecha cotizacion:', | 261 | 'Fecha cotizacion:', |
262 | $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') | 262 | $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') |
263 | ); | 263 | ); |
264 | addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); | 264 | addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); |
265 | $scope.remito.vendedor = {}; | 265 | $scope.remito.vendedor = {}; |
266 | $scope.remito.cliente = {}; | 266 | $scope.remito.cliente = {}; |
267 | $scope.remito.proveedor = {}; | 267 | $scope.remito.proveedor = {}; |
268 | $scope.remito.domicilio = {}; | 268 | $scope.remito.domicilio = {}; |
269 | $scope.remito.flete = null; | 269 | $scope.remito.flete = null; |
270 | $scope.remito.fob = null; | 270 | $scope.remito.fob = null; |
271 | $scope.remito.bomba = null; | 271 | $scope.remito.bomba = null; |
272 | $scope.remito.kilometros = null; | 272 | $scope.remito.kilometros = null; |
273 | $scope.articulosTabla = []; | 273 | $scope.articulosTabla = []; |
274 | } | 274 | } |
275 | ); | 275 | ); |
276 | }; | 276 | }; |
277 | 277 | ||
278 | $scope.seleccionarArticulo = function() { | 278 | $scope.seleccionarArticulo = function() { |
279 | if ($scope.idLista === undefined) { | 279 | if ($scope.idLista === undefined) { |
280 | focaModalService.alert( | 280 | focaModalService.alert( |
281 | 'Primero seleccione una lista de precio y condicion'); | 281 | 'Primero seleccione una lista de precio y condicion'); |
282 | return; | 282 | return; |
283 | } | 283 | } |
284 | var modalInstance = $uibModal.open( | 284 | var modalInstance = $uibModal.open( |
285 | { | 285 | { |
286 | ariaLabelledBy: 'Busqueda de Productos', | 286 | ariaLabelledBy: 'Busqueda de Productos', |
287 | templateUrl: 'modal-busqueda-productos.html', | 287 | templateUrl: 'modal-busqueda-productos.html', |
288 | controller: 'modalBusquedaProductosCtrl', | 288 | controller: 'modalBusquedaProductosCtrl', |
289 | resolve: { | 289 | resolve: { |
290 | parametroProducto: { | 290 | parametroProducto: { |
291 | idLista: $scope.idLista, | 291 | idLista: $scope.idLista, |
292 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 292 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
293 | simbolo: $scope.remito.moneda.simbolo | 293 | simbolo: $scope.remito.moneda.simbolo |
294 | } | 294 | } |
295 | }, | 295 | }, |
296 | size: 'lg' | 296 | size: 'lg' |
297 | } | 297 | } |
298 | ); | 298 | ); |
299 | modalInstance.result.then( | 299 | modalInstance.result.then( |
300 | function(producto) { | 300 | function(producto) { |
301 | var newArt = | 301 | var newArt = |
302 | { | 302 | { |
303 | id: 0, | 303 | id: 0, |
304 | codigo: producto.codigo, | 304 | codigo: producto.codigo, |
305 | sector: producto.sector, | 305 | sector: producto.sector, |
306 | sectorCodigo: producto.sector + '-' + producto.codigo, | 306 | sectorCodigo: producto.sector + '-' + producto.codigo, |
307 | descripcion: producto.descripcion, | 307 | descripcion: producto.descripcion, |
308 | item: $scope.articulosTabla.length + 1, | 308 | item: $scope.articulosTabla.length + 1, |
309 | nombre: producto.descripcion, | 309 | nombre: producto.descripcion, |
310 | precio: parseFloat(producto.precio.toFixed(4)), | 310 | precio: parseFloat(producto.precio.toFixed(4)), |
311 | costoUnitario: producto.costo, | 311 | costoUnitario: producto.costo, |
312 | editCantidad: false, | 312 | editCantidad: false, |
313 | editPrecio: false | 313 | editPrecio: false |
314 | }; | 314 | }; |
315 | $scope.articuloACargar = newArt; | 315 | $scope.articuloACargar = newArt; |
316 | $scope.cargando = false; | 316 | $scope.cargando = false; |
317 | }, function() { | 317 | }, function() { |
318 | // funcion ejecutada cuando se cancela el modal | 318 | // funcion ejecutada cuando se cancela el modal |
319 | } | 319 | } |
320 | ); | 320 | ); |
321 | }; | 321 | }; |
322 | 322 | ||
323 | $scope.seleccionarVendedor = function() { | 323 | $scope.seleccionarVendedor = function() { |
324 | var modalInstance = $uibModal.open( | 324 | var modalInstance = $uibModal.open( |
325 | { | 325 | { |
326 | ariaLabelledBy: 'Busqueda de Vendedores', | 326 | ariaLabelledBy: 'Busqueda de Vendedores', |
327 | templateUrl: 'modal-vendedores.html', | 327 | templateUrl: 'modal-vendedores.html', |
328 | controller: 'modalVendedoresCtrl', | 328 | controller: 'modalVendedoresCtrl', |
329 | size: 'lg' | 329 | size: 'lg' |
330 | } | 330 | } |
331 | ); | 331 | ); |
332 | modalInstance.result.then( | 332 | modalInstance.result.then( |
333 | function(vendedor) { | 333 | function(vendedor) { |
334 | addCabecera('Vendedor:', vendedor.NomVen); | 334 | addCabecera('Vendedor:', vendedor.NomVen); |
335 | $scope.remito.vendedor.codigo = vendedor.CodVen; | 335 | $scope.remito.vendedor.codigo = vendedor.CodVen; |
336 | }, function() { | 336 | }, function() { |
337 | 337 | ||
338 | } | 338 | } |
339 | ); | 339 | ); |
340 | }; | 340 | }; |
341 | 341 | ||
342 | $scope.seleccionarProveedor = function() { | 342 | $scope.seleccionarProveedor = function() { |
343 | var modalInstance = $uibModal.open( | 343 | var modalInstance = $uibModal.open( |
344 | { | 344 | { |
345 | ariaLabelledBy: 'Busqueda de Proveedor', | 345 | ariaLabelledBy: 'Busqueda de Proveedor', |
346 | templateUrl: 'modal-proveedor.html', | 346 | templateUrl: 'modal-proveedor.html', |
347 | controller: 'focaModalProveedorCtrl', | 347 | controller: 'focaModalProveedorCtrl', |
348 | size: 'lg' | 348 | size: 'lg' |
349 | } | 349 | } |
350 | ); | 350 | ); |
351 | modalInstance.result.then( | 351 | modalInstance.result.then( |
352 | function(proveedor) { | 352 | function(proveedor) { |
353 | $scope.remito.proveedor.codigo = proveedor.COD; | 353 | $scope.remito.proveedor.codigo = proveedor.COD; |
354 | addCabecera('Proveedor:', proveedor.NOM); | 354 | addCabecera('Proveedor:', proveedor.NOM); |
355 | }, function() { | 355 | }, function() { |
356 | 356 | ||
357 | } | 357 | } |
358 | ); | 358 | ); |
359 | }; | 359 | }; |
360 | 360 | ||
361 | $scope.seleccionarCliente = function() { | 361 | $scope.seleccionarCliente = function() { |
362 | 362 | ||
363 | var modalInstance = $uibModal.open( | 363 | var modalInstance = $uibModal.open( |
364 | { | 364 | { |
365 | ariaLabelledBy: 'Busqueda de Cliente', | 365 | ariaLabelledBy: 'Busqueda de Cliente', |
366 | templateUrl: 'foca-busqueda-cliente-modal.html', | 366 | templateUrl: 'foca-busqueda-cliente-modal.html', |
367 | controller: 'focaBusquedaClienteModalController', | 367 | controller: 'focaBusquedaClienteModalController', |
368 | size: 'lg' | 368 | size: 'lg' |
369 | } | 369 | } |
370 | ); | 370 | ); |
371 | modalInstance.result.then( | 371 | modalInstance.result.then( |
372 | function(cliente) { | 372 | function(cliente) { |
373 | $scope.abrirModalDomicilios(cliente); | 373 | $scope.abrirModalDomicilios(cliente); |
374 | }, function() { | 374 | }, function() { |
375 | 375 | ||
376 | } | 376 | } |
377 | ); | 377 | ); |
378 | }; | 378 | }; |
379 | 379 | ||
380 | $scope.abrirModalDomicilios = function(cliente) { | 380 | $scope.abrirModalDomicilios = function(cliente) { |
381 | var modalInstanceDomicilio = $uibModal.open( | 381 | var modalInstanceDomicilio = $uibModal.open( |
382 | { | 382 | { |
383 | ariaLabelledBy: 'Busqueda de Domicilios', | 383 | ariaLabelledBy: 'Busqueda de Domicilios', |
384 | templateUrl: 'modal-domicilio.html', | 384 | templateUrl: 'modal-domicilio.html', |
385 | controller: 'focaModalDomicilioController', | 385 | controller: 'focaModalDomicilioController', |
386 | resolve: { idCliente: function() { return cliente.cod; }}, | 386 | resolve: { idCliente: function() { return cliente.cod; }}, |
387 | size: 'lg', | 387 | size: 'lg', |
388 | } | 388 | } |
389 | ); | 389 | ); |
390 | modalInstanceDomicilio.result.then( | 390 | modalInstanceDomicilio.result.then( |
391 | function(domicilio) { | 391 | function(domicilio) { |
392 | $scope.remito.domicilio.id = domicilio.nivel2; | 392 | $scope.remito.domicilio.id = domicilio.nivel2; |
393 | $scope.remito.cliente = cliente; | 393 | $scope.remito.cliente = cliente; |
394 | 394 | ||
395 | addCabecera('Cliente:', cliente.nom); | 395 | addCabecera('Cliente:', cliente.nom); |
396 | addCabecera('Domicilio:', domicilio.dom); | 396 | addCabecera('Domicilio:', domicilio.dom); |
397 | }, function() { | 397 | }, function() { |
398 | $scope.seleccionarCliente(); | 398 | $scope.seleccionarCliente(); |
399 | return; | 399 | return; |
400 | } | 400 | } |
401 | ); | 401 | ); |
402 | }; | 402 | }; |
403 | 403 | ||
404 | $scope.mostrarFichaCliente = function() { | 404 | $scope.mostrarFichaCliente = function() { |
405 | $uibModal.open( | 405 | $uibModal.open( |
406 | { | 406 | { |
407 | ariaLabelledBy: 'Datos del Cliente', | 407 | ariaLabelledBy: 'Datos del Cliente', |
408 | templateUrl: 'foca-crear-remito-ficha-cliente.html', | 408 | templateUrl: 'foca-crear-remito-ficha-cliente.html', |
409 | controller: 'focaCrearRemitoFichaClienteController', | 409 | controller: 'focaCrearRemitoFichaClienteController', |
410 | size: 'lg' | 410 | size: 'lg' |
411 | } | 411 | } |
412 | ); | 412 | ); |
413 | }; | 413 | }; |
414 | 414 | ||
415 | $scope.getTotal = function() { | 415 | $scope.getTotal = function() { |
416 | var total = 0; | 416 | var total = 0; |
417 | var arrayTempArticulos = $scope.articulosTabla; | 417 | var arrayTempArticulos = $scope.articulosTabla; |
418 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 418 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
419 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 419 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
420 | } | 420 | } |
421 | return parseFloat(total.toFixed(2)); | 421 | return parseFloat(total.toFixed(2)); |
422 | }; | 422 | }; |
423 | 423 | ||
424 | $scope.getSubTotal = function() { | 424 | $scope.getSubTotal = function() { |
425 | if($scope.articuloACargar) { | 425 | if($scope.articuloACargar) { |
426 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 426 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
427 | } | 427 | } |
428 | }; | 428 | }; |
429 | 429 | ||
430 | $scope.abrirModalListaPrecio = function() { | 430 | $scope.abrirModalListaPrecio = function() { |
431 | var modalInstance = $uibModal.open( | 431 | var modalInstance = $uibModal.open( |
432 | { | 432 | { |
433 | ariaLabelledBy: 'Busqueda de Precio Condición', | 433 | ariaLabelledBy: 'Busqueda de Precio Condición', |
434 | templateUrl: 'modal-precio-condicion.html', | 434 | templateUrl: 'modal-precio-condicion.html', |
435 | controller: 'focaModalPrecioCondicionController', | 435 | controller: 'focaModalPrecioCondicionController', |
436 | size: 'lg' | 436 | size: 'lg' |
437 | } | 437 | } |
438 | ); | 438 | ); |
439 | modalInstance.result.then( | 439 | modalInstance.result.then( |
440 | function(precioCondicion) { | 440 | function(precioCondicion) { |
441 | var cabecera = ''; | 441 | var cabecera = ''; |
442 | var plazosConcat = ''; | 442 | var plazosConcat = ''; |
443 | if(!Array.isArray(precioCondicion)) { | 443 | if(!Array.isArray(precioCondicion)) { |
444 | $scope.plazosPagos = precioCondicion.plazoPago; | 444 | $scope.plazosPagos = precioCondicion.plazoPago; |
445 | $scope.idLista = precioCondicion.idListaPrecio; | 445 | $scope.idLista = precioCondicion.idListaPrecio; |
446 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 446 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
447 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 447 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
448 | } | 448 | } |
449 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 449 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
450 | } else { //Cuando se ingresan los plazos manualmente | 450 | } else { //Cuando se ingresan los plazos manualmente |
451 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 451 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
452 | $scope.plazosPagos = precioCondicion; | 452 | $scope.plazosPagos = precioCondicion; |
453 | for(var j = 0; j < precioCondicion.length; j++) { | 453 | for(var j = 0; j < precioCondicion.length; j++) { |
454 | plazosConcat += precioCondicion[j].dias + ' '; | 454 | plazosConcat += precioCondicion[j].dias + ' '; |
455 | } | 455 | } |
456 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 456 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
457 | } | 457 | } |
458 | $scope.articulosTabla = []; | 458 | $scope.articulosTabla = []; |
459 | addCabecera('Precios y condiciones:', cabecera); | 459 | addCabecera('Precios y condiciones:', cabecera); |
460 | }, function() { | 460 | }, function() { |
461 | 461 | ||
462 | } | 462 | } |
463 | ); | 463 | ); |
464 | }; | 464 | }; |
465 | 465 | ||
466 | $scope.abrirModalFlete = function() { | 466 | $scope.abrirModalFlete = function() { |
467 | var modalInstance = $uibModal.open( | 467 | var modalInstance = $uibModal.open( |
468 | { | 468 | { |
469 | ariaLabelledBy: 'Busqueda de Flete', | 469 | ariaLabelledBy: 'Busqueda de Flete', |
470 | templateUrl: 'modal-flete.html', | 470 | templateUrl: 'modal-flete.html', |
471 | controller: 'focaModalFleteController', | 471 | controller: 'focaModalFleteController', |
472 | size: 'lg', | 472 | size: 'lg', |
473 | resolve: { | 473 | resolve: { |
474 | parametrosFlete: | 474 | parametrosFlete: |
475 | function() { | 475 | function() { |
476 | return { | 476 | return { |
477 | flete: $scope.remito.flete ? '1' : | 477 | flete: $scope.remito.flete ? '1' : |
478 | ($scope.remito.fob ? 'FOB' : | 478 | ($scope.remito.fob ? 'FOB' : |
479 | ($scope.remito.flete === undefined ? null : '0')), | 479 | ($scope.remito.flete === undefined ? null : '0')), |
480 | bomba: $scope.remito.bomba ? '1' : | 480 | bomba: $scope.remito.bomba ? '1' : |
481 | ($scope.remito.bomba === undefined ? null : '0'), | 481 | ($scope.remito.bomba === undefined ? null : '0'), |
482 | kilometros: $scope.remito.kilometros | 482 | kilometros: $scope.remito.kilometros |
483 | }; | 483 | }; |
484 | } | 484 | } |
485 | } | 485 | } |
486 | } | 486 | } |
487 | ); | 487 | ); |
488 | modalInstance.result.then( | 488 | modalInstance.result.then( |
489 | function(datos) { | 489 | function(datos) { |
490 | $scope.remito.flete = datos.flete; | 490 | $scope.remito.flete = datos.flete; |
491 | $scope.remito.fob = datos.FOB; | 491 | $scope.remito.fob = datos.FOB; |
492 | $scope.remito.bomba = datos.bomba; | 492 | $scope.remito.bomba = datos.bomba; |
493 | $scope.remito.kilometros = datos.kilometros; | 493 | $scope.remito.kilometros = datos.kilometros; |
494 | 494 | ||
495 | addCabecera('Flete:', datos.flete ? 'Si' : | 495 | addCabecera('Flete:', datos.flete ? 'Si' : |
496 | ($scope.remito.fob ? 'FOB' : 'No')); | 496 | ($scope.remito.fob ? 'FOB' : 'No')); |
497 | if(datos.flete) { | 497 | if(datos.flete) { |
498 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | 498 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); |
499 | addCabecera('Kilometros:', datos.kilometros); | 499 | addCabecera('Kilometros:', datos.kilometros); |
500 | } else { | 500 | } else { |
501 | removeCabecera('Bomba:'); | 501 | removeCabecera('Bomba:'); |
502 | removeCabecera('Kilometros:'); | 502 | removeCabecera('Kilometros:'); |
503 | $scope.remito.fob = false; | 503 | $scope.remito.fob = false; |
504 | $scope.remito.bomba = false; | 504 | $scope.remito.bomba = false; |
505 | $scope.remito.kilometros = null; | 505 | $scope.remito.kilometros = null; |
506 | } | 506 | } |
507 | }, function() { | 507 | }, function() { |
508 | 508 | ||
509 | } | 509 | } |
510 | ); | 510 | ); |
511 | }; | 511 | }; |
512 | 512 | ||
513 | $scope.abrirModalMoneda = function() { | 513 | $scope.abrirModalMoneda = function() { |
514 | var modalInstance = $uibModal.open( | 514 | var modalInstance = $uibModal.open( |
515 | { | 515 | { |
516 | ariaLabelledBy: 'Busqueda de Moneda', | 516 | ariaLabelledBy: 'Busqueda de Moneda', |
517 | templateUrl: 'modal-moneda.html', | 517 | templateUrl: 'modal-moneda.html', |
518 | controller: 'focaModalMonedaController', | 518 | controller: 'focaModalMonedaController', |
519 | size: 'lg' | 519 | size: 'lg' |
520 | } | 520 | } |
521 | ); | 521 | ); |
522 | modalInstance.result.then( | 522 | modalInstance.result.then( |
523 | function(moneda) { | 523 | function(moneda) { |
524 | $scope.abrirModalCotizacion(moneda); | 524 | $scope.abrirModalCotizacion(moneda); |
525 | }, function() { | 525 | }, function() { |
526 | 526 | ||
527 | } | 527 | } |
528 | ); | 528 | ); |
529 | }; | 529 | }; |
530 | 530 | ||
531 | $scope.abrirModalCotizacion = function(moneda) { | 531 | $scope.abrirModalCotizacion = function(moneda) { |
532 | var modalInstance = $uibModal.open( | 532 | var modalInstance = $uibModal.open( |
533 | { | 533 | { |
534 | ariaLabelledBy: 'Busqueda de Cotización', | 534 | ariaLabelledBy: 'Busqueda de Cotización', |
535 | templateUrl: 'modal-cotizacion.html', | 535 | templateUrl: 'modal-cotizacion.html', |
536 | controller: 'focaModalCotizacionController', | 536 | controller: 'focaModalCotizacionController', |
537 | size: 'lg', | 537 | size: 'lg', |
538 | resolve: {idMoneda: function() {return moneda.ID;}} | 538 | resolve: {idMoneda: function() {return moneda.ID;}} |
539 | } | 539 | } |
540 | ); | 540 | ); |
541 | modalInstance.result.then( | 541 | modalInstance.result.then( |
542 | function(cotizacion) { | 542 | function(cotizacion) { |
543 | var articulosTablaTemp = $scope.articulosTabla; | 543 | var articulosTablaTemp = $scope.articulosTabla; |
544 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 544 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
545 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 545 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
546 | $scope.remito.cotizacion.COTIZACION; | 546 | $scope.remito.cotizacion.COTIZACION; |
547 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 547 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
548 | cotizacion.COTIZACION; | 548 | cotizacion.COTIZACION; |
549 | } | 549 | } |
550 | $scope.articulosTabla = articulosTablaTemp; | 550 | $scope.articulosTabla = articulosTablaTemp; |
551 | $scope.remito.moneda = { | 551 | $scope.remito.moneda = { |
552 | id: moneda.ID, | 552 | id: moneda.ID, |
553 | detalle: moneda.DETALLE, | 553 | detalle: moneda.DETALLE, |
554 | simbolo: moneda.SIMBOLO | 554 | simbolo: moneda.SIMBOLO |
555 | }; | 555 | }; |
556 | $scope.remito.cotizacion = { | 556 | $scope.remito.cotizacion = { |
557 | ID: cotizacion.ID, | 557 | ID: cotizacion.ID, |
558 | COTIZACION: cotizacion.COTIZACION, | 558 | COTIZACION: cotizacion.COTIZACION, |
559 | FECHA: cotizacion.FECHA | 559 | FECHA: cotizacion.FECHA |
560 | }; | 560 | }; |
561 | addCabecera('Moneda:', moneda.DETALLE); | 561 | addCabecera('Moneda:', moneda.DETALLE); |
562 | addCabecera( | 562 | addCabecera( |
563 | 'Fecha cotizacion:', | 563 | 'Fecha cotizacion:', |
564 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 564 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
565 | ); | 565 | ); |
566 | addCabecera('Cotizacion:', cotizacion.COTIZACION); | 566 | addCabecera('Cotizacion:', cotizacion.COTIZACION); |
567 | }, function() { | 567 | }, function() { |
568 | 568 | ||
569 | } | 569 | } |
570 | ); | 570 | ); |
571 | }; | 571 | }; |
572 | 572 | ||
573 | $scope.agregarATabla = function(key) { | 573 | $scope.agregarATabla = function(key) { |
574 | if(key === 13) { | 574 | if(key === 13) { |
575 | if($scope.articuloACargar.cantidad === undefined || | 575 | if($scope.articuloACargar.cantidad === undefined || |
576 | $scope.articuloACargar.cantidad === 0 || | 576 | $scope.articuloACargar.cantidad === 0 || |
577 | $scope.articuloACargar.cantidad === null ){ | 577 | $scope.articuloACargar.cantidad === null ) { |
578 | focaModalService.alert('El valor debe ser al menos 1'); | 578 | focaModalService.alert('El valor debe ser al menos 1'); |
579 | return; | 579 | return; |
580 | } | 580 | } |
581 | delete $scope.articuloACargar.sectorCodigo; | 581 | delete $scope.articuloACargar.sectorCodigo; |
582 | $scope.articulosTabla.push($scope.articuloACargar); | 582 | $scope.articulosTabla.push($scope.articuloACargar); |
583 | $scope.cargando = true; | 583 | $scope.cargando = true; |
584 | } | 584 | } |
585 | }; | 585 | }; |
586 | 586 | ||
587 | $scope.quitarArticulo = function(key) { | 587 | $scope.quitarArticulo = function(key) { |
588 | $scope.articulosTabla.splice(key, 1); | 588 | $scope.articulosTabla.splice(key, 1); |
589 | }; | 589 | }; |
590 | 590 | ||
591 | $scope.editarArticulo = function(key, articulo) { | 591 | $scope.editarArticulo = function(key, articulo) { |
592 | if(key === 13) { | 592 | if(key === 13) { |
593 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 593 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
594 | articulo.cantidad === undefined){ | 594 | articulo.cantidad === undefined) { |
595 | focaModalService.alert('El valor debe ser al menos 1'); | 595 | focaModalService.alert('El valor debe ser al menos 1'); |
596 | return; | 596 | return; |
597 | } | 597 | } |
598 | articulo.editCantidad = false; | 598 | articulo.editCantidad = false; |
599 | articulo.editPrecio = false; | 599 | articulo.editPrecio = false; |
600 | } | 600 | } |
601 | }; | 601 | }; |
602 | 602 | ||
603 | $scope.cambioEdit = function(articulo, propiedad) { | 603 | $scope.cambioEdit = function(articulo, propiedad) { |
604 | if(propiedad === 'cantidad') { | 604 | if(propiedad === 'cantidad') { |
605 | articulo.editCantidad = true; | 605 | articulo.editCantidad = true; |
606 | } else if(propiedad === 'precio') { | 606 | } else if(propiedad === 'precio') { |
607 | articulo.editPrecio = true; | 607 | articulo.editPrecio = true; |
608 | } | 608 | } |
609 | }; | 609 | }; |
610 | 610 | ||
611 | $scope.limpiarFlete = function() { | 611 | $scope.limpiarFlete = function() { |
612 | $scope.remito.fleteNombre = ''; | 612 | $scope.remito.fleteNombre = ''; |
613 | $scope.remito.chofer = ''; | 613 | $scope.remito.chofer = ''; |
614 | $scope.remito.vehiculo = ''; | 614 | $scope.remito.vehiculo = ''; |
615 | $scope.remito.kilometros = ''; | 615 | $scope.remito.kilometros = ''; |
616 | $scope.remito.costoUnitarioKmFlete = ''; | 616 | $scope.remito.costoUnitarioKmFlete = ''; |
617 | $scope.choferes = ''; | 617 | $scope.choferes = ''; |
618 | $scope.vehiculos = ''; | 618 | $scope.vehiculos = ''; |
619 | }; | 619 | }; |
620 | 620 | ||
621 | $scope.limpiarPantalla = function() { | 621 | $scope.limpiarPantalla = function() { |
622 | $scope.limpiarFlete(); | 622 | $scope.limpiarFlete(); |
623 | $scope.remito.flete = '0'; | 623 | $scope.remito.flete = '0'; |
624 | $scope.remito.bomba = '0'; | 624 | $scope.remito.bomba = '0'; |
625 | $scope.remito.precioCondicion = ''; | 625 | $scope.remito.precioCondicion = ''; |
626 | $scope.articulosTabla = []; | 626 | $scope.articulosTabla = []; |
627 | $scope.remito.vendedor.nombre = ''; | 627 | $scope.remito.vendedor.nombre = ''; |
628 | $scope.remito.cliente = {nombre: ''}; | 628 | $scope.remito.cliente = {nombre: ''}; |
629 | $scope.remito.domicilio = {dom: ''}; | 629 | $scope.remito.domicilio = {dom: ''}; |
630 | $scope.domiciliosCliente = []; | 630 | $scope.domiciliosCliente = []; |
631 | }; | 631 | }; |
632 | 632 | ||
633 | $scope.resetFilter = function() { | 633 | $scope.resetFilter = function() { |
634 | $scope.articuloACargar = {}; | 634 | $scope.articuloACargar = {}; |
635 | $scope.cargando = true; | 635 | $scope.cargando = true; |
636 | }; | 636 | }; |
637 | 637 | ||
638 | $scope.selectFocus = function($event) { | 638 | $scope.selectFocus = function($event) { |
639 | $event.target.select(); | 639 | $event.target.select(); |
640 | }; | 640 | }; |
641 | 641 | ||
642 | $scope.salir = function() { | 642 | $scope.salir = function() { |
643 | $location.path('/'); | 643 | $location.path('/'); |
644 | }; | 644 | }; |
645 | 645 | ||
646 | function addCabecera(label, valor) { | 646 | function addCabecera(label, valor) { |
647 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 647 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
648 | if(propiedad.length === 1) { | 648 | if(propiedad.length === 1) { |
649 | propiedad[0].valor = valor; | 649 | propiedad[0].valor = valor; |
650 | } else { | 650 | } else { |
651 | $scope.cabecera.push({label: label, valor: valor}); | 651 | $scope.cabecera.push({label: label, valor: valor}); |
652 | } | 652 | } |
653 | } | 653 | } |
654 | 654 | ||
655 | function removeCabecera(label) { | 655 | function removeCabecera(label) { |
656 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 656 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
657 | if(propiedad.length === 1){ | 657 | if(propiedad.length === 1) { |
658 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 658 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
659 | } | 659 | } |
660 | } | 660 | } |
661 | } | 661 | } |
662 | ] | 662 | ] |
663 | ) | 663 | ) |
664 | .controller('remitoListaCtrl', [ | 664 | .controller('remitoListaCtrl', [ |
665 | '$scope', | 665 | '$scope', |
666 | 'crearRemitoService', | 666 | 'crearRemitoService', |
667 | '$location', | 667 | '$location', |
668 | function($scope, crearRemitoService, $location) { | 668 | function($scope, crearRemitoService, $location) { |
669 | crearRemitoService.obtenerRemito().then(function(datos) { | 669 | crearRemitoService.obtenerRemito().then(function(datos) { |
670 | $scope.remitos = datos.data; | 670 | $scope.remitos = datos.data; |
671 | }); | 671 | }); |
672 | $scope.editar = function(remito) { | 672 | $scope.editar = function(remito) { |
673 | crearRemitoService.setRemito(remito); | 673 | crearRemitoService.setRemito(remito); |
674 | $location.path('/venta-nota-remito/abm/'); | 674 | $location.path('/venta-nota-remito/abm/'); |
675 | }; | 675 | }; |
676 | $scope.crearRemito = function() { | 676 | $scope.crearRemito = function() { |
677 | crearRemitoService.clearRemito(); | 677 | crearRemitoService.clearRemito(); |
678 | $location.path('/venta-nota-remito/abm/'); | 678 | $location.path('/venta-nota-remito/abm/'); |
679 | }; | 679 | }; |
680 | } | 680 | } |
681 | ]) | 681 | ]) |
682 | .controller('focaCrearRemitoFichaClienteController', [ | 682 | .controller('focaCrearRemitoFichaClienteController', [ |
683 | '$scope', | 683 | '$scope', |
684 | 'crearRemitoService', | 684 | 'crearRemitoService', |
685 | '$location', | 685 | '$location', |
686 | function($scope, crearRemitoService, $location) { | 686 | function($scope, crearRemitoService, $location) { |
687 | crearRemitoService.obtenerRemito().then(function(datos) { | 687 | crearRemitoService.obtenerRemito().then(function(datos) { |
688 | $scope.remitos = datos.data; | 688 | $scope.remitos = datos.data; |
689 | }); | 689 | }); |
690 | $scope.editar = function(remito) { | 690 | $scope.editar = function(remito) { |
691 | crearRemitoService.setRemito(remito); | 691 | crearRemitoService.setRemito(remito); |
692 | $location.path('/venta-nota-remito/abm/'); | 692 | $location.path('/venta-nota-remito/abm/'); |
693 | }; | 693 | }; |
694 | $scope.crearRemito = function() { | 694 | $scope.crearRemito = function() { |
695 | crearRemitoService.clearRemito(); | 695 | crearRemitoService.clearRemito(); |
696 | $location.path('/venta-nota-remito/abm/'); | 696 | $location.path('/venta-nota-remito/abm/'); |
697 | }; | 697 | }; |
698 | } | 698 | } |
699 | ]); | 699 | ]); |
700 | 700 |