Commit d1dceaf34bb4d6a3e55779814e59ba419b7a05d3
Exists in
master
Merge branch 'master' into 'master'
header info dinamico See merge request modulos-npm/foca-crear-nota-pedido!22
Showing
2 changed files
Show diff stats
src/js/controller.js
1 | -angular.module('focaCrearNotaPedido') | |
2 | - .controller('notaPedidoCtrl', | |
3 | - ['$scope', '$uibModal', '$location', 'crearNotaPedidoService', 'focaModalService', | |
4 | - function($scope, $uibModal, $location, crearNotaPedidoService, focaModalService) { | |
5 | - $scope.botonera = [ | |
6 | - {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, | |
7 | - {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | |
8 | - {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | |
9 | - { | |
10 | - texto: 'Precios y condiciones', | |
11 | - accion: function() {$scope.abrirModalListaPrecio();}}, | |
12 | - {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | |
13 | - {texto: 'Bomba', accion: function() {}}, | |
14 | - {texto: 'Detalle', accion: function() {}}, | |
15 | - {texto: 'Totales', accion: function() {}} | |
16 | - ]; | |
17 | - $scope.show = false; | |
18 | - $scope.cargando = true; | |
19 | - $scope.dateOptions = { | |
20 | - maxDate: new Date(), | |
21 | - minDate: new Date(2010, 0, 1) | |
22 | - }; | |
23 | - $scope.notaPedido = { | |
24 | - vendedor: {}, | |
25 | - cliente: {}, | |
26 | - domicilio: {dom: ''}, | |
27 | - moneda: {detalle: ''} | |
28 | - }; | |
29 | - $scope.articulosTabla = []; | |
30 | - var idLista; | |
31 | - var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | |
32 | - crearNotaPedidoService.getPrecioCondicion().then( | |
33 | - function(res) { | |
34 | - $scope.precioCondiciones = res.data; | |
35 | - } | |
36 | - ); | |
37 | - if (notaPedidoTemp !== undefined) { | |
38 | - notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | |
39 | - $scope.notaPedido = notaPedidoTemp; | |
40 | - $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | |
41 | - $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | |
42 | - idLista = $scope.notaPedido.precioCondicion; | |
43 | - crearNotaPedidoService | |
44 | - .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | |
45 | - function(res) { | |
46 | - $scope.articulosTabla = res.data; | |
47 | - } | |
48 | - ); | |
49 | - //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | |
50 | - //(NO REQUERIDO EN ESTA VERSION) | |
51 | - // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | |
52 | - // function(res) { | |
53 | - // $scope.notaPedido.domicilio = res.data; | |
54 | - // } | |
55 | - // ); | |
56 | - } else { | |
57 | - $scope.notaPedido.fechaCarga = new Date(); | |
58 | - $scope.notaPedido.bomba = '0'; | |
59 | - $scope.notaPedido.flete = '0'; | |
60 | - idLista = undefined; | |
1 | +angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | |
2 | + [ | |
3 | + '$scope', '$uibModal', '$location', 'crearNotaPedidoService', 'focaModalService', | |
4 | + function($scope, $uibModal, $location, crearNotaPedidoService, focaModalService) { | |
5 | + $scope.botonera = [ | |
6 | + {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, | |
7 | + {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | |
8 | + {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | |
9 | + { | |
10 | + texto: 'Precios y condiciones', | |
11 | + accion: function() {$scope.abrirModalListaPrecio();}}, | |
12 | + {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | |
13 | + {texto: 'Bomba', accion: function() {}}, | |
14 | + {texto: 'Detalle', accion: function() {}}, | |
15 | + {texto: 'Totales', accion: function() {}} | |
16 | + ]; | |
17 | + | |
18 | + $scope.show = false; | |
19 | + $scope.cargando = true; | |
20 | + $scope.dateOptions = { | |
21 | + maxDate: new Date(), | |
22 | + minDate: new Date(2010, 0, 1) | |
23 | + }; | |
24 | + | |
25 | + $scope.notaPedido = { | |
26 | + vendedor: {}, | |
27 | + cliente: {}, | |
28 | + domicilio: {dom: ''}, | |
29 | + moneda: {detalle: ''} | |
30 | + }; | |
31 | + | |
32 | + $scope.cabecera = []; | |
33 | + | |
34 | + $scope.now = new Date(); | |
35 | + $scope.puntoVenta = Math.round(Math.random() * 10000); | |
36 | + $scope.comprobante = Math.round(Math.random() * 1000000); | |
37 | + | |
38 | + $scope.articulosTabla = []; | |
39 | + var idLista; | |
40 | + var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | |
41 | + crearNotaPedidoService.getPrecioCondicion().then( | |
42 | + function(res) { | |
43 | + $scope.precioCondiciones = res.data; | |
61 | 44 | } |
62 | - //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | |
63 | - // $scope.addNewDom = function() { | |
64 | - // $scope.notaPedido.domicilio.push({ 'id': 0 }); | |
65 | - // }; | |
66 | - // $scope.removeNewChoice = function(choice) { | |
67 | - // if ($scope.notaPedido.domicilio.length > 1) { | |
68 | - // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | |
69 | - // function(c) { | |
70 | - // return c.$$hashKey === choice.$$hashKey; | |
71 | - // } | |
72 | - // ), 1); | |
73 | - // } | |
74 | - // }; | |
75 | - $scope.crearNotaPedido = function() { | |
76 | - if($scope.articulosTabla.length === 0) { | |
77 | - focaModalService.alert('Debe cargar almenos un articulo'); | |
78 | - return; | |
79 | - } | |
80 | - if($scope.notaPedido.domicilio.id === undefined) { | |
81 | - $scope.notaPedido.domicilio.id = 0; | |
82 | - } | |
83 | - var date = new Date(); | |
84 | - var notaPedido = { | |
85 | - id: 0, | |
86 | - fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | |
87 | - .toISOString().slice(0, 19).replace('T', ' '), | |
88 | - vendedor: $scope.notaPedido.vendedor.nombre, | |
89 | - idCliente: $scope.notaPedido.cliente.id, | |
90 | - domicilio: $scope.notaPedido.domicilio, | |
91 | - precioCondicion: $scope.notaPedido.precioCondicion, | |
92 | - bomba: $scope.notaPedido.bomba, | |
93 | - flete: $scope.notaPedido.flete, | |
94 | - total: $scope.getTotal() | |
95 | - }; | |
96 | - crearNotaPedidoService.crearNotaPedido(notaPedido).then( | |
97 | - function(data) { | |
98 | - focaModalService.alert('Nota pedido creada'); | |
99 | - if($scope.notaPedido.flete === 1) { | |
100 | - var flete = { | |
101 | - idNotaPedido: data.data.id, | |
102 | - idTransportista: $scope.notaPedido.fleteId, | |
103 | - idChofer: $scope.notaPedido.chofer.id, | |
104 | - idVehiculo: $scope.notaPedido.vehiculo.id, | |
105 | - kilometros: $scope.notaPedido.kilometros, | |
106 | - costoKilometro: $scope.notaPedido.costoUnitarioKmFlete | |
107 | - }; | |
108 | - crearNotaPedidoService.crearFlete(flete); | |
109 | - } | |
110 | - var articulosNotaPedido = $scope.articulosTabla; | |
111 | - for(var i = 0; i < articulosNotaPedido.length; i++) { | |
112 | - delete articulosNotaPedido[i].edit; | |
113 | - articulosNotaPedido[i].idNotaPedido = data.data.id; | |
114 | - crearNotaPedidoService | |
115 | - .crearArticulosParaNotaPedido(articulosNotaPedido[i]); | |
116 | - } | |
117 | - $scope.limpiarPantalla(); | |
45 | + ); | |
46 | + if (notaPedidoTemp !== undefined) { | |
47 | + notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | |
48 | + $scope.notaPedido = notaPedidoTemp; | |
49 | + $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | |
50 | + $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | |
51 | + idLista = $scope.notaPedido.precioCondicion; | |
52 | + crearNotaPedidoService | |
53 | + .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | |
54 | + function(res) { | |
55 | + $scope.articulosTabla = res.data; | |
118 | 56 | } |
119 | 57 | ); |
58 | + //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | |
59 | + //(NO REQUERIDO EN ESTA VERSION) | |
60 | + // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | |
61 | + // function(res) { | |
62 | + // $scope.notaPedido.domicilio = res.data; | |
63 | + // } | |
64 | + // ); | |
65 | + } else { | |
66 | + $scope.notaPedido.fechaCarga = new Date(); | |
67 | + $scope.notaPedido.bomba = '0'; | |
68 | + $scope.notaPedido.flete = '0'; | |
69 | + idLista = undefined; | |
70 | + } | |
71 | + //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | |
72 | + // $scope.addNewDom = function() { | |
73 | + // $scope.notaPedido.domicilio.push({ 'id': 0 }); | |
74 | + // }; | |
75 | + // $scope.removeNewChoice = function(choice) { | |
76 | + // if ($scope.notaPedido.domicilio.length > 1) { | |
77 | + // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | |
78 | + // function(c) { | |
79 | + // return c.$$hashKey === choice.$$hashKey; | |
80 | + // } | |
81 | + // ), 1); | |
82 | + // } | |
83 | + // }; | |
84 | + $scope.crearNotaPedido = function() { | |
85 | + if($scope.articulosTabla.length === 0) { | |
86 | + focaModalService.alert('Debe cargar almenos un articulo'); | |
87 | + return; | |
88 | + } | |
89 | + if($scope.notaPedido.domicilio.id === undefined) { | |
90 | + $scope.notaPedido.domicilio.id = 0; | |
91 | + } | |
92 | + var date = new Date(); | |
93 | + var notaPedido = { | |
94 | + id: 0, | |
95 | + fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | |
96 | + .toISOString().slice(0, 19).replace('T', ' '), | |
97 | + vendedor: $scope.notaPedido.vendedor.nombre, | |
98 | + idCliente: $scope.notaPedido.cliente.id, | |
99 | + domicilio: $scope.notaPedido.domicilio, | |
100 | + precioCondicion: $scope.notaPedido.precioCondicion, | |
101 | + bomba: $scope.notaPedido.bomba, | |
102 | + flete: $scope.notaPedido.flete, | |
103 | + total: $scope.getTotal() | |
120 | 104 | }; |
121 | - $scope.seleccionarArticulo = function() { | |
122 | - if (idLista === undefined) { | |
123 | - focaModalService.alert( | |
124 | - 'Primero seleccione una lista de precio y condicion'); | |
125 | - return; | |
126 | - } | |
127 | - var modalInstance = $uibModal.open( | |
128 | - { | |
129 | - ariaLabelledBy: 'Busqueda de Productos', | |
130 | - templateUrl: 'modal-busqueda-productos.html', | |
131 | - controller: 'modalBusquedaProductosCtrl', | |
132 | - resolve: { idLista: function() { return idLista; } }, | |
133 | - size: 'lg' | |
134 | - } | |
135 | - ); | |
136 | - modalInstance.result.then( | |
137 | - function(producto) { | |
138 | - var newArt = | |
139 | - { | |
140 | - id: 0, | |
141 | - codigo: producto.codigo, | |
142 | - sector: producto.sector, | |
143 | - descripcion: producto.descripcion, | |
144 | - item: $scope.articulosTabla.length + 1, | |
145 | - nombre: producto.descripcion, | |
146 | - precio: producto.precio.toFixed(2), | |
147 | - costoUnitario: producto.costo, | |
148 | - edit: false | |
105 | + crearNotaPedidoService.crearNotaPedido(notaPedido).then( | |
106 | + function(data) { | |
107 | + focaModalService.alert('Nota pedido creada'); | |
108 | + if($scope.notaPedido.flete === 1) { | |
109 | + var flete = { | |
110 | + idNotaPedido: data.data.id, | |
111 | + idTransportista: $scope.notaPedido.fleteId, | |
112 | + idChofer: $scope.notaPedido.chofer.id, | |
113 | + idVehiculo: $scope.notaPedido.vehiculo.id, | |
114 | + kilometros: $scope.notaPedido.kilometros, | |
115 | + costoKilometro: $scope.notaPedido.costoUnitarioKmFlete | |
149 | 116 | }; |
150 | - $scope.articuloACargar = newArt; | |
151 | - $scope.cargando = false; | |
152 | - }, function() { | |
153 | - // funcion ejecutada cuando se cancela el modal | |
117 | + crearNotaPedidoService.crearFlete(flete); | |
154 | 118 | } |
155 | - ); | |
156 | - }; | |
157 | - $scope.seleccionarVendedor = function() { | |
158 | - var modalInstance = $uibModal.open( | |
159 | - { | |
160 | - ariaLabelledBy: 'Busqueda de Vendedores', | |
161 | - templateUrl: 'modal-vendedores.html', | |
162 | - controller: 'modalVendedoresCtrl', | |
163 | - size: 'lg' | |
119 | + var articulosNotaPedido = $scope.articulosTabla; | |
120 | + for(var i = 0; i < articulosNotaPedido.length; i++) { | |
121 | + delete articulosNotaPedido[i].edit; | |
122 | + articulosNotaPedido[i].idNotaPedido = data.data.id; | |
123 | + crearNotaPedidoService | |
124 | + .crearArticulosParaNotaPedido(articulosNotaPedido[i]); | |
164 | 125 | } |
165 | - ); | |
166 | - modalInstance.result.then( | |
167 | - function(vendedor) { | |
168 | - $scope.notaPedido.vendedor.nombre = vendedor.NomVen; | |
169 | - }, function() { | |
126 | + $scope.limpiarPantalla(); | |
127 | + } | |
128 | + ); | |
129 | + }; | |
170 | 130 | |
171 | - } | |
172 | - ); | |
173 | - }; | |
174 | - $scope.seleccionarPetrolera = function() { | |
175 | - var modalInstance = $uibModal.open( | |
131 | + $scope.seleccionarArticulo = function() { | |
132 | + if (idLista === undefined) { | |
133 | + focaModalService.alert( | |
134 | + 'Primero seleccione una lista de precio y condicion'); | |
135 | + return; | |
136 | + } | |
137 | + var modalInstance = $uibModal.open( | |
138 | + { | |
139 | + ariaLabelledBy: 'Busqueda de Productos', | |
140 | + templateUrl: 'modal-busqueda-productos.html', | |
141 | + controller: 'modalBusquedaProductosCtrl', | |
142 | + resolve: { idLista: function() { return idLista; } }, | |
143 | + size: 'lg' | |
144 | + } | |
145 | + ); | |
146 | + modalInstance.result.then( | |
147 | + function(producto) { | |
148 | + var newArt = | |
176 | 149 | { |
177 | - ariaLabelledBy: 'Busqueda de Petrolera', | |
178 | - templateUrl: 'modal-petroleras.html', | |
179 | - controller: 'modalPetrolerasCtrl', | |
180 | - size: 'lg' | |
181 | - } | |
182 | - ); | |
183 | - modalInstance.result.then( | |
184 | - function(petrolera) { | |
185 | - $scope.notaPedido.petrolera = petrolera.NOM; | |
186 | - }, function() { | |
150 | + id: 0, | |
151 | + codigo: producto.codigo, | |
152 | + sector: producto.sector, | |
153 | + descripcion: producto.descripcion, | |
154 | + item: $scope.articulosTabla.length + 1, | |
155 | + nombre: producto.descripcion, | |
156 | + precio: producto.precio.toFixed(2), | |
157 | + costoUnitario: producto.costo, | |
158 | + edit: false | |
159 | + }; | |
160 | + $scope.articuloACargar = newArt; | |
161 | + $scope.cargando = false; | |
162 | + }, function() { | |
163 | + // funcion ejecutada cuando se cancela el modal | |
164 | + } | |
165 | + ); | |
166 | + }; | |
187 | 167 | |
188 | - } | |
189 | - ); | |
190 | - }; | |
191 | - $scope.seleccionarCliente = function() { | |
192 | - var modalInstance = $uibModal.open( | |
193 | - { | |
194 | - ariaLabelledBy: 'Busqueda de Cliente', | |
195 | - templateUrl: 'foca-busqueda-cliente-modal.html', | |
196 | - controller: 'focaBusquedaClienteModalController', | |
197 | - size: 'lg' | |
198 | - } | |
199 | - ); | |
200 | - modalInstance.result.then( | |
201 | - function(cliente) { | |
202 | - $scope.notaPedido.cliente.nombre = cliente.nom; | |
203 | - $scope.notaPedido.cliente.id = cliente.cod; | |
204 | - crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( | |
205 | - function(data) { | |
206 | - if(data.data.length === 0){ | |
207 | - focaModalService | |
208 | - .alert('El cliente no tienen domicilios de entrega') | |
209 | - .then( | |
210 | - function() { | |
211 | - $scope.seleccionarCliente(); | |
212 | - $scope.notaPedido.cliente = {nombre: ''}; | |
213 | - } | |
214 | - ); | |
215 | - return; | |
216 | - } | |
217 | - $scope.domiciliosCliente = data.data; | |
168 | + $scope.seleccionarVendedor = function() { | |
169 | + var modalInstance = $uibModal.open( | |
170 | + { | |
171 | + ariaLabelledBy: 'Busqueda de Vendedores', | |
172 | + templateUrl: 'modal-vendedores.html', | |
173 | + controller: 'modalVendedoresCtrl', | |
174 | + size: 'lg' | |
175 | + } | |
176 | + ); | |
177 | + modalInstance.result.then( | |
178 | + function(vendedor) { | |
179 | + addCabecera('Vendedor:', vendedor.NomVen); | |
180 | + $scope.notaPedido.vendedor.nombre = vendedor.NomVen; | |
181 | + }, function() { | |
182 | + | |
183 | + } | |
184 | + ); | |
185 | + }; | |
186 | + | |
187 | + $scope.seleccionarPetrolera = function() { | |
188 | + var modalInstance = $uibModal.open( | |
189 | + { | |
190 | + ariaLabelledBy: 'Busqueda de Petrolera', | |
191 | + templateUrl: 'modal-petroleras.html', | |
192 | + controller: 'modalPetrolerasCtrl', | |
193 | + size: 'lg' | |
194 | + } | |
195 | + ); | |
196 | + modalInstance.result.then( | |
197 | + function(petrolera) { | |
198 | + $scope.notaPedido.petrolera = petrolera.NOM; | |
199 | + }, function() { | |
200 | + | |
201 | + } | |
202 | + ); | |
203 | + }; | |
204 | + | |
205 | + $scope.seleccionarCliente = function() { | |
206 | + var modalInstance = $uibModal.open( | |
207 | + { | |
208 | + ariaLabelledBy: 'Busqueda de Cliente', | |
209 | + templateUrl: 'foca-busqueda-cliente-modal.html', | |
210 | + controller: 'focaBusquedaClienteModalController', | |
211 | + size: 'lg' | |
212 | + } | |
213 | + ); | |
214 | + modalInstance.result.then( | |
215 | + function(cliente) { | |
216 | + $scope.notaPedido.cliente.nombre = cliente.nom; | |
217 | + $scope.notaPedido.cliente.id = cliente.cod; | |
218 | + crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( | |
219 | + function(data) { | |
220 | + if(data.data.length === 0){ | |
221 | + focaModalService | |
222 | + .alert('El cliente no tienen domicilios de entrega') | |
223 | + .then( | |
224 | + function() { | |
225 | + $scope.seleccionarCliente(); | |
226 | + $scope.notaPedido.cliente = {nombre: ''}; | |
227 | + } | |
228 | + ); | |
229 | + return; | |
218 | 230 | } |
219 | - ); | |
220 | - }, function() { | |
231 | + $scope.domiciliosCliente = data.data; | |
232 | + } | |
233 | + ); | |
234 | + | |
235 | + addCabecera('Cliente:', cliente.nom); | |
236 | + }, function() { | |
221 | 237 | |
222 | - } | |
223 | - ); | |
224 | - }; | |
225 | - $scope.mostrarFichaCliente = function() { | |
226 | - $uibModal.open( | |
227 | - { | |
228 | - ariaLabelledBy: 'Datos del Cliente', | |
229 | - templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | |
230 | - controller: 'focaCrearNotaPedidoFichaClienteController', | |
231 | - size: 'lg' | |
232 | - } | |
233 | - ); | |
234 | - }; | |
235 | - $scope.getTotal = function() { | |
236 | - var total = 0; | |
237 | - var arrayTempArticulos = $scope.articulosTabla; | |
238 | - for (var i = 0; i < arrayTempArticulos.length; i++) { | |
239 | - total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | |
240 | 238 | } |
241 | - return total.toFixed(2); | |
242 | - }; | |
243 | - $scope.getSubTotal = function() { | |
244 | - if($scope.articuloACargar) { | |
245 | - return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | |
239 | + ); | |
240 | + }; | |
241 | + | |
242 | + $scope.mostrarFichaCliente = function() { | |
243 | + $uibModal.open( | |
244 | + { | |
245 | + ariaLabelledBy: 'Datos del Cliente', | |
246 | + templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | |
247 | + controller: 'focaCrearNotaPedidoFichaClienteController', | |
248 | + size: 'lg' | |
246 | 249 | } |
247 | - }; | |
248 | - $scope.abrirModalListaPrecio = function() { | |
249 | - var modalInstance = $uibModal.open( | |
250 | - { | |
251 | - ariaLabelledBy: 'Busqueda de Precio Condiciรณn', | |
252 | - templateUrl: 'modal-precio-condicion.html', | |
253 | - controller: 'focaModalPrecioCondicionController', | |
254 | - size: 'lg' | |
255 | - } | |
256 | - ); | |
257 | - modalInstance.result.then( | |
258 | - function(precioCondicion) { | |
259 | - $scope.notaPedido.precioCondicion = precioCondicion.nombre; | |
260 | - idLista = precioCondicion.idListaPrecio; | |
261 | - $scope.articulosTabla = []; | |
262 | - }, function() { | |
250 | + ); | |
251 | + }; | |
263 | 252 | |
264 | - } | |
265 | - ); | |
266 | - }; | |
267 | - $scope.abrirModalFlete = function() { | |
268 | - var modalInstance = $uibModal.open( | |
269 | - { | |
270 | - ariaLabelledBy: 'Busqueda de Flete', | |
271 | - templateUrl: 'modal-flete.html', | |
272 | - controller: 'focaModalFleteController', | |
273 | - size: 'lg' | |
274 | - } | |
275 | - ); | |
276 | - modalInstance.result.then( | |
277 | - function(flete) { | |
278 | - $scope.limpiarFlete(); | |
279 | - $scope.notaPedido.fleteNombre = flete.nombre; | |
280 | - $scope.notaPedido.fleteId = flete.id; | |
281 | - $scope.choferes = flete.chofer; | |
282 | - $scope.vehiculos = flete.vehiculo; | |
283 | - }, function() { | |
253 | + $scope.getTotal = function() { | |
254 | + var total = 0; | |
255 | + var arrayTempArticulos = $scope.articulosTabla; | |
256 | + for (var i = 0; i < arrayTempArticulos.length; i++) { | |
257 | + total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | |
258 | + } | |
259 | + return total.toFixed(2); | |
260 | + }; | |
284 | 261 | |
285 | - } | |
286 | - ); | |
287 | - }; | |
288 | - $scope.abrirModalMoneda = function() { | |
289 | - var modalInstance = $uibModal.open( | |
290 | - { | |
291 | - ariaLabelledBy: 'Busqueda de Moneda', | |
292 | - templateUrl: 'modal-moneda.html', | |
293 | - controller: 'focaModalMonedaController', | |
294 | - size: 'lg' | |
295 | - } | |
296 | - ); | |
297 | - modalInstance.result.then( | |
298 | - function(moneda) { | |
299 | - $scope.notaPedido.moneda = { | |
300 | - id: moneda.ID, | |
301 | - detalle: moneda.DETALLE, | |
302 | - simbolo: moneda.SIMBOLO | |
303 | - }; | |
304 | - }, function() { | |
262 | + $scope.getSubTotal = function() { | |
263 | + if($scope.articuloACargar) { | |
264 | + return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | |
265 | + } | |
266 | + }; | |
305 | 267 | |
306 | - } | |
307 | - ); | |
308 | - }; | |
309 | - $scope.agregarATabla = function(key) { | |
310 | - if(key === 13) { | |
311 | - if($scope.articuloACargar.cantidad === undefined || | |
312 | - $scope.articuloACargar.cantidad === 0 || | |
313 | - $scope.articuloACargar.cantidad === null ){ | |
314 | - focaModalService.alert('El valor debe ser al menos 1'); | |
315 | - return; | |
316 | - } | |
317 | - $scope.articulosTabla.unshift($scope.articuloACargar); | |
318 | - $scope.cargando = true; | |
268 | + $scope.abrirModalListaPrecio = function() { | |
269 | + var modalInstance = $uibModal.open( | |
270 | + { | |
271 | + ariaLabelledBy: 'Busqueda de Precio Condiciรณn', | |
272 | + templateUrl: 'modal-precio-condicion.html', | |
273 | + controller: 'focaModalPrecioCondicionController', | |
274 | + size: 'lg' | |
319 | 275 | } |
320 | - }; | |
321 | - $scope.quitarArticulo = function(key) { | |
322 | - $scope.articulosTabla.splice(key, 1); | |
323 | - }; | |
324 | - $scope.editarArticulo = function(key, articulo) { | |
325 | - if(key === 13) { | |
326 | - if(articulo.cantidad === null || articulo.cantidad === 0 || | |
327 | - articulo.cantidad === undefined){ | |
276 | + ); | |
277 | + modalInstance.result.then( | |
278 | + function(precioCondicion) { | |
279 | + $scope.notaPedido.precioCondicion = precioCondicion.nombre; | |
280 | + idLista = precioCondicion.idListaPrecio; | |
281 | + $scope.articulosTabla = []; | |
282 | + | |
283 | + addCabecera('Precios y condiciones:', precioCondicion.nombre); | |
284 | + }, function() { | |
285 | + | |
286 | + } | |
287 | + ); | |
288 | + }; | |
289 | + | |
290 | + $scope.abrirModalFlete = function() { | |
291 | + var modalInstance = $uibModal.open( | |
292 | + { | |
293 | + ariaLabelledBy: 'Busqueda de Flete', | |
294 | + templateUrl: 'modal-flete.html', | |
295 | + controller: 'focaModalFleteController', | |
296 | + size: 'lg' | |
297 | + } | |
298 | + ); | |
299 | + modalInstance.result.then( | |
300 | + function(flete) { | |
301 | + $scope.limpiarFlete(); | |
302 | + $scope.notaPedido.fleteNombre = flete.nombre; | |
303 | + $scope.notaPedido.fleteId = flete.id; | |
304 | + $scope.choferes = flete.chofer; | |
305 | + $scope.vehiculos = flete.vehiculo; | |
306 | + | |
307 | + addCabecera('Flete:', flete.nombre); | |
308 | + }, function() { | |
309 | + | |
310 | + } | |
311 | + ); | |
312 | + }; | |
313 | + | |
314 | + $scope.abrirModalMoneda = function() { | |
315 | + var modalInstance = $uibModal.open( | |
316 | + { | |
317 | + ariaLabelledBy: 'Busqueda de Moneda', | |
318 | + templateUrl: 'modal-moneda.html', | |
319 | + controller: 'focaModalMonedaController', | |
320 | + size: 'lg' | |
321 | + } | |
322 | + ); | |
323 | + modalInstance.result.then( | |
324 | + function(moneda) { | |
325 | + $scope.notaPedido.moneda = { | |
326 | + id: moneda.ID, | |
327 | + detalle: moneda.DETALLE, | |
328 | + simbolo: moneda.SIMBOLO | |
329 | + }; | |
330 | + | |
331 | + addCabecera('Moneda:', moneda.DETALLE); | |
332 | + }, function() { | |
333 | + | |
334 | + } | |
335 | + ); | |
336 | + }; | |
337 | + | |
338 | + $scope.agregarATabla = function(key) { | |
339 | + if(key === 13) { | |
340 | + if($scope.articuloACargar.cantidad === undefined || | |
341 | + $scope.articuloACargar.cantidad === 0 || | |
342 | + $scope.articuloACargar.cantidad === null ){ | |
328 | 343 | focaModalService.alert('El valor debe ser al menos 1'); |
329 | 344 | return; |
330 | - } | |
331 | - articulo.edit = false; | |
332 | 345 | } |
333 | - }; | |
334 | - $scope.cambioEdit = function(articulo) { | |
335 | - articulo.edit = true; | |
336 | - }; | |
337 | - $scope.limpiarFlete = function() { | |
338 | - $scope.notaPedido.fleteNombre = ''; | |
339 | - $scope.notaPedido.chofer = ''; | |
340 | - $scope.notaPedido.vehiculo = ''; | |
341 | - $scope.notaPedido.kilometros = ''; | |
342 | - $scope.notaPedido.costoUnitarioKmFlete = ''; | |
343 | - $scope.choferes = ''; | |
344 | - $scope.vehiculos = ''; | |
345 | - }; | |
346 | - $scope.limpiarPantalla = function() { | |
347 | - $scope.limpiarFlete(); | |
348 | - $scope.notaPedido.flete = '0'; | |
349 | - $scope.notaPedido.bomba = '0'; | |
350 | - $scope.notaPedido.precioCondicion = ''; | |
351 | - $scope.articulosTabla = []; | |
352 | - $scope.notaPedido.vendedor.nombre = ''; | |
353 | - $scope.notaPedido.cliente = {nombre: ''}; | |
354 | - $scope.notaPedido.domicilio = {dom: ''}; | |
355 | - $scope.domiciliosCliente = []; | |
356 | - }; | |
357 | - $scope.resetFilter = function() { | |
358 | - $scope.articuloACargar = {}; | |
346 | + $scope.articulosTabla.unshift($scope.articuloACargar); | |
359 | 347 | $scope.cargando = true; |
360 | - }; | |
361 | - $scope.selectFocus = function($event) { | |
362 | - $event.target.select(); | |
363 | - }; | |
364 | - $scope.salir = function() { | |
365 | - $location.path('/'); | |
366 | 348 | } |
367 | - } | |
368 | - ] | |
369 | - ) | |
370 | - .controller('notaPedidoListaCtrl', [ | |
371 | - '$scope', | |
372 | - 'crearNotaPedidoService', | |
373 | - '$location', | |
374 | - function($scope, crearNotaPedidoService, $location) { | |
375 | - crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | |
376 | - $scope.notaPedidos = datos.data; | |
377 | - }); | |
378 | - $scope.editar = function(notaPedido) { | |
379 | - crearNotaPedidoService.setNotaPedido(notaPedido); | |
380 | - $location.path('/venta-nota-pedido/abm/'); | |
381 | 349 | }; |
382 | - $scope.crearPedido = function() { | |
383 | - crearNotaPedidoService.clearNotaPedido(); | |
384 | - $location.path('/venta-nota-pedido/abm/'); | |
350 | + | |
351 | + $scope.quitarArticulo = function(key) { | |
352 | + $scope.articulosTabla.splice(key, 1); | |
385 | 353 | }; |
386 | - } | |
387 | - ]) | |
388 | - .controller('focaCrearNotaPedidoFichaClienteController', [ | |
389 | - '$scope', | |
390 | - 'crearNotaPedidoService', | |
391 | - '$location', | |
392 | - function($scope, crearNotaPedidoService, $location) { | |
393 | - crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | |
394 | - $scope.notaPedidos = datos.data; | |
395 | - }); | |
396 | - $scope.editar = function(notaPedido) { | |
397 | - crearNotaPedidoService.setNotaPedido(notaPedido); | |
398 | - $location.path('/venta-nota-pedido/abm/'); | |
354 | + | |
355 | + $scope.editarArticulo = function(key, articulo) { | |
356 | + if(key === 13) { | |
357 | + if(articulo.cantidad === null || articulo.cantidad === 0 || | |
358 | + articulo.cantidad === undefined){ | |
359 | + focaModalService.alert('El valor debe ser al menos 1'); | |
360 | + return; | |
361 | + } | |
362 | + articulo.edit = false; | |
363 | + } | |
364 | + }; | |
365 | + | |
366 | + $scope.cambioEdit = function(articulo) { | |
367 | + articulo.edit = true; | |
368 | + }; | |
369 | + | |
370 | + $scope.limpiarFlete = function() { | |
371 | + $scope.notaPedido.fleteNombre = ''; | |
372 | + $scope.notaPedido.chofer = ''; | |
373 | + $scope.notaPedido.vehiculo = ''; | |
374 | + $scope.notaPedido.kilometros = ''; | |
375 | + $scope.notaPedido.costoUnitarioKmFlete = ''; | |
376 | + $scope.choferes = ''; | |
377 | + $scope.vehiculos = ''; | |
378 | + }; | |
379 | + | |
380 | + $scope.limpiarPantalla = function() { | |
381 | + $scope.limpiarFlete(); | |
382 | + $scope.notaPedido.flete = '0'; | |
383 | + $scope.notaPedido.bomba = '0'; | |
384 | + $scope.notaPedido.precioCondicion = ''; | |
385 | + $scope.articulosTabla = []; | |
386 | + $scope.notaPedido.vendedor.nombre = ''; | |
387 | + $scope.notaPedido.cliente = {nombre: ''}; | |
388 | + $scope.notaPedido.domicilio = {dom: ''}; | |
389 | + $scope.domiciliosCliente = []; | |
390 | + }; | |
391 | + | |
392 | + $scope.resetFilter = function() { | |
393 | + $scope.articuloACargar = {}; | |
394 | + $scope.cargando = true; | |
395 | + }; | |
396 | + | |
397 | + $scope.selectFocus = function($event) { | |
398 | + $event.target.select(); | |
399 | 399 | }; |
400 | - $scope.crearPedido = function() { | |
401 | - crearNotaPedidoService.clearNotaPedido(); | |
402 | - $location.path('/venta-nota-pedido/abm/'); | |
400 | + | |
401 | + $scope.salir = function() { | |
402 | + $location.path('/'); | |
403 | 403 | }; |
404 | + | |
405 | + function addCabecera(label, valor) { | |
406 | + let existe = false; | |
407 | + | |
408 | + for (var i = $scope.cabecera.length - 1; i >= 0; i--) { | |
409 | + if ($scope.cabecera[i].label === label) { | |
410 | + $scope.cabecera[i].valor = valor; | |
411 | + existe = true; | |
412 | + break; | |
413 | + } | |
414 | + | |
415 | + } | |
416 | + | |
417 | + if (!existe) { | |
418 | + $scope.cabecera.push({ | |
419 | + label: label, | |
420 | + valor: valor | |
421 | + }); | |
422 | + } | |
423 | + } | |
404 | 424 | } |
405 | - ]); | |
425 | + ] | |
426 | +) | |
427 | +.controller('notaPedidoListaCtrl', [ | |
428 | + '$scope', | |
429 | + 'crearNotaPedidoService', | |
430 | + '$location', | |
431 | + function($scope, crearNotaPedidoService, $location) { | |
432 | + crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | |
433 | + $scope.notaPedidos = datos.data; | |
434 | + }); | |
435 | + $scope.editar = function(notaPedido) { | |
436 | + crearNotaPedidoService.setNotaPedido(notaPedido); | |
437 | + $location.path('/venta-nota-pedido/abm/'); | |
438 | + }; | |
439 | + $scope.crearPedido = function() { | |
440 | + crearNotaPedidoService.clearNotaPedido(); | |
441 | + $location.path('/venta-nota-pedido/abm/'); | |
442 | + }; | |
443 | + } | |
444 | +]) | |
445 | +.controller('focaCrearNotaPedidoFichaClienteController', [ | |
446 | + '$scope', | |
447 | + 'crearNotaPedidoService', | |
448 | + '$location', | |
449 | + function($scope, crearNotaPedidoService, $location) { | |
450 | + crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | |
451 | + $scope.notaPedidos = datos.data; | |
452 | + }); | |
453 | + $scope.editar = function(notaPedido) { | |
454 | + crearNotaPedidoService.setNotaPedido(notaPedido); | |
455 | + $location.path('/venta-nota-pedido/abm/'); | |
456 | + }; | |
457 | + $scope.crearPedido = function() { | |
458 | + crearNotaPedidoService.clearNotaPedido(); | |
459 | + $location.path('/venta-nota-pedido/abm/'); | |
460 | + }; | |
461 | + } | |
462 | +]); |
src/views/nota-pedido.html
... | ... | @@ -5,31 +5,18 @@ |
5 | 5 | <div class="row p-1 panel-informativo"> |
6 | 6 | <div class="col-12"> |
7 | 7 | <div class="row"> |
8 | - <div class="col-5"> | |
9 | - <span class="label">Vendedor:</span> | |
10 | - <span class="valor" ng-bind="notaPedido.vendedor.nombre"></span> | |
8 | + <div class="col-3"> | |
9 | + {{ now | date:'dd/MM/yyyy HH:mm'}} | |
11 | 10 | </div> |
12 | - <div class="col-5"> | |
13 | - <span class="label">Moneda:</span> | |
14 | - <span class="valor" ng-bind="notaPedido.moneda.detalle"></span> | |
15 | - </div> | |
16 | - <div class="col-2"> | |
17 | - <span class="label">Flete:</span> | |
18 | - <span class="valor" ng-bind="notaPedido.flete"></span> | |
11 | + <div class="col-6 text-center"> | |
12 | + <div class="h2">NOTA DE PEDIDO</div> | |
19 | 13 | </div> |
14 | + <div class="col-3 text-right">{{puntoVenta}}-{{comprobante}}</div> | |
20 | 15 | </div> |
21 | 16 | <div class="row"> |
22 | - <div class="col-5"> | |
23 | - <span class="label">Cliente:</span> | |
24 | - <span class="valor" ng-bind="notaPedido.cliente.nombre"></span> | |
25 | - </div> | |
26 | - <div class="col-5"> | |
27 | - <span class="label">Precios y condiciones:</span> | |
28 | - <span class="valor" ng-bind="notaPedido.precioCondicion"></span> | |
29 | - </div> | |
30 | - <div class="col-2"> | |
31 | - <span class="label">Bomba:</span> | |
32 | - <span class="valor" ng-bind="notaPedido.bomba"></span> | |
17 | + <div class="col-auto" ng-repeat="cab in cabecera"> | |
18 | + <span class="label" ng-bind="cab.label"></span> | |
19 | + <span class="valor" ng-bind="cab.valor"></span> | |
33 | 20 | </div> |
34 | 21 | </div> |
35 | 22 | </div> |