Commit 6f0638a17d864ac5f29733d61235db9ef76308b3
1 parent
79ceaacf3a
Exists in
master
Precio de articulos se calcula por la cotización
Showing
3 changed files
with
73 additions
and
49 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: 'focaCrearNotaPedido', | 26 | module: 'focaCrearNotaPedido', |
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-nota-pedido.js'), | 41 | concat('foca-crear-nota-pedido.js'), |
42 | replace('src/views/', ''), | 42 | replace('src/views/', ''), |
43 | gulp.dest(paths.tmp), | 43 | gulp.dest(paths.tmp), |
44 | rename('foca-crear-nota-pedido.min.js'), | 44 | rename('foca-crear-nota-pedido.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 | '"angular-ladda"', ''), | 49 | '"angular-ladda","focaModalMoneda","focaModalCotizacion"', ''), |
50 | gulp.dest(paths.dist) | 50 | gulp.dest(paths.dist) |
51 | ] | 51 | ] |
52 | ); | 52 | ); |
53 | }); | 53 | }); |
54 | 54 | ||
55 | gulp.task('clean', function(){ | 55 | gulp.task('clean', function(){ |
56 | return gulp.src(['tmp', 'dist'], {read: false}) | 56 | return gulp.src(['tmp', 'dist'], {read: false}) |
57 | .pipe(clean()); | 57 | .pipe(clean()); |
58 | }); | 58 | }); |
59 | 59 | ||
60 | gulp.task('pre-commit', function() { | 60 | gulp.task('pre-commit', function() { |
61 | return pump( | 61 | return pump( |
62 | [ | 62 | [ |
63 | gulp.src(paths.srcJS), | 63 | gulp.src(paths.srcJS), |
64 | jshint('.jshintrc'), | 64 | jshint('.jshintrc'), |
65 | jshint.reporter('default'), | 65 | jshint.reporter('default'), |
66 | jshint.reporter('fail') | 66 | jshint.reporter('fail') |
67 | ] | 67 | ] |
68 | ); | 68 | ); |
69 | 69 | ||
70 | gulp.start('uglify'); | 70 | gulp.start('uglify'); |
71 | }); | 71 | }); |
72 | 72 | ||
73 | gulp.task('webserver', function() { | 73 | gulp.task('webserver', function() { |
74 | pump [ | 74 | pump [ |
75 | connect.server({port: 3300, host: '0.0.0.0'}) | 75 | connect.server({port: 3300, host: '0.0.0.0'}) |
76 | ] | 76 | ] |
77 | }); | 77 | }); |
78 | 78 | ||
79 | gulp.task('clean-post-install', function() { | 79 | gulp.task('clean-post-install', function() { |
80 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 80 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
81 | 'index.html'], {read: false}) | 81 | 'index.html'], {read: false}) |
82 | .pipe(clean()); | 82 | .pipe(clean()); |
83 | }); | 83 | }); |
84 | 84 | ||
85 | gulp.task('default', ['webserver']); | 85 | gulp.task('default', ['webserver']); |
86 | 86 | ||
87 | gulp.task('watch', function() { | 87 | gulp.task('watch', function() { |
88 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | 88 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); |
89 | }); | 89 | }); |
90 | 90 |
src/js/controller.js
1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
2 | [ | 2 | [ |
3 | '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', |
4 | 'focaModalService', | 4 | 'focaModalService', |
5 | function( | 5 | function( |
6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService | 6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService |
7 | ) { | 7 | ) { |
8 | $scope.botonera = [ | 8 | $scope.botonera = [ |
9 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, | 9 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, |
10 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | 10 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
11 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, | 11 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, |
12 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | 12 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, |
13 | { | 13 | { |
14 | texto: 'Precios y condiciones', | 14 | texto: 'Precios y condiciones', |
15 | accion: function() {$scope.abrirModalListaPrecio();}}, | 15 | accion: function() {$scope.abrirModalListaPrecio();}}, |
16 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | 16 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, |
17 | {texto: '', accion: function() {}}, | 17 | {texto: '', accion: function() {}}, |
18 | {texto: '', accion: function() {}} | 18 | {texto: '', accion: function() {}} |
19 | ]; | 19 | ]; |
20 | $scope.datepickerAbierto = false; | 20 | $scope.datepickerAbierto = false; |
21 | 21 | ||
22 | $scope.show = false; | 22 | $scope.show = false; |
23 | $scope.cargando = true; | 23 | $scope.cargando = true; |
24 | $scope.dateOptions = { | 24 | $scope.dateOptions = { |
25 | maxDate: new Date(), | 25 | maxDate: new Date(), |
26 | minDate: new Date(2010, 0, 1) | 26 | minDate: new Date(2010, 0, 1) |
27 | }; | 27 | }; |
28 | $scope.crearObjetoNotaPedido = function() { | ||
29 | $scope.notaPedido = { | ||
30 | vendedor: {}, | ||
31 | cliente: {}, | ||
32 | proveedor: {}, | ||
33 | domicilio: {dom: ''}, | ||
34 | moneda: {}, | ||
35 | cotizacion: {} | ||
36 | }; | ||
37 | }; | ||
38 | 28 | ||
39 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 29 | $scope.notaPedido = { |
40 | $scope.obtenerMonedaPorDefecto = function() { | 30 | vendedor: {}, |
41 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | 31 | cliente: {}, |
42 | monedaPorDefecto = { | 32 | proveedor: {}, |
43 | id: res.data[0].ID, | 33 | domicilio: {dom: ''}, |
44 | detalle: res.data[0].DETALLE, | 34 | moneda: {}, |
45 | simbolo: res.data[0].SIMBOLO, | 35 | cotizacion: {} |
46 | cotizaciones: res.data[0].cotizaciones | ||
47 | }; | ||
48 | addCabecera('Moneda:', monedaPorDefecto.detalle); | ||
49 | addCabecera('Fecha cotizacion:', | ||
50 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | ||
51 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); | ||
52 | $scope.notaPedido.moneda = monedaPorDefecto; | ||
53 | $scope.notaPedido.cotizacion.id = monedaPorDefecto.cotizaciones[0].ID; | ||
54 | }); | ||
55 | }; | 36 | }; |
56 | |||
57 | var monedaPorDefecto; | 37 | var monedaPorDefecto; |
58 | $scope.crearObjetoNotaPedido(); | 38 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
59 | $scope.obtenerMonedaPorDefecto(); | 39 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { |
40 | monedaPorDefecto = { | ||
41 | id: res.data[0].ID, | ||
42 | detalle: res.data[0].DETALLE, | ||
43 | simbolo: res.data[0].SIMBOLO, | ||
44 | cotizaciones: res.data[0].cotizaciones | ||
45 | }; | ||
46 | addCabecera('Moneda:', monedaPorDefecto.detalle); | ||
47 | addCabecera('Fecha cotizacion:', | ||
48 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | ||
49 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); | ||
50 | $scope.notaPedido.moneda = monedaPorDefecto; | ||
51 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; | ||
52 | }); | ||
53 | |||
60 | $scope.cabecera = []; | 54 | $scope.cabecera = []; |
61 | $scope.showCabecera = true; | 55 | $scope.showCabecera = true; |
62 | 56 | ||
63 | $scope.now = new Date(); | 57 | $scope.now = new Date(); |
64 | $scope.puntoVenta = Math.round(Math.random() * 10000); | 58 | $scope.puntoVenta = Math.round(Math.random() * 10000); |
65 | $scope.comprobante = Math.round(Math.random() * 1000000); | 59 | $scope.comprobante = Math.round(Math.random() * 1000000); |
66 | 60 | ||
67 | $scope.articulosTabla = []; | 61 | $scope.articulosTabla = []; |
68 | $scope.idLista = undefined; | 62 | $scope.idLista = undefined; |
69 | //La pantalla solo se usa para cargar pedidos | 63 | //La pantalla solo se usa para cargar pedidos |
70 | //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | 64 | //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
71 | 65 | ||
72 | crearNotaPedidoService.getPrecioCondicion().then( | 66 | crearNotaPedidoService.getPrecioCondicion().then( |
73 | function(res) { | 67 | function(res) { |
74 | $scope.precioCondiciones = res.data; | 68 | $scope.precioCondiciones = res.data; |
75 | } | 69 | } |
76 | ); | 70 | ); |
77 | //La pantalla solo se usa para cargar pedidos | 71 | //La pantalla solo se usa para cargar pedidos |
78 | // if (notaPedidoTemp !== undefined) { | 72 | // if (notaPedidoTemp !== undefined) { |
79 | // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | 73 | // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
80 | // $scope.notaPedido = notaPedidoTemp; | 74 | // $scope.notaPedido = notaPedidoTemp; |
81 | // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | 75 | // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
82 | // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | 76 | // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
83 | // $scope.idLista = $scope.notaPedido.precioCondicion; | 77 | // $scope.idLista = $scope.notaPedido.precioCondicion; |
84 | // crearNotaPedidoService | 78 | // crearNotaPedidoService |
85 | // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | 79 | // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
86 | // function(res) { | 80 | // function(res) { |
87 | // $scope.articulosTabla = res.data; | 81 | // $scope.articulosTabla = res.data; |
88 | // } | 82 | // } |
89 | // ); | 83 | // ); |
90 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | 84 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
91 | //(NO REQUERIDO EN ESTA VERSION) | 85 | //(NO REQUERIDO EN ESTA VERSION) |
92 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 86 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
93 | // function(res) { | 87 | // function(res) { |
94 | // $scope.notaPedido.domicilio = res.data; | 88 | // $scope.notaPedido.domicilio = res.data; |
95 | // } | 89 | // } |
96 | // ); | 90 | // ); |
97 | // } else { | 91 | // } else { |
98 | // $scope.notaPedido.fechaCarga = new Date(); | 92 | // $scope.notaPedido.fechaCarga = new Date(); |
99 | // $scope.notaPedido.bomba = '0'; | 93 | // $scope.notaPedido.bomba = '0'; |
100 | // $scope.notaPedido.flete = '0'; | 94 | // $scope.notaPedido.flete = '0'; |
101 | // $scope.idLista = undefined; | 95 | // $scope.idLista = undefined; |
102 | // } | 96 | // } |
103 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 97 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
104 | // $scope.addNewDom = function() { | 98 | // $scope.addNewDom = function() { |
105 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); | 99 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); |
106 | // }; | 100 | // }; |
107 | // $scope.removeNewChoice = function(choice) { | 101 | // $scope.removeNewChoice = function(choice) { |
108 | // if ($scope.notaPedido.domicilio.length > 1) { | 102 | // if ($scope.notaPedido.domicilio.length > 1) { |
109 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | 103 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
110 | // function(c) { | 104 | // function(c) { |
111 | // return c.$$hashKey === choice.$$hashKey; | 105 | // return c.$$hashKey === choice.$$hashKey; |
112 | // } | 106 | // } |
113 | // ), 1); | 107 | // ), 1); |
114 | // } | 108 | // } |
115 | // }; | 109 | // }; |
116 | 110 | ||
117 | $scope.crearNotaPedido = function() { | 111 | $scope.crearNotaPedido = function() { |
118 | if(!$scope.notaPedido.vendedor.codigo) { | 112 | if(!$scope.notaPedido.vendedor.codigo) { |
119 | focaModalService.alert('Ingrese Vendedor'); | 113 | focaModalService.alert('Ingrese Vendedor'); |
120 | return; | 114 | return; |
121 | } else if(!$scope.notaPedido.cliente.id) { | 115 | } else if(!$scope.notaPedido.cliente.id) { |
122 | focaModalService.alert('Ingrese Cliente'); | 116 | focaModalService.alert('Ingrese Cliente'); |
123 | return; | 117 | return; |
124 | } else if(!$scope.notaPedido.proveedor.codigo) { | 118 | } else if(!$scope.notaPedido.proveedor.codigo) { |
125 | focaModalService.alert('Ingrese Proveedor'); | 119 | focaModalService.alert('Ingrese Proveedor'); |
126 | return; | 120 | return; |
127 | } else if(!$scope.notaPedido.moneda.id) { | 121 | } else if(!$scope.notaPedido.moneda.id) { |
128 | focaModalService.alert('Ingrese Moneda'); | 122 | focaModalService.alert('Ingrese Moneda'); |
129 | return; | 123 | return; |
130 | } else if(!$scope.notaPedido.cotizacion.id) { | 124 | } else if(!$scope.notaPedido.cotizacion.ID) { |
131 | focaModalService.alert('Ingrese Cotización'); | 125 | focaModalService.alert('Ingrese Cotización'); |
132 | return; | 126 | return; |
133 | } else if(!$scope.plazosPagos) { | 127 | } else if(!$scope.plazosPagos) { |
134 | focaModalService.alert('Ingrese Precios y Condiciones'); | 128 | focaModalService.alert('Ingrese Precios y Condiciones'); |
135 | return; | 129 | return; |
136 | } else if(!$scope.notaPedido.flete) { | 130 | } else if(!$scope.notaPedido.flete) { |
137 | focaModalService.alert('Ingrese Flete'); | 131 | focaModalService.alert('Ingrese Flete'); |
138 | return; | 132 | return; |
139 | } else if(!$scope.notaPedido.domicilio.id) { | 133 | } else if(!$scope.notaPedido.domicilio.id) { |
140 | focaModalService.aler('Ingrese Domicilio'); | 134 | focaModalService.aler('Ingrese Domicilio'); |
141 | return; | 135 | return; |
142 | } else if($scope.articulosTabla.length === 0) { | 136 | } else if($scope.articulosTabla.length === 0) { |
143 | focaModalService.alert('Debe cargar almenos un articulo'); | 137 | focaModalService.alert('Debe cargar al menos un articulo'); |
144 | return; | 138 | return; |
145 | } | 139 | } |
146 | var date = new Date(); | 140 | var date = new Date(); |
147 | var notaPedido = { | 141 | var notaPedido = { |
148 | id: 0, | 142 | id: 0, |
149 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 143 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
150 | .toISOString().slice(0, 19).replace('T', ' '), | 144 | .toISOString().slice(0, 19).replace('T', ' '), |
151 | idVendedor: $scope.notaPedido.vendedor.codigo, | 145 | idVendedor: $scope.notaPedido.vendedor.codigo, |
152 | idCliente: $scope.notaPedido.cliente.id, | 146 | idCliente: $scope.notaPedido.cliente.id, |
153 | idProveedor: $scope.notaPedido.proveedor.codigo, | 147 | idProveedor: $scope.notaPedido.proveedor.codigo, |
154 | idDomicilio: $scope.notaPedido.domicilio.id, | 148 | idDomicilio: $scope.notaPedido.domicilio.id, |
155 | idCotizacion: $scope.notaPedido.cotizacion.id, | 149 | idCotizacion: $scope.notaPedido.cotizacion.id, |
156 | flete: parseInt($scope.notaPedido.flete), | 150 | flete: $scope.notaPedido.flete ? 1 : 0, |
157 | fob: parseInt($scope.notaPedido.fob), | 151 | fob: $scope.notaPedido.fob ? 1 : 0, |
158 | bomba: parseInt($scope.notaPedido.bomba), | 152 | bomba: $scope.notaPedido.bomba ? 1 : 0, |
159 | kilometros: $scope.notaPedido.kilometros, | 153 | kilometros: $scope.notaPedido.kilometros, |
160 | total: $scope.getTotal() | 154 | total: $scope.getTotal() |
161 | }; | 155 | }; |
162 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 156 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
163 | function(data) { | 157 | function(data) { |
164 | 158 | ||
165 | var articulosNotaPedido = $scope.articulosTabla; | 159 | var articulosNotaPedido = $scope.articulosTabla; |
166 | for(var i = 0; i < articulosNotaPedido.length; i++) { | 160 | for(var i = 0; i < articulosNotaPedido.length; i++) { |
167 | delete articulosNotaPedido[i].editCantidad; | 161 | delete articulosNotaPedido[i].editCantidad; |
168 | delete articulosNotaPedido[i].editPrecio; | 162 | delete articulosNotaPedido[i].editPrecio; |
169 | articulosNotaPedido[i].idNotaPedido = data.data.id; | 163 | articulosNotaPedido[i].idNotaPedido = data.data.id; |
170 | crearNotaPedidoService | 164 | crearNotaPedidoService |
171 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); | 165 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); |
172 | } | 166 | } |
173 | var plazos = $scope.plazosPagos; | 167 | var plazos = $scope.plazosPagos; |
174 | for(var j = 0; j < plazos.length; j++) { | 168 | for(var j = 0; j < plazos.length; j++) { |
175 | var json = { | 169 | var json = { |
176 | idPedido: data.data.id, | 170 | idPedido: data.data.id, |
177 | dias: plazos[j].dias | 171 | dias: plazos[j].dias |
178 | }; | 172 | }; |
179 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); | 173 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); |
180 | } | 174 | } |
181 | focaModalService.alert('Nota pedido creada'); | 175 | focaModalService.alert('Nota pedido creada'); |
182 | $scope.obtenerMonedaPorDefecto(); | ||
183 | $scope.crearObjetoNotaPedido(); | ||
184 | $scope.cabecera = []; | 176 | $scope.cabecera = []; |
177 | addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); | ||
178 | addCabecera( | ||
179 | 'Fecha cotizacion:', | ||
180 | $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') | ||
181 | ); | ||
182 | addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.cotizacion); | ||
183 | $scope.notaPedido.vendedor = {}; | ||
184 | $scope.notaPedido.cliente = {}; | ||
185 | $scope.notaPedido.proveedor = {}; | ||
186 | $scope.notaPedido.domicilio = {}; | ||
187 | $scope.notaPedido.flete = null; | ||
188 | $scope.notaPedido.fob = null; | ||
189 | $scope.notaPedido.bomba = null; | ||
190 | $scope.notaPedido.kilometros = null; | ||
185 | $scope.articulosTabla = []; | 191 | $scope.articulosTabla = []; |
186 | } | 192 | } |
187 | ); | 193 | ); |
188 | }; | 194 | }; |
189 | 195 | ||
190 | $scope.seleccionarArticulo = function() { | 196 | $scope.seleccionarArticulo = function() { |
191 | if ($scope.idLista === undefined) { | 197 | if ($scope.idLista === undefined) { |
192 | focaModalService.alert( | 198 | focaModalService.alert( |
193 | 'Primero seleccione una lista de precio y condicion'); | 199 | 'Primero seleccione una lista de precio y condicion'); |
194 | return; | 200 | return; |
195 | } | 201 | } |
196 | var modalInstance = $uibModal.open( | 202 | var modalInstance = $uibModal.open( |
197 | { | 203 | { |
198 | ariaLabelledBy: 'Busqueda de Productos', | 204 | ariaLabelledBy: 'Busqueda de Productos', |
199 | templateUrl: 'modal-busqueda-productos.html', | 205 | templateUrl: 'modal-busqueda-productos.html', |
200 | controller: 'modalBusquedaProductosCtrl', | 206 | controller: 'modalBusquedaProductosCtrl', |
201 | resolve: { idLista: function() { return $scope.idLista; } }, | 207 | resolve: { |
208 | idLista: function() { return $scope.idLista; }, | ||
209 | cotizacion: $scope.notaPedido.cotizacion.COTIZACION | ||
210 | }, | ||
202 | size: 'lg' | 211 | size: 'lg' |
203 | } | 212 | } |
204 | ); | 213 | ); |
205 | modalInstance.result.then( | 214 | modalInstance.result.then( |
206 | function(producto) { | 215 | function(producto) { |
207 | var newArt = | 216 | var newArt = |
208 | { | 217 | { |
209 | id: 0, | 218 | id: 0, |
210 | codigo: producto.codigo, | 219 | codigo: producto.codigo, |
211 | sector: producto.sector, | 220 | sector: producto.sector, |
212 | sectorCodigo: producto.sector + '-' + producto.codigo, | 221 | sectorCodigo: producto.sector + '-' + producto.codigo, |
213 | descripcion: producto.descripcion, | 222 | descripcion: producto.descripcion, |
214 | item: $scope.articulosTabla.length + 1, | 223 | item: $scope.articulosTabla.length + 1, |
215 | nombre: producto.descripcion, | 224 | nombre: producto.descripcion, |
216 | precio: parseFloat(producto.precio.toFixed(2)), | 225 | precio: parseFloat(producto.precio.toFixed(2)), |
217 | costoUnitario: producto.costo, | 226 | costoUnitario: producto.costo, |
218 | editCantidad: false, | 227 | editCantidad: false, |
219 | editPrecio: false | 228 | editPrecio: false |
220 | }; | 229 | }; |
221 | $scope.articuloACargar = newArt; | 230 | $scope.articuloACargar = newArt; |
222 | $scope.cargando = false; | 231 | $scope.cargando = false; |
223 | }, function() { | 232 | }, function() { |
224 | // funcion ejecutada cuando se cancela el modal | 233 | // funcion ejecutada cuando se cancela el modal |
225 | } | 234 | } |
226 | ); | 235 | ); |
227 | }; | 236 | }; |
228 | 237 | ||
229 | $scope.seleccionarVendedor = function() { | 238 | $scope.seleccionarVendedor = function() { |
230 | var modalInstance = $uibModal.open( | 239 | var modalInstance = $uibModal.open( |
231 | { | 240 | { |
232 | ariaLabelledBy: 'Busqueda de Vendedores', | 241 | ariaLabelledBy: 'Busqueda de Vendedores', |
233 | templateUrl: 'modal-vendedores.html', | 242 | templateUrl: 'modal-vendedores.html', |
234 | controller: 'modalVendedoresCtrl', | 243 | controller: 'modalVendedoresCtrl', |
235 | size: 'lg' | 244 | size: 'lg' |
236 | } | 245 | } |
237 | ); | 246 | ); |
238 | modalInstance.result.then( | 247 | modalInstance.result.then( |
239 | function(vendedor) { | 248 | function(vendedor) { |
240 | addCabecera('Vendedor:', vendedor.NomVen); | 249 | addCabecera('Vendedor:', vendedor.NomVen); |
241 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; | 250 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; |
242 | }, function() { | 251 | }, function() { |
243 | 252 | ||
244 | } | 253 | } |
245 | ); | 254 | ); |
246 | }; | 255 | }; |
247 | 256 | ||
248 | $scope.seleccionarProveedor = function() { | 257 | $scope.seleccionarProveedor = function() { |
249 | var modalInstance = $uibModal.open( | 258 | var modalInstance = $uibModal.open( |
250 | { | 259 | { |
251 | ariaLabelledBy: 'Busqueda de Proveedor', | 260 | ariaLabelledBy: 'Busqueda de Proveedor', |
252 | templateUrl: 'modal-proveedor.html', | 261 | templateUrl: 'modal-proveedor.html', |
253 | controller: 'focaModalProveedorCtrl', | 262 | controller: 'focaModalProveedorCtrl', |
254 | size: 'lg' | 263 | size: 'lg' |
255 | } | 264 | } |
256 | ); | 265 | ); |
257 | modalInstance.result.then( | 266 | modalInstance.result.then( |
258 | function(proveedor) { | 267 | function(proveedor) { |
259 | $scope.notaPedido.proveedor.codigo = proveedor.COD; | 268 | $scope.notaPedido.proveedor.codigo = proveedor.COD; |
260 | addCabecera('Proveedor:', proveedor.NOM); | 269 | addCabecera('Proveedor:', proveedor.NOM); |
261 | }, function() { | 270 | }, function() { |
262 | 271 | ||
263 | } | 272 | } |
264 | ); | 273 | ); |
265 | }; | 274 | }; |
266 | 275 | ||
267 | $scope.seleccionarCliente = function() { | 276 | $scope.seleccionarCliente = function() { |
268 | 277 | ||
269 | var modalInstance = $uibModal.open( | 278 | var modalInstance = $uibModal.open( |
270 | { | 279 | { |
271 | ariaLabelledBy: 'Busqueda de Cliente', | 280 | ariaLabelledBy: 'Busqueda de Cliente', |
272 | templateUrl: 'foca-busqueda-cliente-modal.html', | 281 | templateUrl: 'foca-busqueda-cliente-modal.html', |
273 | controller: 'focaBusquedaClienteModalController', | 282 | controller: 'focaBusquedaClienteModalController', |
274 | size: 'lg' | 283 | size: 'lg' |
275 | } | 284 | } |
276 | ); | 285 | ); |
277 | modalInstance.result.then( | 286 | modalInstance.result.then( |
278 | function(cliente) { | 287 | function(cliente) { |
279 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( | 288 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( |
280 | function(data) { | 289 | function(data) { |
281 | if(data.data.length === 0){ | 290 | if(data.data.length === 0){ |
282 | focaModalService | 291 | focaModalService |
283 | .alert('El cliente no tienen domicilios de entrega') | 292 | .alert('El cliente no tienen domicilios de entrega') |
284 | .then( | 293 | .then( |
285 | function() { | 294 | function() { |
286 | $scope.seleccionarCliente(); | 295 | $scope.seleccionarCliente(); |
287 | } | 296 | } |
288 | ); | 297 | ); |
289 | return; | 298 | return; |
290 | } | 299 | } |
291 | $scope.abrirModalDomicilios(cliente); | 300 | $scope.abrirModalDomicilios(cliente); |
292 | } | 301 | } |
293 | ); | 302 | ); |
294 | }, function() { | 303 | }, function() { |
295 | 304 | ||
296 | } | 305 | } |
297 | ); | 306 | ); |
298 | }; | 307 | }; |
299 | 308 | ||
300 | $scope.abrirModalDomicilios = function(cliente) { | 309 | $scope.abrirModalDomicilios = function(cliente) { |
301 | var modalInstanceDomicilio = $uibModal.open( | 310 | var modalInstanceDomicilio = $uibModal.open( |
302 | { | 311 | { |
303 | ariaLabelledBy: 'Busqueda de Domicilios', | 312 | ariaLabelledBy: 'Busqueda de Domicilios', |
304 | templateUrl: 'modal-domicilio.html', | 313 | templateUrl: 'modal-domicilio.html', |
305 | controller: 'focaModalDomicilioController', | 314 | controller: 'focaModalDomicilioController', |
306 | resolve: { idCliente: function() { return cliente.cod; }}, | 315 | resolve: { idCliente: function() { return cliente.cod; }}, |
307 | size: 'lg', | 316 | size: 'lg', |
308 | } | 317 | } |
309 | ); | 318 | ); |
310 | modalInstanceDomicilio.result.then( | 319 | modalInstanceDomicilio.result.then( |
311 | function(domicilio) { | 320 | function(domicilio) { |
312 | $scope.notaPedido.domicilio.id = domicilio.id; | 321 | $scope.notaPedido.domicilio.id = domicilio.id; |
313 | $scope.notaPedido.cliente.id = cliente.cod; | 322 | $scope.notaPedido.cliente.id = cliente.cod; |
314 | addCabecera('Cliente:', cliente.nom); | 323 | addCabecera('Cliente:', cliente.nom); |
315 | addCabecera('Domicilio:', domicilio.dom); | 324 | addCabecera('Domicilio:', domicilio.dom); |
316 | }, function() { | 325 | }, function() { |
317 | $scope.seleccionarCliente(); | 326 | $scope.seleccionarCliente(); |
318 | return; | 327 | return; |
319 | } | 328 | } |
320 | ); | 329 | ); |
321 | }; | 330 | }; |
322 | 331 | ||
323 | $scope.mostrarFichaCliente = function() { | 332 | $scope.mostrarFichaCliente = function() { |
324 | $uibModal.open( | 333 | $uibModal.open( |
325 | { | 334 | { |
326 | ariaLabelledBy: 'Datos del Cliente', | 335 | ariaLabelledBy: 'Datos del Cliente', |
327 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 336 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
328 | controller: 'focaCrearNotaPedidoFichaClienteController', | 337 | controller: 'focaCrearNotaPedidoFichaClienteController', |
329 | size: 'lg' | 338 | size: 'lg' |
330 | } | 339 | } |
331 | ); | 340 | ); |
332 | }; | 341 | }; |
333 | 342 | ||
334 | $scope.getTotal = function() { | 343 | $scope.getTotal = function() { |
335 | var total = 0; | 344 | var total = 0; |
336 | var arrayTempArticulos = $scope.articulosTabla; | 345 | var arrayTempArticulos = $scope.articulosTabla; |
337 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 346 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
338 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 347 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
339 | } | 348 | } |
340 | return parseFloat(total.toFixed(2)); | 349 | return parseFloat(total.toFixed(2)); |
341 | }; | 350 | }; |
342 | 351 | ||
343 | $scope.getSubTotal = function() { | 352 | $scope.getSubTotal = function() { |
344 | if($scope.articuloACargar) { | 353 | if($scope.articuloACargar) { |
345 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 354 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
346 | } | 355 | } |
347 | }; | 356 | }; |
348 | 357 | ||
349 | $scope.abrirModalListaPrecio = function() { | 358 | $scope.abrirModalListaPrecio = function() { |
350 | var modalInstance = $uibModal.open( | 359 | var modalInstance = $uibModal.open( |
351 | { | 360 | { |
352 | ariaLabelledBy: 'Busqueda de Precio Condición', | 361 | ariaLabelledBy: 'Busqueda de Precio Condición', |
353 | templateUrl: 'modal-precio-condicion.html', | 362 | templateUrl: 'modal-precio-condicion.html', |
354 | controller: 'focaModalPrecioCondicionController', | 363 | controller: 'focaModalPrecioCondicionController', |
355 | size: 'lg' | 364 | size: 'lg' |
356 | } | 365 | } |
357 | ); | 366 | ); |
358 | modalInstance.result.then( | 367 | modalInstance.result.then( |
359 | function(precioCondicion) { | 368 | function(precioCondicion) { |
360 | var cabecera = ''; | 369 | var cabecera = ''; |
361 | var plazosConcat = ''; | 370 | var plazosConcat = ''; |
362 | if(!Array.isArray(precioCondicion)) { | 371 | if(!Array.isArray(precioCondicion)) { |
363 | $scope.plazosPagos = precioCondicion.plazoPago; | 372 | $scope.plazosPagos = precioCondicion.plazoPago; |
364 | $scope.idLista = precioCondicion.idListaPrecio; | 373 | $scope.idLista = precioCondicion.idListaPrecio; |
365 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 374 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
366 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 375 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
367 | } | 376 | } |
368 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 377 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
369 | } else { //Cuando se ingresan los plazos manualmente | 378 | } else { //Cuando se ingresan los plazos manualmente |
370 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 379 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
371 | $scope.plazosPagos = precioCondicion; | 380 | $scope.plazosPagos = precioCondicion; |
372 | for(var j = 0; j < precioCondicion.length; j++) { | 381 | for(var j = 0; j < precioCondicion.length; j++) { |
373 | plazosConcat += precioCondicion[j].dias + ' '; | 382 | plazosConcat += precioCondicion[j].dias + ' '; |
374 | } | 383 | } |
375 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 384 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
376 | } | 385 | } |
377 | $scope.articulosTabla = []; | 386 | $scope.articulosTabla = []; |
378 | addCabecera('Precios y condiciones:', cabecera); | 387 | addCabecera('Precios y condiciones:', cabecera); |
379 | }, function() { | 388 | }, function() { |
380 | 389 | ||
381 | } | 390 | } |
382 | ); | 391 | ); |
383 | }; | 392 | }; |
384 | 393 | ||
385 | $scope.abrirModalFlete = function() { | 394 | $scope.abrirModalFlete = function() { |
386 | var modalInstance = $uibModal.open( | 395 | var modalInstance = $uibModal.open( |
387 | { | 396 | { |
388 | ariaLabelledBy: 'Busqueda de Flete', | 397 | ariaLabelledBy: 'Busqueda de Flete', |
389 | templateUrl: 'modal-flete.html', | 398 | templateUrl: 'modal-flete.html', |
390 | controller: 'focaModalFleteController', | 399 | controller: 'focaModalFleteController', |
391 | size: 'lg', | 400 | size: 'lg', |
392 | resolve: { | 401 | resolve: { |
393 | parametrosFlete: | 402 | parametrosFlete: |
394 | function() { | 403 | function() { |
395 | return { | 404 | return { |
396 | flete: $scope.notaPedido.flete, | 405 | flete: $scope.notaPedido.flete ? '1' : |
397 | bomba: $scope.notaPedido.bomba, | 406 | ($scope.notaPedido.fob ? 'FOB' : |
407 | ($scope.notaPedido.flete === undefined ? null : '0')), | ||
408 | bomba: $scope.notaPedido.bomba ? '1' : | ||
409 | ($scope.notaPedido.bomba === undefined ? null : '0'), | ||
398 | kilometros: $scope.notaPedido.kilometros | 410 | kilometros: $scope.notaPedido.kilometros |
399 | }; | 411 | }; |
400 | } | 412 | } |
401 | } | 413 | } |
402 | } | 414 | } |
403 | ); | 415 | ); |
404 | modalInstance.result.then( | 416 | modalInstance.result.then( |
405 | function(datos) { | 417 | function(datos) { |
406 | $scope.notaPedido.flete = datos.flete; | 418 | $scope.notaPedido.flete = datos.flete; |
407 | $scope.notaPedido.fob = datos.FOB; | 419 | $scope.notaPedido.fob = datos.FOB; |
408 | $scope.notaPedido.bomba = datos.bomba; | 420 | $scope.notaPedido.bomba = datos.bomba; |
409 | $scope.notaPedido.kilometros = datos.kilometros; | 421 | $scope.notaPedido.kilometros = datos.kilometros; |
410 | 422 | ||
411 | addCabecera('Flete:', datos.flete); | 423 | addCabecera('Flete:', datos.flete ? 'Si' : |
412 | if(datos.flete === '1') { | 424 | ($scope.notaPedido.fob ? 'FOB' : 'No')); |
413 | addCabecera('Bomba:', datos.bomba); | 425 | if(datos.flete) { |
414 | addCabecera('Kilometros:', datos.kilometros); | 426 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); |
427 | addCabecera('Kilometros:', datos.kilometros ? 'Si' : 'No'); | ||
415 | } else { | 428 | } else { |
416 | removeCabecera('Bomba:'); | 429 | removeCabecera('Bomba:'); |
417 | removeCabecera('Kilometros:'); | 430 | removeCabecera('Kilometros:'); |
431 | $scope.notaPedido.fob = false; | ||
432 | $scope.notaPedido.bomba = false; | ||
433 | $scope.notaPedido.kilometros = null; | ||
418 | } | 434 | } |
419 | }, function() { | 435 | }, function() { |
420 | 436 | ||
421 | } | 437 | } |
422 | ); | 438 | ); |
423 | }; | 439 | }; |
424 | 440 | ||
425 | $scope.abrirModalMoneda = function() { | 441 | $scope.abrirModalMoneda = function() { |
426 | var modalInstance = $uibModal.open( | 442 | var modalInstance = $uibModal.open( |
427 | { | 443 | { |
428 | ariaLabelledBy: 'Busqueda de Moneda', | 444 | ariaLabelledBy: 'Busqueda de Moneda', |
429 | templateUrl: 'modal-moneda.html', | 445 | templateUrl: 'modal-moneda.html', |
430 | controller: 'focaModalMonedaController', | 446 | controller: 'focaModalMonedaController', |
431 | size: 'lg' | 447 | size: 'lg' |
432 | } | 448 | } |
433 | ); | 449 | ); |
434 | modalInstance.result.then( | 450 | modalInstance.result.then( |
435 | function(moneda) { | 451 | function(moneda) { |
436 | |||
437 | $scope.abrirModalCotizacion(moneda); | 452 | $scope.abrirModalCotizacion(moneda); |
438 | }, function() { | 453 | }, function() { |
439 | 454 | ||
440 | } | 455 | } |
441 | ); | 456 | ); |
442 | }; | 457 | }; |
443 | 458 | ||
444 | $scope.abrirModalCotizacion = function(moneda) { | 459 | $scope.abrirModalCotizacion = function(moneda) { |
445 | var modalInstance = $uibModal.open( | 460 | var modalInstance = $uibModal.open( |
446 | { | 461 | { |
447 | ariaLabelledBy: 'Busqueda de Cotización', | 462 | ariaLabelledBy: 'Busqueda de Cotización', |
448 | templateUrl: 'modal-cotizacion.html', | 463 | templateUrl: 'modal-cotizacion.html', |
449 | controller: 'focaModalCotizacionController', | 464 | controller: 'focaModalCotizacionController', |
450 | size: 'lg', | 465 | size: 'lg', |
451 | resolve: {idMoneda: function() {return moneda.ID;}} | 466 | resolve: {idMoneda: function() {return moneda.ID;}} |
452 | } | 467 | } |
453 | ); | 468 | ); |
454 | modalInstance.result.then( | 469 | modalInstance.result.then( |
455 | function(cotizacion) { | 470 | function(cotizacion) { |
471 | var articulosTablaTemp = $scope.articulosTabla; | ||
472 | for(var i = 0; i < articulosTablaTemp.length; i++) { | ||
473 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | ||
474 | $scope.notaPedido.cotizacion.COTIZACION; | ||
475 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | ||
476 | cotizacion.COTIZACION; | ||
477 | } | ||
478 | $scope.articulosTabla = articulosTablaTemp; | ||
456 | $scope.notaPedido.moneda = { | 479 | $scope.notaPedido.moneda = { |
457 | id: moneda.ID, | 480 | id: moneda.ID, |
458 | detalle: moneda.DETALLE, | 481 | detalle: moneda.DETALLE, |
459 | simbolo: moneda.SIMBOLO | 482 | simbolo: moneda.SIMBOLO |
460 | }; | 483 | }; |
461 | $scope.notaPedido.cotizacion = { | 484 | $scope.notaPedido.cotizacion = { |
462 | id: cotizacion.ID, | 485 | ID: cotizacion.ID, |
463 | cotizacion: cotizacion.COTIZACION | 486 | COTIZACION: cotizacion.COTIZACION, |
487 | FECHA: cotizacion.fecha | ||
464 | }; | 488 | }; |
465 | addCabecera('Moneda:', moneda.DETALLE); | 489 | addCabecera('Moneda:', moneda.DETALLE); |
466 | addCabecera( | 490 | addCabecera( |
467 | 'Fecha cotizacion:', | 491 | 'Fecha cotizacion:', |
468 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 492 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
469 | ); | 493 | ); |
470 | addCabecera('Cotizacion:', cotizacion.COTIZACION); | 494 | addCabecera('Cotizacion:', cotizacion.COTIZACION); |
471 | }, function() { | 495 | }, function() { |
472 | 496 | ||
473 | } | 497 | } |
474 | ); | 498 | ); |
475 | }; | 499 | }; |
476 | 500 | ||
477 | $scope.agregarATabla = function(key) { | 501 | $scope.agregarATabla = function(key) { |
478 | if(key === 13) { | 502 | if(key === 13) { |
479 | if($scope.articuloACargar.cantidad === undefined || | 503 | if($scope.articuloACargar.cantidad === undefined || |
480 | $scope.articuloACargar.cantidad === 0 || | 504 | $scope.articuloACargar.cantidad === 0 || |
481 | $scope.articuloACargar.cantidad === null ){ | 505 | $scope.articuloACargar.cantidad === null ){ |
482 | focaModalService.alert('El valor debe ser al menos 1'); | 506 | focaModalService.alert('El valor debe ser al menos 1'); |
483 | return; | 507 | return; |
484 | } | 508 | } |
485 | delete $scope.articuloACargar.sectorCodigo; | 509 | delete $scope.articuloACargar.sectorCodigo; |
486 | $scope.articulosTabla.push($scope.articuloACargar); | 510 | $scope.articulosTabla.push($scope.articuloACargar); |
487 | $scope.cargando = true; | 511 | $scope.cargando = true; |
488 | } | 512 | } |
489 | }; | 513 | }; |
490 | 514 | ||
491 | $scope.quitarArticulo = function(key) { | 515 | $scope.quitarArticulo = function(key) { |
492 | $scope.articulosTabla.splice(key, 1); | 516 | $scope.articulosTabla.splice(key, 1); |
493 | }; | 517 | }; |
494 | 518 | ||
495 | $scope.editarArticulo = function(key, articulo) { | 519 | $scope.editarArticulo = function(key, articulo) { |
496 | if(key === 13) { | 520 | if(key === 13) { |
497 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 521 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
498 | articulo.cantidad === undefined){ | 522 | articulo.cantidad === undefined){ |
499 | focaModalService.alert('El valor debe ser al menos 1'); | 523 | focaModalService.alert('El valor debe ser al menos 1'); |
500 | return; | 524 | return; |
501 | } | 525 | } |
502 | articulo.editCantidad = false; | 526 | articulo.editCantidad = false; |
503 | articulo.editPrecio = false; | 527 | articulo.editPrecio = false; |
504 | } | 528 | } |
505 | }; | 529 | }; |
506 | 530 | ||
507 | $scope.cambioEdit = function(articulo, propiedad) { | 531 | $scope.cambioEdit = function(articulo, propiedad) { |
508 | if(propiedad === 'cantidad') { | 532 | if(propiedad === 'cantidad') { |
509 | articulo.editCantidad = true; | 533 | articulo.editCantidad = true; |
510 | } else if(propiedad === 'precio') { | 534 | } else if(propiedad === 'precio') { |
511 | articulo.editPrecio = true; | 535 | articulo.editPrecio = true; |
512 | } | 536 | } |
513 | }; | 537 | }; |
514 | 538 | ||
515 | $scope.limpiarFlete = function() { | 539 | $scope.limpiarFlete = function() { |
516 | $scope.notaPedido.fleteNombre = ''; | 540 | $scope.notaPedido.fleteNombre = ''; |
517 | $scope.notaPedido.chofer = ''; | 541 | $scope.notaPedido.chofer = ''; |
518 | $scope.notaPedido.vehiculo = ''; | 542 | $scope.notaPedido.vehiculo = ''; |
519 | $scope.notaPedido.kilometros = ''; | 543 | $scope.notaPedido.kilometros = ''; |
520 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 544 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
521 | $scope.choferes = ''; | 545 | $scope.choferes = ''; |
522 | $scope.vehiculos = ''; | 546 | $scope.vehiculos = ''; |
523 | }; | 547 | }; |
524 | 548 | ||
525 | $scope.limpiarPantalla = function() { | 549 | $scope.limpiarPantalla = function() { |
526 | $scope.limpiarFlete(); | 550 | $scope.limpiarFlete(); |
527 | $scope.notaPedido.flete = '0'; | 551 | $scope.notaPedido.flete = '0'; |
528 | $scope.notaPedido.bomba = '0'; | 552 | $scope.notaPedido.bomba = '0'; |
529 | $scope.notaPedido.precioCondicion = ''; | 553 | $scope.notaPedido.precioCondicion = ''; |
530 | $scope.articulosTabla = []; | 554 | $scope.articulosTabla = []; |
531 | $scope.notaPedido.vendedor.nombre = ''; | 555 | $scope.notaPedido.vendedor.nombre = ''; |
532 | $scope.notaPedido.cliente = {nombre: ''}; | 556 | $scope.notaPedido.cliente = {nombre: ''}; |
533 | $scope.notaPedido.domicilio = {dom: ''}; | 557 | $scope.notaPedido.domicilio = {dom: ''}; |
534 | $scope.domiciliosCliente = []; | 558 | $scope.domiciliosCliente = []; |
535 | }; | 559 | }; |
536 | 560 | ||
537 | $scope.resetFilter = function() { | 561 | $scope.resetFilter = function() { |
538 | $scope.articuloACargar = {}; | 562 | $scope.articuloACargar = {}; |
539 | $scope.cargando = true; | 563 | $scope.cargando = true; |
540 | }; | 564 | }; |
541 | 565 | ||
542 | $scope.selectFocus = function($event) { | 566 | $scope.selectFocus = function($event) { |
543 | $event.target.select(); | 567 | $event.target.select(); |
544 | }; | 568 | }; |
545 | 569 | ||
546 | $scope.salir = function() { | 570 | $scope.salir = function() { |
547 | $location.path('/'); | 571 | $location.path('/'); |
548 | }; | 572 | }; |
549 | 573 | ||
550 | function addCabecera(label, valor) { | 574 | function addCabecera(label, valor) { |
551 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 575 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
552 | if(propiedad.length === 1) { | 576 | if(propiedad.length === 1) { |
553 | propiedad[0].valor = valor; | 577 | propiedad[0].valor = valor; |
554 | } else { | 578 | } else { |
555 | $scope.cabecera.push({label: label, valor: valor}); | 579 | $scope.cabecera.push({label: label, valor: valor}); |
556 | } | 580 | } |
557 | } | 581 | } |
558 | 582 | ||
559 | function removeCabecera(label) { | 583 | function removeCabecera(label) { |
560 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 584 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
561 | if(propiedad.length === 1){ | 585 | if(propiedad.length === 1){ |
562 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 586 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
563 | } | 587 | } |
564 | } | 588 | } |
565 | } | 589 | } |
566 | ] | 590 | ] |
567 | ) | 591 | ) |
568 | .controller('notaPedidoListaCtrl', [ | 592 | .controller('notaPedidoListaCtrl', [ |
569 | '$scope', | 593 | '$scope', |
570 | 'crearNotaPedidoService', | 594 | 'crearNotaPedidoService', |
571 | '$location', | 595 | '$location', |
572 | function($scope, crearNotaPedidoService, $location) { | 596 | function($scope, crearNotaPedidoService, $location) { |
573 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 597 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
574 | $scope.notaPedidos = datos.data; | 598 | $scope.notaPedidos = datos.data; |
575 | }); | 599 | }); |
576 | $scope.editar = function(notaPedido) { | 600 | $scope.editar = function(notaPedido) { |
577 | crearNotaPedidoService.setNotaPedido(notaPedido); | 601 | crearNotaPedidoService.setNotaPedido(notaPedido); |
578 | $location.path('/venta-nota-pedido/abm/'); | 602 | $location.path('/venta-nota-pedido/abm/'); |
579 | }; | 603 | }; |
580 | $scope.crearPedido = function() { | 604 | $scope.crearPedido = function() { |
581 | crearNotaPedidoService.clearNotaPedido(); | 605 | crearNotaPedidoService.clearNotaPedido(); |
src/views/nota-pedido.html
1 | <div class="crear-nota-pedido"> | 1 | <div class="crear-nota-pedido"> |
2 | <form name="formCrearNota" ng-submit="crearNotaPedido()" class="mb-0"> | 2 | <form name="formCrearNota" ng-submit="crearNotaPedido()" class="mb-0"> |
3 | <div class="row"> | 3 | <div class="row"> |
4 | <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2"> | 4 | <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2"> |
5 | <div class="row p-1 panel-informativo"> | 5 | <div class="row p-1 panel-informativo"> |
6 | <div class="col-12"> | 6 | <div class="col-12"> |
7 | <div class="row"> | 7 | <div class="row"> |
8 | <div class="col-12 col-sm-4 nota-pedido"> | 8 | <div class="col-12 col-sm-4 nota-pedido"> |
9 | <h5>NOTA DE PEDIDO</h5> | 9 | <h5>NOTA DE PEDIDO</h5> |
10 | </div> | 10 | </div> |
11 | <div class="col-5 col-sm-4 numero-pedido" | 11 | <div class="col-5 col-sm-4 numero-pedido" |
12 | >Nº {{puntoVenta}}-{{comprobante}} | 12 | >Nº {{puntoVenta}}-{{comprobante}} |
13 | </div> | 13 | </div> |
14 | <div class="col-7 col-sm-4 text-right"> | 14 | <div class="col-7 col-sm-4 text-right"> |
15 | Fecha: | 15 | Fecha: |
16 | <span | 16 | <span |
17 | ng-show="!datepickerAbierto" | 17 | ng-show="!datepickerAbierto" |
18 | ng-bind="now | date:'dd/MM/yyyy HH:mm'" | 18 | ng-bind="now | date:'dd/MM/yyyy HH:mm'" |
19 | ng-click="datepickerAbierto = true" | 19 | ng-click="datepickerAbierto = true" |
20 | > | 20 | > |
21 | </span> | 21 | </span> |
22 | <input | 22 | <input |
23 | ng-show="datepickerAbierto" | 23 | ng-show="datepickerAbierto" |
24 | type="date" | 24 | type="date" |
25 | ng-model="now" | 25 | ng-model="now" |
26 | ng-change="datepickerAbierto = false" | 26 | ng-change="datepickerAbierto = false" |
27 | ng-blur="datepickerAbierto = false" | 27 | ng-blur="datepickerAbierto = false" |
28 | class="form-control form-control-sm col-8 float-right" | 28 | class="form-control form-control-sm col-8 float-right" |
29 | foca-focus="datepickerAbierto" | 29 | foca-focus="datepickerAbierto" |
30 | hasta-hoy | 30 | hasta-hoy |
31 | /> | 31 | /> |
32 | </div> | 32 | </div> |
33 | </div> | 33 | </div> |
34 | <div class="row"> | 34 | <div class="row"> |
35 | <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> | 35 | <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> |
36 | <span class="label" ng-bind="cab.label"></span> | 36 | <span class="label" ng-bind="cab.label"></span> |
37 | <span class="valor" ng-bind="cab.valor"></span> | 37 | <span class="valor" ng-bind="cab.valor"></span> |
38 | </div> | 38 | </div> |
39 | <a | 39 | <a |
40 | class="btn col-12 btn-secondary d-sm-none" | 40 | class="btn col-12 btn-secondary d-sm-none" |
41 | ng-show="cabecera.length > 0" | 41 | ng-show="cabecera.length > 0" |
42 | ng-click="showCabecera = !showCabecera" | 42 | ng-click="showCabecera = !showCabecera" |
43 | > | 43 | > |
44 | <i | 44 | <i |
45 | class="fa fa-chevron-down" | 45 | class="fa fa-chevron-down" |
46 | ng-hide="showCabecera" | 46 | ng-hide="showCabecera" |
47 | aria-hidden="true" | 47 | aria-hidden="true" |
48 | > | 48 | > |
49 | </i> | 49 | </i> |
50 | <i | 50 | <i |
51 | class="fa fa-chevron-up" | 51 | class="fa fa-chevron-up" |
52 | ng-show="showCabecera" | 52 | ng-show="showCabecera" |
53 | aria-hidden="true"> | 53 | aria-hidden="true"> |
54 | </i> | 54 | </i> |
55 | </a> | 55 | </a> |
56 | </div> | 56 | </div> |
57 | </div> | 57 | </div> |
58 | </div> | 58 | </div> |
59 | <div class="row p-1 botonera-secundaria"> | 59 | <div class="row p-1 botonera-secundaria"> |
60 | <div class="col-12"> | 60 | <div class="col-12"> |
61 | <div class="row"> | 61 | <div class="row"> |
62 | <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera"> | 62 | <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera"> |
63 | <button | 63 | <button |
64 | type="button" | 64 | type="button" |
65 | class="btn btn-default btn-block btn-xs text-left py-2" | 65 | class="btn btn-default btn-block btn-xs text-left py-2" |
66 | ng-click="boton.accion()" | 66 | ng-click="boton.accion()" |
67 | ng-class="{'d-none d-sm-block': boton.texto == ''}" | 67 | ng-class="{'d-none d-sm-block': boton.texto == ''}" |
68 | > | 68 | > |
69 | <i | 69 | <i |
70 | class="fa fa-arrow-circle-right" | 70 | class="fa fa-arrow-circle-right" |
71 | ng-show="boton.texto != ''" | 71 | ng-show="boton.texto != ''" |
72 | ></i> | 72 | ></i> |
73 | | 73 | |
74 | {{boton.texto}} | 74 | {{boton.texto}} |
75 | </button> | 75 | </button> |
76 | </div> | 76 | </div> |
77 | </div> | 77 | </div> |
78 | </div> | 78 | </div> |
79 | </div> | 79 | </div> |
80 | </div> | 80 | </div> |
81 | </div> | 81 | </div> |
82 | </form> | 82 | </form> |
83 | <div class="row"> | 83 | <div class="row"> |
84 | <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> | 84 | <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> |
85 | <!-- PC --> | 85 | <!-- PC --> |
86 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> | 86 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> |
87 | <table class="table tabla-articulo table-striped table-sm table-dark"> | 87 | <table class="table tabla-articulo table-striped table-sm table-dark"> |
88 | <thead> | 88 | <thead> |
89 | <tr class="d-flex"> | 89 | <tr class="d-flex"> |
90 | <th class="">#</th> | 90 | <th class="">#</th> |
91 | <th class="col">Código</th> | 91 | <th class="col">Código</th> |
92 | <th class="col-4">Descripción</th> | 92 | <th class="col-4">Descripción</th> |
93 | <th class="col text-right">Cantidad</th> | 93 | <th class="col text-right">Cantidad</th> |
94 | <th class="col text-right">Precio Unitario</th> | 94 | <th class="col text-right">Precio Unitario</th> |
95 | <th class="col text-right">SubTotal</th> | 95 | <th class="col text-right">SubTotal</th> |
96 | <th class="text-right"> | 96 | <th class="text-right"> |
97 | <button | 97 | <button |
98 | class="btn btn-outline-secondary selectable" | 98 | class="btn btn-outline-secondary selectable" |
99 | ng-click="show = !show; masMenos()" | 99 | ng-click="show = !show; masMenos()" |
100 | > | 100 | > |
101 | <i | 101 | <i |
102 | class="fa fa-chevron-down" | 102 | class="fa fa-chevron-down" |
103 | ng-show="show" | 103 | ng-show="show" |
104 | aria-hidden="true" | 104 | aria-hidden="true" |
105 | > | 105 | > |
106 | </i> | 106 | </i> |
107 | <i | 107 | <i |
108 | class="fa fa-chevron-up" | 108 | class="fa fa-chevron-up" |
109 | ng-hide="show" | 109 | ng-hide="show" |
110 | aria-hidden="true"> | 110 | aria-hidden="true"> |
111 | </i> | 111 | </i> |
112 | </button> | 112 | </button> |
113 | </th> | 113 | </th> |
114 | </tr> | 114 | </tr> |
115 | </thead> | 115 | </thead> |
116 | <tbody class="tabla-articulo-body"> | 116 | <tbody class="tabla-articulo-body"> |
117 | <tr | 117 | <tr |
118 | ng-repeat="(key, articulo) in articulosTabla" | 118 | ng-repeat="(key, articulo) in articulosTabla" |
119 | ng-show="show || key == (articulosTabla.length - 1)" | 119 | ng-show="show || key == (articulosTabla.length - 1)" |
120 | class="d-flex" | 120 | class="d-flex" |
121 | > | 121 | > |
122 | <td ng-bind="key + 1"></td> | 122 | <td ng-bind="key + 1"></td> |
123 | <td | 123 | <td |
124 | class="col" | 124 | class="col" |
125 | ng-bind="articulo.sector + '-' + articulo.codigo" | 125 | ng-bind="articulo.sector + '-' + articulo.codigo" |
126 | ></td> | 126 | ></td> |
127 | <td | 127 | <td |
128 | class="col-4" | 128 | class="col-4" |
129 | ng-bind="articulo.descripcion" | 129 | ng-bind="articulo.descripcion" |
130 | ></td> | 130 | ></td> |
131 | <td class="col text-right"> | 131 | <td class="col text-right"> |
132 | <input | 132 | <input |
133 | ng-show="articulo.editCantidad" | 133 | ng-show="articulo.editCantidad" |
134 | ng-model="articulo.cantidad" | 134 | ng-model="articulo.cantidad" |
135 | class="form-control" | 135 | class="form-control" |
136 | type="number" | 136 | type="number" |
137 | min="1" | 137 | min="1" |
138 | foca-focus="articulo.editCantidad" | 138 | foca-focus="articulo.editCantidad" |
139 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 139 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
140 | ng-focus="selectFocus($event)" | 140 | ng-focus="selectFocus($event)" |
141 | > | 141 | > |
142 | <i | 142 | <i |
143 | class="selectable" | 143 | class="selectable" |
144 | ng-click="cambioEdit(articulo, 'cantidad')" | 144 | ng-click="cambioEdit(articulo, 'cantidad')" |
145 | ng-hide="articulo.editCantidad" | 145 | ng-hide="articulo.editCantidad" |
146 | ng-bind="articulo.cantidad"> | 146 | ng-bind="articulo.cantidad"> |
147 | </i> | 147 | </i> |
148 | </td> | 148 | </td> |
149 | <td class="col text-right"> | 149 | <td class="col text-right"> |
150 | <input | 150 | <input |
151 | ng-show="articulo.editPrecio" | 151 | ng-show="articulo.editPrecio" |
152 | ng-model="articulo.precio" | 152 | ng-model="articulo.precio" |
153 | class="form-control" | 153 | class="form-control" |
154 | type="number" | 154 | type="number" |
155 | min="1" | 155 | min="1" |
156 | step="0.01" | 156 | step="0.01" |
157 | foca-focus="articulo.editPrecio" | 157 | foca-focus="articulo.editPrecio" |
158 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 158 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
159 | ng-focus="selectFocus($event)" | 159 | ng-focus="selectFocus($event)" |
160 | > | 160 | > |
161 | <i | 161 | <i |
162 | class="selectable" | 162 | class="selectable" |
163 | ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" | 163 | ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" |
164 | ng-hide="articulo.editPrecio" | 164 | ng-hide="articulo.editPrecio" |
165 | ng-bind="articulo.precio"> | 165 | ng-bind="articulo.precio | currency: '$'"> |
166 | </i> | 166 | </i> |
167 | </td> | 167 | </td> |
168 | <td | 168 | <td |
169 | class="col text-right" | 169 | class="col text-right" |
170 | ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'"> | 170 | ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'"> |
171 | </td> | 171 | </td> |
172 | <td class="text-center"> | 172 | <td class="text-center"> |
173 | <button | 173 | <button |
174 | class="btn btn-outline-secondary" | 174 | class="btn btn-outline-secondary" |
175 | ng-click="quitarArticulo(key)" | 175 | ng-click="quitarArticulo(key)" |
176 | > | 176 | > |
177 | <i class="fa fa-trash"></i> | 177 | <i class="fa fa-trash"></i> |
178 | </button> | 178 | </button> |
179 | </td> | 179 | </td> |
180 | </tr> | 180 | </tr> |
181 | </tbody> | 181 | </tbody> |
182 | <tfoot> | 182 | <tfoot> |
183 | <tr ng-show="!cargando" class="d-flex"> | 183 | <tr ng-show="!cargando" class="d-flex"> |
184 | <td | 184 | <td |
185 | class="align-middle" | 185 | class="align-middle" |
186 | ng-bind="articulosTabla.length + 1" | 186 | ng-bind="articulosTabla.length + 1" |
187 | ></td> | 187 | ></td> |
188 | <td class="col"> | 188 | <td class="col"> |
189 | <input | 189 | <input |
190 | class="form-control" | 190 | class="form-control" |
191 | ng-model="articuloACargar.sectorCodigo" | 191 | ng-model="articuloACargar.sectorCodigo" |
192 | readonly | 192 | readonly |
193 | > | 193 | > |
194 | </td> | 194 | </td> |
195 | <td class="col-4 tabla-articulo-descripcion"> | 195 | <td class="col-4 tabla-articulo-descripcion"> |
196 | <input | 196 | <input |
197 | class="form-control" | 197 | class="form-control" |
198 | ng-model="articuloACargar.descripcion" | 198 | ng-model="articuloACargar.descripcion" |
199 | readonly | 199 | readonly |
200 | > | 200 | > |
201 | </td> | 201 | </td> |
202 | <td class="col text-right"> | 202 | <td class="col text-right"> |
203 | <input | 203 | <input |
204 | class="form-control" | 204 | class="form-control" |
205 | type="number" | 205 | type="number" |
206 | min="1" | 206 | min="1" |
207 | ng-model="articuloACargar.cantidad" | 207 | ng-model="articuloACargar.cantidad" |
208 | foca-focus="!cargando" | 208 | foca-focus="!cargando" |
209 | esc-key="resetFilter()" | 209 | esc-key="resetFilter()" |
210 | ng-keypress="agregarATabla($event.keyCode)" | 210 | ng-keypress="agregarATabla($event.keyCode)" |
211 | > | 211 | > |
212 | </td> | 212 | </td> |
213 | <td class="col text-right"> | 213 | <td class="col text-right"> |
214 | <input | 214 | <input |
215 | class="form-control" | 215 | class="form-control" |
216 | ng-value="articuloACargar.precio | currency: '$'" | 216 | ng-value="articuloACargar.precio | currency: '$'" |
217 | ng-show="idLista != -1" | 217 | ng-show="idLista != -1" |
218 | readonly | 218 | readonly |
219 | > | 219 | > |
220 | <input | 220 | <input |
221 | class="form-control" | 221 | class="form-control" |
222 | type="number" | 222 | type="number" |
223 | step="0.01" | 223 | step="0.01" |
224 | ng-model="articuloACargar.precio" | 224 | ng-model="articuloACargar.precio" |
225 | esc-key="resetFilter()" | 225 | esc-key="resetFilter()" |
226 | ng-keypress="agregarATabla($event.keyCode)" | 226 | ng-keypress="agregarATabla($event.keyCode)" |
227 | ng-show="idLista == -1" | 227 | ng-show="idLista == -1" |
228 | > | 228 | > |
229 | </td> | 229 | </td> |
230 | <td class="col text-right"> | 230 | <td class="col text-right"> |
231 | <input | 231 | <input |
232 | class="form-control" | 232 | class="form-control" |
233 | ng-value="getSubTotal() | currency: '$'" | 233 | ng-value="getSubTotal() | currency: '$'" |
234 | readonly | 234 | readonly |
235 | ></td> | 235 | ></td> |
236 | <td class="text-center align-middle"> | 236 | <td class="text-center align-middle"> |
237 | <button | 237 | <button |
238 | class="btn btn-outline-secondary" | 238 | class="btn btn-outline-secondary" |
239 | ng-click="agregarATabla(13)" | 239 | ng-click="agregarATabla(13)" |
240 | > | 240 | > |
241 | <i class="fa fa-save"></i> | 241 | <i class="fa fa-save"></i> |
242 | </button> | 242 | </button> |
243 | </td> | 243 | </td> |
244 | </tr> | 244 | </tr> |
245 | <tr ng-show="cargando" class="d-flex"> | 245 | <tr ng-show="cargando" class="d-flex"> |
246 | <td colspan="7" class="col-12"> | 246 | <td colspan="7" class="col-12"> |
247 | <input | 247 | <input |
248 | placeholder="Seleccione Articulo" | 248 | placeholder="Seleccione Articulo" |
249 | class="form-control form-control-sm" | 249 | class="form-control form-control-sm" |
250 | readonly | 250 | readonly |
251 | ng-click="seleccionarArticulo()" | 251 | ng-click="seleccionarArticulo()" |
252 | /> | 252 | /> |
253 | </td> | 253 | </td> |
254 | </tr> | 254 | </tr> |
255 | <tr class="d-flex"> | 255 | <tr class="d-flex"> |
256 | <td colspan="4" class="no-border-top"> | 256 | <td colspan="4" class="no-border-top"> |
257 | <strong>Cantidad Items:</strong> | 257 | <strong>Items:</strong> |
258 | <a ng-bind="articulosTabla.length"></a> | 258 | <a ng-bind="articulosTabla.length"></a> |
259 | </td> | 259 | </td> |
260 | <td class="text-right ml-auto table-celda-total no-border-top"> | 260 | <td class="text-right ml-auto table-celda-total no-border-top"> |
261 | <h3>Total:</h3> | 261 | <h3>Total:</h3> |
262 | </td> | 262 | </td> |
263 | <td class="table-celda-total text-right no-border-top" colspan="1"> | 263 | <td class="table-celda-total text-right no-border-top" colspan="1"> |
264 | <h3>{{getTotal() | currency: '$'}}</h3> | 264 | <h3>{{getTotal() | currency: '$'}}</h3> |
265 | </td> | 265 | </td> |
266 | <td class="text-right no-border-top"> | 266 | <td class="text-right no-border-top"> |
267 | <button | 267 | <button |
268 | type="button" | 268 | type="button" |
269 | class="btn btn-default btn-sm" | 269 | class="btn btn-default btn-sm" |
270 | > | 270 | > |
271 | Totales | 271 | Totales |
272 | </button> | 272 | </button> |
273 | </td> | 273 | </td> |
274 | </tr> | 274 | </tr> |
275 | </tfoot> | 275 | </tfoot> |
276 | </table> | 276 | </table> |
277 | </div> | 277 | </div> |
278 | 278 | ||
279 | <!-- MOBILE --> | 279 | <!-- MOBILE --> |
280 | <div class="row d-sm-none"> | 280 | <div class="row d-sm-none"> |
281 | <table class="table table-sm table-striped table-dark margin-bottom-mobile"> | 281 | <table class="table table-sm table-striped table-dark margin-bottom-mobile"> |
282 | <thead> | 282 | <thead> |
283 | <tr class="d-flex"> | 283 | <tr class="d-flex"> |
284 | <th class="">#</th> | 284 | <th class="">#</th> |
285 | <th class="col px-0"> | 285 | <th class="col px-0"> |
286 | <div class="d-flex"> | 286 | <div class="d-flex"> |
287 | <div class="col-4 px-1">Código</div> | 287 | <div class="col-4 px-1">Código</div> |
288 | <div class="col-8 px-1">Descripción</div> | 288 | <div class="col-8 px-1">Descripción</div> |
289 | </div> | 289 | </div> |
290 | <div class="d-flex"> | 290 | <div class="d-flex"> |
291 | <div class="col-3 px-1">Cantidad</div> | 291 | <div class="col-3 px-1">Cantidad</div> |
292 | <div class="col px-1 text-right">P. Uni.</div> | 292 | <div class="col px-1 text-right">P. Uni.</div> |
293 | <div class="col px-1 text-right">Subtotal</div> | 293 | <div class="col px-1 text-right">Subtotal</div> |
294 | </div> | 294 | </div> |
295 | </th> | 295 | </th> |
296 | <th class="text-center tamaño-boton"> | 296 | <th class="text-center tamaño-boton"> |
297 | | 297 | |
298 | </th> | 298 | </th> |
299 | </tr> | 299 | </tr> |
300 | </thead> | 300 | </thead> |
301 | <tbody> | 301 | <tbody> |
302 | <tr | 302 | <tr |
303 | ng-repeat="(key, articulo) in articulosTabla" | 303 | ng-repeat="(key, articulo) in articulosTabla" |
304 | ng-show="show || key == articulosTabla.length - 1" | 304 | ng-show="show || key == articulosTabla.length - 1" |
305 | > | 305 | > |
306 | <td class="w-100 align-middle d-flex p-0"> | 306 | <td class="w-100 align-middle d-flex p-0"> |
307 | <div class="align-middle p-1"> | 307 | <div class="align-middle p-1"> |
308 | <span ng-bind="key+1" class="align-middle"></span> | 308 | <span ng-bind="key+1" class="align-middle"></span> |
309 | </div> | 309 | </div> |
310 | <div class="col px-0"> | 310 | <div class="col px-0"> |
311 | <div class="d-flex"> | 311 | <div class="d-flex"> |
312 | <div class="col-4 px-1"> | 312 | <div class="col-4 px-1"> |
313 | <span | 313 | <span |
314 | ng-bind="articulo.sector + '-' + articulo.codigo" | 314 | ng-bind="articulo.sector + '-' + articulo.codigo" |
315 | ></span> | 315 | ></span> |
316 | </div> | 316 | </div> |
317 | <div class="col-8 px-1"> | 317 | <div class="col-8 px-1"> |
318 | <span ng-bind="articulo.descripcion"></span> | 318 | <span ng-bind="articulo.descripcion"></span> |
319 | </div> | 319 | </div> |
320 | </div> | 320 | </div> |
321 | <div class="d-flex"> | 321 | <div class="d-flex"> |
322 | <div class="col-3 px-1"> | 322 | <div class="col-3 px-1"> |
323 | <span ng-bind="'x' + articulo.cantidad"></span> | 323 | <span ng-bind="'x' + articulo.cantidad"></span> |
324 | </div> | 324 | </div> |
325 | <div class="col-3 px-1 text-right"> | 325 | <div class="col-3 px-1 text-right"> |
326 | <span ng-bind="articulo.precio | currency: '$'"></span> | 326 | <span ng-bind="articulo.precio | currency: '$'"></span> |
327 | </div> | 327 | </div> |
328 | <div class="col px-1 text-right"> | 328 | <div class="col px-1 text-right"> |
329 | <span | 329 | <span |
330 | ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'" | 330 | ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'" |
331 | > | 331 | > |
332 | </span> | 332 | </span> |
333 | </div> | 333 | </div> |
334 | </div> | 334 | </div> |
335 | </div> | 335 | </div> |
336 | <div class="align-middle p-1"> | 336 | <div class="align-middle p-1"> |
337 | <button | 337 | <button |
338 | class="btn btn-outline-secondary" | 338 | class="btn btn-outline-secondary" |
339 | ng-click="quitarArticulo(key)" | 339 | ng-click="quitarArticulo(key)" |
340 | > | 340 | > |
341 | <i class="fa fa-trash"></i> | 341 | <i class="fa fa-trash"></i> |
342 | </button> | 342 | </button> |
343 | </div> | 343 | </div> |
344 | </td> | 344 | </td> |
345 | </tr> | 345 | </tr> |
346 | </tbody> | 346 | </tbody> |
347 | <tfoot> | 347 | <tfoot> |
348 | <!-- CARGANDO ITEM --> | 348 | <!-- CARGANDO ITEM --> |
349 | <tr ng-show="!cargando" class="d-flex"> | 349 | <tr ng-show="!cargando" class="d-flex"> |
350 | <td | 350 | <td |
351 | class="align-middle p-1" | 351 | class="align-middle p-1" |
352 | ng-bind="articulosTabla.length + 1" | 352 | ng-bind="articulosTabla.length + 1" |
353 | ></td> | 353 | ></td> |
354 | <td class="col p-0"> | 354 | <td class="col p-0"> |
355 | <div class="d-flex"> | 355 | <div class="d-flex"> |
356 | <div class="col-4 px-1"> | 356 | <div class="col-4 px-1"> |
357 | <span | 357 | <span |
358 | ng-bind="articuloACargar.sectorCodigo" | 358 | ng-bind="articuloACargar.sectorCodigo" |
359 | ></span> | 359 | ></span> |
360 | </div> | 360 | </div> |
361 | <div class="col-8 px-1"> | 361 | <div class="col-8 px-1"> |
362 | <span ng-bind="articuloACargar.descripcion"></span> | 362 | <span ng-bind="articuloACargar.descripcion"></span> |
363 | </div> | 363 | </div> |
364 | </div> | 364 | </div> |
365 | <div class="d-flex"> | 365 | <div class="d-flex"> |
366 | <div class="col-3 px-1 m-1"> | 366 | <div class="col-3 px-1 m-1"> |
367 | <input | 367 | <input |
368 | class="form-control p-1" | 368 | class="form-control p-1" |
369 | type="number" | 369 | type="number" |
370 | min="1" | 370 | min="1" |
371 | ng-model="articuloACargar.cantidad" | 371 | ng-model="articuloACargar.cantidad" |
372 | foca-focus="!cargando" | 372 | foca-focus="!cargando" |
373 | ng-keypress="agregarATabla($event.keyCode)" | 373 | ng-keypress="agregarATabla($event.keyCode)" |
374 | style="height: auto; line-height: 1.1em" | 374 | style="height: auto; line-height: 1.1em" |
375 | > | 375 | > |
376 | </div> | 376 | </div> |
377 | <div class="col-3 px-1 text-right"> | 377 | <div class="col-3 px-1 text-right"> |
378 | <span ng-bind="articuloACargar.precio | currency: '$'"></span> | 378 | <span ng-bind="articuloACargar.precio | currency: '$'"></span> |
379 | </div> | 379 | </div> |
380 | <div class="col px-1 text-right"> | 380 | <div class="col px-1 text-right"> |
381 | <span | 381 | <span |
382 | ng-bind="getSubTotal() | currency: '$'" | 382 | ng-bind="getSubTotal() | currency: '$'" |
383 | > | 383 | > |
384 | </span> | 384 | </span> |
385 | </div> | 385 | </div> |
386 | </div> | 386 | </div> |
387 | </td> | 387 | </td> |
388 | <td class="text-center align-middle"> | 388 | <td class="text-center align-middle"> |
389 | <button | 389 | <button |
390 | class="btn btn-outline-secondary" | 390 | class="btn btn-outline-secondary" |
391 | ng-click="agregarATabla(13)" | 391 | ng-click="agregarATabla(13)" |
392 | > | 392 | > |
393 | <i class="fa fa-save"></i> | 393 | <i class="fa fa-save"></i> |
394 | </button> | 394 | </button> |
395 | </td> | 395 | </td> |
396 | </tr> | 396 | </tr> |
397 | <!-- SELECCIONAR PRODUCTO --> | 397 | <!-- SELECCIONAR PRODUCTO --> |
398 | <tr ng-show="cargando" class="d-flex"> | 398 | <tr ng-show="cargando" class="d-flex"> |
399 | <td class="col-12"> | 399 | <td class="col-12"> |
400 | <input | 400 | <input |
401 | placeholder="Seleccione Articulo" | 401 | placeholder="Seleccione Articulo" |
402 | class="form-control form-control-sm" | 402 | class="form-control form-control-sm" |
403 | readonly | 403 | readonly |
404 | ng-click="seleccionarArticulo()" | 404 | ng-click="seleccionarArticulo()" |
405 | /> | 405 | /> |
406 | </td> | 406 | </td> |
407 | </tr> | 407 | </tr> |
408 | <!-- TOOGLE EXPANDIR --> | 408 | <!-- TOOGLE EXPANDIR --> |
409 | <tr> | 409 | <tr> |
410 | <td class="col"> | 410 | <td class="col"> |
411 | <button | 411 | <button |
412 | class="btn btn-outline-secondary selectable w-100" | 412 | class="btn btn-outline-secondary selectable w-100" |
413 | ng-click="show = !show; masMenos()" | 413 | ng-click="show = !show; masMenos()" |
414 | ng-show="articulosTabla.length > 0" | 414 | ng-show="articulosTabla.length > 0" |
415 | > | 415 | > |
416 | <i | 416 | <i |
417 | class="fa fa-chevron-down" | 417 | class="fa fa-chevron-down" |
418 | ng-hide="show" | 418 | ng-hide="show" |
419 | aria-hidden="true" | 419 | aria-hidden="true" |
420 | > | 420 | > |
421 | </i> | 421 | </i> |
422 | <i | 422 | <i |
423 | class="fa fa-chevron-up" | 423 | class="fa fa-chevron-up" |
424 | ng-show="show" | 424 | ng-show="show" |
425 | aria-hidden="true"> | 425 | aria-hidden="true"> |
426 | </i> | 426 | </i> |
427 | </button> | 427 | </button> |
428 | </td> | 428 | </td> |
429 | </tr> | 429 | </tr> |
430 | <!-- FOOTER --> | 430 | <!-- FOOTER --> |
431 | <tr class="d-flex"> | 431 | <tr class="d-flex"> |
432 | <td class="align-middle no-border-top" colspan="2"> | 432 | <td class="align-middle no-border-top" colspan="2"> |
433 | <strong>Cantidad Items:</strong> | 433 | <strong>Cantidad Items:</strong> |
434 | <a ng-bind="articulosTabla.length"></a> | 434 | <a ng-bind="articulosTabla.length"></a> |
435 | </td> | 435 | </td> |
436 | <td class="text-right ml-auto table-celda-total no-border-top"> | 436 | <td class="text-right ml-auto table-celda-total no-border-top"> |
437 | <h3>Total:</h3> | 437 | <h3>Total:</h3> |
438 | </td> | 438 | </td> |
439 | <td class="table-celda-total text-right no-border-top"> | 439 | <td class="table-celda-total text-right no-border-top"> |
440 | <h3>{{getTotal() | currency: '$'}}</h3> | 440 | <h3>{{getTotal() | currency: '$'}}</h3> |
441 | </td> | 441 | </td> |
442 | </tr> | 442 | </tr> |
443 | </tfoot> | 443 | </tfoot> |
444 | </table> | 444 | </table> |
445 | </div> | 445 | </div> |
446 | </div> | 446 | </div> |
447 | <div class="col-auto my-2 col-lg-2 botonera-lateral d-none d-md-block"> | 447 | <div class="col-auto my-2 col-lg-2 botonera-lateral d-none d-md-block"> |
448 | <div class="row align-items-end"> | 448 | <div class="row align-items-end"> |
449 | <div class="col-12"> | 449 | <div class="col-12"> |
450 | <button | 450 | <button |
451 | ng-click="crearNotaPedido()" | 451 | ng-click="crearNotaPedido()" |
452 | type="submit" | 452 | type="submit" |
453 | title="Crear nota pedido" | 453 | title="Crear nota pedido" |
454 | class="btn btn-default btn-block mb-2"> | 454 | class="btn btn-default btn-block mb-2"> |
455 | Guardar | 455 | Guardar |
456 | </button> | 456 | </button> |
457 | <button | 457 | <button |
458 | ng-click="salir()" | 458 | ng-click="salir()" |
459 | type="button" | 459 | type="button" |
460 | title="Salir" | 460 | title="Salir" |
461 | class="btn btn-default btn-block"> | 461 | class="btn btn-default btn-block"> |
462 | Salir | 462 | Salir |
463 | </button> | 463 | </button> |
464 | </div> | 464 | </div> |
465 | </div> | 465 | </div> |
466 | </div> | 466 | </div> |
467 | </div> | 467 | </div> |
468 | <div class="row d-md-none fixed-bottom"> | 468 | <div class="row d-md-none fixed-bottom"> |
469 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> | 469 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> |
470 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> | 470 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> |
471 | <span class="mr-3 ml-auto" ng-click="crearNotaPedido()">Guardar</span> | 471 | <span class="mr-3 ml-auto" ng-click="crearNotaPedido()">Guardar</span> |
472 | </div> | 472 | </div> |
473 | </div> | 473 | </div> |
474 | </div> | 474 | </div> |
475 | 475 |