Commit 71d49b911642941668dfb6d1cc463a8b10412e1d

Authored by Jose Pinto
Exists in master

Merge remote-tracking branch 'upstream/develop'

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