Commit be0c90f0211b0c04817eba730756f4eccca33167

Authored by Eric Fernandez
Exists in master

Merge branch 'develop' into 'master'

Develop

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