Commit 0eb9138d2b5b517626ece4c3b0a153578262efa0

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'master'

Master(efernandez)

See merge request modulos-npm/foca-crear-nota-pedido!6
1 const templateCache = require('gulp-angular-templatecache'); 1 const templateCache = require('gulp-angular-templatecache');
2 const clean = require('gulp-clean'); 2 const clean = require('gulp-clean');
3 const concat = require('gulp-concat'); 3 const concat = require('gulp-concat');
4 const htmlmin = require('gulp-htmlmin'); 4 const htmlmin = require('gulp-htmlmin');
5 const rename = require('gulp-rename'); 5 const rename = require('gulp-rename');
6 const uglify = require('gulp-uglify'); 6 const uglify = require('gulp-uglify');
7 const gulp = require('gulp'); 7 const gulp = require('gulp');
8 const pump = require('pump'); 8 const pump = require('pump');
9 const jshint = require('gulp-jshint'); 9 const jshint = require('gulp-jshint');
10 const replace = require('gulp-replace'); 10 const replace = require('gulp-replace');
11 const connect = require('gulp-connect'); 11 const connect = require('gulp-connect');
12 12
13 var paths = { 13 var paths = {
14 srcJS: 'src/js/*.js', 14 srcJS: 'src/js/*.js',
15 srcViews: 'src/views/*.html', 15 srcViews: 'src/views/*.html',
16 tmp: 'tmp', 16 tmp: 'tmp',
17 dist: 'dist/' 17 dist: 'dist/'
18 }; 18 };
19 19
20 gulp.task('templates', ['clean'], function() { 20 gulp.task('templates', ['clean'], function() {
21 return pump( 21 return pump(
22 [ 22 [
23 gulp.src(paths.srcViews), 23 gulp.src(paths.srcViews),
24 htmlmin(), 24 htmlmin(),
25 templateCache('views.js', { 25 templateCache('views.js', {
26 module: 'focaCrearNotaPedido', 26 module: 'focaCrearNotaPedido',
27 root: '' 27 root: ''
28 }), 28 }),
29 gulp.dest(paths.tmp) 29 gulp.dest(paths.tmp)
30 ] 30 ]
31 ); 31 );
32 }); 32 });
33 33
34 gulp.task('uglify', ['templates'], function() { 34 gulp.task('uglify', ['templates'], function() {
35 return pump( 35 return pump(
36 [ 36 [
37 gulp.src([ 37 gulp.src([
38 paths.srcJS, 38 paths.srcJS,
39 'tmp/views.js' 39 'tmp/views.js'
40 ]), 40 ]),
41 concat('foca-crear-nota-pedido.js'), 41 concat('foca-crear-nota-pedido.js'),
42 replace('src/views/', ''), 42 replace('src/views/', ''),
43 gulp.dest(paths.tmp), 43 gulp.dest(paths.tmp),
44 rename('foca-crear-nota-pedido.min.js'), 44 rename('foca-crear-nota-pedido.min.js'),
45 uglify(), 45 uglify(),
46 replace('"ngRoute","ui.bootstrap","focaModalVendedores","focaBusquedaProductos",'+
47 '"focaModalPetroleras","focaBusquedaCliente"', ''),
46 gulp.dest(paths.dist) 48 gulp.dest(paths.dist)
47 ] 49 ]
48 ); 50 );
49 }); 51 });
50 52
51 gulp.task('clean', function(){ 53 gulp.task('clean', function(){
52 return gulp.src(['tmp', 'dist'], {read: false}) 54 return gulp.src(['tmp', 'dist'], {read: false})
53 .pipe(clean()); 55 .pipe(clean());
54 }); 56 });
55 57
56 gulp.task('pre-commit', function() { 58 gulp.task('pre-commit', function() {
57 return pump( 59 return pump(
58 [ 60 [
59 gulp.src(paths.srcJS), 61 gulp.src(paths.srcJS),
60 jshint('.jshintrc'), 62 jshint('.jshintrc'),
61 jshint.reporter('default'), 63 jshint.reporter('default'),
62 jshint.reporter('fail') 64 jshint.reporter('fail')
63 ] 65 ]
64 ); 66 );
65 67
66 gulp.start('uglify'); 68 gulp.start('uglify');
67 }); 69 });
68 70
69 gulp.task('webserver', function() { 71 gulp.task('webserver', function() {
70 pump [ 72 pump [
71 connect.server({port: 3000}) 73 connect.server({port: 3000})
72 ] 74 ]
73 }); 75 });
74 76
77 gulp.task('clean-post-install', function() {
78 return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js',
79 'index.html'], {read: false})
80 .pipe(clean());
81 });
82
75 gulp.task('default', ['webserver']); 83 gulp.task('default', ['webserver']);
76 84
1 { 1 {
2 "name": "foca-crear-nota-pedido", 2 "name": "foca-crear-nota-pedido",
3 "version": "0.0.1", 3 "version": "0.0.1",
4 "description": "Listado y ABM nota de pedidos", 4 "description": "Listado y ABM nota de pedidos",
5 "main": "index.js", 5 "main": "index.js",
6 "scripts": { 6 "scripts": {
7 "test": "echo \"Error: no test specified\" && exit 1", 7 "test": "echo \"Error: no test specified\" && exit 1",
8 "compile": "gulp uglify", 8 "compile": "gulp uglify",
9 "postinstall": "npm run compile && rm -R src && rm index.html && rm .jshintrc && rm gulpfile.js", 9 "gulp-pre-commit": "gulp pre-commit",
10 "install-dev": "npm install -D jasmine-core pre-commit angular angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es jquery jshint pump" 10 "postinstall": "npm run compile && gulp clean-post-install",
11 "install-dev": "npm install -D jasmine-core pre-commit angular angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+https://debo.suite.repo/modulos-npm/foca-directivas.git git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git git+https://debo.suite.repo/modulos-npm/foca-modal-petroleras.git git+https://debo.suite.repo/nguarnieri/foca-modal-busqueda-productos git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git"
11 }, 12 },
13 "pre-commit": [
14 "gulp-pre-commit"
15 ],
12 "repository": { 16 "repository": {
13 "type": "git", 17 "type": "git",
14 "url": "https://192.168.0.11/modulos-npm/foca-crear-nota-pedido.git" 18 "url": "https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido.git"
15 }, 19 },
16 "author": "Foca Software", 20 "author": "Foca Software",
17 "license": "ISC", 21 "license": "ISC",
18 "dependencies": { 22 "peerDependencies": {
19 "foca-directivas": "git+https://192.168.0.11/modulos-npm/foca-directivas.git", 23 "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git",
20 "foca-modal-busqueda-productos": "git+https://192.168.0.11/nguarnieri/foca-modal-busqueda-productos", 24 "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git",
21 "foca-modal-petroleras": "git+https://192.168.0.11/modulos-npm/foca-modal-petroleras.git", 25 "foca-modal-busqueda-productos": "git+https://debo.suite.repo/nguarnieri/foca-modal-busqueda-productos",
22 "foca-modal-vendedores": "git+https://192.168.0.11/modulos-npm/foca-modal-vendedores.git", 26 "foca-modal-petroleras": "git+https://debo.suite.repo/modulos-npm/foca-modal-petroleras.git",
23 "jquery": "^3.3.x" 27 "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git"
24 }, 28 },
25 "devDependencies": { 29 "devDependencies": {
26 "angular": "^1.7.5", 30 "angular": "^1.7.5",
27 "angular-route": "^1.7.5", 31 "angular-route": "^1.7.5",
28 "bootstrap": "^4.1.3", 32 "bootstrap": "^4.1.3",
29 "foca-busqueda-cliente": "git+https://192.168.0.11/modulos-npm/foca-busqueda-cliente", 33 "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git",
34 "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git",
35 "foca-modal-busqueda-productos": "git+https://debo.suite.repo/nguarnieri/foca-modal-busqueda-productos",
36 "foca-modal-petroleras": "git+https://debo.suite.repo/modulos-npm/foca-modal-petroleras.git",
37 "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git",
30 "font-awesome": "^4.7.0", 38 "font-awesome": "^4.7.0",
31 "gulp": "^3.9.1", 39 "gulp": "^3.9.1",
32 "gulp-angular-templatecache": "^2.2.2", 40 "gulp-angular-templatecache": "^2.2.2",
33 "gulp-clean": "^0.4.0", 41 "gulp-clean": "^0.4.0",
34 "gulp-concat": "^2.6.1", 42 "gulp-concat": "^2.6.1",
35 "gulp-connect": "^5.6.1", 43 "gulp-connect": "^5.6.1",
36 "gulp-htmlmin": "^5.0.1", 44 "gulp-htmlmin": "^5.0.1",
37 "gulp-jshint": "^2.1.0", 45 "gulp-jshint": "^2.1.0",
38 "gulp-rename": "^1.4.0", 46 "gulp-rename": "^1.4.0",
39 "gulp-replace": "^1.0.0", 47 "gulp-replace": "^1.0.0",
48 "gulp-sequence": "^1.0.0",
40 "gulp-uglify": "^3.0.1", 49 "gulp-uglify": "^3.0.1",
41 "gulp-uglify-es": "^1.0.4", 50 "gulp-uglify-es": "^1.0.4",
42 "jasmine-core": "^3.2.1", 51 "jasmine-core": "^3.2.1",
52 "jquery": "^3.3.1",
43 "jshint": "^2.9.6", 53 "jshint": "^2.9.6",
44 "pre-commit": "^1.2.2", 54 "pre-commit": "^1.2.2",
45 "pump": "^3.0.0", 55 "pump": "^3.0.0",
46 "ui-bootstrap4": "^3.0.5" 56 "ui-bootstrap4": "^3.0.5"
47 } 57 }
48 } 58 }
49 59
src/js/controller.js
1 angular.module('focaCrearNotaPedido') 1 angular.module('focaCrearNotaPedido')
2 .controller('notaPedidoCtrl', 2 .controller('notaPedidoCtrl',
3 ['$scope', '$uibModal', '$location', 'crearNotaPedidoService', 3 ['$scope', '$uibModal', '$location', 'crearNotaPedidoService',
4 function($scope, $uibModal, $location, crearNotaPedidoService) { 4 function($scope, $uibModal, $location, crearNotaPedidoService) {
5 $scope.show = false; 5 $scope.show = false;
6 6
7 $scope.dateOptions = { 7 $scope.dateOptions = {
8 maxDate: new Date(), 8 maxDate: new Date(),
9 minDate: new Date(2010,0,1) 9 minDate: new Date(2010,0,1)
10 }; 10 };
11 11
12 $scope.notaPedido = {}; 12 $scope.notaPedido = {};
13 $scope.articulosTabla = []; 13 $scope.articulosTabla = [];
14 var idLista; 14 var idLista;
15 var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); 15 var notaPedidoTemp = crearNotaPedidoService.getNotaPedido();
16 $scope.domiciliosCliente = crearNotaPedidoService.getDomicilios(1); 16 $scope.domiciliosCliente = crearNotaPedidoService.getDomicilios(1);
17 crearNotaPedidoService.getPrecioCondicion().then( 17 crearNotaPedidoService.getPrecioCondicion().then(
18 function(res) { 18 function(res) {
19 $scope.precioCondiciones = res.data; 19 $scope.precioCondiciones = res.data;
20 } 20 }
21 ); 21 );
22 if (notaPedidoTemp != undefined) { 22 if (notaPedidoTemp !== undefined) {
23 notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); 23 notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga);
24 $scope.notaPedido = notaPedidoTemp; 24 $scope.notaPedido = notaPedidoTemp;
25 $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); 25 $scope.notaPedido.flete = ($scope.notaPedido.flete).toString();
26 $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); 26 $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString();
27 idLista = $scope.notaPedido.precioCondicion; 27 idLista = $scope.notaPedido.precioCondicion;
28 crearNotaPedidoService 28 crearNotaPedidoService
29 .getArticulosByIdNotaPedido($scope.notaPedido.id).then( 29 .getArticulosByIdNotaPedido($scope.notaPedido.id).then(
30 function(res) { 30 function(res) {
31 $scope.articulosTabla = res.data; 31 $scope.articulosTabla = res.data;
32 } 32 }
33 ); 33 );
34 crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( 34 crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then(
35 function(res) { 35 function(res) {
36 $scope.notaPedido.domicilio = res.data; 36 $scope.notaPedido.domicilio = res.data;
37 } 37 }
38 ) 38 );
39 } else { 39 } else {
40 $scope.notaPedido.fechaCarga = new Date(); 40 $scope.notaPedido.fechaCarga = new Date();
41 $scope.notaPedido.domicilio = [{ id: 0 }] 41 $scope.notaPedido.domicilio = [{ id: 0 }];
42 $scope.notaPedido.bomba = '1'; 42 $scope.notaPedido.bomba = '1';
43 $scope.notaPedido.flete = '1'; 43 $scope.notaPedido.flete = '1';
44 idLista = undefined; 44 idLista = undefined;
45 } 45 }
46 $scope.addNewDom = function() { 46 $scope.addNewDom = function() {
47 $scope.notaPedido.domicilio.push({ 'id': 0 }); 47 $scope.notaPedido.domicilio.push({ 'id': 0 });
48 } 48 };
49 $scope.removeNewChoice = function(choice) { 49 $scope.removeNewChoice = function(choice) {
50 if ($scope.notaPedido.domicilio.length > 1) { 50 if ($scope.notaPedido.domicilio.length > 1) {
51 $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( 51 $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex(
52 function(c) { 52 function(c) {
53 return c.$$hashKey == choice.$$hashKey; 53 return c.$$hashKey === choice.$$hashKey;
54 } 54 }
55 ), 1) 55 ), 1);
56 } 56 }
57 } 57 };
58 $scope.crearNotaPedido = function() { 58 $scope.crearNotaPedido = function() {
59 var notaPedido = { 59 var notaPedido = {
60 id: 0, 60 id: 0,
61 precioCondicion: $scope.notaPedido.precioCondicion, 61 precioCondicion: $scope.notaPedido.precioCondicion,
62 fechaCarga: $scope.notaPedido.fechaCarga, 62 fechaCarga: $scope.notaPedido.fechaCarga,
63 vendedor: $scope.notaPedido.vendedor, 63 vendedor: $scope.notaPedido.vendedor,
64 cliente: $scope.notaPedido.cliente, 64 cliente: $scope.notaPedido.cliente,
65 producto: $scope.notaPedido.producto, 65 producto: $scope.notaPedido.producto,
66 bomba: $scope.notaPedido.bomba, 66 bomba: $scope.notaPedido.bomba,
67 petrolera: $scope.notaPedido.petrolera, 67 petrolera: $scope.notaPedido.petrolera,
68 domicilio: $scope.notaPedido.domicilio, 68 domicilio: $scope.notaPedido.domicilio,
69 kilometros: $scope.notaPedido.kilometros, 69 kilometros: $scope.notaPedido.kilometros,
70 jurisdiccionIIBB: $scope.notaPedido.jurisdiccionIIBB, 70 jurisdiccionIIBB: $scope.notaPedido.jurisdiccionIIBB,
71 costoFinanciacion: $scope.notaPedido.costoFinanciacion, 71 costoFinanciacion: $scope.notaPedido.costoFinanciacion,
72 flete: $scope.notaPedido.flete, 72 flete: $scope.notaPedido.flete,
73 costoUnitarioKmFlete: $scope.notaPedido.costoUnitarioKmFlete, 73 costoUnitarioKmFlete: $scope.notaPedido.costoUnitarioKmFlete,
74 total : $scope.articulosTabla[0].subTotal 74 total: $scope.articulosTabla[0].subTotal
75 } 75 };
76 crearNotaPedidoService.crearNotaPedido(notaPedido).then( 76 crearNotaPedidoService.crearNotaPedido(notaPedido).then(
77 function(res) { 77 function() {
78 alert('Nota pedido creada'); 78 alert('Nota pedido creada');
79 $location.path('/venta-nota-pedido'); 79 $location.path('/venta-nota-pedido');
80 } 80 }
81 ) 81 );
82 var articulosNotaPedido = $scope.articulosTabla; 82 var articulosNotaPedido = $scope.articulosTabla;
83 for(var i = 0; i< articulosNotaPedido.length;i++) { 83 for(var i = 0; i< articulosNotaPedido.length;i++) {
84 crearNotaPedidoService.crearArticulosParaNotaPedido(articulosNotaPedido[i]).then( 84 crearNotaPedidoService
85 function(res) { 85 .crearArticulosParaNotaPedido(articulosNotaPedido[i]).then(
86 return; 86 function() {
87 } 87 return;
88 ) 88 }
89 );
89 } 90 }
90 91
91 } 92 };
92 $scope.siguienteTab = function() { 93 $scope.siguienteTab = function() {
93 $scope.active = 1; 94 $scope.active = 1;
94 } 95 };
95 $scope.seleccionarArticulo = function() { 96 $scope.seleccionarArticulo = function() {
96 if (idLista == undefined) { 97 if (idLista === undefined) {
97 alert('primero seleccione una lista de precio y condicion'); 98 alert('primero seleccione una lista de precio y condicion');
98 return; 99 return;
99 } 100 }
100 var modalInstance = $uibModal.open( 101 var modalInstance = $uibModal.open(
101 { 102 {
102 ariaLabelledBy: 'Busqueda de Productos', 103 ariaLabelledBy: 'Busqueda de Productos',
103 templateUrl: 'modal-busqueda-productos.html', 104 templateUrl: 'modal-busqueda-productos.html',
104 controller: 'modalBusquedaProductosCtrl', 105 controller: 'modalBusquedaProductosCtrl',
105 resolve: { idLista: function() { return idLista } }, 106 resolve: { idLista: function() { return idLista; } },
106 size: 'lg' 107 size: 'lg'
107 } 108 }
108 ) 109 );
109 modalInstance.result.then( 110 modalInstance.result.then(
110 function(producto) { 111 function(producto) {
111 var newArt = 112 var newArt =
112 { 113 {
113 id: 0, 114 id: 0,
114 codigo: producto.FiltroSectorCodigo, 115 codigo: producto.FiltroSectorCodigo,
115 item: $scope.articulosTabla.length + 1, 116 item: $scope.articulosTabla.length + 1,
116 nombre: producto.descripcion, 117 nombre: producto.descripcion,
117 precio: producto.precio, 118 precio: producto.precio,
118 costoUnitario: producto.costo, 119 costoUnitario: producto.costo,
119 cantidad: 1 120 cantidad: 1
120 } 121 };
121 $scope.articulosTabla.unshift(newArt); 122 $scope.articulosTabla.unshift(newArt);
122 }, function() { 123 }, function() {
123 // funcion ejecutada cuando se cancela el modal 124 // funcion ejecutada cuando se cancela el modal
124 } 125 }
125 ); 126 );
126 } 127 };
127 $scope.seleccionarVendedor = function() { 128 $scope.seleccionarVendedor = function() {
128 var modalInstance = $uibModal.open( 129 var modalInstance = $uibModal.open(
129 { 130 {
130 ariaLabelledBy: 'Busqueda de Vendedores', 131 ariaLabelledBy: 'Busqueda de Vendedores',
131 templateUrl: 'modal-vendedores.html', 132 templateUrl: 'modal-vendedores.html',
132 controller: 'modalVendedoresCtrl', 133 controller: 'modalVendedoresCtrl',
133 size: 'lg' 134 size: 'lg'
134 } 135 }
135 ) 136 );
136 modalInstance.result.then( 137 modalInstance.result.then(
137 function(vendedor) { 138 function(vendedor) {
138 $scope.notaPedido.vendedor = vendedor.NomVen; 139 $scope.notaPedido.vendedor = vendedor.NomVen;
139 }, function() { 140 }, function() {
140 141
141 } 142 }
142 ); 143 );
143 } 144 };
144 $scope.seleccionarPetrolera = function() { 145 $scope.seleccionarPetrolera = function() {
145 var modalInstance = $uibModal.open( 146 var modalInstance = $uibModal.open(
146 { 147 {
147 ariaLabelledBy: 'Busqueda de Petrolera', 148 ariaLabelledBy: 'Busqueda de Petrolera',
148 templateUrl: 'modal-petroleras.html', 149 templateUrl: 'modal-petroleras.html',
149 controller: 'modalPetrolerasCtrl', 150 controller: 'modalPetrolerasCtrl',
150 size: 'lg' 151 size: 'lg'
151 } 152 }
152 ) 153 );
153 modalInstance.result.then( 154 modalInstance.result.then(
154 function(petrolera) { 155 function(petrolera) {
155 $scope.notaPedido.petrolera = petrolera.NOM; 156 $scope.notaPedido.petrolera = petrolera.NOM;
156 }, function() { 157 }, function() {
157 158
158 } 159 }
159 ); 160 );
160 } 161 };
161 $scope.seleccionarCliente = function() { 162 $scope.seleccionarCliente = function() {
162 var modalInstance = $uibModal.open( 163 var modalInstance = $uibModal.open(
163 { 164 {
164 ariaLabelledBy: 'Busqueda de Cliente', 165 ariaLabelledBy: 'Busqueda de Cliente',
165 templateUrl: 'foca-busqueda-cliente-modal.html', 166 templateUrl: 'foca-busqueda-cliente-modal.html',
166 controller: 'focaBusquedaClienteModalController', 167 controller: 'focaBusquedaClienteModalController',
167 size: 'lg' 168 size: 'lg'
168 } 169 }
169 ) 170 );
170 modalInstance.result.then( 171 modalInstance.result.then(
171 function(cliente) { 172 function(cliente) {
172 $scope.notaPedido.cliente = cliente.nom; 173 $scope.notaPedido.cliente = cliente.nom;
173 }, function() { 174 }, function() {
174 175
175 } 176 }
176 ); 177 );
177 } 178 };
178 $scope.obtenerDomicilios = function(id) { 179 $scope.obtenerDomicilios = function(id) {
179 crearNotaPedidoService.getDomicilios(id).then( 180 crearNotaPedidoService.getDomicilios(id).then(
180 function(res) { 181 function(res) {
181 $scope.notaPedido.domicilio = res.data; 182 $scope.notaPedido.domicilio = res.data;
182 } 183 }
183 ) 184 );
184 } 185 };
185 $scope.getSubTotal = function(item) { 186 $scope.getSubTotal = function(item) {
186 var subTotal = 0; 187 var subTotal = 0;
187 var array = $scope.articulosTabla.filter( 188 var array = $scope.articulosTabla.filter(
188 function(a) { 189 function(a) {
189 return a.item <= item; 190 return a.item <= item;
190 } 191 }
191 ); 192 );
192 for (var i = 0; i < array.length; i++) { 193 for (var i = 0; i < array.length; i++) {
193 subTotal += array[i].precio * array[i].cantidad 194 subTotal += array[i].precio * array[i].cantidad;
194 } 195 }
195 return subTotal.toFixed(2); 196 return subTotal.toFixed(2);
196 } 197 };
197 $scope.cargarArticulos = function() { 198 $scope.cargarArticulos = function() {
198 idLista = $scope.notaPedido.precioCondicion; 199 idLista = $scope.notaPedido.precioCondicion;
199 $scope.articulosTabla = []; 200 $scope.articulosTabla = [];
200 } 201 };
201 } 202 }
202 ] 203 ]
203 ) 204 )
204 .controller('notaPedidoListaCtrl', [ 205 .controller('notaPedidoListaCtrl', [
205 '$scope', 206 '$scope',
206 'crearNotaPedidoService', 207 'crearNotaPedidoService',
207 '$location', 208 '$location',
208 function($scope, crearNotaPedidoService, $location) { 209 function($scope, crearNotaPedidoService, $location) {
209 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { 210 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) {
210 $scope.notaPedidos = datos.data; 211 $scope.notaPedidos = datos.data;
211 }); 212 });
212 $scope.editar = function(notaPedido) { 213 $scope.editar = function(notaPedido) {
213 crearNotaPedidoService.setNotaPedido(notaPedido); 214 crearNotaPedidoService.setNotaPedido(notaPedido);
214 $location.path('/venta-nota-pedido/abm/'); 215 $location.path('/venta-nota-pedido/abm/');
215 } 216 };
216 $scope.crearPedido = function() { 217 $scope.crearPedido = function() {
217 crearNotaPedidoService.clearNotaPedido(); 218 crearNotaPedidoService.clearNotaPedido();
218 $location.path('/venta-nota-pedido/abm/'); 219 $location.path('/venta-nota-pedido/abm/');
219 } 220 };
220 } 221 }
221 ]) 222 ]);
222 223
1 angular.module('focaCrearNotaPedido') 1 angular.module('focaCrearNotaPedido')
2 .service('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { 2 .service('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) {
3 var route = API_ENDPOINT.URL; 3 var route = API_ENDPOINT.URL;
4 var notaPedido;
5 return { 4 return {
6 crearNotaPedido: function(notaPedido) { 5 crearNotaPedido: function(notaPedido) {
7 return $http.post(route + '/nota-pedido', {notaPedido: notaPedido}); 6 return $http.post(route + '/nota-pedido', {notaPedido: notaPedido});
8 }, 7 },
9 obtenerNotaPedido: function() { 8 obtenerNotaPedido: function() {
10 return $http.get(route +'/nota-pedido'); 9 return $http.get(route +'/nota-pedido');
11 }, 10 },
12 setNotaPedido: function(notaPedido) { 11 setNotaPedido: function(notaPedido) {
13 this.notaPedido = notaPedido; 12 this.notaPedido = notaPedido;
14 }, 13 },
15 clearNotaPedido: function() { 14 clearNotaPedido: function() {
16 this.notaPedido = undefined; 15 this.notaPedido = undefined;
17 }, 16 },
18 getNotaPedido: function() { 17 getNotaPedido: function() {
19 return this.notaPedido; 18 return this.notaPedido;
20 }, 19 },
21 getArticulosByIdNotaPedido: function(id) { 20 getArticulosByIdNotaPedido: function(id) {
22 return $http.get(route+'/articulos/nota-pedido/'+id); 21 return $http.get(route+'/articulos/nota-pedido/'+id);
23 }, 22 },
24 crearArticulosParaNotaPedido: function(articuloNotaPedido) { 23 crearArticulosParaNotaPedido: function(articuloNotaPedido) {
25 return $http.post(route + '/articulos/nota-pedido', {articuloNotaPedido: articuloNotaPedido}); 24 return $http.post(route + '/articulos/nota-pedido',
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 //EN DESARROLLO 30 //EN DESARROLLO
31 getDomicilios: function(id) { 31 getDomicilios: function(id) {
32 // return $http.get(route + '/'+id) 32 // return $http.get(route + '/'+id)
33 id='le asigno un valor para pasar pre commit';
33 var domicilio = [ 34 var domicilio = [
34 { 35 {
35 id: 1, 36 id: 1,
36 dom: 'RISSO PATRON 781' 37 dom: 'RISSO PATRON 781'
37 }, 38 },
38 { 39 {
39 id: 2, 40 id: 2,
40 dom: 'MARIANO MORENO 533' 41 dom: 'MARIANO MORENO 533'
41 }, 42 },
42 { 43 {
43 id: 3, 44 id: 3,
44 dom: 'SALTA 796' 45 dom: 'SALTA 796'
45 } 46 }
46 ] 47 ];
47 return domicilio; 48 return domicilio;
48 }, 49 },
49 getPrecioCondicion: function() { 50 getPrecioCondicion: function() {
50 return $http.get(route + '/precio-condicion') 51 return $http.get(route + '/precio-condicion');
51 }, 52 },
52 getPrecioCondicionById: function(id) { 53 getPrecioCondicionById: function(id) {
53 return $http.get(route + '/precio-condicion/' + id) 54 return $http.get(route + '/precio-condicion/' + id);
54 }, 55 },
55 getPlazoPagoByPrecioCondicion: function(id) { 56 getPlazoPagoByPrecioCondicion: function(id) {
56 return $http.get(route + '/plazo-pago/precio-condicion/'+ id) 57 return $http.get(route + '/plazo-pago/precio-condicion/'+ id);
57 } 58 }
58 } 59 };
59 }]) 60 }]);