Commit 77ac48e5dd6f5002a69d0d5e6433c3fa1f057ecc

Authored by Eric Fernandez
Exists in master and in 1 other branch develop

Merge branch 'develop' into 'master'

Develop

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