Commit 97cd35be9ae79e3c3e5f5a913b3782a45bbd2640

Authored by Marcelo
Exists in master

Merge branch 'develop' of git.focasoftware.com:npm/foca-crear-nota-pedido

1 const templateCache = require('gulp-angular-templatecache'); 1 const templateCache = require('gulp-angular-templatecache');
2 const clean = require('gulp-clean'); 2 const clean = require('gulp-clean');
3 const concat = require('gulp-concat'); 3 const concat = require('gulp-concat');
4 const htmlmin = require('gulp-htmlmin'); 4 const htmlmin = require('gulp-htmlmin');
5 const rename = require('gulp-rename'); 5 const rename = require('gulp-rename');
6 const uglify = require('gulp-uglify'); 6 const uglify = require('gulp-uglify');
7 const gulp = require('gulp'); 7 const gulp = require('gulp');
8 const pump = require('pump'); 8 const pump = require('pump');
9 const jshint = require('gulp-jshint'); 9 const jshint = require('gulp-jshint');
10 const replace = require('gulp-replace'); 10 const replace = require('gulp-replace');
11 const connect = require('gulp-connect'); 11 const connect = require('gulp-connect');
12 const header = require('gulp-header'); 12 const header = require('gulp-header');
13 const footer = require('gulp-footer'); 13 const footer = require('gulp-footer');
14 const gulpSequence = require('gulp-sequence'); 14 const gulpSequence = require('gulp-sequence');
15 15
16 var paths = { 16 var paths = {
17 srcJS: 'src/js/*.js', 17 srcJS: 'src/js/*.js',
18 srcViews: 'src/views/*.html', 18 srcViews: 'src/views/*.html',
19 specs: 'spec/*.js', 19 specs: 'spec/*.js',
20 tmp: 'tmp', 20 tmp: 'tmp',
21 dist: 'dist/' 21 dist: 'dist/'
22 }; 22 };
23 23
24 gulp.task('uglify', gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')); 24 gulp.task('uglify', function(callback) {
25 gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')(callback);
26 });
25 27
26 gulp.task('templates', function() { 28 gulp.task('templates', function() {
27 return pump( 29 return pump(
28 [ 30 [
29 gulp.src(paths.srcViews), 31 gulp.src(paths.srcViews),
30 htmlmin(), 32 htmlmin(),
31 templateCache('views.js', { 33 templateCache('views.js', {
32 module: 'focaCrearNotaPedido', 34 module: 'focaCrearNotaPedido',
33 root: '' 35 root: ''
34 }), 36 }),
35 gulp.dest(paths.tmp) 37 gulp.dest(paths.tmp)
36 ] 38 ]
37 ); 39 );
38 }); 40 });
39 41
40 gulp.task('uglify-app', function() { 42 gulp.task('uglify-app', function() {
41 return pump( 43 return pump(
42 [ 44 [
43 gulp.src([ 45 gulp.src([
44 paths.srcJS, 46 paths.srcJS,
45 'tmp/views.js' 47 'tmp/views.js'
46 ]), 48 ]),
47 concat('foca-crear-nota-pedido.js'), 49 concat('foca-crear-nota-pedido.js'),
48 replace('src/views/', ''), 50 replace('src/views/', ''),
49 gulp.dest(paths.tmp), 51 gulp.dest(paths.tmp),
50 rename('foca-crear-nota-pedido.min.js'), 52 rename('foca-crear-nota-pedido.min.js'),
51 uglify(), 53 uglify(),
52 gulp.dest(paths.dist) 54 gulp.dest(paths.dist)
53 ] 55 ]
54 ); 56 );
55 }); 57 });
56 58
57 gulp.task('uglify-spec', function() { 59 gulp.task('uglify-spec', function() {
58 return pump([ 60 return pump([
59 gulp.src(paths.specs), 61 gulp.src(paths.specs),
60 concat('foca-crear-nota-pedido.spec.js'), 62 concat('foca-crear-nota-pedido.spec.js'),
61 replace("src/views/", ''), 63 replace("src/views/", ''),
62 header("describe('Módulo foca-crear-nota-pedido', function() { \n"), 64 header("describe('Módulo foca-crear-nota-pedido', function() { \n"),
63 footer("});"), 65 footer("});"),
64 gulp.dest(paths.dist) 66 gulp.dest(paths.dist)
65 ]); 67 ]);
66 }); 68 });
67 69
68 gulp.task('clean', function() { 70 gulp.task('clean', function() {
69 return gulp.src(['tmp', 'dist'], {read: false}) 71 return gulp.src(['tmp', 'dist'], {read: false})
70 .pipe(clean()); 72 .pipe(clean());
71 }); 73 });
72 74
73 gulp.task('pre-commit', function() { 75 gulp.task('pre-commit', function() {
74 return pump( 76 return pump(
75 [ 77 [
76 gulp.src([paths.srcJS, paths.specs]), 78 gulp.src([paths.srcJS, paths.specs]),
77 jshint('.jshintrc'), 79 jshint('.jshintrc'),
78 jshint.reporter('default'), 80 jshint.reporter('default'),
79 jshint.reporter('fail') 81 jshint.reporter('fail')
80 ] 82 ]
81 ); 83 );
82 84
83 gulp.start('uglify'); 85 gulp.start('uglify');
84 }); 86 });
85 87
86 gulp.task('webserver', function() { 88 gulp.task('webserver', function() {
87 pump [ 89 pump [
88 connect.server({port: 3300, host: '0.0.0.0'}) 90 connect.server({port: 3300, host: '0.0.0.0'})
89 ] 91 ]
90 }); 92 });
91 93
92 gulp.task('clean-post-install', function() { 94 gulp.task('clean-post-install', function() {
93 return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', 95 return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js',
94 'index.html', 'test.html', 'spec'], {read: false}) 96 'index.html', 'test.html', 'spec'], {read: false})
95 .pipe(clean()); 97 .pipe(clean());
96 }); 98 });
97 99
98 gulp.task('default', ['webserver']); 100 gulp.task('default', ['webserver']);
99 101
100 gulp.task('watch', function() { 102 gulp.task('watch', function() {
101 gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); 103 gulp.watch([paths.srcJS, paths.srcViews], ['uglify']);
102 }); 104 });
103 105
104 gulp.task('copy', ['uglify'], function() { 106 gulp.task('copy', ['uglify'], function() {
105 return gulp.src('dist/*.js') 107 return gulp.src('dist/*.js')
106 .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-crear-nota-pedido/dist/')); 108 .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-crear-nota-pedido/dist/'));
107 }); 109 });
108 110
109 gulp.task('watchAndCopy', function() { 111 gulp.task('watchAndCopy', function() {
110 return gulp.watch([paths.srcJS], ['copy']); 112 return gulp.watch([paths.srcJS], ['copy']);
111 }); 113 });
112 114
spec/controllerSpec.js
1 describe('Controladores módulo crear nota de pedido', function() { 1 describe('Controladores módulo crear nota de pedido', function() {
2 2
3 var $controler; 3 var $controler;
4 4
5 beforeEach(function() { 5 beforeEach(function() {
6 module('focaCrearNotaPedido'); 6 module('focaCrearNotaPedido');
7 inject(function(_$controller_) { 7 inject(function(_$controller_) {
8 $controler = _$controller_; 8 $controler = _$controller_;
9 }); 9 });
10 }); 10 });
11 11
12 describe('Controlador notaPedidoCtrl', function() { 12 describe('Controlador notaPedidoCtrl', function() {
13 13
14 var filter = function() { 14 var filter = function() {
15 return function() { }; 15 return function() { };
16 }; 16 };
17 var timeout; 17 var timeout;
18 18
19 beforeEach(function() { 19 beforeEach(function() {
20 20
21 inject(function($timeout) { 21 inject(function($timeout) {
22 timeout = $timeout; 22 timeout = $timeout;
23 }); 23 });
24 }); 24 });
25 25
26 it('La función seleccionarNotaPedido levanta modal', function() { 26 it('La función seleccionarNotaPedido levanta modal', function() {
27 //arrange 27 //arrange
28 var scope = { 28 var scope = {
29 $watch: function() { }, 29 $watch: function() { },
30 $broadcast: function() { } 30 $broadcast: function() { }
31 }; 31 };
32 var uibModal = { 32 var uibModal = {
33 open: function() { } 33 open: function() { }
34 }; 34 };
35 35
36 $controler('notaPedidoCtrl', { 36 $controler('notaPedidoCtrl', {
37 $scope: scope, 37 $scope: scope,
38 $uibModal: uibModal, 38 $uibModal: uibModal,
39 $location: {}, 39 $location: {},
40 $filter: filter, 40 $filter: filter,
41 $timeout: timeout, 41 $timeout: timeout,
42 crearNotaPedidoService: { 42 crearNotaPedidoService: {
43 getNumeroNotaPedido: function() { 43 getNumeroNotaPedido: function() {
44 return { 44 return {
45 then: function() { } 45 then: function() { }
46 }; 46 };
47 }, 47 },
48 getBotonera: function() { }, 48 getBotonera: function() { },
49 getCotizacionByIdMoneda: function() { 49 getCotizacionByIdMoneda: function() {
50 return { 50 return {
51 then: function() { } 51 then: function() { }
52 }; 52 };
53 } 53 }
54 }, 54 },
55 focaBotoneraLateralService: {}, 55 focaBotoneraLateralService: {},
56 focaModalService: {}, 56 focaModalService: {},
57 notaPedidoBusinessService: {}, 57 notaPedidoBusinessService: {},
58 $rootScope: { 58 $rootScope: {
59 $on: function() { } 59 $on: function() { }
60 }, 60 },
61 focaSeguimientoService: {}, 61 focaSeguimientoService: {},
62 APP: {}, 62 APP: {},
63 focaLoginService: {}, 63 focaLoginService: {},
64 $localStorage: {} 64 $localStorage: {}
65 }); 65 });
66 var respuesta = { result: { then: function() { } } }; 66 var respuesta = { result: { then: function() { } } };
67 67
68 //act 68 //act
69 spyOn(uibModal, 'open').and.returnValue(respuesta); 69 spyOn(uibModal, 'open').and.returnValue(respuesta);
70 scope.seleccionarNotaPedido(); 70 scope.seleccionarNotaPedido();
71 71
72 //assert 72 //assert
73 expect(uibModal.open).toHaveBeenCalled(); 73 expect(uibModal.open).toHaveBeenCalled();
74 }); 74 });
75 75
76 it('La función seleccionarNotaPedido llama a broadCast en promesa', function(done) { 76 it('La función seleccionarNotaPedido llama a broadCast en promesa', function(done) {
77 //arrange 77 //arrange
78 var scope = { 78 var scope = {
79 $watch: function() { }, 79 $watch: function() { },
80 $broadcast: function() { } 80 $broadcast: function() { }
81 }; 81 };
82 var uibModal = { 82 var uibModal = {
83 open: function() { } 83 open: function() { }
84 }; 84 };
85 85
86 $controler('notaPedidoCtrl', { 86 $controler('notaPedidoCtrl', {
87 $scope: scope, 87 $scope: scope,
88 $uibModal: uibModal, 88 $uibModal: uibModal,
89 $location: {}, 89 $location: {},
90 $filter: filter, 90 $filter: filter,
91 $timeout: timeout, 91 $timeout: timeout,
92 crearNotaPedidoService: { 92 crearNotaPedidoService: {
93 getNumeroNotaPedido: function() { 93 getNumeroNotaPedido: function() {
94 return { 94 return {
95 then: function() { } 95 then: function() { }
96 }; 96 };
97 }, 97 },
98 getBotonera: function() { }, 98 getBotonera: function() { },
99 getCotizacionByIdMoneda: function() { 99 getCotizacionByIdMoneda: function() {
100 return { 100 return {
101 then: function() { } 101 then: function() { }
102 }; 102 };
103 } 103 }
104 }, 104 },
105 focaBotoneraLateralService: {}, 105 focaBotoneraLateralService: {},
106 focaModalService: {}, 106 focaModalService: {},
107 notaPedidoBusinessService: { 107 notaPedidoBusinessService: {
108 plazoToString: function() { }, 108 plazoToString: function() { },
109 calcularArticulos: function() { } 109 calcularArticulos: function() { }
110 }, 110 },
111 $rootScope: { 111 $rootScope: {
112 $on: function() { } 112 $on: function() { }
113 }, 113 },
114 focaSeguimientoService: {}, 114 focaSeguimientoService: {},
115 APP: {}, 115 APP: {},
116 focaLoginService: {}, 116 focaLoginService: {},
117 $localStorage: {} 117 $localStorage: {}
118 }); 118 });
119 var notaPedido = { 119 var notaPedido = {
120 cotizacion: { 120 cotizacion: {
121 moneda: {} 121 moneda: {}
122 }, 122 },
123 cliente: {}, 123 cliente: {},
124 vendedor: {}, 124 vendedor: {},
125 proveedor: {}, 125 proveedor: {},
126 notaPedidoPlazo: [], 126 notaPedidoPlazo: [],
127 notaPedidoPuntoDescarga: [] 127 notaPedidoPuntoDescarga: []
128 }; 128 };
129 var respuesta = { result: Promise.resolve(notaPedido) }; 129 var respuesta = { result: Promise.resolve(notaPedido) };
130 130
131 //act 131 //act
132 scope.notaPedido = {}; 132 scope.notaPedido = {};
133 scope.$broadcast = function() { }; 133 scope.$broadcast = function() { };
134 spyOn(uibModal, 'open').and.returnValue(respuesta); 134 spyOn(uibModal, 'open').and.returnValue(respuesta);
135 spyOn(scope, '$broadcast'); 135 spyOn(scope, '$broadcast');
136 scope.seleccionarNotaPedido(); 136 scope.seleccionarNotaPedido();
137 137
138 //assert 138 //assert
139 respuesta.result.then(function() { 139 respuesta.result.then(function() {
140 expect(scope.$broadcast).toHaveBeenCalledWith('removeCabecera', 'Bomba:'); 140 expect(scope.$broadcast).toHaveBeenCalledWith('removeCabecera', 'Bomba:');
141 expect(scope.$broadcast).toHaveBeenCalledWith('removeCabecera', 'Kilometros:'); 141 expect(scope.$broadcast).toHaveBeenCalledWith('removeCabecera', 'Kilometros:');
142 done(); 142 done();
143 }); 143 });
144 }); 144 });
145 145
146 it('función seleccionarProductos muestra alerta cuando idLista undefined', function() { 146 it('función seleccionarProductos muestra alerta cuando idLista undefined', function() {
147 //arrange 147 //arrange
148 var scope = { 148 var scope = {
149 $watch: function() { }, 149 $watch: function() { },
150 $broadcast: function() { } 150 $broadcast: function() { }
151 }; 151 };
152 var focaModalService = { 152 var focaModalService = {
153 alert: function() { } 153 alert: function() { }
154 }; 154 };
155 155
156 $controler('notaPedidoCtrl', { 156 $controler('notaPedidoCtrl', {
157 $scope: scope, 157 $scope: scope,
158 $uibModal: {}, 158 $uibModal: {},
159 $location: {}, 159 $location: {},
160 $filter: filter, 160 $filter: filter,
161 $timeout: timeout, 161 $timeout: timeout,
162 crearNotaPedidoService: { 162 crearNotaPedidoService: {
163 getNumeroNotaPedido: function() { 163 getNumeroNotaPedido: function() {
164 return { 164 return {
165 then: function() { } 165 then: function() { }
166 }; 166 };
167 }, 167 },
168 getBotonera: function() { }, 168 getBotonera: function() { },
169 getCotizacionByIdMoneda: function() { 169 getCotizacionByIdMoneda: function() {
170 return { 170 return {
171 then: function() { } 171 then: function() { }
172 }; 172 };
173 } 173 }
174 }, 174 },
175 focaBotoneraLateralService: {}, 175 focaBotoneraLateralService: {},
176 focaModalService: focaModalService, 176 focaModalService: focaModalService,
177 notaPedidoBusinessService: {}, 177 notaPedidoBusinessService: {},
178 $rootScope: { 178 $rootScope: {
179 $on: function() { } 179 $on: function() { }
180 }, 180 },
181 focaSeguimientoService: {}, 181 focaSeguimientoService: {},
182 APP: {}, 182 APP: {},
183 focaLoginService: {}, 183 focaLoginService: {},
184 $localStorage: {} 184 $localStorage: {}
185 }); 185 });
186 186
187 //act 187 //act
188 spyOn(focaModalService, 'alert'); 188 spyOn(focaModalService, 'alert');
189 scope.idLista = undefined; 189 scope.idLista = undefined;
190 scope.seleccionarProductos(); 190 scope.seleccionarProductos();
191 191
192 //assert 192 //assert
193 expect(focaModalService.alert) 193 expect(focaModalService.alert)
194 .toHaveBeenCalledWith('Primero seleccione una lista de precio y condicion'); 194 .toHaveBeenCalledWith('Primero seleccione una lista de precio y condicion');
195 }); 195 });
196 196
197 it('función seleccionarProductos abre modal', function() { 197 it('función seleccionarProductos abre modal', function() {
198 //arrange 198 //arrange
199 var scope = { 199 var scope = {
200 $watch: function() { }, 200 $watch: function() { },
201 $broadcast: function() { } 201 $broadcast: function() { }
202 }; 202 };
203 var uibModal = { 203 var uibModal = {
204 open: function() { } 204 open: function() { }
205 }; 205 };
206 206
207 $controler('notaPedidoCtrl', { 207 $controler('notaPedidoCtrl', {
208 $scope: scope, 208 $scope: scope,
209 $uibModal: uibModal, 209 $uibModal: uibModal,
210 $location: {}, 210 $location: {},
211 $filter: filter, 211 $filter: filter,
212 $timeout: timeout, 212 $timeout: timeout,
213 crearNotaPedidoService: { 213 crearNotaPedidoService: {
214 getNumeroNotaPedido: function() { 214 getNumeroNotaPedido: function() {
215 return { 215 return {
216 then: function() { } 216 then: function() { }
217 }; 217 };
218 }, 218 },
219 getBotonera: function() { }, 219 getBotonera: function() { },
220 getCotizacionByIdMoneda: function() { 220 getCotizacionByIdMoneda: function() {
221 return { 221 return {
222 then: function() { } 222 then: function() { }
223 }; 223 };
224 } 224 }
225 }, 225 },
226 focaBotoneraLateralService: {}, 226 focaBotoneraLateralService: {},
227 focaModalService: {}, 227 focaModalService: {},
228 notaPedidoBusinessService: {}, 228 notaPedidoBusinessService: {},
229 $rootScope: { 229 $rootScope: {
230 $on: function() { } 230 $on: function() { }
231 }, 231 },
232 focaSeguimientoService: {}, 232 focaSeguimientoService: {},
233 APP: {}, 233 APP: {},
234 focaLoginService: {}, 234 focaLoginService: {},
235 $localStorage: {} 235 $localStorage: {}
236 }); 236 });
237 scope.idLista = true; 237 scope.idLista = true;
238 scope.notaPedido = { 238 scope.notaPedido = {
239 cotizacion: { 239 cotizacion: {
240 moneda: {} 240 moneda: {}
241 }, 241 },
242 242
243 }; 243 };
244 var respuesta = { result: {then: function() { } } }; 244 var respuesta = { result: {then: function() { } } };
245 245
246 //act 246 //act
247 spyOn(uibModal, 'open').and.returnValue(respuesta); 247 spyOn(uibModal, 'open').and.returnValue(respuesta);
248 scope.seleccionarProductos(); 248 scope.seleccionarProductos();
249 249
250 //assert 250 //assert
251 expect(uibModal.open).toHaveBeenCalled(); 251 expect(uibModal.open).toHaveBeenCalled();
252 }); 252 });
253 253
254 it('función seleccionarPuntosDeDescarga muestra alerta cuando cliente y domicilio son' + 254 it('función seleccionarPuntosDeDescarga muestra alerta cuando cliente y domicilio son' +
255 'undefined', function() 255 'undefined', function()
256 { 256 {
257 //arrange 257 //arrange
258 var scope = { 258 var scope = {
259 $watch: function() { }, 259 $watch: function() { },
260 $broadcast: function() { } 260 $broadcast: function() { }
261 }; 261 };
262 var focaModalService = { 262 var focaModalService = {
263 alert: function() { } 263 alert: function() { }
264 }; 264 };
265 265
266 $controler('notaPedidoCtrl', { 266 $controler('notaPedidoCtrl', {
267 $scope: scope, 267 $scope: scope,
268 $uibModal: {}, 268 $uibModal: {},
269 $location: {}, 269 $location: {},
270 $filter: filter, 270 $filter: filter,
271 $timeout: timeout, 271 $timeout: timeout,
272 crearNotaPedidoService: { 272 crearNotaPedidoService: {
273 getNumeroNotaPedido: function() { 273 getNumeroNotaPedido: function() {
274 return { 274 return {
275 then: function() { } 275 then: function() { }
276 }; 276 };
277 }, 277 },
278 getBotonera: function() { }, 278 getBotonera: function() { },
279 getCotizacionByIdMoneda: function() { 279 getCotizacionByIdMoneda: function() {
280 return { 280 return {
281 then: function() { } 281 then: function() { }
282 }; 282 };
283 } 283 }
284 }, 284 },
285 focaBotoneraLateralService: {}, 285 focaBotoneraLateralService: {},
286 focaModalService: focaModalService, 286 focaModalService: focaModalService,
287 notaPedidoBusinessService: {}, 287 notaPedidoBusinessService: {},
288 $rootScope: { 288 $rootScope: {
289 $on: function() { } 289 $on: function() { }
290 }, 290 },
291 focaSeguimientoService: {}, 291 focaSeguimientoService: {},
292 APP: {}, 292 APP: {},
293 focaLoginService: {}, 293 focaLoginService: {},
294 $localStorage: {} 294 $localStorage: {}
295 }); 295 });
296 scope.idLista = true; 296 scope.idLista = true;
297 scope.notaPedido = { 297 scope.notaPedido = {
298 cliente: { COD: false }, 298 cliente: { COD: false },
299 domicilio: { id: false} 299 domicilio: { id: false}
300 }; 300 };
301 301
302 //act 302 //act
303 spyOn(focaModalService, 'alert'); 303 spyOn(focaModalService, 'alert');
304 scope.seleccionarPuntosDeDescarga(); 304 scope.seleccionarPuntosDeDescarga();
305 305
306 //assert 306 //assert
307 expect(focaModalService.alert).toHaveBeenCalled(); 307 expect(focaModalService.alert).toHaveBeenCalled();
308 }); 308 });
309 309
310 it('función seleccionarPuntosDeDescarga abre modal', function() { 310 it('función seleccionarPuntosDeDescarga abre modal', function() {
311 //arrange 311 //arrange
312 var scope = { 312 var scope = {
313 $watch: function() { }, 313 $watch: function() { },
314 $broadcast: function() { } 314 $broadcast: function() { }
315 }; 315 };
316 var uibModal = { 316 var uibModal = {
317 open: function() { } 317 open: function() { }
318 }; 318 };
319 319
320 $controler('notaPedidoCtrl', { 320 $controler('notaPedidoCtrl', {
321 $scope: scope, 321 $scope: scope,
322 $uibModal: uibModal, 322 $uibModal: uibModal,
323 $location: {}, 323 $location: {},
324 $filter: filter, 324 $filter: filter,
325 $timeout: timeout, 325 $timeout: timeout,
326 crearNotaPedidoService: { 326 crearNotaPedidoService: {
327 getNumeroNotaPedido: function() { 327 getNumeroNotaPedido: function() {
328 return { 328 return {
329 then: function() { } 329 then: function() { }
330 }; 330 };
331 }, 331 },
332 getBotonera: function() { }, 332 getBotonera: function() { },
333 getCotizacionByIdMoneda: function() { 333 getCotizacionByIdMoneda: function() {
334 return { 334 return {
335 then: function() { } 335 then: function() { }
336 }; 336 };
337 } 337 }
338 }, 338 },
339 focaBotoneraLateralService: {}, 339 focaBotoneraLateralService: {},
340 focaModalService: {}, 340 focaModalService: {},
341 notaPedidoBusinessService: {}, 341 notaPedidoBusinessService: {},
342 $rootScope: { 342 $rootScope: {
343 $on: function() { } 343 $on: function() { }
344 }, 344 },
345 focaSeguimientoService: {}, 345 focaSeguimientoService: {},
346 APP: {}, 346 APP: {},
347 focaLoginService: {}, 347 focaLoginService: {},
348 $localStorage: {} 348 $localStorage: {}
349 }); 349 });
350 scope.idLista = true; 350 scope.idLista = true;
351 scope.notaPedido = { 351 scope.notaPedido = {
352 cliente: { COD: true }, 352 cliente: { COD: true },
353 domicilio: { id: true } 353 domicilio: { id: true }
354 }; 354 };
355 var respuesta = { result: { then: function() { } } }; 355 var respuesta = { result: { then: function() { } } };
356 356
357 //act 357 //act
358 spyOn(uibModal, 'open').and.returnValue(respuesta); 358 spyOn(uibModal, 'open').and.returnValue(respuesta);
359 scope.seleccionarPuntosDeDescarga(); 359 scope.seleccionarPuntosDeDescarga();
360 360
361 //assert 361 //assert
362 expect(uibModal.open).toHaveBeenCalled(); 362 expect(uibModal.open).toHaveBeenCalled();
363 }); 363 });
364 364
365 it('función seleccionarPuntosDeDescarga setea punto elegido', function(done) { 365 it('función seleccionarPuntosDeDescarga setea punto elegido', function(done) {
366 //arrange 366 //arrange
367 var scope = { 367 var scope = {
368 $watch: function() { }, 368 $watch: function() { },
369 $broadcast: function() { } 369 $broadcast: function() { }
370 }; 370 };
371 var uibModal = { 371 var uibModal = {
372 open: function() { } 372 open: function() { }
373 }; 373 };
374 374
375 $controler('notaPedidoCtrl', { 375 $controler('notaPedidoCtrl', {
376 $scope: scope, 376 $scope: scope,
377 $uibModal: uibModal, 377 $uibModal: uibModal,
378 $location: {}, 378 $location: {},
379 $filter: filter, 379 $filter: filter,
380 $timeout: timeout, 380 $timeout: timeout,
381 crearNotaPedidoService: { 381 crearNotaPedidoService: {
382 getNumeroNotaPedido: function() { 382 getNumeroNotaPedido: function() {
383 return { 383 return {
384 then: function() { } 384 then: function() { }
385 }; 385 };
386 }, 386 },
387 getBotonera: function() { }, 387 getBotonera: function() { },
388 getCotizacionByIdMoneda: function() { 388 getCotizacionByIdMoneda: function() {
389 return { 389 return {
390 then: function() { } 390 then: function() { }
391 }; 391 };
392 } 392 }
393 }, 393 },
394 focaBotoneraLateralService: {}, 394 focaBotoneraLateralService: {},
395 focaModalService: {}, 395 focaModalService: {},
396 notaPedidoBusinessService: {}, 396 notaPedidoBusinessService: {},
397 $rootScope: { 397 $rootScope: {
398 $on: function() { } 398 $on: function() { }
399 }, 399 },
400 focaSeguimientoService: {}, 400 focaSeguimientoService: {},
401 APP: {}, 401 APP: {},
402 focaLoginService: {}, 402 focaLoginService: {},
403 $localStorage: {} 403 $localStorage: {}
404 }); 404 });
405 scope.idLista = true; 405 scope.idLista = true;
406 scope.notaPedido = { 406 scope.notaPedido = {
407 cliente: { COD: true }, 407 cliente: { COD: true },
408 domicilio: { id: true }, 408 domicilio: { id: true },
409 puntosDescarga: [] 409 puntosDescarga: []
410 }; 410 };
411 var respuesta = []; 411 var respuesta = [];
412 var promiseRespuesta = { result: Promise.resolve(respuesta) }; 412 var promiseRespuesta = { result: Promise.resolve(respuesta) };
413 scope.$broadcast = function() { }; 413 scope.$broadcast = function() { };
414 414
415 //act 415 //act
416 spyOn(uibModal, 'open').and.returnValue(promiseRespuesta); 416 spyOn(uibModal, 'open').and.returnValue(promiseRespuesta);
417 scope.seleccionarPuntosDeDescarga(); 417 scope.seleccionarPuntosDeDescarga();
418 418
419 //assert 419 //assert
420 promiseRespuesta.result.then(function() { 420 promiseRespuesta.result.then(function() {
421 expect(scope.notaPedido.puntosDescarga).toEqual(respuesta); 421 expect(scope.notaPedido.puntosDescarga).toEqual(respuesta);
422 done(); 422 done();
423 }); 423 });
424 }); 424 });
425 425
426 it('función seleccionarVendedor abre modal', function() { 426 it('función seleccionarVendedor abre modal', function() {
427 //arrange 427 //arrange
428 var scope = { 428 var scope = {
429 $watch: function() { }, 429 $watch: function() { },
430 $broadcast: function() { } 430 $broadcast: function() { }
431 }; 431 };
432 var focaModalService = { 432 var focaModalService = {
433 modal: function() { } 433 modal: function() { }
434 }; 434 };
435 435
436 $controler('notaPedidoCtrl', { 436 $controler('notaPedidoCtrl', {
437 $scope: scope, 437 $scope: scope,
438 $uibModal: {}, 438 $uibModal: {},
439 $location: {}, 439 $location: {},
440 $filter: filter, 440 $filter: filter,
441 $timeout: timeout, 441 $timeout: timeout,
442 crearNotaPedidoService: { 442 crearNotaPedidoService: {
443 getNumeroNotaPedido: function() { 443 getNumeroNotaPedido: function() {
444 return { 444 return {
445 then: function() { } 445 then: function() { }
446 }; 446 };
447 }, 447 },
448 getBotonera: function() { }, 448 getBotonera: function() { },
449 getCotizacionByIdMoneda: function() { 449 getCotizacionByIdMoneda: function() {
450 return { 450 return {
451 then: function() { } 451 then: function() { }
452 }; 452 };
453 } 453 }
454 }, 454 },
455 focaBotoneraLateralService: {}, 455 focaBotoneraLateralService: {},
456 focaModalService: focaModalService, 456 focaModalService: focaModalService,
457 notaPedidoBusinessService: {}, 457 notaPedidoBusinessService: {},
458 $rootScope: { 458 $rootScope: {
459 $on: function() { } 459 $on: function() { }
460 }, 460 },
461 focaSeguimientoService: {}, 461 focaSeguimientoService: {},
462 APP: {}, 462 APP: {},
463 focaLoginService: {}, 463 focaLoginService: {},
464 $localStorage: {} 464 $localStorage: {}
465 }); 465 });
466 scope.idLista = true; 466 scope.idLista = true;
467 scope.notaPedido = { 467 scope.notaPedido = {
468 cliente: { COD: true }, 468 cliente: { COD: true },
469 domicilio: { id: true } 469 domicilio: { id: true }
470 }; 470 };
471 471
472 var respuesta = { then: function() { } }; 472 var respuesta = { then: function() { } };
473 473
474 //act 474 //act
475 spyOn(focaModalService, 'modal').and.returnValue(respuesta); 475 spyOn(focaModalService, 'modal').and.returnValue(respuesta);
476 scope.seleccionarVendedor(); 476 scope.seleccionarVendedor();
477 477
478 //assert 478 //assert
479 expect(focaModalService.modal).toHaveBeenCalled(); 479 expect(focaModalService.modal).toHaveBeenCalled();
480 }); 480 });
481 481
482 it('función seleccionarVendedor setea vendedor y cabecera', function(done) { 482 it('función seleccionarVendedor setea vendedor y cabecera', function(done) {
483 //arrange 483 //arrange
484 var scope = { 484 var scope = {
485 $watch: function() { }, 485 $watch: function() { },
486 $broadcast: function() { } 486 $broadcast: function() { }
487 }; 487 };
488 var focaModalService = { 488 var focaModalService = {
489 modal: function() { } 489 modal: function() { }
490 }; 490 };
491 491
492 $controler('notaPedidoCtrl', { 492 $controler('notaPedidoCtrl', {
493 $scope: scope, 493 $scope: scope,
494 $uibModal: {}, 494 $uibModal: {},
495 $location: {}, 495 $location: {},
496 $filter: filter, 496 $filter: filter,
497 $timeout: timeout, 497 $timeout: timeout,
498 crearNotaPedidoService: { 498 crearNotaPedidoService: {
499 getNumeroNotaPedido: function() { 499 getNumeroNotaPedido: function() {
500 return { 500 return {
501 then: function() { } 501 then: function() { }
502 }; 502 };
503 }, 503 },
504 getBotonera: function() { }, 504 getBotonera: function() { },
505 getCotizacionByIdMoneda: function() { 505 getCotizacionByIdMoneda: function() {
506 return { 506 return {
507 then: function() { } 507 then: function() { }
508 }; 508 };
509 } 509 }
510 }, 510 },
511 focaBotoneraLateralService: {}, 511 focaBotoneraLateralService: {},
512 focaModalService: focaModalService, 512 focaModalService: focaModalService,
513 notaPedidoBusinessService: {}, 513 notaPedidoBusinessService: {},
514 $rootScope: { 514 $rootScope: {
515 $on: function() { } 515 $on: function() { }
516 }, 516 },
517 focaSeguimientoService: {}, 517 focaSeguimientoService: {},
518 APP: {}, 518 APP: {},
519 focaLoginService: {}, 519 focaLoginService: {},
520 $localStorage: {} 520 $localStorage: {}
521 }); 521 });
522 scope.idLista = true; 522 scope.idLista = true;
523 scope.notaPedido = { 523 scope.notaPedido = {
524 cliente: { COD: true }, 524 cliente: { COD: true },
525 domicilio: { id: true } 525 domicilio: { id: true }
526 }; 526 };
527 var respuesta = {}; 527 var respuesta = {};
528 var promesaRespuesta = Promise.resolve(respuesta); 528 var promesaRespuesta = Promise.resolve(respuesta);
529 scope.$broadcast = function() { }; 529 scope.$broadcast = function() { };
530 530
531 //act 531 //act
532 spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); 532 spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta);
533 spyOn(scope, '$broadcast'); 533 spyOn(scope, '$broadcast');
534 scope.seleccionarVendedor(); 534 scope.seleccionarVendedor();
535 535
536 //assert 536 //assert
537 promesaRespuesta.then(function() { 537 promesaRespuesta.then(function() {
538 expect(scope.notaPedido.vendedor).toEqual(respuesta); 538 expect(scope.notaPedido.vendedor).toEqual(respuesta);
539 expect(scope.$broadcast).toHaveBeenCalled(); 539 expect(scope.$broadcast).toHaveBeenCalled();
540 done(); 540 done();
541 }); 541 });
542 }); 542 });
543 543
544 it('función seleccionarProveedor abre modal', function() { 544 it('función seleccionarProveedor abre modal', function() {
545 //arrange 545 //arrange
546 var scope = { 546 var scope = {
547 $watch: function() { }, 547 $watch: function() { },
548 $broadcast: function() { } 548 $broadcast: function() { }
549 }; 549 };
550 var focaModalService = { 550 var focaModalService = {
551 modal: function() { } 551 modal: function() { }
552 }; 552 };
553 553
554 $controler('notaPedidoCtrl', { 554 $controler('notaPedidoCtrl', {
555 $scope: scope, 555 $scope: scope,
556 $uibModal: {}, 556 $uibModal: {},
557 $location: {}, 557 $location: {},
558 $filter: filter, 558 $filter: filter,
559 $timeout: timeout, 559 $timeout: timeout,
560 crearNotaPedidoService: { 560 crearNotaPedidoService: {
561 getNumeroNotaPedido: function() { 561 getNumeroNotaPedido: function() {
562 return { 562 return {
563 then: function() { } 563 then: function() { }
564 }; 564 };
565 }, 565 },
566 getBotonera: function() { }, 566 getBotonera: function() { },
567 getCotizacionByIdMoneda: function() { 567 getCotizacionByIdMoneda: function() {
568 return { 568 return {
569 then: function() { } 569 then: function() { }
570 }; 570 };
571 } 571 }
572 }, 572 },
573 focaBotoneraLateralService: {}, 573 focaBotoneraLateralService: {},
574 focaModalService: focaModalService, 574 focaModalService: focaModalService,
575 notaPedidoBusinessService: {}, 575 notaPedidoBusinessService: {},
576 $rootScope: { 576 $rootScope: {
577 $on: function() { } 577 $on: function() { }
578 }, 578 },
579 focaSeguimientoService: {}, 579 focaSeguimientoService: {},
580 APP: {}, 580 APP: {},
581 focaLoginService: {}, 581 focaLoginService: {},
582 $localStorage: {} 582 $localStorage: {}
583 }); 583 });
584 scope.notaPedido = {}; 584 scope.notaPedido = {};
585 585
586 var respuesta = { then: function() { } }; 586 var respuesta = { then: function() { } };
587 587
588 //act 588 //act
589 spyOn(focaModalService, 'modal').and.returnValue(respuesta); 589 spyOn(focaModalService, 'modal').and.returnValue(respuesta);
590 scope.seleccionarProveedor(); 590 scope.seleccionarProveedor();
591 591
592 //assert 592 //assert
593 expect(focaModalService.modal).toHaveBeenCalled(); 593 expect(focaModalService.modal).toHaveBeenCalled();
594 }); 594 });
595 595
596 it('función seleccionarProveedor setea vendedor y cabecera', function(done) { 596 it('función seleccionarProveedor setea vendedor y cabecera', function(done) {
597 //arrange 597 //arrange
598 var scope = { 598 var scope = {
599 $watch: function() { }, 599 $watch: function() { },
600 $broadcast: function() { } 600 $broadcast: function() { }
601 }; 601 };
602 var focaModalService = { 602 var focaModalService = {
603 modal: function() { } 603 modal: function() { }
604 }; 604 };
605 605
606 $controler('notaPedidoCtrl', { 606 $controler('notaPedidoCtrl', {
607 $scope: scope, 607 $scope: scope,
608 $uibModal: {}, 608 $uibModal: {},
609 $location: {}, 609 $location: {},
610 $filter: filter, 610 $filter: filter,
611 $timeout: timeout, 611 $timeout: timeout,
612 crearNotaPedidoService: { 612 crearNotaPedidoService: {
613 getNumeroNotaPedido: function() { 613 getNumeroNotaPedido: function() {
614 return { 614 return {
615 then: function() { } 615 then: function() { }
616 }; 616 };
617 }, 617 },
618 getBotonera: function() { }, 618 getBotonera: function() { },
619 getCotizacionByIdMoneda: function() { 619 getCotizacionByIdMoneda: function() {
620 return { 620 return {
621 then: function() { } 621 then: function() { }
622 }; 622 };
623 } 623 }
624 }, 624 },
625 focaBotoneraLateralService: {}, 625 focaBotoneraLateralService: {},
626 focaModalService: focaModalService, 626 focaModalService: focaModalService,
627 notaPedidoBusinessService: {}, 627 notaPedidoBusinessService: {},
628 $rootScope: { 628 $rootScope: {
629 $on: function() { } 629 $on: function() { }
630 }, 630 },
631 focaSeguimientoService: {}, 631 focaSeguimientoService: {},
632 APP: {}, 632 APP: {},
633 focaLoginService: {}, 633 focaLoginService: {},
634 $localStorage: {} 634 $localStorage: {}
635 }); 635 });
636 636
637 scope.notaPedido = {}; 637 scope.notaPedido = {};
638 var respuesta = {}; 638 var respuesta = {};
639 var promesaRespuesta = Promise.resolve(respuesta); 639 var promesaRespuesta = Promise.resolve(respuesta);
640 scope.$broadcast = function() { }; 640 scope.$broadcast = function() { };
641 641
642 //act 642 //act
643 spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); 643 spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta);
644 spyOn(scope, '$broadcast'); 644 spyOn(scope, '$broadcast');
645 scope.seleccionarProveedor(); 645 scope.seleccionarProveedor();
646 646
647 //assert 647 //assert
648 promesaRespuesta.then(function() { 648 promesaRespuesta.then(function() {
649 expect(scope.notaPedido.proveedor).toEqual(respuesta); 649 expect(scope.notaPedido.proveedor).toEqual(respuesta);
650 expect(scope.$broadcast).toHaveBeenCalled(); 650 expect(scope.$broadcast).toHaveBeenCalled();
651 done(); 651 done();
652 }); 652 });
653 }); 653 });
654 654
655 it('función seleccionarCliente abre modal', function() { 655 it('función seleccionarCliente abre modal', function() {
656 //arrange 656 //arrange
657 var scope = { 657 var scope = {
658 $watch: function() { }, 658 $watch: function() { },
659 $broadcast: function() { } 659 $broadcast: function() { }
660 }; 660 };
661 var uibModal = { 661 var uibModal = {
662 open: function() { } 662 open: function() { }
663 }; 663 };
664 664
665 $controler('notaPedidoCtrl', { 665 $controler('notaPedidoCtrl', {
666 $scope: scope, 666 $scope: scope,
667 $uibModal: uibModal, 667 $uibModal: uibModal,
668 $location: {}, 668 $location: {},
669 $filter: filter, 669 $filter: filter,
670 $timeout: timeout, 670 $timeout: timeout,
671 crearNotaPedidoService: { 671 crearNotaPedidoService: {
672 getNumeroNotaPedido: function() { 672 getNumeroNotaPedido: function() {
673 return { 673 return {
674 then: function() { } 674 then: function() { }
675 }; 675 };
676 }, 676 },
677 getBotonera: function() { }, 677 getBotonera: function() { },
678 getCotizacionByIdMoneda: function() { 678 getCotizacionByIdMoneda: function() {
679 return { 679 return {
680 then: function() { } 680 then: function() { }
681 }; 681 };
682 }, 682 },
683 getVendedorById: function() { 683 getVendedorById: function() {
684 return { 684 return {
685 then: function() { } 685 then: function() { }
686 }; 686 };
687 } 687 }
688 }, 688 },
689 focaBotoneraLateralService: {}, 689 focaBotoneraLateralService: {},
690 focaModalService: { 690 focaModalService: {
691 modal: function() { 691 modal: function() {
692 return { 692 return {
693 then: function() {} 693 then: function() {}
694 }; 694 };
695 } 695 }
696 }, 696 },
697 notaPedidoBusinessService: {}, 697 notaPedidoBusinessService: {},
698 $rootScope: { 698 $rootScope: {
699 $on: function() { } 699 $on: function() { }
700 }, 700 },
701 focaSeguimientoService: {}, 701 focaSeguimientoService: {},
702 APP: 'distribuidor', 702 APP: 'distribuidor',
703 focaLoginService: { 703 focaLoginService: {
704 getLoginData: function() { 704 getLoginData: function() {
705 return { 705 return {
706 vendedorCorbrador: true 706 vendedorCorbrador: true
707 }; 707 };
708 } 708 }
709 }, 709 },
710 $localStorage: {} 710 $localStorage: {}
711 }); 711 });
712 scope.notaPedido = { 712 scope.notaPedido = {
713 vendedor: { NUM: true } 713 vendedor: { NUM: true }
714 }; 714 };
715 715
716 var respuesta = { result: {then: function() { } } }; 716 var respuesta = { result: {then: function() { } } };
717 717
718 //act 718 //act
719 spyOn(uibModal, 'open').and.returnValue(respuesta); 719 spyOn(uibModal, 'open').and.returnValue(respuesta);
720 scope.seleccionarCliente(); 720 scope.seleccionarCliente();
721 721
722 //assert 722 //assert
723 expect(uibModal.open).toHaveBeenCalled(); 723 expect(uibModal.open).toHaveBeenCalled();
724 }); 724 });
725 725
726 it('función seleccionarCliente setea vendedor y llama a domicilios', function(done) { 726 it('función seleccionarCliente setea vendedor y llama a domicilios', function(done) {
727 727
728 //arrange 728 //arrange
729 var scope = { 729 var scope = {
730 $watch: function() { }, 730 $watch: function() { },
731 $broadcast: function() { }, 731 $broadcast: function() { },
732 seleccionarVendedor: function() { }, 732 seleccionarVendedor: function() { },
733 notaPedido: {} 733 notaPedido: {}
734 }; 734 };
735 var uibModal = { 735 var uibModal = {
736 open: function() { } 736 open: function() { }
737 }; 737 };
738 738
739 $controler('notaPedidoCtrl', { 739 $controler('notaPedidoCtrl', {
740 $scope: scope, 740 $scope: scope,
741 $uibModal: uibModal, 741 $uibModal: uibModal,
742 $location: {}, 742 $location: {},
743 $filter: filter, 743 $filter: filter,
744 $timeout: timeout, 744 $timeout: timeout,
745 crearNotaPedidoService: { 745 crearNotaPedidoService: {
746 getNumeroNotaPedido: function() { 746 getNumeroNotaPedido: function() {
747 return { 747 return {
748 then: function() { } 748 then: function() { }
749 }; 749 };
750 }, 750 },
751 getBotonera: function() { }, 751 getBotonera: function() { },
752 getCotizacionByIdMoneda: function() { 752 getCotizacionByIdMoneda: function() {
753 return { 753 return {
754 then: function() { } 754 then: function() { }
755 }; 755 };
756 }, 756 },
757 getVendedorById : function() { 757 getVendedorById : function() {
758 return { 758 return {
759 then: function() { } 759 then: function() { }
760 }; 760 };
761 } 761 }
762 }, 762 },
763 focaBotoneraLateralService: {}, 763 focaBotoneraLateralService: {},
764 focaModalService: { 764 focaModalService: {
765 modal: function() { 765 modal: function() {
766 return { 766 return {
767 then: function() { } 767 then: function() { }
768 }; 768 };
769 } 769 }
770 }, 770 },
771 notaPedidoBusinessService: {}, 771 notaPedidoBusinessService: {},
772 $rootScope: { 772 $rootScope: {
773 $on: function() { } 773 $on: function() { }
774 }, 774 },
775 focaSeguimientoService: {}, 775 focaSeguimientoService: {},
776 APP: 'distribuidor', 776 APP: 'distribuidor',
777 focaLoginService: { 777 focaLoginService: {
778 getLoginData: function() { 778 getLoginData: function() {
779 return { 779 return {
780 vendedorCorbrador: true 780 vendedorCorbrador: true
781 }; 781 };
782 } 782 }
783 }, 783 },
784 $localStorage: {} 784 $localStorage: {}
785 }); 785 });
786 scope.idLista = true; 786 scope.idLista = true;
787 scope.notaPedido = { 787 scope.notaPedido = {
788 vendedor: { NUM: true } 788 vendedor: { NUM: true }
789 }; 789 };
790 var respuesta = {}; 790 var respuesta = {};
791 var promesaRespuesta = { result: Promise.resolve(respuesta) }; 791 var promesaRespuesta = { result: Promise.resolve(respuesta) };
792 792
793 //act 793 //act
794 spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); 794 spyOn(uibModal, 'open').and.returnValue(promesaRespuesta);
795 spyOn(scope, 'abrirModalDomicilios'); 795 spyOn(scope, 'abrirModalDomicilios');
796 scope.seleccionarCliente(); 796 scope.seleccionarCliente();
797 797
798 //assert 798 //assert
799 promesaRespuesta.result.then(function() { 799 promesaRespuesta.result.then(function() {
800 expect(scope.cliente).toEqual(respuesta); 800 expect(scope.cliente).toEqual(respuesta);
801 expect(scope.abrirModalDomicilios).toHaveBeenCalled(); 801 expect(scope.abrirModalDomicilios).toHaveBeenCalled();
802 done(); 802 done();
803 }); 803 });
804 }); 804 });
805 805
806 it('función abrirModalDomicilios abre modal', function() { 806 it('función abrirModalDomicilios abre modal', function() {
807 //arrange 807 //arrange
808 var scope = { 808 var scope = {
809 $watch: function() { }, 809 $watch: function() { },
810 $broadcast: function() { } 810 $broadcast: function() { }
811 }; 811 };
812 var uibModal = { 812 var uibModal = {
813 open: function() { } 813 open: function() { }
814 }; 814 };
815 815
816 $controler('notaPedidoCtrl', { 816 $controler('notaPedidoCtrl', {
817 $scope: scope, 817 $scope: scope,
818 $uibModal: uibModal, 818 $uibModal: uibModal,
819 $location: {}, 819 $location: {},
820 $filter: filter, 820 $filter: filter,
821 $timeout: timeout, 821 $timeout: timeout,
822 crearNotaPedidoService: { 822 crearNotaPedidoService: {
823 getNumeroNotaPedido: function() { 823 getNumeroNotaPedido: function() {
824 return { 824 return {
825 then: function() { } 825 then: function() { }
826 }; 826 };
827 }, 827 },
828 getBotonera: function() { }, 828 getBotonera: function() { },
829 getCotizacionByIdMoneda: function() { 829 getCotizacionByIdMoneda: function() {
830 return { 830 return {
831 then: function() { } 831 then: function() { }
832 }; 832 };
833 } 833 }
834 }, 834 },
835 focaBotoneraLateralService: {}, 835 focaBotoneraLateralService: {},
836 focaModalService: {}, 836 focaModalService: {},
837 notaPedidoBusinessService: {}, 837 notaPedidoBusinessService: {},
838 $rootScope: { 838 $rootScope: {
839 $on: function() { } 839 $on: function() { }
840 }, 840 },
841 focaSeguimientoService: {}, 841 focaSeguimientoService: {},
842 APP: {}, 842 APP: {},
843 focaLoginService: {}, 843 focaLoginService: {},
844 $localStorage: {} 844 $localStorage: {}
845 }); 845 });
846 846
847 var respuesta = { result: {then: function() { } } }; 847 var respuesta = { result: {then: function() { } } };
848 848
849 //act 849 //act
850 spyOn(uibModal, 'open').and.returnValue(respuesta); 850 spyOn(uibModal, 'open').and.returnValue(respuesta);
851 scope.abrirModalDomicilios(); 851 scope.abrirModalDomicilios();
852 852
853 //assert 853 //assert
854 expect(uibModal.open).toHaveBeenCalled(); 854 expect(uibModal.open).toHaveBeenCalled();
855 }); 855 });
856 856
857 it('función abrirModalDomicilios setea domicilio, cliente y cabeceras', function(done) { 857 it('función abrirModalDomicilios setea domicilio, cliente y cabeceras', function(done) {
858 858
859 //arrange 859 //arrange
860 var scope = { 860 var scope = {
861 $watch: function() { }, 861 $watch: function() { },
862 $broadcast: function() { } 862 $broadcast: function() { }
863 }; 863 };
864 var uibModal = { 864 var uibModal = {
865 open: function() { } 865 open: function() { }
866 }; 866 };
867 867
868 $controler('notaPedidoCtrl', { 868 $controler('notaPedidoCtrl', {
869 $scope: scope, 869 $scope: scope,
870 $uibModal: uibModal, 870 $uibModal: uibModal,
871 $location: {}, 871 $location: {},
872 $filter: filter, 872 $filter: filter,
873 $timeout: timeout, 873 $timeout: timeout,
874 crearNotaPedidoService: { 874 crearNotaPedidoService: {
875 getNumeroNotaPedido: function() { 875 getNumeroNotaPedido: function() {
876 return { 876 return {
877 then: function() { } 877 then: function() { }
878 }; 878 };
879 }, 879 },
880 getBotonera: function() { }, 880 getBotonera: function() { },
881 getCotizacionByIdMoneda: function() { 881 getCotizacionByIdMoneda: function() {
882 return { 882 return {
883 then: function() { } 883 then: function() { }
884 }; 884 };
885 }, 885 },
886 getPuntosDescargaByClienDom: function() { 886 getPuntosDescargaByClienDom: function() {
887 return { 887 return {
888 then: function() { } 888 then: function() { }
889 }; 889 };
890 } 890 }
891 }, 891 },
892 focaBotoneraLateralService: {}, 892 focaBotoneraLateralService: {},
893 focaModalService: {}, 893 focaModalService: {},
894 notaPedidoBusinessService: {}, 894 notaPedidoBusinessService: {},
895 $rootScope: { 895 $rootScope: {
896 $on: function() { } 896 $on: function() { }
897 }, 897 },
898 focaSeguimientoService: {}, 898 focaSeguimientoService: {},
899 APP: {}, 899 APP: {},
900 focaLoginService: {}, 900 focaLoginService: {},
901 $localStorage: {} 901 $localStorage: {}
902 }); 902 });
903 scope.idLista = true; 903 scope.idLista = true;
904 scope.notaPedido = { 904 scope.notaPedido = {
905 vendedor: { NUM: true } 905 vendedor: { NUM: true }
906 }; 906 };
907 var respuesta = {}; 907 var respuesta = {};
908 var promesaRespuesta = { result: Promise.resolve(respuesta) }; 908 var promesaRespuesta = { result: Promise.resolve(respuesta) };
909 scope.$broadcast = function() { }; 909 scope.$broadcast = function() { };
910 var cliente = { 910 var cliente = {
911 COD: undefined, 911 COD: undefined,
912 CUIT: undefined, 912 CUIT: undefined,
913 NOM: undefined, 913 NOM: undefined,
914 MOD: undefined
914 MOD: undefined 915 };
915 }; 916
916 917 //act
917 //act 918 spyOn(uibModal, 'open').and.returnValue(promesaRespuesta);
918 spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); 919 spyOn(scope, '$broadcast');
919 spyOn(scope, '$broadcast'); 920 scope.abrirModalDomicilios(cliente);
920 scope.abrirModalDomicilios(cliente); 921
921 922 //assert
922 //assert 923 promesaRespuesta.result.then(function() {
924 //scope.notaPedido.domicilio sea vacio
923 promesaRespuesta.result.then(function() { 925 expect(scope.notaPedido.domicilio).toEqual(respuesta);
924 //scope.notaPedido.domicilio sea vacio 926 expect(scope.notaPedido.cliente).toEqual(cliente);
925 expect(scope.notaPedido.domicilio).toEqual(respuesta); 927 expect(scope.$broadcast).toHaveBeenCalled();
926 expect(scope.notaPedido.cliente).toEqual(cliente); 928 done();
927 expect(scope.$broadcast).toHaveBeenCalled(); 929 });
928 done(); 930 });
929 }); 931
930 }); 932 it('función getTotal devulve correctamente', function() {
931 933
932 it('función getTotal devulve correctamente', function() { 934 //arrange
933 935 var scope = {
934 //arrange 936 $watch: function() { },
935 var scope = { 937 $broadcast: function() { }
936 $watch: function() { }, 938 };
937 $broadcast: function() { } 939
938 }; 940 $controler('notaPedidoCtrl', {
939 941 $scope: scope,
940 $controler('notaPedidoCtrl', { 942 $uibModal: {},
941 $scope: scope, 943 $location: {},
942 $uibModal: {}, 944 $filter: filter,
943 $location: {}, 945 $timeout: timeout,
944 $filter: filter, 946 crearNotaPedidoService: {
945 $timeout: timeout, 947 getNumeroNotaPedido: function() {
946 crearNotaPedidoService: { 948 return {
947 getNumeroNotaPedido: function() { 949 then: function() { }
948 return { 950 };
949 then: function() { } 951 },
950 }; 952 getBotonera: function() { },
951 }, 953 getCotizacionByIdMoneda: function() {
952 getBotonera: function() { }, 954 return {
953 getCotizacionByIdMoneda: function() { 955 then: function() { }
954 return { 956 };
955 then: function() { } 957 }
956 }; 958 },
957 } 959 focaBotoneraLateralService: {},
958 }, 960 focaModalService: {},
959 focaBotoneraLateralService: {}, 961 notaPedidoBusinessService: {},
960 focaModalService: {}, 962 $rootScope: {
961 notaPedidoBusinessService: {}, 963 $on: function() { }
962 $rootScope: { 964 },
963 $on: function() { } 965 focaSeguimientoService: {},
964 }, 966 APP: {},
965 focaSeguimientoService: {}, 967 focaLoginService: {},
966 APP: {}, 968 $localStorage: {}
967 focaLoginService: {}, 969 });
968 $localStorage: {} 970 scope.idLista = true;
969 }); 971 scope.notaPedido = {
970 scope.idLista = true; 972 vendedor: { NUM: true }
971 scope.notaPedido = { 973 };
972 vendedor: { NUM: true } 974
973 }; 975 //act
974 976 scope.notaPedido.articulosNotaPedido = [{ precio: 2, cantidad: 1}];
975 //act 977 var esperado = 2;
976 scope.notaPedido.articulosNotaPedido = [{ precio: 2, cantidad: 1}]; 978 var resultado = scope.getTotal();
977 var esperado = 2; 979
978 var resultado = scope.getTotal(); 980 //assert
979 981 expect(resultado).toEqual(esperado);
980 //assert 982 });
981 expect(resultado).toEqual(esperado); 983
982 }); 984 it('función getSubTotal devulve correctamente', function() {
983 985
984 it('función getSubTotal devulve correctamente', function() { 986 //arrange
985 987 var scope = {
986 //arrange 988 $watch: function() { },
987 var scope = { 989 $broadcast: function() { }
988 $watch: function() { }, 990 };
989 $broadcast: function() { } 991
990 }; 992 $controler('notaPedidoCtrl', {
991 993 $scope: scope,
992 $controler('notaPedidoCtrl', { 994 $uibModal: {},
993 $scope: scope, 995 $location: {},
994 $uibModal: {}, 996 $filter: filter,
995 $location: {}, 997 $timeout: timeout,
996 $filter: filter, 998 crearNotaPedidoService: {
997 $timeout: timeout, 999 getNumeroNotaPedido: function() {
998 crearNotaPedidoService: { 1000 return {
999 getNumeroNotaPedido: function() { 1001 then: function() { }
1000 return { 1002 };
1001 then: function() { } 1003 },
1002 }; 1004 getBotonera: function() { },
1003 }, 1005 getCotizacionByIdMoneda: function() {
1004 getBotonera: function() { }, 1006 return {
1005 getCotizacionByIdMoneda: function() { 1007 then: function() { }
1006 return { 1008 };
1007 then: function() { } 1009 }
1008 }; 1010 },
1009 } 1011 focaBotoneraLateralService: {},
1010 }, 1012 focaModalService: {},
1011 focaBotoneraLateralService: {}, 1013 notaPedidoBusinessService: {},
1012 focaModalService: {}, 1014 $rootScope: {
1013 notaPedidoBusinessService: {}, 1015 $on: function() { }
1014 $rootScope: { 1016 },
1015 $on: function() { } 1017 focaSeguimientoService: {},
1016 }, 1018 APP: {},
1017 focaSeguimientoService: {}, 1019 focaLoginService: {},
1018 APP: {}, 1020 $localStorage: {}
1019 focaLoginService: {}, 1021 });
1020 $localStorage: {} 1022 scope.idLista = true;
1021 }); 1023 scope.notaPedido = {
1022 scope.idLista = true; 1024 vendedor: { NUM: true }
1023 scope.notaPedido = { 1025 };
1024 vendedor: { NUM: true } 1026
1025 }; 1027 //act
1026 1028 scope.articuloACargar = { precio: 2, cantidad: 1};
1027 //act 1029 var esperado = 2;
1028 scope.articuloACargar = { precio: 2, cantidad: 1}; 1030 var resultado = scope.getSubTotal();
1029 var esperado = 2; 1031
1030 var resultado = scope.getSubTotal(); 1032 //assert
1031 1033 expect(resultado).toEqual(esperado);
1032 //assert 1034 });
1033 expect(resultado).toEqual(esperado); 1035
1034 }); 1036 it('función seleccionarPreciosYCondiciones abre modal', function() {
1035 1037
1036 it('función seleccionarPreciosYCondiciones abre modal', function() { 1038 //arrange
1037 1039 var scope = {
1038 //arrange 1040 $watch: function() { },
1039 var scope = { 1041 $broadcast: function() { }
1040 $watch: function() { }, 1042 };
1041 $broadcast: function() { } 1043 var uibModal = {
1042 }; 1044 open: function() { }
1043 var uibModal = { 1045 };
1044 open: function() { } 1046
1045 }; 1047 $controler('notaPedidoCtrl', {
1046 1048 $scope: scope,
1047 $controler('notaPedidoCtrl', { 1049 $uibModal: uibModal,
1048 $scope: scope, 1050 $location: {},
1049 $uibModal: uibModal, 1051 $filter: filter,
1050 $location: {}, 1052 $timeout: timeout,
1051 $filter: filter, 1053 crearNotaPedidoService: {
1052 $timeout: timeout, 1054 getNumeroNotaPedido: function() {
1053 crearNotaPedidoService: { 1055 return {
1054 getNumeroNotaPedido: function() { 1056 then: function() { }
1055 return { 1057 };
1056 then: function() { } 1058 },
1057 }; 1059 getBotonera: function() { },
1058 }, 1060 getCotizacionByIdMoneda: function() {
1059 getBotonera: function() { }, 1061 return {
1060 getCotizacionByIdMoneda: function() { 1062 then: function() { }
1061 return { 1063 };
1062 then: function() { } 1064 }
1063 }; 1065 },
1064 } 1066 focaBotoneraLateralService: {},
1065 }, 1067 focaModalService: {},
1066 focaBotoneraLateralService: {}, 1068 notaPedidoBusinessService: {},
1067 focaModalService: {}, 1069 $rootScope: {
1068 notaPedidoBusinessService: {}, 1070 $on: function() { }
1069 $rootScope: { 1071 },
1070 $on: function() { } 1072 focaSeguimientoService: {},
1071 }, 1073 APP: {},
1072 focaSeguimientoService: {}, 1074 focaLoginService: {},
1073 APP: {}, 1075 $localStorage: {}
1074 focaLoginService: {}, 1076 });
1075 $localStorage: {} 1077
1076 }); 1078 scope.notaPedido = {
1079 cliente: { COD: true }
1080 };
1077 1081
1078 scope.notaPedido = { 1082 var respuesta = { result: {then: function() { } } };
1079 cliente: { COD: true } 1083
1080 }; 1084 //act
1081 1085 spyOn(uibModal, 'open').and.returnValue(respuesta);
1082 var respuesta = { result: {then: function() { } } }; 1086 scope.seleccionarPreciosYCondiciones();
1083 1087
1084 //act 1088 //assert
1085 spyOn(uibModal, 'open').and.returnValue(respuesta); 1089 expect(uibModal.open).toHaveBeenCalled();
1086 scope.seleccionarPreciosYCondiciones(); 1090 });
1087 1091
1088 //assert 1092 it('función seleccionarPreciosYCondiciones setea articulos y cabecera', function(done) {
1089 expect(uibModal.open).toHaveBeenCalled(); 1093
1090 }); 1094 //arrange
1091 1095 var scope = {
1092 it('función seleccionarPreciosYCondiciones setea articulos y cabecera', function(done) { 1096 $watch: function() { },
1093 1097 $broadcast: function() { }
1094 //arrange 1098 };
1095 var scope = { 1099 var uibModal = {
1096 $watch: function() { }, 1100 open: function() { }
1097 $broadcast: function() { } 1101 };
1098 }; 1102
1099 var uibModal = { 1103 $controler('notaPedidoCtrl', {
1100 open: function() { } 1104 $scope: scope,
1101 }; 1105 $uibModal: uibModal,
1102 1106 $location: {},
1103 $controler('notaPedidoCtrl', { 1107 $filter: filter,
1104 $scope: scope, 1108 $timeout: timeout,
1105 $uibModal: uibModal, 1109 crearNotaPedidoService: {
1106 $location: {}, 1110 getNumeroNotaPedido: function() {
1107 $filter: filter, 1111 return {
1108 $timeout: timeout, 1112 then: function() { }
1109 crearNotaPedidoService: { 1113 };
1110 getNumeroNotaPedido: function() { 1114 },
1111 return { 1115 getBotonera: function() { },
1112 then: function() { } 1116 getCotizacionByIdMoneda: function() {
1113 }; 1117 return {
1114 }, 1118 then: function() { }
1115 getBotonera: function() { }, 1119 };
1116 getCotizacionByIdMoneda: function() { 1120 }
1117 return { 1121 },
1118 then: function() { } 1122 focaBotoneraLateralService: {},
1119 }; 1123 focaModalService: {},
1120 } 1124 notaPedidoBusinessService: {},
1121 }, 1125 $rootScope: {
1122 focaBotoneraLateralService: {}, 1126 $on: function() { }
1123 focaModalService: {}, 1127 },
1124 notaPedidoBusinessService: {}, 1128 focaSeguimientoService: {},
1125 $rootScope: { 1129 APP: {},
1126 $on: function() { } 1130 focaLoginService: {},
1127 }, 1131 $localStorage: {}
1128 focaSeguimientoService: {}, 1132 });
1129 APP: {}, 1133 scope.idLista = true;
1130 focaLoginService: {}, 1134 scope.notaPedido = {
1131 $localStorage: {} 1135 vendedor: { NUM: true },
1136 cliente: { COD: true }
1132 }); 1137 };
1133 scope.idLista = true; 1138 var respuesta = { plazoPago: { } };
1134 scope.notaPedido = { 1139 var promesaRespuesta = { result: Promise.resolve(respuesta) };
1135 vendedor: { NUM: true }, 1140 scope.$broadcast = function() { };
1136 cliente: { COD: true } 1141
1137 }; 1142 //act
1138 var respuesta = { plazoPago: { } }; 1143 spyOn(uibModal, 'open').and.returnValue(promesaRespuesta);
1139 var promesaRespuesta = { result: Promise.resolve(respuesta) }; 1144 spyOn(scope, '$broadcast');
1140 scope.$broadcast = function() { }; 1145 scope.seleccionarPreciosYCondiciones();
1141 1146
1142 //act 1147 //assert
1143 spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); 1148 promesaRespuesta.result.then(function() {
1144 spyOn(scope, '$broadcast'); 1149 expect(scope.notaPedido.articulosNotaPedido.length).toEqual(0);
1145 scope.seleccionarPreciosYCondiciones(); 1150 expect(scope.$broadcast).toHaveBeenCalled();
1146 1151 done();
1147 //assert 1152 });
1148 promesaRespuesta.result.then(function() { 1153 });
1149 expect(scope.notaPedido.articulosNotaPedido.length).toEqual(0); 1154
1150 expect(scope.$broadcast).toHaveBeenCalled(); 1155 it('función seleccionarMoneda abre modal', function() {
1151 done(); 1156 //arrange
1152 }); 1157 var scope = {
1153 }); 1158 $watch: function() { },
1154 1159 $broadcast: function() { }
1155 it('función seleccionarMoneda abre modal', function() { 1160 };
1156 //arrange 1161 var focaModalService = {
1157 var scope = { 1162 modal: function() { }
1158 $watch: function() { }, 1163 };
1159 $broadcast: function() { } 1164
1160 }; 1165 $controler('notaPedidoCtrl', {
1161 var focaModalService = { 1166 $scope: scope,
1162 modal: function() { } 1167 $uibModal: {},
1163 }; 1168 $location: {},
1164 1169 $filter: filter,
1165 $controler('notaPedidoCtrl', { 1170 $timeout: timeout,
1166 $scope: scope, 1171 crearNotaPedidoService: {
1167 $uibModal: {}, 1172 getNumeroNotaPedido: function() {
1168 $location: {}, 1173 return {
1169 $filter: filter, 1174 then: function() { }
1170 $timeout: timeout, 1175 };
1171 crearNotaPedidoService: { 1176 },
1172 getNumeroNotaPedido: function() { 1177 getBotonera: function() { },
1173 return { 1178 getCotizacionByIdMoneda: function() {
1174 then: function() { } 1179 return {
1175 }; 1180 then: function() { }
1176 }, 1181 };
1177 getBotonera: function() { }, 1182 }
1178 getCotizacionByIdMoneda: function() { 1183 },
1179 return { 1184 focaBotoneraLateralService: {},
1180 then: function() { } 1185 focaModalService: focaModalService,
1181 }; 1186 notaPedidoBusinessService: {},
1182 } 1187 $rootScope: {
1183 }, 1188 $on: function() { }
1184 focaBotoneraLateralService: {}, 1189 },
1185 focaModalService: focaModalService, 1190 focaSeguimientoService: {},
1186 notaPedidoBusinessService: {}, 1191 APP: {},
1187 $rootScope: { 1192 focaLoginService: {},
1188 $on: function() { } 1193 $localStorage: {}
1189 }, 1194 });
1190 focaSeguimientoService: {}, 1195 scope.notaPedido = {};
1191 APP: {}, 1196
1192 focaLoginService: {}, 1197 var respuesta = { then: function() { } };
1193 $localStorage: {} 1198
1194 }); 1199 //act
1195 scope.notaPedido = {}; 1200 spyOn(focaModalService, 'modal').and.returnValue(respuesta);
1196 1201 scope.seleccionarMoneda();
1197 var respuesta = { then: function() { } }; 1202
1198 1203 //assert
1199 //act 1204 expect(focaModalService.modal).toHaveBeenCalled();
1200 spyOn(focaModalService, 'modal').and.returnValue(respuesta); 1205 });
1201 scope.seleccionarMoneda(); 1206
1202 1207 it('función seleccionarMoneda llama Modal Cotizacion', function(done) {
1203 //assert 1208 //arrange
1204 expect(focaModalService.modal).toHaveBeenCalled(); 1209 var scope = {
1205 }); 1210 $watch: function() { },
1206 1211 $broadcast: function() { }
1207 it('función seleccionarMoneda llama Modal Cotizacion', function(done) { 1212 };
1208 //arrange 1213 var focaModalService = {
1209 var scope = { 1214 modal: function() { }
1210 $watch: function() { }, 1215 };
1211 $broadcast: function() { } 1216
1212 }; 1217 $controler('notaPedidoCtrl', {
1213 var focaModalService = { 1218 $scope: scope,
1214 modal: function() { } 1219 $uibModal: {},
1215 }; 1220 $location: {},
1216 1221 $filter: filter,
1217 $controler('notaPedidoCtrl', { 1222 $timeout: timeout,
1218 $scope: scope, 1223 crearNotaPedidoService: {
1219 $uibModal: {}, 1224 getNumeroNotaPedido: function() {
1220 $location: {}, 1225 return {
1221 $filter: filter, 1226 then: function() { }
1222 $timeout: timeout, 1227 };
1223 crearNotaPedidoService: { 1228 },
1224 getNumeroNotaPedido: function() { 1229 getBotonera: function() { },
1225 return { 1230 getCotizacionByIdMoneda: function() {
1226 then: function() { } 1231 return {
1227 }; 1232 then: function() { }
1228 }, 1233 };
1229 getBotonera: function() { }, 1234 }
1230 getCotizacionByIdMoneda: function() { 1235 },
1231 return { 1236 focaBotoneraLateralService: {},
1232 then: function() { } 1237 focaModalService: focaModalService,
1233 }; 1238 notaPedidoBusinessService: {},
1234 } 1239 $rootScope: {
1235 }, 1240 $on: function() { }
1236 focaBotoneraLateralService: {}, 1241 },
1237 focaModalService: focaModalService, 1242 focaSeguimientoService: {},
1238 notaPedidoBusinessService: {}, 1243 APP: {},
1239 $rootScope: { 1244 focaLoginService: {},
1240 $on: function() { } 1245 $localStorage: {}
1241 }, 1246 });
1242 focaSeguimientoService: {}, 1247
1243 APP: {}, 1248 scope.notaPedido = {};
1244 focaLoginService: {}, 1249 var respuesta = 'test';
1245 $localStorage: {} 1250 var promesaRespuesta = Promise.resolve(respuesta);
1246 }); 1251
1247 1252 //act
1248 scope.notaPedido = {}; 1253 spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta);
1249 var respuesta = 'test'; 1254 spyOn(scope, 'abrirModalCotizacion');
1250 var promesaRespuesta = Promise.resolve(respuesta); 1255 scope.seleccionarMoneda();
1251 1256
1252 //act 1257 //assert
1253 spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); 1258 promesaRespuesta.then(function() {
1254 spyOn(scope, 'abrirModalCotizacion'); 1259 expect(scope.abrirModalCotizacion).toHaveBeenCalledWith('test');
1255 scope.seleccionarMoneda(); 1260 done();
1256 1261 });
1257 //assert 1262 });
1258 promesaRespuesta.then(function() { 1263
1259 expect(scope.abrirModalCotizacion).toHaveBeenCalledWith('test'); 1264 it('función seleccionarObservaciones llama a prompt', function() {
1260 done(); 1265
1261 }); 1266 //arrange
1262 }); 1267 var scope = {
1263 1268 $watch: function() { },
1264 it('función seleccionarObservaciones llama a prompt', function() { 1269 $broadcast: function() { }
1265 1270 };
1266 //arrange 1271 var focaModalService = {
1267 var scope = { 1272 prompt: function() { }
1268 $watch: function() { }, 1273 };
1269 $broadcast: function() { } 1274
1270 }; 1275 $controler('notaPedidoCtrl', {
1271 var focaModalService = { 1276 $scope: scope,
1272 prompt: function() { } 1277 $uibModal: {},
1273 }; 1278 $location: {},
1274 1279 $filter: filter,
1275 $controler('notaPedidoCtrl', { 1280 $timeout: timeout,
1276 $scope: scope, 1281 crearNotaPedidoService: {
1277 $uibModal: {}, 1282 getNumeroNotaPedido: function() {
1278 $location: {}, 1283 return {
1279 $filter: filter, 1284 then: function() { }
1280 $timeout: timeout, 1285 };
1281 crearNotaPedidoService: { 1286 },
1282 getNumeroNotaPedido: function() { 1287 getBotonera: function() { },
1283 return { 1288 getCotizacionByIdMoneda: function() {
1284 then: function() { } 1289 return {
1285 }; 1290 then: function() { }
1286 }, 1291 };
1287 getBotonera: function() { }, 1292 }
1288 getCotizacionByIdMoneda: function() { 1293 },
1289 return { 1294 focaBotoneraLateralService: {},
1290 then: function() { } 1295 focaModalService: focaModalService,
1291 }; 1296 notaPedidoBusinessService: {},
1292 } 1297 $rootScope: {
1293 }, 1298 $on: function() { }
1294 focaBotoneraLateralService: {}, 1299 },
1295 focaModalService: focaModalService, 1300 focaSeguimientoService: {},
1296 notaPedidoBusinessService: {}, 1301 APP: {},
1297 $rootScope: { 1302 focaLoginService: {},
1298 $on: function() { } 1303 $localStorage: {}
1299 }, 1304 });
1300 focaSeguimientoService: {}, 1305 var respuesta = { then: function() { } };
1301 APP: {}, 1306 scope.notaPedido = {};
1302 focaLoginService: {}, 1307
1303 $localStorage: {} 1308 //act
1304 }); 1309 spyOn(focaModalService, 'prompt').and.returnValue(respuesta);
1305 var respuesta = { then: function() { } }; 1310 scope.seleccionarObservaciones();
1306 scope.notaPedido = {}; 1311
1307 1312 //assert
1308 //act 1313 expect(focaModalService.prompt).toHaveBeenCalled();
1309 spyOn(focaModalService, 'prompt').and.returnValue(respuesta); 1314 });
1310 scope.seleccionarObservaciones(); 1315
1311 1316 it('función seleccionarObservaciones setea observaciones', function(done) {
1312 //assert 1317
1313 expect(focaModalService.prompt).toHaveBeenCalled(); 1318 //arrange
1314 }); 1319 var scope = {
1315 1320 $watch: function() { },
1316 it('función seleccionarObservaciones setea observaciones', function(done) { 1321 $broadcast: function() { }
1317 1322 };
1318 //arrange 1323 var focaModalService = {
1319 var scope = { 1324 prompt: function() { }
1320 $watch: function() { }, 1325 };
1321 $broadcast: function() { } 1326
1322 }; 1327 $controler('notaPedidoCtrl', {
1323 var focaModalService = { 1328 $scope: scope,
1324 prompt: function() { } 1329 $uibModal: {},
1325 }; 1330 $location: {},
1326 1331 $filter: filter,
1327 $controler('notaPedidoCtrl', { 1332 $timeout: timeout,
1328 $scope: scope, 1333 crearNotaPedidoService: {
1329 $uibModal: {}, 1334 getNumeroNotaPedido: function() {
1330 $location: {}, 1335 return {
1331 $filter: filter, 1336 then: function() { }
1332 $timeout: timeout, 1337 };
1333 crearNotaPedidoService: { 1338 },
1334 getNumeroNotaPedido: function() { 1339 getBotonera: function() { },
1335 return { 1340 getCotizacionByIdMoneda: function() {
1336 then: function() { } 1341 return {
1337 }; 1342 then: function() { }
1338 }, 1343 };
1339 getBotonera: function() { }, 1344 }
1340 getCotizacionByIdMoneda: function() { 1345 },
1341 return { 1346 focaBotoneraLateralService: {},
1342 then: function() { } 1347 focaModalService: focaModalService,
1343 }; 1348 notaPedidoBusinessService: {},
1344 } 1349 $rootScope: {
1345 }, 1350 $on: function() { }
1346 focaBotoneraLateralService: {}, 1351 },
1347 focaModalService: focaModalService, 1352 focaSeguimientoService: {},
1348 notaPedidoBusinessService: {}, 1353 APP: {},
1349 $rootScope: { 1354 focaLoginService: {},
1350 $on: function() { } 1355 $localStorage: {}
1351 }, 1356 });
1352 focaSeguimientoService: {}, 1357 var respuesta = 'unit test';
1353 APP: {}, 1358 var promesa = Promise.resolve(respuesta);
1354 focaLoginService: {}, 1359 scope.notaPedido = {};
1355 $localStorage: {} 1360
1356 }); 1361 //act
1357 var respuesta = 'unit test'; 1362 spyOn(focaModalService, 'prompt').and.returnValue(promesa);
1358 var promesa = Promise.resolve(respuesta); 1363 scope.seleccionarObservaciones();
1359 scope.notaPedido = {}; 1364
1360 1365 //assert
1361 //act 1366 promesa.then(function() {
1362 spyOn(focaModalService, 'prompt').and.returnValue(promesa); 1367 expect(scope.notaPedido.observaciones).toEqual(respuesta);
1363 scope.seleccionarObservaciones(); 1368 done();
1364 1369 });
1365 //assert 1370 });
1366 promesa.then(function() { 1371
1367 expect(scope.notaPedido.observaciones).toEqual(respuesta); 1372 it('función abrirModalCotizacion abre modal', function() {
1368 done(); 1373
1369 }); 1374 //arrange
1370 }); 1375 var scope = {
1371 1376 $watch: function() { },
1372 it('función abrirModalCotizacion abre modal', function() { 1377 $broadcast: function() { }
1373 1378 };
1374 //arrange 1379 var uibModal = {
1375 var scope = { 1380 open: function() { }
1376 $watch: function() { }, 1381 };
1377 $broadcast: function() { } 1382
1378 }; 1383 $controler('notaPedidoCtrl', {
1379 var uibModal = { 1384 $scope: scope,
1380 open: function() { } 1385 $uibModal: uibModal,
1381 }; 1386 $location: {},
1382 1387 $filter: filter,
1383 $controler('notaPedidoCtrl', { 1388 $timeout: timeout,
1384 $scope: scope, 1389 crearNotaPedidoService: {
1385 $uibModal: uibModal, 1390 getNumeroNotaPedido: function() {
1386 $location: {}, 1391 return {
1387 $filter: filter, 1392 then: function() { }
1388 $timeout: timeout, 1393 };
1389 crearNotaPedidoService: { 1394 },
1390 getNumeroNotaPedido: function() { 1395 getBotonera: function() { },
1391 return { 1396 getCotizacionByIdMoneda: function() {
1392 then: function() { } 1397 return {
1393 }; 1398 then: function() { }
1394 }, 1399 };
1395 getBotonera: function() { }, 1400 }
1396 getCotizacionByIdMoneda: function() { 1401 },
1397 return { 1402 focaBotoneraLateralService: {},
1398 then: function() { } 1403 focaModalService: {},
1399 }; 1404 notaPedidoBusinessService: {},
1400 } 1405 $rootScope: {
1401 }, 1406 $on: function() { }
1402 focaBotoneraLateralService: {}, 1407 },
1403 focaModalService: {}, 1408 focaSeguimientoService: {},
1404 notaPedidoBusinessService: {}, 1409 APP: {},
1405 $rootScope: { 1410 focaLoginService: {},
1406 $on: function() { } 1411 $localStorage: {}
1407 }, 1412 });
1408 focaSeguimientoService: {}, 1413
1409 APP: {}, 1414 scope.notaPedido = {};
1410 focaLoginService: {}, 1415
1411 $localStorage: {} 1416 var respuesta = { result: {then: function() { } } };
1412 }); 1417
1413 1418 //act
1414 scope.notaPedido = {}; 1419 spyOn(uibModal, 'open').and.returnValue(respuesta);
1415 1420 scope.abrirModalCotizacion();
1416 var respuesta = { result: {then: function() { } } }; 1421
1417 1422 //assert
1418 //act 1423 expect(uibModal.open).toHaveBeenCalled();
1419 spyOn(uibModal, 'open').and.returnValue(respuesta); 1424 });
1420 scope.abrirModalCotizacion(); 1425
1421 1426 it('función abrirModalCotizacion setea datos y cabecera', function(done) {
1422 //assert 1427 //arrange
1423 expect(uibModal.open).toHaveBeenCalled(); 1428 var scope = {
1424 }); 1429 $watch: function() { },
1425 1430 $broadcast: function() { }
1426 it('función abrirModalCotizacion setea datos y cabecera', function(done) { 1431 };
1427 //arrange 1432 var uibModal = {
1428 var scope = { 1433 open: function() { }
1429 $watch: function() { }, 1434 };
1430 $broadcast: function() { } 1435
1431 }; 1436 $controler('notaPedidoCtrl', {
1432 var uibModal = { 1437 $scope: scope,
1433 open: function() { } 1438 $uibModal: uibModal,
1434 }; 1439 $location: {},
1435 1440 $filter: filter,
1436 $controler('notaPedidoCtrl', { 1441 $timeout: timeout,
1437 $scope: scope, 1442 crearNotaPedidoService: {
1438 $uibModal: uibModal, 1443 getNumeroNotaPedido: function() {
1439 $location: {}, 1444 return {
1440 $filter: filter, 1445 then: function() { }
1441 $timeout: timeout, 1446 };
1442 crearNotaPedidoService: { 1447 },
1443 getNumeroNotaPedido: function() { 1448 getBotonera: function() { },
1444 return { 1449 getCotizacionByIdMoneda: function() {
1445 then: function() { } 1450 return {
1446 }; 1451 then: function() { }
1447 }, 1452 };
1448 getBotonera: function() { }, 1453 }
1449 getCotizacionByIdMoneda: function() { 1454 },
1450 return { 1455 focaBotoneraLateralService: {},
1451 then: function() { } 1456 focaModalService: {},
1452 }; 1457 notaPedidoBusinessService: {},
1453 } 1458 $rootScope: {
1454 }, 1459 $on: function() { }
1455 focaBotoneraLateralService: {}, 1460 },
1456 focaModalService: {}, 1461 focaSeguimientoService: {},
1457 notaPedidoBusinessService: {}, 1462 APP: {},
1458 $rootScope: { 1463 focaLoginService: {},
1459 $on: function() { } 1464 $localStorage: {},
1460 }, 1465 articulosNotaPedido: []
1461 focaSeguimientoService: {}, 1466 });
1462 APP: {}, 1467
1463 focaLoginService: {}, 1468 scope.notaPedido = {};
1464 $localStorage: {}, 1469 scope.articulosTabla = [];
1465 articulosNotaPedido: [] 1470 scope.$broadcast = function() { };
1466 }); 1471 var moneda = 'moneda';
1467 1472 var cotizacion = 'test';
1468 scope.notaPedido = {}; 1473 var promesaRespuesta = { result: Promise.resolve(cotizacion) };
1469 scope.articulosTabla = []; 1474
1470 scope.$broadcast = function() { }; 1475 //act
1471 var moneda = 'moneda'; 1476 spyOn(uibModal, 'open').and.returnValue(promesaRespuesta);
1472 var cotizacion = 'test'; 1477 spyOn(scope, '$broadcast');
1473 var promesaRespuesta = { result: Promise.resolve(cotizacion) }; 1478 scope.abrirModalCotizacion(moneda);
1474 1479
1475 //act 1480 //assert
1476 spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); 1481 promesaRespuesta.result.then(function() {
1477 spyOn(scope, '$broadcast'); 1482
1478 scope.abrirModalCotizacion(moneda); 1483 expect(scope.$broadcast).toHaveBeenCalled();
1479 1484 expect(scope.notaPedido.cotizacion).toEqual(cotizacion);
1480 //assert 1485 done();
1481 promesaRespuesta.result.then(function() { 1486 });
1482 1487 });
1483 expect(scope.$broadcast).toHaveBeenCalled(); 1488
1484 expect(scope.notaPedido.cotizacion).toEqual(cotizacion); 1489 it('función agregarATabla muestra alerta cuando a cargar undefined', function() {
1485 done(); 1490
1486 }); 1491 //arrange
1487 }); 1492 var scope = {
1488 1493 $watch: function() { },
1489 it('función agregarATabla muestra alerta cuando a cargar undefined', function() { 1494 $broadcast: function() { }
1490 1495 };
1491 //arrange 1496 var focaModalService = {
1492 var scope = { 1497 alert: function() { }
1493 $watch: function() { }, 1498 };
1494 $broadcast: function() { } 1499
1495 }; 1500 $controler('notaPedidoCtrl', {
1496 var focaModalService = { 1501 $scope: scope,
1497 alert: function() { } 1502 $uibModal: {},
1498 }; 1503 $location: {},
1499 1504 $filter: filter,
1500 $controler('notaPedidoCtrl', { 1505 $timeout: timeout,
1501 $scope: scope, 1506 crearNotaPedidoService: {
1502 $uibModal: {}, 1507 getNumeroNotaPedido: function() {
1503 $location: {}, 1508 return {
1504 $filter: filter, 1509 then: function() { }
1505 $timeout: timeout, 1510 };
1506 crearNotaPedidoService: { 1511 },
1507 getNumeroNotaPedido: function() { 1512 getBotonera: function() { },
1508 return { 1513 getCotizacionByIdMoneda: function() {
1509 then: function() { } 1514 return {
1510 }; 1515 then: function() { }
1511 }, 1516 };
1512 getBotonera: function() { }, 1517 }
1513 getCotizacionByIdMoneda: function() { 1518 },
1514 return { 1519 focaBotoneraLateralService: {},
1515 then: function() { } 1520 focaModalService: focaModalService,
1516 }; 1521 notaPedidoBusinessService: {},
1517 } 1522 $rootScope: {
1518 }, 1523 $on: function() { }
1519 focaBotoneraLateralService: {}, 1524 },
1520 focaModalService: focaModalService, 1525 focaSeguimientoService: {},
1521 notaPedidoBusinessService: {}, 1526 APP: {},
1522 $rootScope: { 1527 focaLoginService: {},
1523 $on: function() { } 1528 $localStorage: {}
1524 }, 1529 });
1525 focaSeguimientoService: {}, 1530 scope.articuloACargar = {};
1526 APP: {}, 1531
1527 focaLoginService: {}, 1532 //act
1528 $localStorage: {} 1533 spyOn(focaModalService, 'alert');
1529 }); 1534 scope.agregarATabla(13);
1530 scope.articuloACargar = {}; 1535
1531 1536 //assert
1532 //act 1537 expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1');
1533 spyOn(focaModalService, 'alert'); 1538 });
1534 scope.agregarATabla(13); 1539
1535 1540 it('función editarArticulo muestra alerta cuando a cargar es undefined', function() {
1536 //assert 1541
1537 expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1'); 1542 //arrange
1538 }); 1543 var scope = {
1539 1544 $watch: function() { },
1540 it('función editarArticulo muestra alerta cuando a cargar es undefined', function() { 1545 $broadcast: function() { }
1541 1546 };
1542 //arrange 1547 var focaModalService = {
1543 var scope = { 1548 alert: function() { }
1544 $watch: function() { }, 1549 };
1545 $broadcast: function() { } 1550
1546 }; 1551 $controler('notaPedidoCtrl', {
1547 var focaModalService = { 1552 $scope: scope,
1548 alert: function() { } 1553 $uibModal: {},
1549 }; 1554 $location: {},
1550 1555 $filter: filter,
1551 $controler('notaPedidoCtrl', { 1556 $timeout: timeout,
1552 $scope: scope, 1557 crearNotaPedidoService: {
1553 $uibModal: {}, 1558 getNumeroNotaPedido: function() {
1554 $location: {}, 1559 return {
1555 $filter: filter, 1560 then: function() { }
1556 $timeout: timeout, 1561 };
1557 crearNotaPedidoService: { 1562 },
1558 getNumeroNotaPedido: function() { 1563 getBotonera: function() { },
1559 return { 1564 getCotizacionByIdMoneda: function() {
1560 then: function() { } 1565 return {
1561 }; 1566 then: function() { }
1562 }, 1567 };
1563 getBotonera: function() { }, 1568 }
1564 getCotizacionByIdMoneda: function() { 1569 },
1565 return { 1570 focaBotoneraLateralService: {},
1566 then: function() { } 1571 focaModalService: focaModalService,
1567 }; 1572 notaPedidoBusinessService: {},
1568 } 1573 $rootScope: {
1569 }, 1574 $on: function() { }
1570 focaBotoneraLateralService: {}, 1575 },
1571 focaModalService: focaModalService, 1576 focaSeguimientoService: {},
1572 notaPedidoBusinessService: {}, 1577 APP: {},
1573 $rootScope: { 1578 focaLoginService: {},
1574 $on: function() { } 1579 $localStorage: {}
1575 }, 1580 });
1576 focaSeguimientoService: {}, 1581 scope.articuloACargar = {};
1577 APP: {}, 1582
1578 focaLoginService: {}, 1583 //act
1579 $localStorage: {} 1584 spyOn(focaModalService, 'alert');
1580 }); 1585 scope.agregarATabla(13);
1581 scope.articuloACargar = {}; 1586
1582 1587 //assert
1583 //act 1588 expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1');
1584 spyOn(focaModalService, 'alert'); 1589 });
1585 scope.agregarATabla(13); 1590
1586 1591 it('función salir lleva a ruta correcta', function() {
1587 //assert 1592
1588 expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1'); 1593 inject(function($location) {
1589 }); 1594
1590 1595 //arrange
1591 it('función salir lleva a ruta correcta', function() { 1596 var scope = {
1592 1597 $watch: function() { },
1593 inject(function($location) { 1598 $broadcast: function() { }
1594 1599 };
1595 //arrange 1600
1596 var scope = { 1601 $controler('notaPedidoCtrl', {
1597 $watch: function() { }, 1602 $scope: scope,
1598 $broadcast: function() { } 1603 $uibModal: {},
1599 }; 1604 $location: $location,
1600 1605 $filter: filter,
1601 $controler('notaPedidoCtrl', { 1606 $timeout: timeout,
1602 $scope: scope, 1607 crearNotaPedidoService: {
1603 $uibModal: {}, 1608 getNumeroNotaPedido: function() {
1604 $location: $location, 1609 return {
1605 $filter: filter, 1610 then: function() { }
1606 $timeout: timeout, 1611 };
1607 crearNotaPedidoService: { 1612 },
1608 getNumeroNotaPedido: function() { 1613 getBotonera: function() { },
1609 return { 1614 getCotizacionByIdMoneda: function() {
1610 then: function() { } 1615 return {
1611 }; 1616 then: function() { }
1612 }, 1617 };
1613 getBotonera: function() { }, 1618 }
1614 getCotizacionByIdMoneda: function() { 1619 },
1615 return { 1620 focaBotoneraLateralService: {},
1616 then: function() { } 1621 focaModalService: {},
1617 }; 1622 notaPedidoBusinessService: {},
1618 } 1623 $rootScope: {
1619 }, 1624 $on: function() { }
1620 focaBotoneraLateralService: {}, 1625 },
1621 focaModalService: {}, 1626 focaSeguimientoService: {},
1622 notaPedidoBusinessService: {}, 1627 APP: {},
1623 $rootScope: { 1628 focaLoginService: {},
1624 $on: function() { } 1629 $localStorage: {},
1625 }, 1630 });
1626 focaSeguimientoService: {}, 1631
1627 APP: {}, 1632 //act
1628 focaLoginService: {}, 1633 scope.salir();
1629 $localStorage: {}, 1634
1630 }); 1635 //assert
1631 1636 expect($location.url()).toEqual('/');
1632 //act 1637 });
1633 scope.salir(); 1638 });
1634 1639 });
1635 //assert 1640 });
1636 expect($location.url()).toEqual('/'); 1641
src/js/businessService.js
1 angular.module('focaCrearNotaPedido') 1 angular.module('focaCrearNotaPedido')
2 .factory('notaPedidoBusinessService', [ 2 .factory('notaPedidoBusinessService', [
3 'crearNotaPedidoService', 3 'crearNotaPedidoService',
4 function(crearNotaPedidoService) { 4 function(crearNotaPedidoService) {
5 return { 5 return {
6 addArticulos: function(articulosNotaPedido, idNotaPedido, cotizacion) { 6 addArticulos: function(articulosNotaPedido, idNotaPedido, cotizacion) {
7 for(var i = 0; i < articulosNotaPedido.length; i++) { 7 for(var i = 0; i < articulosNotaPedido.length; i++) {
8 delete articulosNotaPedido[i].editCantidad; 8 delete articulosNotaPedido[i].editCantidad;
9 delete articulosNotaPedido[i].editPrecio; 9 delete articulosNotaPedido[i].editPrecio;
10 articulosNotaPedido[i].idNotaPedido = idNotaPedido; 10 articulosNotaPedido[i].idNotaPedido = idNotaPedido;
11 articulosNotaPedido[i].precio = articulosNotaPedido[i].precio * cotizacion; 11 articulosNotaPedido[i].precio = articulosNotaPedido[i].precio * cotizacion;
12 crearNotaPedidoService.crearArticulosParaNotaPedido(articulosNotaPedido[i]); 12 crearNotaPedidoService.crearArticulosParaNotaPedido(articulosNotaPedido[i]);
13 } 13 }
14 }, 14 },
15 addEstado: function(idNotaPedido, idVendedor) { 15 addEstado: function(idNotaPedido, idVendedor) {
16 var date = new Date(); 16 var date = new Date();
17 var estado = { 17 var estado = {
18 idNotaPedido: idNotaPedido, 18 idNotaPedido: idNotaPedido,
19 fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) 19 fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000))
20 .toISOString().slice(0, 19).replace('T', ' '), 20 .toISOString().slice(0, 19).replace('T', ' '),
21 estado: 0, 21 estado: 0,
22 idVendedor: idVendedor 22 idVendedor: idVendedor
23 }; 23 };
24 crearNotaPedidoService.crearEstadoParaNotaPedido(estado); 24 crearNotaPedidoService.crearEstadoParaNotaPedido(estado);
25 }, 25 },
26 addPuntosDescarga: function(idNotaPedido, puntosDescarga) { 26 addPuntosDescarga: function(idNotaPedido, puntosDescarga) {
27
27 var puntos = []; 28 var puntos = [];
28 29
29 if (puntosDescarga && puntosDescarga.length > 0) { 30 puntosDescarga.forEach(function(punto) {
30 puntosDescarga.forEach(function(punto) { 31 puntos.push({
31 if (puntos.articulosAgregados && puntos.articulosAgregados.length > 0) { 32 idPuntoDescarga: punto.id,
32 punto.articulosAgregados.forEach(function(articulo) { 33 idNotaPedido: idNotaPedido,
33 puntos.push({
34 idPuntoDescarga: punto.id,
35 idNotaPedido: idNotaPedido,
36 idProducto: articulo.id,
37 cantidad: articulo.cantidad
38 });
39 });
40 }
41 }); 34 });
42 } 35 });
43 36
44 return crearNotaPedidoService.crearPuntosDescarga(puntos); 37 return crearNotaPedidoService.crearPuntosDescarga(puntos);
45 }, 38 },
46 calcularArticulos: function(articulos, cotizacion) { 39 calcularArticulos: function(articulos, cotizacion) {
47 for(var i = 0; i < articulos.length; i++) { 40 for(var i = 0; i < articulos.length; i++) {
48 articulos[i].precio = articulos[i].precio / cotizacion; 41 articulos[i].precio = articulos[i].precio / cotizacion;
49 } 42 }
50 }, 43 },
51 plazoToString: function(plazos) { 44 plazoToString: function(plazos) {
52 var result = ''; 45 var result = '';
53 for(var i = 0; i < plazos.length; i++) { 46 for(var i = 0; i < plazos.length; i++) {
54 result += plazos[i].dias + ' '; 47 result += plazos[i].dias + ' ';
55 } 48 }
56 return result.trim(); 49 return result.trim();
57 } 50 }
58 }; 51 };
59 }]); 52 }]);
src/js/controller.js
1 angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', 1 angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
2 [ 2 [
3 '$scope', 3 '$scope',
4 '$uibModal', 4 '$uibModal',
5 '$location', 5 '$location',
6 '$filter', 6 '$filter',
7 '$timeout', 7 '$timeout',
8 'crearNotaPedidoService', 8 'crearNotaPedidoService',
9 'focaBotoneraLateralService', 9 'focaBotoneraLateralService',
10 'focaModalService', 10 'focaModalService',
11 'notaPedidoBusinessService', 11 'notaPedidoBusinessService',
12 '$rootScope', 12 '$rootScope',
13 'focaSeguimientoService', 13 'focaSeguimientoService',
14 'APP', 14 'APP',
15 'focaLoginService', 15 'focaLoginService',
16 '$localStorage', 16 '$localStorage',
17 function( 17 function(
18 $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService, 18 $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService,
19 focaBotoneraLateralService, focaModalService, notaPedidoBusinessService, 19 focaBotoneraLateralService, focaModalService, notaPedidoBusinessService,
20 $rootScope, focaSeguimientoService, APP, focaLoginService, $localStorage) 20 $rootScope, focaSeguimientoService, APP, focaLoginService, $localStorage)
21 { 21 {
22 config(); 22 config();
23 23
24 function config() { 24 function config() {
25 // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA 25 // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA
26 $scope.notaPedido = {}; 26 $scope.notaPedido = {};
27 $scope.isNumber = angular.isNumber; 27 $scope.isNumber = angular.isNumber;
28 $scope.datepickerAbierto = false; 28 $scope.datepickerAbierto = false;
29 $scope.show = false; 29 $scope.show = false;
30 $scope.cargando = true; 30 $scope.cargando = true;
31 $scope.botonera = crearNotaPedidoService.getBotonera(); 31 $scope.botonera = crearNotaPedidoService.getBotonera();
32 $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); 32 $scope.puntoVenta = $filter('rellenarDigitos')(0, 4);
33 $scope.comprobante = $filter('rellenarDigitos')(0, 8); 33 $scope.comprobante = $filter('rellenarDigitos')(0, 8);
34 $scope.dateOptions = { 34 $scope.dateOptions = {
35 maxDate: new Date(), 35 maxDate: new Date(),
36 minDate: new Date(2010, 0, 1) 36 minDate: new Date(2010, 0, 1)
37 }; 37 };
38 38
39 //SETEO BOTONERA LATERAL 39 //SETEO BOTONERA LATERAL
40 $timeout(function() { 40 $timeout(function() {
41 focaBotoneraLateralService.showSalir(false); 41 focaBotoneraLateralService.showSalir(false);
42 focaBotoneraLateralService.showPausar(true); 42 focaBotoneraLateralService.showPausar(true);
43 focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); 43 focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido);
44 focaBotoneraLateralService.addCustomButton('Salir', salir); 44 focaBotoneraLateralService.addCustomButton('Salir', salir);
45 }); 45 });
46 46
47 // SETEA BOTONERA DE FACTURADOR TENIENDO EN CUENTA SI ESTA SETEADO EL VENDEDOR 47 // SETEA BOTONERA DE FACTURADOR TENIENDO EN CUENTA SI ESTA SETEADO EL VENDEDOR
48 if (APP === 'distribuidor') { 48 if (APP === 'distribuidor') {
49 $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; 49 $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador;
50 } 50 }
51 51
52 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' 52 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
53 crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { 53 crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) {
54 var monedaPorDefecto = res.data[0]; 54 var monedaPorDefecto = res.data[0];
55
56 $scope.notaPedido.cotizacion = Object.assign( 55 $scope.notaPedido.cotizacion = Object.assign(
57 {moneda: monedaPorDefecto}, 56 {moneda: monedaPorDefecto},
58 monedaPorDefecto.cotizaciones[0] 57 monedaPorDefecto.cotizaciones[0]
59 ); 58 );
60 $scope.inicial.cotizacion = $scope.notaPedido.cotizacion; 59 $scope.inicial.cotizacion = $scope.notaPedido.cotizacion;
60 $timeout(function() {getLSNotaPedido();});
61 }); 61 });
62 62
63 init(); 63 init();
64 $timeout(function() {getLSNotaPedido();}); 64
65 } 65 }
66 66
67 function init() { 67 function init() {
68 $scope.$broadcast('cleanCabecera'); 68 $scope.$broadcast('cleanCabecera');
69 69
70 $scope.notaPedido = { 70 $scope.notaPedido = {
71 id: 0, 71 id: 0,
72 cliente: {}, 72 cliente: {},
73 proveedor: {}, 73 proveedor: {},
74 domicilio: {dom: ''}, 74 domicilio: {dom: ''},
75 vendedor: {}, 75 vendedor: {},
76 fechaCarga: new Date(), 76 fechaCarga: new Date(),
77 cotizacion: {}, 77 cotizacion: {},
78 articulosNotaPedido: [], 78 articulosNotaPedido: [],
79 notaPedidoPlazo: [] 79 notaPedidoPlazo: []
80 }; 80 };
81 $scope.idLista = undefined; 81 $scope.idLista = undefined;
82 82
83 crearNotaPedidoService.getNumeroNotaPedido().then( 83 crearNotaPedidoService.getNumeroNotaPedido().then(
84 function(res) { 84 function(res) {
85 $scope.puntoVenta = $filter('rellenarDigitos')( 85 $scope.puntoVenta = $filter('rellenarDigitos')(
86 res.data.sucursal, 4 86 res.data.sucursal, 4
87 ); 87 );
88 88
89 $scope.comprobante = $filter('rellenarDigitos')( 89 $scope.comprobante = $filter('rellenarDigitos')(
90 res.data.numeroNotaPedido, 8 90 res.data.numeroNotaPedido, 8
91 ); 91 );
92 }, 92 },
93 function(err) { 93 function(err) {
94 focaModalService.alert('La terminal no esta configurada correctamente'); 94 focaModalService.alert('La terminal no esta configurada correctamente');
95 console.info(err); 95 console.info(err);
96 } 96 }
97 ); 97 );
98 98
99 if (APP === 'distribuidor') { 99 if (APP === 'distribuidor') {
100 crearNotaPedidoService.getVendedorById($scope.idVendedor).then( 100 crearNotaPedidoService.getVendedorById($scope.idVendedor).then(
101 function(res) { 101 function(res) {
102 var vendedor = res.data; 102 var vendedor = res.data;
103 $scope.$broadcast('addCabecera', { 103 $scope.$broadcast('addCabecera', {
104 label: 'Vendedor:', 104 label: 'Vendedor:',
105 valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + 105 valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' +
106 vendedor.NOM 106 vendedor.NOM
107 }); 107 });
108 108
109 $scope.notaPedido.vendedor = vendedor; 109 $scope.notaPedido.vendedor = vendedor;
110 }
111 ); 110 }
112 } 111 );
113 112 }
114 $scope.inicial = angular.copy($scope.notaPedido); 113
115 } 114 $scope.inicial = angular.copy($scope.notaPedido);
116 115 }
117 $scope.$watch('notaPedido', function(newValue) { 116
118 focaBotoneraLateralService.setPausarData({ 117 $scope.$watch('notaPedido', function(newValue) {
119 label: 'notaPedido', 118 focaBotoneraLateralService.setPausarData({
120 val: newValue 119 label: 'notaPedido',
121 }); 120 val: newValue
122 }, true); 121 });
123 122 }, true);
124 $scope.crearNotaPedido = function() { 123
125 if (!$scope.notaPedido.cliente.COD) { 124 $scope.crearNotaPedido = function() {
126 focaModalService.alert('Ingrese Cliente'); 125 if (!$scope.notaPedido.cliente.COD) {
127 return; 126 focaModalService.alert('Ingrese Cliente');
128 } else if (!$scope.notaPedido.proveedor.COD) { 127 return;
129 focaModalService.alert('Ingrese Proveedor'); 128 } else if (!$scope.notaPedido.proveedor.COD) {
130 return; 129 focaModalService.alert('Ingrese Proveedor');
131 } else if (!$scope.notaPedido.cotizacion.ID) { 130 return;
132 focaModalService.alert('Ingrese Cotización'); 131 } else if (!$scope.notaPedido.cotizacion.ID) {
133 return; 132 focaModalService.alert('Ingrese Cotización');
134 } else if (!$scope.notaPedido.cotizacion.moneda.ID) { 133 return;
135 focaModalService.alert('Ingrese Moneda'); 134 } else if (!$scope.notaPedido.cotizacion.moneda.ID) {
136 return; 135 focaModalService.alert('Ingrese Moneda');
137 } else if (!$scope.notaPedido.notaPedidoPlazo) { 136 return;
138 focaModalService.alert('Ingrese Precios y Condiciones'); 137 } else if (!$scope.notaPedido.notaPedidoPlazo) {
139 return; 138 focaModalService.alert('Ingrese Precios y Condiciones');
140 } else if ( 139 return;
141 $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) 140 } else if (
142 { 141 $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null)
143 focaModalService.alert('Ingrese Flete'); 142 {
144 return; 143 focaModalService.alert('Ingrese Flete');
145 } else if (!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto 144 return;
146 focaModalService.alert('Ingrese Domicilio'); 145 } else if (!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto
147 return; 146 focaModalService.alert('Ingrese Domicilio');
148 } else if ($scope.notaPedido.articulosNotaPedido.length === 0) { 147 return;
149 focaModalService.alert('Debe cargar al menos un articulo'); 148 } else if ($scope.notaPedido.articulosNotaPedido.length === 0) {
150 return; 149 focaModalService.alert('Debe cargar al menos un articulo');
151 } 150 return;
152 focaBotoneraLateralService.startGuardar(); 151 }
153 $scope.saveLoading = true; 152 focaBotoneraLateralService.startGuardar();
154 var notaPedido = { 153 $scope.saveLoading = true;
155 id: $scope.notaPedido.id, 154 var notaPedido = {
156 fechaCarga: new Date($scope.notaPedido.fechaCarga) 155 id: $scope.notaPedido.id,
157 .toISOString().slice(0, 19).replace('T', ' '), 156 fechaCarga: new Date($scope.notaPedido.fechaCarga)
158 idVendedor: $scope.notaPedido.vendedor.id, 157 .toISOString().slice(0, 19).replace('T', ' '),
159 idCliente: $scope.notaPedido.cliente.COD, 158 idVendedor: $scope.notaPedido.vendedor.id,
160 nombreCliente: $scope.notaPedido.cliente.NOM, 159 idCliente: $scope.notaPedido.cliente.COD,
161 cuitCliente: $scope.notaPedido.cliente.CUIT, 160 nombreCliente: $scope.notaPedido.cliente.NOM,
162 idProveedor: $scope.notaPedido.proveedor.COD, 161 cuitCliente: $scope.notaPedido.cliente.CUIT,
163 idDomicilio: $scope.notaPedido.domicilio.id, 162 idProveedor: $scope.notaPedido.proveedor.COD,
164 idCotizacion: $scope.notaPedido.cotizacion.ID, 163 idDomicilio: $scope.notaPedido.domicilio.id,
165 idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, 164 idCotizacion: $scope.notaPedido.cotizacion.ID,
166 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, 165 idPrecioCondicion: $scope.notaPedido.idPrecioCondicion,
167 flete: $scope.notaPedido.flete, 166 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR,
168 fob: $scope.notaPedido.fob, 167 flete: $scope.notaPedido.flete,
169 bomba: $scope.notaPedido.bomba, 168 fob: $scope.notaPedido.fob,
170 kilometros: $scope.notaPedido.kilometros, 169 bomba: $scope.notaPedido.bomba,
171 domicilioStamp: $scope.notaPedido.domicilioStamp, 170 kilometros: $scope.notaPedido.kilometros,
172 observaciones: $scope.notaPedido.observaciones, 171 domicilioStamp: $scope.notaPedido.domicilioStamp,
173 estado: 0, 172 observaciones: $scope.notaPedido.observaciones,
174 total: $scope.getTotal() 173 estado: 0,
175 }; 174 total: $scope.getTotal()
176 crearNotaPedidoService.crearNotaPedido(notaPedido).then( 175 };
177 function(data) { 176 crearNotaPedidoService.crearNotaPedido(notaPedido).then(
178 // Al guardar los datos de la nota de pedido logueamos la 177 function(data) {
179 // actividad para su seguimiento. 178 // Al guardar los datos de la nota de pedido logueamos la
180 //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? 179 // actividad para su seguimiento.
181 focaSeguimientoService.guardarPosicion( 180 //TODO: GUARDAR POSISIONAMIENTO AL EDITAR?
182 'Nota de pedido', 181 focaSeguimientoService.guardarPosicion(
183 data.data.id, 182 'Nota de pedido',
184 '' 183 data.data.id,
185 ); 184 ''
186 notaPedidoBusinessService.addArticulos( 185 );
187 $scope.notaPedido.articulosNotaPedido, 186 notaPedidoBusinessService.addArticulos(
188 data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); 187 $scope.notaPedido.articulosNotaPedido,
189 188 data.data.id, $scope.notaPedido.cotizacion.VENDEDOR);
190 if ($scope.notaPedido.notaPedidoPuntoDescarga) { 189
191 notaPedidoBusinessService.addPuntosDescarga(data.data.id, 190 if ($scope.notaPedido.notaPedidoPuntoDescarga) {
192 $scope.notaPedido.notaPedidoPuntoDescarga); 191 notaPedidoBusinessService.addPuntosDescarga(data.data.id,
193 } 192 $scope.notaPedido.notaPedidoPuntoDescarga);
194 193 }
195 var plazos = $scope.notaPedido.notaPedidoPlazo; 194
196 var plazosACrear = []; 195 var plazos = $scope.notaPedido.notaPedidoPlazo;
197 plazos.forEach(function(plazo) { 196 var plazosACrear = [];
198 plazosACrear.push({ 197 plazos.forEach(function(plazo) {
199 idNotaPedido: data.data.id, 198 plazosACrear.push({
200 dias: plazo.dias 199 idNotaPedido: data.data.id,
201 }); 200 dias: plazo.dias
202 }); 201 });
203 202 });
204 if (plazosACrear.length) { 203
205 crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); 204 if (plazosACrear.length) {
206 } 205 crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear);
207 206 }
208 notaPedidoBusinessService.addEstado(data.data.id, 207
209 $scope.notaPedido.vendedor.id); 208 notaPedidoBusinessService.addEstado(data.data.id,
210 209 $scope.notaPedido.vendedor.id);
211 focaBotoneraLateralService.endGuardar(true); 210
212 $scope.saveLoading = false; 211 focaBotoneraLateralService.endGuardar(true);
213 212 $scope.saveLoading = false;
214 init(); 213
215 }, function(error) { 214 init();
216 focaModalService.alert('Hubo un error al crear la nota de pedido'); 215 }, function(error) {
217 focaBotoneraLateralService.endGuardar(); 216 focaModalService.alert('Hubo un error al crear la nota de pedido');
218 $scope.saveLoading = false; 217 focaBotoneraLateralService.endGuardar();
219 console.info(error); 218 $scope.saveLoading = false;
220 } 219 console.info(error);
221 ); 220 }
222 }; 221 );
223 222 };
224 $scope.seleccionarNotaPedido = function() { 223
225 var modalInstance = $uibModal.open( 224 $scope.seleccionarNotaPedido = function() {
226 { 225 var modalInstance = $uibModal.open(
227 ariaLabelledBy: 'Busqueda de Nota de Pedido', 226 {
228 templateUrl: 'foca-modal-nota-pedido.html', 227 ariaLabelledBy: 'Busqueda de Nota de Pedido',
229 controller: 'focaModalNotaPedidoController', 228 templateUrl: 'foca-modal-nota-pedido.html',
230 size: 'lg', 229 controller: 'focaModalNotaPedidoController',
231 resolve: { 230 size: 'lg',
232 usadoPor: function() {return 'notaPedido';}, 231 resolve: {
233 idVendedor: function() { 232 usadoPor: function() {return 'notaPedido';},
234 if (APP === 'distribuidor') 233 idVendedor: function() {
235 return $scope.notaPedido.vendedor.id; 234 if (APP === 'distribuidor')
236 else 235 return $scope.notaPedido.vendedor.id;
237 return null; 236 else
238 } 237 return null;
239 } 238 }
240 } 239 }
241 ); 240 }
242 modalInstance.result.then(setearNotaPedido); 241 );
243 }; 242 modalInstance.result.then(setearNotaPedido);
244 243 };
245 $scope.seleccionarProductos = function() { 244
246 if ($scope.idLista === undefined) { 245 $scope.seleccionarProductos = function() {
247 focaModalService.alert( 246 if ($scope.idLista === undefined) {
248 'Primero seleccione una lista de precio y condicion'); 247 focaModalService.alert(
249 return; 248 'Primero seleccione una lista de precio y condicion');
250 } 249 return;
251 var modalInstance = $uibModal.open( 250 }
252 { 251 var modalInstance = $uibModal.open(
253 ariaLabelledBy: 'Busqueda de Productos', 252 {
254 templateUrl: 'modal-busqueda-productos.html', 253 ariaLabelledBy: 'Busqueda de Productos',
255 controller: 'modalBusquedaProductosCtrl', 254 templateUrl: 'modal-busqueda-productos.html',
256 resolve: { 255 controller: 'modalBusquedaProductosCtrl',
257 parametroProducto: { 256 resolve: {
258 idLista: $scope.idLista, 257 parametroProducto: {
259 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, 258 idLista: $scope.idLista,
260 simbolo: $scope.notaPedido.cotizacion.moneda.SIMBOLO 259 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR,
261 } 260 simbolo: $scope.notaPedido.cotizacion.moneda.SIMBOLO
262 }, 261 }
263 size: 'lg' 262 },
264 } 263 size: 'lg'
265 ); 264 }
266 modalInstance.result.then( 265 );
267 function(producto) { 266 modalInstance.result.then(
268 var newArt = 267 function(producto) {
269 { 268 var newArt =
270 id: 0, 269 {
271 codigo: producto.codigo, 270 id: 0,
272 sector: producto.sector, 271 codigo: producto.codigo,
273 sectorCodigo: producto.sector + '-' + producto.codigo, 272 sector: producto.sector,
274 descripcion: producto.descripcion, 273 sectorCodigo: producto.sector + '-' + producto.codigo,
275 item: $scope.notaPedido.articulosNotaPedido.length + 1, 274 descripcion: producto.descripcion,
276 nombre: producto.descripcion, 275 item: $scope.notaPedido.articulosNotaPedido.length + 1,
277 precio: parseFloat(producto.precio.toFixed(4)), 276 nombre: producto.descripcion,
278 costoUnitario: producto.costo, 277 precio: parseFloat(producto.precio.toFixed(4)),
279 editCantidad: false, 278 costoUnitario: producto.costo,
280 editPrecio: false, 279 editCantidad: false,
281 rubro: producto.CodRub, 280 editPrecio: false,
282 exentoUnitario: producto.precio, 281 rubro: producto.CodRub,
283 ivaUnitario: producto.IMPIVA, 282 exentoUnitario: producto.precio,
284 impuestoInternoUnitario: producto.ImpInt, 283 ivaUnitario: producto.IMPIVA,
285 impuestoInterno1Unitario: producto.ImpInt2, 284 impuestoInternoUnitario: producto.ImpInt,
286 impuestoInterno2Unitario: producto.ImpInt3, 285 impuestoInterno1Unitario: producto.ImpInt2,
287 precioLista: producto.precio, 286 impuestoInterno2Unitario: producto.ImpInt3,
288 combustible: 1, 287 precioLista: producto.precio,
289 facturado: 0, 288 combustible: 1,
290 idArticulo: producto.id 289 facturado: 0,
291 }; 290 idArticulo: producto.id
292 $scope.articuloACargar = newArt; 291 };
293 $scope.cargando = false; 292 $scope.articuloACargar = newArt;
294 }, function() { 293 $scope.cargando = false;
295 // funcion ejecutada cuando se cancela el modal 294 }, function() {
296 } 295 // funcion ejecutada cuando se cancela el modal
297 ); 296 }
298 }; 297 );
299 298 };
300 $scope.seleccionarPuntosDeDescarga = function() { 299
301 if (!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { 300 $scope.seleccionarPuntosDeDescarga = function() {
302 focaModalService.alert('Primero seleccione un cliente y un domicilio'); 301 if (!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) {
303 return; 302 focaModalService.alert('Primero seleccione un cliente y un domicilio');
304 } else { 303 return;
305 var modalInstance = $uibModal.open( 304 } else {
306 { 305 var modalInstance = $uibModal.open(
307 ariaLabelledBy: 'Búsqueda de Puntos de descarga', 306 {
308 templateUrl: 'modal-punto-descarga.html', 307 ariaLabelledBy: 'Búsqueda de Puntos de descarga',
309 controller: 'focaModalPuntoDescargaController', 308 templateUrl: 'modal-punto-descarga.html',
310 size: 'lg', 309 controller: 'focaModalPuntoDescargaController',
311 resolve: { 310 size: 'lg',
312 filters: { 311 resolve: {
313 idDomicilio: $scope.notaPedido.domicilio.id, 312 filters: {
314 idCliente: $scope.notaPedido.cliente.COD, 313 idDomicilio: $scope.notaPedido.domicilio.id,
315 articulos: $scope.notaPedido.articulosNotaPedido, 314 idCliente: $scope.notaPedido.cliente.COD,
316 puntosDescarga: $scope.notaPedido.notaPedidoPuntoDescarga 315 articulos: $scope.notaPedido.articulosNotaPedido,
317 } 316 puntosDescarga: $scope.notaPedido.notaPedidoPuntoDescarga,
317 domicilio: $scope.notaPedido.domicilio
318 } 318 }
319 } 319 }
320 ); 320 }
321 modalInstance.result.then( 321 );
322 function(puntosDescarga) { 322 modalInstance.result.then(
323 $scope.notaPedido.notaPedidoPuntoDescarga = puntosDescarga; 323 function(puntosDescarga) {
324 324 $scope.notaPedido.notaPedidoPuntoDescarga = puntosDescarga;
325 //AGREGO PUNTOS DE DESCARGA A CABECERA 325
326 var puntosStamp = ''; 326 //AGREGO PUNTOS DE DESCARGA A CABECERA
327 puntosDescarga.forEach(function(punto, idx, arr) { 327 var puntosStamp = '';
328 puntosStamp += punto.descripcion; 328 puntosDescarga.forEach(function(punto, idx, arr) {
329 if ((idx + 1) !== arr.length) puntosStamp += ', '; 329 puntosStamp += punto.descripcion;
330 }); 330 if ((idx + 1) !== arr.length) puntosStamp += ', ';
331 331 });
332 $scope.$broadcast('addCabecera', { 332
333 label: 'Puntos de descarga:', 333 $scope.$broadcast('addCabecera', {
334 valor: puntosStamp 334 label: 'Puntos de descarga:',
335 }); 335 valor: puntosStamp
336 }, function() { 336 });
337 $scope.abrirModalDomicilios($scope.cliente); 337 }, function() {
338 } 338 $scope.abrirModalDomicilios($scope.cliente);
339 ); 339 }
340 } 340 );
341 }; 341 }
342 342 };
343 $scope.seleccionarProveedor = function() { 343
344 $scope.abrirModalProveedores(function() { 344 $scope.seleccionarProveedor = function() {
345 if (validarNotaRemitada()) { 345 $scope.abrirModalProveedores(function() {
346 var modalInstance = $uibModal.open( 346 if (validarNotaRemitada()) {
347 { 347 var modalInstance = $uibModal.open(
348 ariaLabelledBy: 'Busqueda de Flete', 348 {
349 templateUrl: 'modal-flete.html', 349 ariaLabelledBy: 'Busqueda de Flete',
350 controller: 'focaModalFleteController', 350 templateUrl: 'modal-flete.html',
351 size: 'lg', 351 controller: 'focaModalFleteController',
352 resolve: { 352 size: 'lg',
353 parametrosFlete: 353 resolve: {
354 function() { 354 parametrosFlete:
355 return { 355 function() {
356 flete: $scope.notaPedido.fob ? 'FOB' : 356 return {
357 ( $scope.notaPedido.flete ? '1' : 357 flete: $scope.notaPedido.fob ? 'FOB' :
358 ($scope.notaPedido.flete === undefined ? 358 ( $scope.notaPedido.flete ? '1' :
359 null : '0')), 359 ($scope.notaPedido.flete === undefined ?
360 bomba: $scope.notaPedido.bomba ? '1' : 360 null : '0')),
361 ($scope.notaPedido.bomba === undefined ? 361 bomba: $scope.notaPedido.bomba ? '1' :
362 null : '0'), 362 ($scope.notaPedido.bomba === undefined ?
363 kilometros: $scope.notaPedido.kilometros 363 null : '0'),
364 }; 364 kilometros: $scope.notaPedido.kilometros
365 } 365 };
366 } 366 }
367 } 367 }
368 ); 368 }
369 modalInstance.result.then( 369 );
370 function(datos) { 370 modalInstance.result.then(
371 $scope.notaPedido.flete = datos.flete; 371 function(datos) {
372 $scope.notaPedido.fob = datos.FOB; 372 $scope.notaPedido.flete = datos.flete;
373 $scope.notaPedido.bomba = datos.bomba; 373 $scope.notaPedido.fob = datos.FOB;
374 $scope.notaPedido.kilometros = datos.kilometros; 374 $scope.notaPedido.bomba = datos.bomba;
375 $scope.$broadcast('addCabecera', { 375 $scope.notaPedido.kilometros = datos.kilometros;
376 label: 'Flete:', 376 $scope.$broadcast('addCabecera', {
377 valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') 377 label: 'Flete:',
378 }); 378 valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No')
379 if (datos.flete) { 379 });
380 $scope.$broadcast('addCabecera', { 380 if (datos.flete) {
381 label: 'Bomba:', 381 $scope.$broadcast('addCabecera', {
382 valor: datos.bomba ? 'Si' : 'No' 382 label: 'Bomba:',
383 }); 383 valor: datos.bomba ? 'Si' : 'No'
384 $scope.$broadcast('addCabecera', { 384 });
385 label: 'Kilometros:', 385 $scope.$broadcast('addCabecera', {
386 valor: datos.kilometros 386 label: 'Kilometros:',
387 }); 387 valor: datos.kilometros
388 } else { 388 });
389 $scope.$broadcast('removeCabecera', 'Bomba:'); 389 } else {
390 $scope.$broadcast('removeCabecera', 'Kilometros:'); 390 $scope.$broadcast('removeCabecera', 'Bomba:');
391 $scope.notaPedido.bomba = false; 391 $scope.$broadcast('removeCabecera', 'Kilometros:');
392 $scope.notaPedido.kilometros = null; 392 $scope.notaPedido.bomba = false;
393 } 393 $scope.notaPedido.kilometros = null;
394 }, function() { 394 }
395 $scope.seleccionarTransportista(); 395 }, function() {
396 } 396 $scope.seleccionarTransportista();
397 ); 397 }
398 } 398 );
399 }); 399 }
400 }; 400 });
401 401 };
402 $scope.seleccionarVendedor = function(callback, ocultarVendedor) { 402
403 if (APP === 'distribuidor' || ocultarVendedor) { 403 $scope.seleccionarVendedor = function(callback, ocultarVendedor) {
404 callback(); 404 if (APP === 'distribuidor' || ocultarVendedor) {
405 return; 405 callback();
406 } 406 return;
407 407 }
408 if (validarNotaRemitada()) { 408
409 var parametrosModal = { 409 if (validarNotaRemitada()) {
410 titulo: 'Búsqueda vendedores', 410 var parametrosModal = {
411 query: '/vendedor', 411 titulo: 'Búsqueda vendedores',
412 columnas: [ 412 query: '/vendedor',
413 { 413 columnas: [
414 propiedad: 'NUM', 414 {
415 nombre: 'Código', 415 propiedad: 'NUM',
416 filtro: { 416 nombre: 'Código',
417 nombre: 'rellenarDigitos', 417 filtro: {
418 parametro: 3 418 nombre: 'rellenarDigitos',
419 } 419 parametro: 3
420 }, 420 }
421 { 421 },
422 propiedad: 'NOM', 422 {
423 nombre: 'Nombre' 423 propiedad: 'NOM',
424 } 424 nombre: 'Nombre'
425 ], 425 }
426 size: 'md' 426 ],
427 }; 427 size: 'md'
428 focaModalService.modal(parametrosModal).then( 428 };
429 function(vendedor) { 429 focaModalService.modal(parametrosModal).then(
430 $scope.$broadcast('addCabecera', { 430 function(vendedor) {
431 label: 'Vendedor:', 431 $scope.$broadcast('addCabecera', {
432 valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + 432 label: 'Vendedor:',
433 vendedor.NOM 433 valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' +
434 }); 434 vendedor.NOM
435 $scope.notaPedido.vendedor = vendedor; 435 });
436 deleteCliente(); 436 $scope.notaPedido.vendedor = vendedor;
437 callback(); 437 deleteCliente();
438 }, function() {} 438 callback();
439 ); 439 }, function() {}
440 } 440 );
441 }; 441 }
442 442 };
443 $scope.seleccionarCliente = function(ocultarVendedor) { 443
444 $scope.seleccionarVendedor(function() { 444 $scope.seleccionarCliente = function(ocultarVendedor) {
445 if (validarNotaRemitada()) { 445 $scope.seleccionarVendedor(function() {
446 var modalInstance = $uibModal.open( 446 if (validarNotaRemitada()) {
447 { 447 var modalInstance = $uibModal.open(
448 ariaLabelledBy: 'Busqueda de Cliente', 448 {
449 templateUrl: 'foca-busqueda-cliente-modal.html', 449 ariaLabelledBy: 'Busqueda de Cliente',
450 controller: 'focaBusquedaClienteModalController', 450 templateUrl: 'foca-busqueda-cliente-modal.html',
451 resolve: { 451 controller: 'focaBusquedaClienteModalController',
452 vendedor: function() { return $scope.notaPedido.vendedor; }, 452 resolve: {
453 cobrador: function() { return null; } 453 vendedor: function() { return $scope.notaPedido.vendedor; },
454 }, 454 cobrador: function() { return null; }
455 size: 'lg' 455 },
456 } 456 size: 'lg'
457 ); 457 }
458 modalInstance.result.then( 458 );
459 function(cliente) { 459 modalInstance.result.then(
460 $scope.abrirModalDomicilios(cliente); 460 function(cliente) {
461 $scope.cliente = cliente; 461 $scope.abrirModalDomicilios(cliente);
462 }, function() { 462 $scope.cliente = cliente;
463 if (APP !== 'distribuidor') $scope.seleccionarCliente(); 463 }, function() {
464 } 464 if (APP !== 'distribuidor') $scope.seleccionarCliente();
465 ); 465 }
466 } 466 );
467 }, ocultarVendedor); 467 }
468 }; 468 }, ocultarVendedor);
469 469 };
470 $scope.abrirModalProveedores = function(callback) { 470
471 if (validarNotaRemitada()) { 471 $scope.abrirModalProveedores = function(callback) {
472 var parametrosModal = { 472 if (validarNotaRemitada()) {
473 titulo: 'Búsqueda de Proveedor', 473 var parametrosModal = {
474 query: '/proveedor', 474 titulo: 'Búsqueda de Proveedor',
475 columnas: [ 475 query: '/proveedor',
476 { 476 columnas: [
477 nombre: 'Código', 477 {
478 propiedad: 'COD', 478 nombre: 'Código',
479 filtro: { 479 propiedad: 'COD',
480 nombre: 'rellenarDigitos', 480 filtro: {
481 parametro: 5 481 nombre: 'rellenarDigitos',
482 } 482 parametro: 5
483 }, 483 }
484 { 484 },
485 nombre: 'Nombre', 485 {
486 propiedad: 'NOM' 486 nombre: 'Nombre',
487 }, 487 propiedad: 'NOM'
488 { 488 },
489 nombre: 'CUIT', 489 {
490 propiedad: 'CUIT' 490 nombre: 'CUIT',
491 } 491 propiedad: 'CUIT'
492 ], 492 }
493 tipo: 'POST', 493 ],
494 json: {razonCuitCod: ''} 494 tipo: 'POST',
495 }; 495 json: {razonCuitCod: ''}
496 focaModalService.modal(parametrosModal).then( 496 };
497 function(proveedor) { 497 focaModalService.modal(parametrosModal).then(
498 $scope.notaPedido.proveedor = proveedor; 498 function(proveedor) {
499 $scope.$broadcast('addCabecera', { 499 $scope.notaPedido.proveedor = proveedor;
500 label: 'Proveedor:', 500 $scope.$broadcast('addCabecera', {
501 valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + 501 label: 'Proveedor:',
502 proveedor.NOM 502 valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' +
503 }); 503 proveedor.NOM
504 callback(); 504 });
505 }, function() { 505 callback();
506 506 }, function() {
507 } 507
508 ); 508 }
509 } 509 );
510 }; 510 }
511 511 };
512 $scope.abrirModalDomicilios = function(cliente) { 512
513 var modalInstanceDomicilio = $uibModal.open( 513 $scope.abrirModalDomicilios = function(cliente) {
514 { 514 var modalInstanceDomicilio = $uibModal.open(
515 ariaLabelledBy: 'Busqueda de Domicilios', 515 {
516 templateUrl: 'modal-domicilio.html', 516 ariaLabelledBy: 'Busqueda de Domicilios',
517 controller: 'focaModalDomicilioController', 517 templateUrl: 'modal-domicilio.html',
518 resolve: { 518 controller: 'focaModalDomicilioController',
519 idCliente: function() { return cliente.cod; }, 519 resolve: {
520 esNuevo: function() { return cliente.esNuevo; } 520 idCliente: function() { return cliente.cod; },
521 }, 521 esNuevo: function() { return cliente.esNuevo; }
522 size: 'lg', 522 },
523 } 523 size: 'lg',
524 ); 524 }
525 modalInstanceDomicilio.result.then( 525 );
526 function(domicilio) { 526 modalInstanceDomicilio.result.then(
527 $scope.notaPedido.domicilio = domicilio; 527 function(domicilio) {
528 $scope.notaPedido.cliente = { 528 $scope.notaPedido.domicilio = domicilio;
529 COD: cliente.cod, 529 $scope.notaPedido.cliente = {
530 CUIT: cliente.cuit, 530 COD: cliente.cod,
531 NOM: cliente.nom, 531 CUIT: cliente.cuit,
532 MOD: cliente.mod 532 NOM: cliente.nom,
533 }; 533 MOD: cliente.mod
534 var domicilioStamp = 534 };
535 domicilio.Calle + ' ' + domicilio.Numero + ', ' + 535 var domicilioStamp =
536 domicilio.Localidad + ', ' + domicilio.Provincia; 536 domicilio.Calle + ' ' + domicilio.Numero + ', ' +
537 $scope.notaPedido.domicilioStamp = domicilioStamp; 537 domicilio.Localidad + ', ' + domicilio.Provincia;
538 538 $scope.notaPedido.domicilioStamp = domicilioStamp;
539 $scope.notaPedido.notaPedidoPuntoDescarga = domicilio.puntosDescarga; 539
540 540 $scope.notaPedido.notaPedidoPuntoDescarga = domicilio.puntosDescarga;
541 $scope.$broadcast('addCabecera', { 541
542 label: 'Cliente:', 542 $scope.$broadcast('addCabecera', {
543 valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom 543 label: 'Cliente:',
544 }); 544 valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom
545 $scope.$broadcast('addCabecera', { 545 });
546 label: 'Domicilio:', 546 $scope.$broadcast('addCabecera', {
547 valor: domicilioStamp 547 label: 'Domicilio:',
548 }); 548 valor: domicilioStamp
549 if (domicilio.verPuntos) { 549 });
550 delete $scope.notaPedido.domicilio.verPuntos; 550 if (domicilio.verPuntos) {
551 $scope.seleccionarPuntosDeDescarga(); 551 delete $scope.notaPedido.domicilio.verPuntos;
552 } else { 552 $scope.seleccionarPuntosDeDescarga();
553 crearNotaPedidoService 553 } else {
554 .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) 554 crearNotaPedidoService
555 .then(function(res) { 555 .getPuntosDescargaByClienDom(domicilio.id, cliente.cod)
556 if (res.data.length) $scope.seleccionarPuntosDeDescarga(); 556 .then(function(res) {
557 }); 557 if (res.data.length) $scope.seleccionarPuntosDeDescarga();
558 } 558 });
559 }, function() { 559 }
560 $scope.seleccionarCliente(true); 560 }, function() {
561 return; 561 $scope.seleccionarCliente(true);
562 } 562 return;
563 ); 563 }
564 }; 564 );
565 565 };
566 $scope.getTotal = function() { 566
567 var total = 0; 567 $scope.getTotal = function() {
568 if ($scope.notaPedido.articulosNotaPedido) { 568 var total = 0;
569 var arrayTempArticulos = $scope.notaPedido.articulosNotaPedido; 569 if ($scope.notaPedido.articulosNotaPedido) {
570 for (var i = 0; i < arrayTempArticulos.length; i++) { 570 var arrayTempArticulos = $scope.notaPedido.articulosNotaPedido;
571 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 571 for (var i = 0; i < arrayTempArticulos.length; i++) {
572 } 572 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
573 } 573 }
574 return parseFloat(total.toFixed(2)); 574 }
575 };
576 575 return parseFloat(total.toFixed(2));
577 $scope.getSubTotal = function() { 576 };
578 if ($scope.articuloACargar) { 577
579 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 578 $scope.getSubTotal = function() {
580 } 579 if ($scope.articuloACargar) {
581 }; 580 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
582 581 }
583 $scope.seleccionarPreciosYCondiciones = function() { 582 };
584 if (!$scope.notaPedido.cliente.COD) { 583
585 focaModalService.alert('Primero seleccione un cliente'); 584 $scope.seleccionarPreciosYCondiciones = function() {
586 return; 585 if (!$scope.notaPedido.cliente.COD) {
587 } 586 focaModalService.alert('Primero seleccione un cliente');
588 if (validarNotaRemitada()) { 587 return;
589 var modalInstance = $uibModal.open( 588 }
590 { 589 if (validarNotaRemitada()) {
591 ariaLabelledBy: 'Busqueda de Precio Condición', 590 var modalInstance = $uibModal.open(
592 templateUrl: 'modal-precio-condicion.html', 591 {
593 controller: 'focaModalPrecioCondicionController', 592 ariaLabelledBy: 'Busqueda de Precio Condición',
594 size: 'lg', 593 templateUrl: 'modal-precio-condicion.html',
595 resolve: { 594 controller: 'focaModalPrecioCondicionController',
596 idListaPrecio: function() { 595 size: 'lg',
597 return $scope.notaPedido.cliente.MOD || null; 596 resolve: {
598 } 597 idListaPrecio: function() {
599 } 598 return $scope.notaPedido.cliente.MOD || null;
600 } 599 }
601 ); 600 }
602 modalInstance.result.then( 601 }
603 function(precioCondicion) { 602 );
604 var cabecera = ''; 603 modalInstance.result.then(
605 var plazosConcat = ''; 604 function(precioCondicion) {
606 if (!Array.isArray(precioCondicion)) { 605 var cabecera = '';
607 $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; 606 var plazosConcat = '';
608 $scope.notaPedido.precioCondicion = precioCondicion; 607 if (!Array.isArray(precioCondicion)) {
609 $scope.notaPedido.idPrecioCondicion = precioCondicion.id; 608 $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago;
610 $scope.idLista = precioCondicion.idListaPrecio; 609 $scope.notaPedido.precioCondicion = precioCondicion;
611 for (var i = 0; i < precioCondicion.plazoPago.length; i++) { 610 $scope.notaPedido.idPrecioCondicion = precioCondicion.id;
612 plazosConcat += precioCondicion.plazoPago[i].dias + ' '; 611 $scope.idLista = precioCondicion.idListaPrecio;
613 } 612 for (var i = 0; i < precioCondicion.plazoPago.length; i++) {
614 cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + 613 plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
615 ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); 614 }
616 } else { //Cuando se ingresan los plazos manualmente 615 cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) +
617 $scope.notaPedido.idPrecioCondicion = 0; 616 ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim();
618 //-1, el modal productos busca todos los productos 617 } else { //Cuando se ingresan los plazos manualmente
619 $scope.idLista = -1; 618 $scope.notaPedido.idPrecioCondicion = 0;
620 $scope.notaPedido.notaPedidoPlazo = precioCondicion; 619 //-1, el modal productos busca todos los productos
621 for (var j = 0; j < precioCondicion.length; j++) { 620 $scope.idLista = -1;
622 plazosConcat += precioCondicion[j].dias + ' '; 621 $scope.notaPedido.notaPedidoPlazo = precioCondicion;
623 } 622 for (var j = 0; j < precioCondicion.length; j++) {
624 cabecera = 'Ingreso manual ' + plazosConcat.trim(); 623 plazosConcat += precioCondicion[j].dias + ' ';
625 } 624 }
626 $scope.notaPedido.articulosNotaPedido = []; 625 cabecera = 'Ingreso manual ' + plazosConcat.trim();
627 $scope.$broadcast('addCabecera', { 626 }
628 label: 'Precios y condiciones:', 627 $scope.notaPedido.articulosNotaPedido = [];
629 valor: cabecera 628 $scope.$broadcast('addCabecera', {
630 }); 629 label: 'Precios y condiciones:',
631 }, function() { 630 valor: cabecera
632 631 });
633 } 632 }, function() {
634 ); 633
635 } 634 }
636 }; 635 );
637 636 }
638 $scope.seleccionarMoneda = function() { 637 };
639 if (validarNotaRemitada()) { 638
640 var parametrosModal = { 639 $scope.seleccionarMoneda = function() {
641 titulo: 'Búsqueda de monedas', 640 if (validarNotaRemitada()) {
642 query: '/moneda', 641 var parametrosModal = {
643 columnas: [ 642 titulo: 'Búsqueda de monedas',
644 { 643 query: '/moneda',
645 propiedad: 'DETALLE', 644 columnas: [
646 nombre: 'Nombre' 645 {
647 }, 646 propiedad: 'DETALLE',
648 { 647 nombre: 'Nombre'
649 propiedad: 'SIMBOLO', 648 },
650 nombre: 'Símbolo' 649 {
651 } 650 propiedad: 'SIMBOLO',
652 ], 651 nombre: 'Símbolo'
653 size: 'md' 652 }
654 }; 653 ],
655 focaModalService.modal(parametrosModal).then( 654 size: 'md'
656 function(moneda) { 655 };
657 $scope.abrirModalCotizacion(moneda); 656 focaModalService.modal(parametrosModal).then(
658 }, function() { 657 function(moneda) {
659 658 $scope.abrirModalCotizacion(moneda);
660 } 659 }, function() {
661 ); 660
662 } 661 }
663 }; 662 );
664 663 }
665 $scope.seleccionarObservaciones = function() { 664 };
666 var observacion = { 665
667 titulo: 'Ingrese Observaciones', 666 $scope.seleccionarObservaciones = function() {
668 value: $scope.notaPedido.observaciones, 667 var observacion = {
669 maxlength: 155, 668 titulo: 'Ingrese Observaciones',
670 textarea: true 669 value: $scope.notaPedido.observaciones,
671 }; 670 maxlength: 155,
672 671 textarea: true
673 focaModalService 672 };
674 .prompt(observacion) 673
675 .then(function(observaciones) { 674 focaModalService
676 $scope.$broadcast('addCabecera', { 675 .prompt(observacion)
677 label: 'Observaciones:', 676 .then(function(observaciones) {
678 valor: observaciones
679 });
680 $scope.notaPedido.observaciones = observaciones;
681 });
682 }; 677 $scope.notaPedido.observaciones = observaciones;
683 678 });
684 $scope.abrirModalCotizacion = function(moneda) { 679 };
685 var modalInstance = $uibModal.open( 680
686 { 681 $scope.abrirModalCotizacion = function(moneda) {
687 ariaLabelledBy: 'Busqueda de Cotización', 682 var modalInstance = $uibModal.open(
688 templateUrl: 'modal-cotizacion.html', 683 {
689 controller: 'focaModalCotizacionController', 684 ariaLabelledBy: 'Busqueda de Cotización',
690 size: 'lg', 685 templateUrl: 'modal-cotizacion.html',
691 resolve: { 686 controller: 'focaModalCotizacionController',
692 idMoneda: function() { 687 size: 'lg',
693 return moneda.ID; 688 resolve: {
694 } 689 idMoneda: function() {
695 } 690 return moneda.ID;
696 } 691 }
697 ); 692 }
698 modalInstance.result.then( 693 }
699 function(cotizacion) { 694 );
700 var articulosTablaTemp = $scope.notaPedido.articulosNotaPedido || []; 695 modalInstance.result.then(
701 for (var i = 0; i < articulosTablaTemp.length; i++) { 696 function(cotizacion) {
702 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * 697 var articulosTablaTemp = $scope.notaPedido.articulosNotaPedido || [];
703 $scope.notaPedido.cotizacion.VENDEDOR; 698 for (var i = 0; i < articulosTablaTemp.length; i++) {
704 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / 699 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
705 cotizacion.VENDEDOR; 700 $scope.notaPedido.cotizacion.VENDEDOR;
706 } 701 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio /
707 $scope.notaPedido.articulosNotaPedido = articulosTablaTemp; 702 cotizacion.VENDEDOR;
708 $scope.notaPedido.cotizacion = cotizacion; 703 }
709 $scope.notaPedido.cotizacion.moneda = moneda; 704 $scope.notaPedido.articulosNotaPedido = articulosTablaTemp;
710 if (moneda.DETALLE === 'PESOS ARGENTINOS') { 705 $scope.notaPedido.cotizacion = cotizacion;
711 $scope.$broadcast('removeCabecera', 'Moneda:'); 706 $scope.notaPedido.cotizacion.moneda = moneda;
712 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); 707 if (moneda.DETALLE === 'PESOS ARGENTINOS') {
713 $scope.$broadcast('removeCabecera', 'Cotizacion:'); 708 $scope.$broadcast('removeCabecera', 'Moneda:');
714 } else { 709 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
715 $scope.$broadcast('addCabecera', { 710 $scope.$broadcast('removeCabecera', 'Cotizacion:');
716 label: 'Moneda:', 711 } else {
717 valor: moneda.DETALLE 712 $scope.$broadcast('addCabecera', {
718 }); 713 label: 'Moneda:',
719 $scope.$broadcast('addCabecera', { 714 valor: moneda.DETALLE
720 label: 'Fecha cotizacion:', 715 });
721 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 716 $scope.$broadcast('addCabecera', {
722 }); 717 label: 'Fecha cotizacion:',
723 $scope.$broadcast('addCabecera', { 718 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
724 label: 'Cotizacion:', 719 });
725 valor: $filter('number')(cotizacion.VENDEDOR, '2') 720 $scope.$broadcast('addCabecera', {
726 }); 721 label: 'Cotizacion:',
727 } 722 valor: $filter('number')(cotizacion.VENDEDOR, '2')
728 }, function() { 723 });
729 724 }
730 } 725 }, function() {
731 ); 726
732 }; 727 }
733 728 );
734 $scope.agregarATabla = function(key) { 729 };
735 if (key === 13) { 730
736 if ($scope.articuloACargar.cantidad === undefined || 731 $scope.agregarATabla = function(key) {
737 $scope.articuloACargar.cantidad === 0 || 732 if (key === 13) {
738 $scope.articuloACargar.cantidad === null ) { 733 if ($scope.articuloACargar.cantidad === undefined ||
739 focaModalService.alert('El valor debe ser al menos 1'); 734 $scope.articuloACargar.cantidad === 0 ||
740 return; 735 $scope.articuloACargar.cantidad === null ) {
741 } 736 focaModalService.alert('El valor debe ser al menos 1');
742 delete $scope.articuloACargar.sectorCodigo; 737 return;
743 $scope.notaPedido.articulosNotaPedido.push($scope.articuloACargar); 738 }
744 $scope.cargando = true; 739 delete $scope.articuloACargar.sectorCodigo;
745 } 740 $scope.notaPedido.articulosNotaPedido.push($scope.articuloACargar);
746 }; 741 $scope.cargando = true;
747 742 }
748 $scope.quitarArticulo = function(key) { 743 };
749 $scope.notaPedido.articulosNotaPedido.splice(key, 1); 744
750 }; 745 $scope.quitarArticulo = function(key) {
751 746 $scope.notaPedido.articulosNotaPedido.splice(key, 1);
752 $scope.editarArticulo = function(key, articulo) { 747 };
753 if (key === 13) { 748
754 if (articulo.cantidad === null || articulo.cantidad === 0 || 749 $scope.editarArticulo = function(key, articulo) {
755 articulo.cantidad === undefined) { 750 if (key === 13) {
756 focaModalService.alert('El valor debe ser al menos 1'); 751 if (articulo.cantidad === null || articulo.cantidad === 0 ||
757 return; 752 articulo.cantidad === undefined) {
758 } 753 focaModalService.alert('El valor debe ser al menos 1');
759 articulo.editCantidad = false; 754 return;
760 articulo.editPrecio = false; 755 }
761 } 756 articulo.editCantidad = false;
762 }; 757 articulo.editPrecio = false;
763 758 }
764 $scope.cambioEdit = function(articulo, propiedad) { 759 };
765 if (propiedad === 'cantidad') { 760
766 articulo.editCantidad = true; 761 $scope.cambioEdit = function(articulo, propiedad) {
767 } else if (propiedad === 'precio') { 762 if (propiedad === 'cantidad') {
768 articulo.editPrecio = true; 763 articulo.editCantidad = true;
769 } 764 } else if (propiedad === 'precio') {
770 }; 765 articulo.editPrecio = true;
771 766 }
772 $scope.resetFilter = function() { 767 };
773 $scope.articuloACargar = {}; 768
774 $scope.cargando = true; 769 $scope.resetFilter = function() {
775 }; 770 $scope.articuloACargar = {};
776 //Recibe aviso si el teclado está en uso 771 $scope.cargando = true;
777 $rootScope.$on('usarTeclado', function(event, data) { 772 };
778 if (data) { 773 //Recibe aviso si el teclado está en uso
779 $scope.mostrarTeclado = true; 774 $rootScope.$on('usarTeclado', function(event, data) {
780 return; 775 if (data) {
781 } 776 $scope.mostrarTeclado = true;
782 $scope.mostrarTeclado = false; 777 return;
783 }); 778 }
784 779 $scope.mostrarTeclado = false;
785 $scope.selectFocus = function($event) { 780 });
786 // Si el teclado esta en uso no selecciona el valor 781
787 if ($scope.mostrarTeclado) { 782 $scope.selectFocus = function($event) {
788 return; 783 // Si el teclado esta en uso no selecciona el valor
789 } 784 if ($scope.mostrarTeclado) {
790 $event.target.select(); 785 return;
791 }; 786 }
792 787 $event.target.select();
793 $scope.salir = function() { 788 };
794 $location.path('/'); 789
795 }; 790 $scope.salir = function() {
796 791 $location.path('/');
797 $scope.parsearATexto = function(articulo) { 792 };
798 articulo.cantidad = parseFloat(articulo.cantidad); 793
799 articulo.precio = parseFloat(articulo.precio); 794 $scope.parsearATexto = function(articulo) {
800 }; 795 articulo.cantidad = parseFloat(articulo.cantidad);
801 796 articulo.precio = parseFloat(articulo.precio);
802 function setearNotaPedido(notaPedido) { 797 };
803 //añado cabeceras 798
804 $scope.notaPedido = notaPedido; 799 function setearNotaPedido(notaPedido) {
805 if (!$scope.notaPedido.domicilio) { 800 //añado cabeceras
806 $scope.notaPedido.domicilio = { 801 $scope.notaPedido = notaPedido;
807 id: $scope.notaPedido.idDomicilio 802 if (!$scope.notaPedido.domicilio) {
808 }; 803 $scope.notaPedido.domicilio = {
809 } 804 id: $scope.notaPedido.idDomicilio
810 $scope.$broadcast('removeCabecera', 'Bomba:'); 805 };
811 $scope.$broadcast('removeCabecera', 'Kilometros:'); 806 }
812 807 $scope.$broadcast('removeCabecera', 'Bomba:');
813 var cabeceras = []; 808 $scope.$broadcast('removeCabecera', 'Kilometros:');
809 $scope.$broadcast('cleanCabecera');
814 810
815 if (notaPedido.cotizacion) { 811 var cabeceras = [];
816 cabeceras.push({ 812
817 label: 'Moneda:', 813 if (notaPedido.cotizacion.moneda.CODIGO_AFIP !== 'PES') {
818 valor: notaPedido.cotizacion.moneda.DETALLE 814 cabeceras.push({
819 }); 815 label: 'Moneda:',
820 cabeceras.push({ 816 valor: notaPedido.cotizacion.moneda.DETALLE
821 label: 'Fecha cotizacion:', 817 });
822 valor: $filter('date')(notaPedido.cotizacion.FECHA, 818 cabeceras.push({
823 'dd/MM/yyyy') 819 label: 'Fecha cotizacion:',
824 }); 820 valor: $filter('date')(notaPedido.cotizacion.FECHA,
825 cabeceras.push({ 821 'dd/MM/yyyy')
826 label: 'Cotizacion:', 822 });
827 valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, 823 cabeceras.push({
828 '2') 824 label: 'Cotizacion:',
829 }); 825 valor: $filter('number')(notaPedido.cotizacion.VENDEDOR,
830 } 826 '2')
831 827 });
832 if (notaPedido.cliente.COD) { 828 }
833 cabeceras.push({ 829
834 label: 'Cliente:', 830 if (notaPedido.cliente.COD) {
835 valor: notaPedido.cliente.NOM 831 cabeceras.push({
836 }); 832 label: 'Cliente:',
837 cabeceras.push({ 833 valor: notaPedido.cliente.NOM
838 label: 'Domicilio:', 834 });
839 valor: notaPedido.domicilioStamp 835 cabeceras.push({
840 }); 836 label: 'Domicilio:',
841 } 837 valor: notaPedido.domicilioStamp
842 838 });
843 if (notaPedido.vendedor.NUM) { 839 }
844 cabeceras.push({ 840
845 label: 'Vendedor:', 841 if (notaPedido.vendedor.NUM) {
846 valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + 842 cabeceras.push({
847 ' - ' + notaPedido.vendedor.NOM 843 label: 'Vendedor:',
848 }); 844 valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) +
849 } 845 ' - ' + notaPedido.vendedor.NOM
850 846 });
851 if (notaPedido.proveedor.COD) { 847 }
852 cabeceras.push({ 848
853 label: 'Proveedor:', 849 if (notaPedido.proveedor.COD) {
854 valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) + 850 cabeceras.push({
855 ' - ' + notaPedido.proveedor.NOM 851 label: 'Proveedor:',
856 }); 852 valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) +
857 } 853 ' - ' + notaPedido.proveedor.NOM
858 854 });
859 if (notaPedido.notaPedidoPlazo.length) { 855 }
860 cabeceras.push({ 856
861 label: 'Precios y condiciones:', 857 if (notaPedido.notaPedidoPlazo.length) {
862 valor: valorPrecioCondicion() + ' ' + 858 cabeceras.push({
863 notaPedidoBusinessService 859 label: 'Precios y condiciones:',
864 .plazoToString(notaPedido.notaPedidoPlazo) 860 valor: valorPrecioCondicion() + ' ' +
865 }); 861 notaPedidoBusinessService
866 } 862 .plazoToString(notaPedido.notaPedidoPlazo)
867 863 });
868 if (notaPedido.flete !== undefined) { 864 }
869 cabeceras.push({ 865
870 label: 'Flete:', 866 if (notaPedido.flete !== undefined) {
871 valor: notaPedido.fob === 1 ? 'FOB' : ( 867 cabeceras.push({
872 notaPedido.flete === 1 ? 'Si' : 'No') 868 label: 'Flete:',
873 }); 869 valor: notaPedido.fob === 1 ? 'FOB' : (
874 } 870 notaPedido.flete === 1 ? 'Si' : 'No')
875 871 });
876 function valorPrecioCondicion() { 872 }
877 if (notaPedido.idPrecioCondicion > 0) { 873
878 return notaPedido.precioCondicion.nombre; 874 function valorPrecioCondicion() {
879 } else { 875 if (notaPedido.idPrecioCondicion > 0) {
880 return 'Ingreso Manual'; 876 return notaPedido.precioCondicion.nombre;
881 } 877 } else {
882 } 878 return 'Ingreso Manual';
883 879 }
884 if (notaPedido.flete === 1) { 880 }
885 var cabeceraBomba = { 881
886 label: 'Bomba:', 882 if (notaPedido.flete === 1) {
887 valor: notaPedido.bomba === 1 ? 'Si' : 'No' 883 var cabeceraBomba = {
888 }; 884 label: 'Bomba:',
889 if (notaPedido.kilometros) { 885 valor: notaPedido.bomba === 1 ? 'Si' : 'No'
890 var cabeceraKilometros = { 886 };
891 label: 'Kilometros:', 887 if (notaPedido.kilometros) {
892 valor: notaPedido.kilometros 888 var cabeceraKilometros = {
893 }; 889 label: 'Kilometros:',
894 cabeceras.push(cabeceraKilometros); 890 valor: notaPedido.kilometros
895 } 891 };
896 cabeceras.push(cabeceraBomba); 892 cabeceras.push(cabeceraKilometros);
897 } 893 }
898 894 cabeceras.push(cabeceraBomba);
899 notaPedidoBusinessService.calcularArticulos($scope.notaPedido.articulosNotaPedido, 895 }
900 notaPedido.cotizacion.VENDEDOR); 896
901
902 if (notaPedido.idPrecioCondicion > 0) {
903 $scope.idLista = notaPedido.precioCondicion.idListaPrecio;
904 } else { 897 if (notaPedido.idPrecioCondicion > 0) {
905 $scope.idLista = -1; 898 $scope.idLista = notaPedido.precioCondicion.idListaPrecio;
906 } 899 } else {
907 900 $scope.idLista = -1;
908 $scope.puntoVenta = $filter('rellenarDigitos')( 901 }
909 notaPedido.sucursal, 4 902
910 ); 903 $scope.puntoVenta = $filter('rellenarDigitos')(
911 904 notaPedido.sucursal, 4
912 $scope.comprobante = $filter('rellenarDigitos')( 905 );
913 notaPedido.numeroNotaPedido, 8 906
914 ); 907 $scope.comprobante = $filter('rellenarDigitos')(
915 908 notaPedido.numeroNotaPedido, 8
916 $scope.notaPedido.notaPedidoPuntoDescarga = 909 );
917 formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga || []); 910
918 addArrayCabecera(cabeceras);
919 }
920 911 addArrayCabecera(cabeceras);
921 function addArrayCabecera(array) { 912 }
922 for (var i = 0; i < array.length; i++) { 913
923 $scope.$broadcast('addCabecera', { 914 function addArrayCabecera(array) {
924 label: array[i].label, 915 for (var i = 0; i < array.length; i++) {
925 valor: array[i].valor 916 $scope.$broadcast('addCabecera', {
926 }); 917 label: array[i].label,
927 } 918 valor: array[i].valor
928 } 919 });
929 920 }
930 function validarNotaRemitada() { 921 }
931 if (!$scope.notaPedido.idRemito) { 922
932 return true; 923 function validarNotaRemitada() {
933 } else { 924 if (!$scope.notaPedido.idRemito) {
934 focaModalService.alert('No se puede editar una nota de pedido remitada'); 925 return true;
935 return false; 926 } else {
936 } 927 focaModalService.alert('No se puede editar una nota de pedido remitada');
937 } 928 return false;
938 929 }
939 function formatearPuntosDescarga(puntosDescarga) { 930 }
940 var result = []; 931
941
942 puntosDescarga.forEach(function(el) {
943 var puntoDescarga = result.filter(function(resultPunto) {
944 return resultPunto.id === el.idPuntoDescarga;
945 });
946
947 if (puntoDescarga.length) {
948 puntoDescarga[0].articulosAgregados.push({
949 cantidad: el.cantidad,
950 descripcion: el.producto.descripcion,
951 id: el.producto.id
952 });
953 } else {
954 result.push({
955 id: el.puntoDescarga.id,
956 id_cliente: el.puntoDescarga.id_cliente,
957 id_da_config_0: el.puntoDescarga.id_da_config_0,
958 latitud: el.puntoDescarga.latitud,
959 longitud: el.puntoDescarga.longitud,
960 descripcion: el.puntoDescarga.descripcion,
961 articulosAgregados: [
962 {
963 cantidad: el.cantidad,
964 descripcion: el.producto.descripcion,
965 id: el.producto.id
966 }
967 ]
968 });
969 }
970 });
971 return result;
972 }
973
974 function salir() {
975 var confirmacion = false;
976 932 function salir() {
977 if (!angular.equals($scope.notaPedido, $scope.inicial)) { 933 var confirmacion = false;
978 confirmacion = true; 934
979 } 935 if (!angular.equals($scope.notaPedido, $scope.inicial)) {
980 936 confirmacion = true;
981 if (confirmacion) { 937 }
982 focaModalService.confirm( 938
983 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' 939 if (confirmacion) {
984 ).then(function(data) { 940 focaModalService.confirm(
985 if (data) { 941 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.'
986 $location.path('/'); 942 ).then(function(data) {
987 } 943 if (data) {
988 }); 944 $location.path('/');
989 } else { 945 }
990 $location.path('/'); 946 });
991 } 947 } else {
992 } 948 $location.path('/');
993 949 }
994 function getLSNotaPedido() { 950 }
995 var notaPedido = JSON.parse($localStorage.notaPedido || null); 951
996 if (notaPedido) { 952 function getLSNotaPedido() {
997 setearNotaPedido(notaPedido); 953 var notaPedido = JSON.parse($localStorage.notaPedido || null);
998 delete $localStorage.notaPedido; 954 if (notaPedido) {
999 }
1000 } 955 delete $localStorage.notaPedido;
956 setearNotaPedido(notaPedido);
1001 957 }
1002 function deleteCliente() { 958 }
1003 delete $scope.notaPedido.domicilioStamp; 959
1004 delete $scope.notaPedido.notaPedidoPuntoDescarga; 960 function deleteCliente() {
1005 $scope.notaPedido.domicilio = {dom: ''}; 961 delete $scope.notaPedido.domicilioStamp;
1006 $scope.notaPedido.cliente = {}; 962 delete $scope.notaPedido.notaPedidoPuntosDescarga;
1007 $scope.$broadcast('removeCabecera', 'Cliente:'); 963 $scope.notaPedido.domicilio = {dom: ''};
1008 $scope.$broadcast('removeCabecera', 'Domicilio:'); 964 $scope.notaPedido.cliente = {};
1009 $scope.$broadcast('removeCabecera', 'Puntos de descarga:'); 965 $scope.$broadcast('removeCabecera', 'Cliente:');
1 angular.module('focaCrearNotaPedido') 1 angular.module('focaCrearNotaPedido')
2 .factory('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { 2 .factory('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) {
3 var route = API_ENDPOINT.URL; 3 var route = API_ENDPOINT.URL;
4 return { 4 return {
5 crearNotaPedido: function(notaPedido) { 5 crearNotaPedido: function(notaPedido) {
6 return $http.post(route + '/nota-pedido', {notaPedido: notaPedido}); 6 return $http.post(route + '/nota-pedido', {notaPedido: notaPedido});
7 }, 7 },
8 obtenerNotaPedido: function() { 8 obtenerNotaPedido: function() {
9 return $http.get(route +'/nota-pedido'); 9 return $http.get(route +'/nota-pedido');
10 }, 10 },
11 setNotaPedido: function(notaPedido) { 11 setNotaPedido: function(notaPedido) {
12 this.notaPedido = notaPedido; 12 this.notaPedido = notaPedido;
13 }, 13 },
14 clearNotaPedido: function() { 14 clearNotaPedido: function() {
15 this.notaPedido = undefined; 15 this.notaPedido = undefined;
16 }, 16 },
17 getNotaPedido: function() { 17 getNotaPedido: function() {
18 return this.notaPedido; 18 return this.notaPedido;
19 }, 19 },
20 getArticulosByIdNotaPedido: function(id) { 20 getArticulosByIdNotaPedido: function(id) {
21 return $http.get(route+'/articulos/nota-pedido/'+id); 21 return $http.get(route+'/articulos/nota-pedido/'+id);
22 }, 22 },
23 crearArticulosParaNotaPedido: function(articuloNotaPedido) { 23 crearArticulosParaNotaPedido: function(articuloNotaPedido) {
24 return $http.post(route + '/articulos/nota-pedido', 24 return $http.post(route + '/articulos/nota-pedido',
25 {articuloNotaPedido: articuloNotaPedido}); 25 {articuloNotaPedido: articuloNotaPedido});
26 }, 26 },
27 getDomiciliosByIdNotaPedido: function(id) { 27 getDomiciliosByIdNotaPedido: function(id) {
28 return $http.get(route +'/nota-pedido/'+id+'/domicilios'); 28 return $http.get(route +'/nota-pedido/'+id+'/domicilios');
29 }, 29 },
30 getDomiciliosByIdCliente: function(id) { 30 getDomiciliosByIdCliente: function(id) {
31 var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) 31 var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega)
32 return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); 32 return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id );
33 }, 33 },
34 getPrecioCondicion: function() { 34 getPrecioCondicion: function() {
35 return $http.get(route + '/precio-condicion'); 35 return $http.get(route + '/precio-condicion');
36 }, 36 },
37 getPrecioCondicionById: function(id) { 37 getPrecioCondicionById: function(id) {
38 return $http.get(route + '/precio-condicion/' + id); 38 return $http.get(route + '/precio-condicion/' + id);
39 }, 39 },
40 getPlazoPagoByPrecioCondicion: function(id) { 40 getPlazoPagoByPrecioCondicion: function(id) {
41 return $http.get(route + '/plazo-pago/precio-condicion/'+ id); 41 return $http.get(route + '/plazo-pago/precio-condicion/'+ id);
42 }, 42 },
43 crearFlete: function(flete) { 43 crearFlete: function(flete) {
44 return $http.post(route + '/flete', {flete : flete}); 44 return $http.post(route + '/flete', {flete : flete});
45 }, 45 },
46 crearPlazosParaNotaPedido: function(plazos) { 46 crearPlazosParaNotaPedido: function(plazos) {
47 return $http.post(route + '/plazo-pago/nota-pedido', {plazos: plazos}); 47 return $http.post(route + '/plazo-pago/nota-pedido', {plazos: plazos});
48 }, 48 },
49 getCotizacionByIdMoneda: function(id) { 49 getCotizacionByIdMoneda: function(id) {
50 return $http.get(route + '/moneda/' + id); 50 return $http.get(route + '/moneda/' + id);
51 }, 51 },
52 crearEstadoParaNotaPedido: function(estado) { 52 crearEstadoParaNotaPedido: function(estado) {
53 return $http.post(route + '/estado', {estado: estado}); 53 return $http.post(route + '/estado', {estado: estado});
54 }, 54 },
55 getNumeroNotaPedido: function() { 55 getNumeroNotaPedido: function() {
56 return $http.get(route + '/nota-pedido/numero-siguiente'); 56 return $http.get(route + '/nota-pedido/numero-siguiente');
57 }, 57 },
58 getBotonera: function() { 58 getBotonera: function() {
59 var result = [ 59 var result = [
60 { 60 {
61 label: 'Cliente', 61 label: 'Cliente',
62 image: 'cliente.png' 62 image: 'cliente.png'
63 }, 63 },
64 { 64 {
65 label: 'Proveedor', 65 label: 'Proveedor',
66 image: 'proveedor.png' 66 image: 'proveedor.png'
67 }, 67 },
68 { 68 {
69 label: 'Moneda', 69 label: 'Moneda',
70 image: 'moneda.png' 70 image: 'moneda.png'
71 }, 71 },
72 { 72 {
73 label: 'Precios y condiciones', 73 label: 'Precios y condiciones',
74 image: 'precios-condiciones.png' 74 image: 'precios-condiciones.png'
75 }, 75 },
76 { 76 {
77 label: 'Productos', 77 label: 'Productos',
78 image: 'productos.png' 78 image: 'productos.png'
79 }, 79 },
80 { 80 {
81 label: 'Observaciones', 81 label: 'Observaciones',
82 image: 'botonObservaciones.png' 82 image: 'botonObservaciones.png'
83 } 83 }
84 ]; 84 ];
85 return result; 85 return result;
86 }, 86 },
87 crearPuntosDescarga: function(puntosDescarga) { 87 crearPuntosDescarga: function(puntosDescarga) {
88 return $http.post(route + '/puntos-descarga/nota-pedido', 88 return $http.post(route + '/puntos-descarga/nota-pedido',
89 {puntosDescarga: puntosDescarga}); 89 {puntosDescarga: puntosDescarga});
90 }, 90 },
91 getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { 91 getPuntosDescargaByClienDom: function(idDomicilio, idCliente) {
92 return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + 92 return $http.get(API_ENDPOINT.URL + '/punto-descarga/' +
93 idDomicilio + '/' + idCliente); 93 idDomicilio + '/' + idCliente);
94 }, 94 },
95 getVendedorById: function(id) { 95 getVendedorById: function(id) {
96 return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + id); 96 return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + id);
97 } 97 }
98 }; 98 };
99 }]); 99 }]);
100 100
src/views/nota-pedido.html
1 <div class="crear-nota-pedido foca-crear row"> 1 <div class="crear-nota-pedido foca-crear row">
2 <foca-cabecera-facturador 2 <foca-cabecera-facturador
3 titulo="'Nota de pedido'" 3 titulo="'Nota de pedido'"
4 numero="puntoVenta + '-' + comprobante" 4 numero="puntoVenta + '-' + comprobante"
5 fecha="notaPedido.fechaCarga" 5 fecha="notaPedido.fechaCarga"
6 class="mb-0 col-lg-12" 6 class="mb-0 col-lg-12"
7 busqueda="seleccionarNotaPedido" 7 busqueda="seleccionarNotaPedido"
8 ></foca-cabecera-facturador> 8 ></foca-cabecera-facturador>
9 <marquee
10 bgcolor="#FF9900"
11 behavior="scroll"
12 direction="left"
13 ng-bind="notaPedido.observaciones"
14 ></marquee>
9 <div class="col-lg-12"> 15 <div class="col-lg-12">
10 <div class="row"> 16 <div class="row">
11 <div class="col-12 col-md-10 col-lg-10 border border-light rounded"> 17 <div class="col-12 col-md-10 col-lg-10 border border-light rounded">
12 <div class="row py-2 botonera-secundaria"> 18 <div class="row py-2 botonera-secundaria">
13 <div class="col-12 foca-facturador-px"> 19 <div class="col-12 foca-facturador-px">
14 <foca-botonera-facturador botones="botonera" extra="5" class="row"></foca-botonera-facturador> 20 <foca-botonera-facturador botones="botonera" extra="5" class="row"></foca-botonera-facturador>
15 </div> 21 </div>
16 </div> 22 </div>
17 <!-- PC --> 23 <!-- PC -->
18 <div class="row grilla-articulo align-items-end d-none d-sm-flex"> 24 <div class="row grilla-articulo align-items-end d-none d-sm-flex">
19 <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> 25 <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom">
20 <thead> 26 <thead>
21 <tr class="d-flex"> 27 <tr class="d-flex">
22 <th valign="middle" class="">#</th> 28 <th valign="middle" class="">#</th>
23 <th valign="middle" class="col">Código</th> 29 <th valign="middle" class="col">Código</th>
24 <th valign="middle" class="col-4">Descripción</th> 30 <th valign="middle" class="col-4">Descripción</th>
25 <th valign="middle" class="col text-right">Cantidad</th> 31 <th valign="middle" class="col text-right">Cantidad</th>
26 <th valign="middle" class="col text-right">Precio Unitario</th> 32 <th valign="middle" class="col text-right">Precio Unitario</th>
27 <th valign="middle" class="col text-right">SubTotal</th> 33 <th valign="middle" class="col text-right">SubTotal</th>
28 <th valign="middle" class="text-right"> 34 <th valign="middle" class="text-right">
29 <button 35 <button
30 class="btn btn-outline-light selectable" 36 class="btn btn-outline-light selectable"
31 ng-click="show = !show; masMenos()" 37 ng-click="show = !show; masMenos()"
32 > 38 >
33 <i 39 <i
34 class="fa fa-chevron-down" 40 class="fa fa-chevron-down"
35 ng-show="show" 41 ng-show="show"
36 aria-hidden="true" 42 aria-hidden="true"
37 > 43 >
38 </i> 44 </i>
39 <i 45 <i
40 class="fa fa-chevron-up" 46 class="fa fa-chevron-up"
41 ng-hide="show" 47 ng-hide="show"
42 aria-hidden="true"> 48 aria-hidden="true">
43 </i> 49 </i>
44 </button> 50 </button>
45 </th> 51 </th>
46 </tr> 52 </tr>
47 </thead> 53 </thead>
48 <tbody class="tabla-articulo-body"> 54 <tbody class="tabla-articulo-body">
49 <tr 55 <tr
50 ng-repeat="(key, articulo) in notaPedido.articulosNotaPedido" 56 ng-repeat="(key, articulo) in notaPedido.articulosNotaPedido"
51 ng-show="show || key == (notaPedido.articulosNotaPedido.length - 1)" 57 ng-show="show || key == (notaPedido.articulosNotaPedido.length - 1)"
52 class="d-flex" 58 class="d-flex"
53 > 59 >
54 <td ng-bind="key + 1"></td> 60 <td ng-bind="key + 1"></td>
55 <td 61 <td
56 class="col" 62 class="col"
57 ng-bind="articulo.sector + '-' + articulo.codigo" 63 ng-bind="articulo.sector + '-' + articulo.codigo"
58 ></td> 64 ></td>
59 <td 65 <td
60 class="col-4" 66 class="col-4"
61 ng-bind="articulo.descripcion" 67 ng-bind="articulo.descripcion"
62 ></td> 68 ></td>
63 <td class="col text-right"> 69 <td class="col text-right">
64 <input 70 <input
65 ng-show="articulo.editCantidad" 71 ng-show="articulo.editCantidad"
66 ng-model="articulo.cantidad" 72 ng-model="articulo.cantidad"
67 class="form-control" 73 class="form-control"
68 foca-tipo-input 74 foca-tipo-input
69 min="1" 75 min="1"
70 step="0.001" 76 step="0.001"
71 foca-focus="articulo.editCantidad" 77 foca-focus="articulo.editCantidad"
72 ng-keypress="editarArticulo($event.keyCode, articulo)" 78 ng-keypress="editarArticulo($event.keyCode, articulo)"
73 ng-focus="selectFocus($event)" 79 ng-focus="selectFocus($event)"
74 teclado-virtual 80 teclado-virtual
75 > 81 >
76 <i 82 <i
77 class="selectable" 83 class="selectable"
78 ng-click="cambioEdit(articulo, 'cantidad')" 84 ng-click="cambioEdit(articulo, 'cantidad')"
79 ng-hide="articulo.editCantidad" 85 ng-hide="articulo.editCantidad"
80 ng-bind="articulo.cantidad"> 86 ng-bind="articulo.cantidad">
81 </i> 87 </i>
82 </td> 88 </td>
83 <td class="col text-right"> 89 <td class="col text-right">
84 <input 90 <input
85 ng-show="articulo.editPrecio" 91 ng-show="articulo.editPrecio"
86 ng-model="articulo.precio" 92 ng-model="articulo.precio"
87 class="form-control" 93 class="form-control"
88 foca-tipo-input 94 foca-tipo-input
89 min="0" 95 min="0"
90 step="0.0001" 96 step="0.0001"
91 foca-focus="articulo.editPrecio" 97 foca-focus="articulo.editPrecio"
92 ng-keypress="editarArticulo($event.keyCode, articulo)" 98 ng-keypress="editarArticulo($event.keyCode, articulo)"
93 ng-focus="selectFocus($event)" 99 ng-focus="selectFocus($event)"
94 teclado-virtual 100 teclado-virtual
95 > 101 >
96 <i 102 <i
97 class="selectable" 103 class="selectable"
98 ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" 104 ng-click="idLista == -1 && cambioEdit(articulo, 'precio')"
99 ng-hide="articulo.editPrecio" 105 ng-hide="articulo.editPrecio"
100 ng-bind="articulo.precio | 106 ng-bind="articulo.precio |
101 number: 4"> 107 number: 4">
102 </i> 108 </i>
103 </td> 109 </td>
104 <td 110 <td
105 class="col text-right" 111 class="col text-right"
106 ng-bind="(articulo.precio * articulo.cantidad) | 112 ng-bind="(articulo.precio * articulo.cantidad) |
107 number: 2"> 113 number: 2">
108 </td> 114 </td>
109 <td class="text-center"> 115 <td class="text-center">
110 <button 116 <button
111 ng-show="articulo.editCantidad || articulo.editPrecio" 117 ng-show="articulo.editCantidad || articulo.editPrecio"
112 class="btn btn-outline-light" 118 class="btn btn-outline-light"
113 ng-click="editarArticulo(13, articulo)" 119 ng-click="editarArticulo(13, articulo)"
114 > 120 >
115 <i class="fa fa-save"></i> 121 <i class="fa fa-save"></i>
116 </button> 122 </button>
117 <button 123 <button
118 class="btn btn-outline-light" 124 class="btn btn-outline-light"
119 ng-click="quitarArticulo(key)" 125 ng-click="quitarArticulo(key)"
120 > 126 >
121 <i class="fa fa-trash"></i> 127 <i class="fa fa-trash"></i>
122 </button> 128 </button>
123 </td> 129 </td>
124 </tr> 130 </tr>
125 </tbody> 131 </tbody>
126 <tfoot> 132 <tfoot>
127 <tr ng-show="!cargando" class="d-flex"> 133 <tr ng-show="!cargando" class="d-flex">
128 <td 134 <td
129 class="align-middle" 135 class="align-middle"
130 ng-bind="notaPedido.articulosNotaPedido.length + 1" 136 ng-bind="notaPedido.articulosNotaPedido.length + 1"
131 ></td> 137 ></td>
132 <td class="col"> 138 <td class="col">
133 <input 139 <input
134 class="form-control" 140 class="form-control"
135 ng-model="articuloACargar.sectorCodigo" 141 ng-model="articuloACargar.sectorCodigo"
136 readonly 142 readonly
137 > 143 >
138 </td> 144 </td>
139 <td class="col-4 tabla-articulo-descripcion"> 145 <td class="col-4 tabla-articulo-descripcion">
140 <input 146 <input
141 class="form-control" 147 class="form-control"
142 ng-model="articuloACargar.descripcion" 148 ng-model="articuloACargar.descripcion"
143 readonly 149 readonly
144 > 150 >
145 </td> 151 </td>
146 <td class="col text-right"> 152 <td class="col text-right">
147 <input 153 <input
148 class="form-control" 154 class="form-control"
149 foca-tipo-input 155 foca-tipo-input
150 min="1" 156 min="1"
151 step="0.001" 157 step="0.001"
152 ng-model="articuloACargar.cantidad" 158 ng-model="articuloACargar.cantidad"
153 foca-focus="!cargando" 159 foca-focus="!cargando"
154 esc-key="resetFilter()" 160 esc-key="resetFilter()"
155 ng-keypress="agregarATabla($event.keyCode)" 161 ng-keypress="agregarATabla($event.keyCode)"
156 teclado-virtual 162 teclado-virtual
157 > 163 >
158 </td> 164 </td>
159 <td class="col text-right"> 165 <td class="col text-right">
160 <input 166 <input
161 class="form-control" 167 class="form-control"
162 ng-value="articuloACargar.precio | number: 2" 168 ng-value="articuloACargar.precio | number: 2"
163 ng-show="idLista != -1" 169 ng-show="idLista != -1"
164 readonly 170 readonly
165 > 171 >
166 <input 172 <input
167 class="form-control" 173 class="form-control"
168 foca-tipo-input 174 foca-tipo-input
169 min="0" 175 min="0"
170 step="0.0001" 176 step="0.0001"
171 ng-model="articuloACargar.precio" 177 ng-model="articuloACargar.precio"
172 esc-key="resetFilter()" 178 esc-key="resetFilter()"
173 ng-keypress="agregarATabla($event.keyCode)" 179 ng-keypress="agregarATabla($event.keyCode)"
174 ng-show="idLista == -1" 180 ng-show="idLista == -1"
175 teclado-virtual 181 teclado-virtual
176 > 182 >
177 </td> 183 </td>
178 <td class="col text-right"> 184 <td class="col text-right">
179 <input 185 <input
180 class="form-control" 186 class="form-control"
181 ng-value="getSubTotal() | number: 2" 187 ng-value="getSubTotal() | number: 2"
182 readonly 188 readonly
183 ></td> 189 ></td>
184 <td class="text-center align-middle"> 190 <td class="text-center align-middle">
185 <button 191 <button
186 class="btn btn-outline-light" 192 class="btn btn-outline-light"
187 ng-click="agregarATabla(13)" 193 ng-click="agregarATabla(13)"
188 > 194 >
189 <i class="fa fa-save"></i> 195 <i class="fa fa-save"></i>
190 </button> 196 </button>
191 </td> 197 </td>
192 </tr> 198 </tr>
193 <tr class="d-flex"> 199 <tr class="d-flex">
194 <td colspan="4" class="no-border-top"> 200 <td colspan="4" class="no-border-top">
195 <strong>Items:</strong> 201 <strong>Items:</strong>
196 <a ng-bind="notaPedido.articulosNotaPedido.length"></a> 202 <a ng-bind="notaPedido.articulosNotaPedido.length"></a>
197 </td> 203 </td>
198 <td class="text-right ml-auto table-celda-total no-border-top"> 204 <td class="text-right ml-auto table-celda-total no-border-top">
199 <h3>Total:</h3> 205 <h3>Total:</h3>
200 </td> 206 </td>
201 <td class="table-celda-total text-right no-border-top" colspan="1"> 207 <td class="table-celda-total text-right no-border-top" colspan="1">
202 <h3>{{getTotal() | currency: notaPedido.cotizacion.moneda.SIMBOLO}}</h3> 208 <h3>{{getTotal() | currency: notaPedido.cotizacion.moneda.SIMBOLO}}</h3>
203 </td> 209 </td>
204 <td class="text-right no-border-top"> 210 <td class="text-right no-border-top">
205 <button 211 <button
206 type="button" 212 type="button"
207 class="btn btn-default btn-sm" 213 class="btn btn-default btn-sm"
208 > 214 >
209 Totales 215 Totales
210 </button> 216 </button>
211 </td> 217 </td>
212 </tr> 218 </tr>
213 </tfoot> 219 </tfoot>
214 </table> 220 </table>
215 </div> 221 </div>
216 <!-- MOBILE --> 222 <!-- MOBILE -->
217 <div class="row d-sm-none"> 223 <div class="row d-sm-none">
218 <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile"> 224 <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile">
219 <thead> 225 <thead>
220 <tr class="d-flex"> 226 <tr class="d-flex">
221 <th class="">#</th> 227 <th class="">#</th>
222 <th class="col px-0"> 228 <th class="col px-0">
223 <div class="d-flex"> 229 <div class="d-flex">
224 <div class="col-4 px-1">Código</div> 230 <div class="col-4 px-1">Código</div>
225 <div class="col-8 px-1">Descripción</div> 231 <div class="col-8 px-1">Descripción</div>
226 </div> 232 </div>
227 <div class="d-flex"> 233 <div class="d-flex">
228 <div class="col-3 px-1">Cantidad</div> 234 <div class="col-3 px-1">Cantidad</div>
229 <div class="col px-1 text-right">P. Uni.</div> 235 <div class="col px-1 text-right">P. Uni.</div>
230 <div class="col px-1 text-right">Subtotal</div> 236 <div class="col px-1 text-right">Subtotal</div>
231 </div> 237 </div>
232 </th> 238 </th>
233 <th class="text-center tamaño-boton"> 239 <th class="text-center tamaño-boton">
234 &nbsp; 240 &nbsp;
235 </th> 241 </th>
236 </tr> 242 </tr>
237 </thead> 243 </thead>
238 <tbody> 244 <tbody>
239 <tr 245 <tr
240 ng-repeat="(key, articulo) in notaPedido.articulosNotaPedido" 246 ng-repeat="(key, articulo) in notaPedido.articulosNotaPedido"
241 ng-show="show || key == notaPedido.articulosNotaPedido.length - 1" 247 ng-show="show || key == notaPedido.articulosNotaPedido.length - 1"
242 > 248 >
243 <td class="w-100 align-middle d-flex p-0"> 249 <td class="w-100 align-middle d-flex p-0">
244 <div class="align-middle p-1"> 250 <div class="align-middle p-1">
245 <span ng-bind="key+1" class="align-middle"></span> 251 <span ng-bind="key+1" class="align-middle"></span>
246 </div> 252 </div>
247 <div class="col px-0"> 253 <div class="col px-0">
248 <div class="d-flex"> 254 <div class="d-flex">
249 <div class="col-4 px-1"> 255 <div class="col-4 px-1">
250 <span 256 <span
251 ng-bind="articulo.sector + '-' + articulo.codigo" 257 ng-bind="articulo.sector + '-' + articulo.codigo"
252 ></span> 258 ></span>
253 </div> 259 </div>
254 <div class="col-8 px-1"> 260 <div class="col-8 px-1">
255 <span ng-bind="articulo.descripcion"></span> 261 <span ng-bind="articulo.descripcion"></span>
256 </div> 262 </div>
257 </div> 263 </div>
258 <div class="d-flex"> 264 <div class="d-flex">
259 <div class="col-3 px-1"> 265 <div class="col-3 px-1">
260 <span 266 <span
261 ng-bind="'x' + articulo.cantidad" 267 ng-bind="'x' + articulo.cantidad"
262 ng-hide="articulo.editCantidad" 268 ng-hide="articulo.editCantidad"
263 ></span> 269 ></span>
264 <i 270 <i
265 class="fa fa-pencil text-white-50" 271 class="fa fa-pencil text-white-50"
266 aria-hidden="true" 272 aria-hidden="true"
267 ng-hide="articulo.editCantidad" 273 ng-hide="articulo.editCantidad"
268 ng-click="articulo.editCantidad = true" 274 ng-click="articulo.editCantidad = true"
269 ></i> 275 ></i>
270 <input 276 <input
271 ng-show="articulo.editCantidad" 277 ng-show="articulo.editCantidad"
272 ng-model="articulo.cantidad" 278 ng-model="articulo.cantidad"
273 class="form-control" 279 class="form-control"
274 foca-tipo-input 280 foca-tipo-input
275 min="1" 281 min="1"
276 step="0.001" 282 step="0.001"
277 foca-focus="articulo.editCantidad" 283 foca-focus="articulo.editCantidad"
278 ng-keypress="editarArticulo($event.keyCode, articulo)" 284 ng-keypress="editarArticulo($event.keyCode, articulo)"
279 ng-focus="selectFocus($event)" 285 ng-focus="selectFocus($event)"
280 > 286 >
281 </div> 287 </div>
282 <div class="col px-1 text-right"> 288 <div class="col px-1 text-right">
283 <span ng-bind="articulo.precio | 289 <span ng-bind="articulo.precio |
284 currency: notaPedido.moneda.SIMBOLO : 4"></span> 290 currency: notaPedido.moneda.SIMBOLO : 4"></span>
285 ></span> 291 ></span>
286 </div> 292 </div>
287 <div class="col px-1 text-right"> 293 <div class="col px-1 text-right">
288 <span 294 <span
289 ng-bind="(articulo.precio * articulo.cantidad) | 295 ng-bind="(articulo.precio * articulo.cantidad) |
290 currency: notaPedido.moneda.SIMBOLO" 296 currency: notaPedido.moneda.SIMBOLO"
291 > 297 >
292 </span> 298 </span>
293 </div> 299 </div>
294 </div> 300 </div>
295 </div> 301 </div>
296 <div class="align-middle p-1"> 302 <div class="align-middle p-1">
297 <button 303 <button
298 class="btn btn-outline-light" 304 class="btn btn-outline-light"
299 ng-click="quitarArticulo(key)" 305 ng-click="quitarArticulo(key)"
300 > 306 >
301 <i class="fa fa-trash"></i> 307 <i class="fa fa-trash"></i>
302 </button> 308 </button>
303 </div> 309 </div>
304 </td> 310 </td>
305 </tr> 311 </tr>
306 </tbody> 312 </tbody>
307 <tfoot> 313 <tfoot>
308 <!-- CARGANDO ITEM --> 314 <!-- CARGANDO ITEM -->
309 <tr ng-show="!cargando" class="d-flex"> 315 <tr ng-show="!cargando" class="d-flex">
310 <td 316 <td
311 class="align-middle p-1" 317 class="align-middle p-1"
312 ng-bind="notaPedido.articulosNotaPedido.length + 1" 318 ng-bind="notaPedido.articulosNotaPedido.length + 1"
313 ></td> 319 ></td>
314 <td class="col p-0"> 320 <td class="col p-0">
315 <div class="d-flex"> 321 <div class="d-flex">
316 <div class="col-4 px-1"> 322 <div class="col-4 px-1">
317 <span 323 <span
318 ng-bind="articuloACargar.sectorCodigo" 324 ng-bind="articuloACargar.sectorCodigo"
319 ></span> 325 ></span>
320 </div> 326 </div>
321 <div class="col-8 px-1"> 327 <div class="col-8 px-1">
322 <span ng-bind="articuloACargar.descripcion"></span> 328 <span ng-bind="articuloACargar.descripcion"></span>
323 </div> 329 </div>
324 </div> 330 </div>
325 <div class="d-flex"> 331 <div class="d-flex">
326 <div class="col-3 px-1 m-1"> 332 <div class="col-3 px-1 m-1">
327 <input 333 <input
328 class="form-control p-1" 334 class="form-control p-1"
329 foca-tipo-input 335 foca-tipo-input
330 min="1" 336 min="1"
331 ng-model="articuloACargar.cantidad" 337 ng-model="articuloACargar.cantidad"
332 foca-focus="!cargando" 338 foca-focus="!cargando"
333 ng-keypress="agregarATabla($event.keyCode)" 339 ng-keypress="agregarATabla($event.keyCode)"
334 style="height: auto; line-height: 1.1em" 340 style="height: auto; line-height: 1.1em"
335 > 341 >
336 </div> 342 </div>
337 <div class="col px-1 text-right"> 343 <div class="col px-1 text-right">
338 <span ng-bind="articuloACargar.precio | 344 <span ng-bind="articuloACargar.precio |
339 currency: notaPedido.moneda.SIMBOLO : 4" 345 currency: notaPedido.moneda.SIMBOLO : 4"
340 ></span> 346 ></span>
341 </div> 347 </div>
342 <div class="col px-1 text-right"> 348 <div class="col px-1 text-right">
343 <span 349 <span
344 ng-bind="getSubTotal() | 350 ng-bind="getSubTotal() |
345 currency: notaPedido.moneda.SIMBOLO" 351 currency: notaPedido.moneda.SIMBOLO"
346 > 352 >
347 </span> 353 </span>
348 </div> 354 </div>
349 </div> 355 </div>
350 </td> 356 </td>
351 <td class="text-center align-middle"> 357 <td class="text-center align-middle">
352 <button 358 <button
353 class="btn btn-outline-light" 359 class="btn btn-outline-light"
354 ng-click="agregarATabla(13)" 360 ng-click="agregarATabla(13)"
355 > 361 >
356 <i class="fa fa-save"></i> 362 <i class="fa fa-save"></i>
357 </button> 363 </button>
358 </td> 364 </td>
359 </tr> 365 </tr>
360 <!-- TOOGLE EXPANDIR --> 366 <!-- TOOGLE EXPANDIR -->
361 <tr> 367 <tr>
362 <td class="col"> 368 <td class="col">
363 <button 369 <button
364 class="btn btn-outline-light selectable w-100" 370 class="btn btn-outline-light selectable w-100"
365 ng-click="show = !show; masMenos()" 371 ng-click="show = !show; masMenos()"
366 ng-show="notaPedido.articulosNotaPedido.length > 0" 372 ng-show="notaPedido.articulosNotaPedido.length > 0"
367 > 373 >
368 <i 374 <i
369 class="fa fa-chevron-down" 375 class="fa fa-chevron-down"
370 ng-hide="show" 376 ng-hide="show"
371 aria-hidden="true" 377 aria-hidden="true"
372 > 378 >
373 </i> 379 </i>
374 <i 380 <i
375 class="fa fa-chevron-up" 381 class="fa fa-chevron-up"
376 ng-show="show" 382 ng-show="show"
377 aria-hidden="true"> 383 aria-hidden="true">
378 </i> 384 </i>
379 </button> 385 </button>
380 </td> 386 </td>
381 </tr> 387 </tr>
382 <!-- FOOTER --> 388 <!-- FOOTER -->
383 <tr class="d-flex"> 389 <tr class="d-flex">
384 <td class="align-middle no-border-top" colspan="2"> 390 <td class="align-middle no-border-top" colspan="2">
385 <strong>Cantidad Items:</strong> 391 <strong>Cantidad Items:</strong>
386 <a ng-bind="notaPedido.articulosNotaPedido.length"></a> 392 <a ng-bind="notaPedido.articulosNotaPedido.length"></a>
387 </td> 393 </td>
388 <td class="text-right ml-auto table-celda-total no-border-top"> 394 <td class="text-right ml-auto table-celda-total no-border-top">
389 <h3>Total:</h3> 395 <h3>Total:</h3>
390 </td> 396 </td>
391 <td class="table-celda-total text-right no-border-top"> 397 <td class="table-celda-total text-right no-border-top">
392 <h3>{{getTotal() | currency: notaPedido.cotizacion.moneda.SIMBOLO}}</h3> 398 <h3>{{getTotal() | currency: notaPedido.cotizacion.moneda.SIMBOLO}}</h3>
393 </td> 399 </td>
394 </tr> 400 </tr>
395 </tfoot> 401 </tfoot>
396 </table> 402 </table>
397 </div> 403 </div>
398 </div> 404 </div>
399 </div> 405 </div>
400 </div> 406 </div>
401 <div class="row d-md-none fixed-bottom"> 407 <div class="row d-md-none fixed-bottom">
402 <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> 408 <div class="w-100 bg-dark d-flex px-3 acciones-mobile">
403 <span class="ml-3 text-muted" ng-click="salir()">Salir</span> 409 <span class="ml-3 text-muted" ng-click="salir()">Salir</span>
404 <span 410 <span
405 class="mr-3 ml-auto" 411 class="mr-3 ml-auto"
406 ng-class="saveLoading ? 'text-muted' : ''" 412 ng-class="saveLoading ? 'text-muted' : ''"
407 ng-click="crearNotaPedido()" 413 ng-click="crearNotaPedido()"
408 ladda="saveLoading" 414 ladda="saveLoading"
409 data-style="expand-left" 415 data-style="expand-left"
410 >Guardar</span> 416 >Guardar</span>
411 </div> 417 </div>
412 </div> 418 </div>
413 </div> 419 </div>
414 420