Commit 2f52e0f2bbc71e08387c3cbdd2dada9f9fc0d700
Exists in
master
Merge branch 'master' into 'master'
Master (pmarco) See merge request modulos-npm/foca-crear-nota-pedido!29
Showing
2 changed files
Show diff stats
src/js/controller.js
1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
2 | [ | 2 | [ |
3 | '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', |
4 | 'focaModalService', | 4 | 'focaModalService', |
5 | function( | 5 | function( |
6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService | 6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService |
7 | ) { | 7 | ) { |
8 | $scope.botonera = [ | 8 | $scope.botonera = [ |
9 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, | 9 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, |
10 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | 10 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
11 | {texto: 'Proveedor', accion: function() {}}, | ||
11 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | 12 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, |
12 | { | 13 | { |
13 | texto: 'Precios y condiciones', | 14 | texto: 'Precios y condiciones', |
14 | accion: function() {$scope.abrirModalListaPrecio();}}, | 15 | accion: function() {$scope.abrirModalListaPrecio();}}, |
15 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | 16 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, |
16 | {texto: 'Totales', accion: function() {}}, | ||
17 | {texto: '', accion: function() {}}, | 17 | {texto: '', accion: function() {}}, |
18 | {texto: '', accion: function() {}} | 18 | {texto: '', accion: function() {}} |
19 | ]; | 19 | ]; |
20 | 20 | ||
21 | $scope.show = false; | 21 | $scope.show = false; |
22 | $scope.cargando = true; | 22 | $scope.cargando = true; |
23 | $scope.dateOptions = { | 23 | $scope.dateOptions = { |
24 | maxDate: new Date(), | 24 | maxDate: new Date(), |
25 | minDate: new Date(2010, 0, 1) | 25 | minDate: new Date(2010, 0, 1) |
26 | }; | 26 | }; |
27 | 27 | ||
28 | $scope.notaPedido = { | 28 | $scope.notaPedido = { |
29 | vendedor: {}, | 29 | vendedor: {}, |
30 | cliente: {}, | 30 | cliente: {}, |
31 | domicilio: {dom: ''}, | 31 | domicilio: {dom: ''}, |
32 | moneda: {detalle: ''} | 32 | moneda: {detalle: ''} |
33 | }; | 33 | }; |
34 | 34 | ||
35 | $scope.cabecera = []; | 35 | $scope.cabecera = []; |
36 | 36 | ||
37 | $scope.now = new Date(); | 37 | $scope.now = new Date(); |
38 | $scope.puntoVenta = Math.round(Math.random() * 10000); | 38 | $scope.puntoVenta = Math.round(Math.random() * 10000); |
39 | $scope.comprobante = Math.round(Math.random() * 1000000); | 39 | $scope.comprobante = Math.round(Math.random() * 1000000); |
40 | 40 | ||
41 | $scope.articulosTabla = []; | 41 | $scope.articulosTabla = []; |
42 | var idLista; | 42 | var idLista; |
43 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | 43 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
44 | crearNotaPedidoService.getPrecioCondicion().then( | 44 | crearNotaPedidoService.getPrecioCondicion().then( |
45 | function(res) { | 45 | function(res) { |
46 | $scope.precioCondiciones = res.data; | 46 | $scope.precioCondiciones = res.data; |
47 | } | 47 | } |
48 | ); | 48 | ); |
49 | if (notaPedidoTemp !== undefined) { | 49 | if (notaPedidoTemp !== undefined) { |
50 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | 50 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
51 | $scope.notaPedido = notaPedidoTemp; | 51 | $scope.notaPedido = notaPedidoTemp; |
52 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | 52 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
53 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | 53 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
54 | idLista = $scope.notaPedido.precioCondicion; | 54 | idLista = $scope.notaPedido.precioCondicion; |
55 | crearNotaPedidoService | 55 | crearNotaPedidoService |
56 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | 56 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
57 | function(res) { | 57 | function(res) { |
58 | $scope.articulosTabla = res.data; | 58 | $scope.articulosTabla = res.data; |
59 | } | 59 | } |
60 | ); | 60 | ); |
61 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | 61 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
62 | //(NO REQUERIDO EN ESTA VERSION) | 62 | //(NO REQUERIDO EN ESTA VERSION) |
63 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 63 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
64 | // function(res) { | 64 | // function(res) { |
65 | // $scope.notaPedido.domicilio = res.data; | 65 | // $scope.notaPedido.domicilio = res.data; |
66 | // } | 66 | // } |
67 | // ); | 67 | // ); |
68 | } else { | 68 | } else { |
69 | $scope.notaPedido.fechaCarga = new Date(); | 69 | $scope.notaPedido.fechaCarga = new Date(); |
70 | $scope.notaPedido.bomba = '0'; | 70 | $scope.notaPedido.bomba = '0'; |
71 | $scope.notaPedido.flete = '0'; | 71 | $scope.notaPedido.flete = '0'; |
72 | idLista = undefined; | 72 | idLista = undefined; |
73 | } | 73 | } |
74 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 74 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
75 | // $scope.addNewDom = function() { | 75 | // $scope.addNewDom = function() { |
76 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); | 76 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); |
77 | // }; | 77 | // }; |
78 | // $scope.removeNewChoice = function(choice) { | 78 | // $scope.removeNewChoice = function(choice) { |
79 | // if ($scope.notaPedido.domicilio.length > 1) { | 79 | // if ($scope.notaPedido.domicilio.length > 1) { |
80 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | 80 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
81 | // function(c) { | 81 | // function(c) { |
82 | // return c.$$hashKey === choice.$$hashKey; | 82 | // return c.$$hashKey === choice.$$hashKey; |
83 | // } | 83 | // } |
84 | // ), 1); | 84 | // ), 1); |
85 | // } | 85 | // } |
86 | // }; | 86 | // }; |
87 | $scope.crearNotaPedido = function() { | 87 | $scope.crearNotaPedido = function() { |
88 | if($scope.articulosTabla.length === 0) { | 88 | if($scope.articulosTabla.length === 0) { |
89 | focaModalService.alert('Debe cargar almenos un articulo'); | 89 | focaModalService.alert('Debe cargar almenos un articulo'); |
90 | return; | 90 | return; |
91 | } | 91 | } |
92 | if($scope.notaPedido.domicilio.id === undefined) { | 92 | if($scope.notaPedido.domicilio.id === undefined) { |
93 | $scope.notaPedido.domicilio.id = 0; | 93 | $scope.notaPedido.domicilio.id = 0; |
94 | } | 94 | } |
95 | var date = new Date(); | 95 | var date = new Date(); |
96 | var notaPedido = { | 96 | var notaPedido = { |
97 | id: 0, | 97 | id: 0, |
98 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 98 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
99 | .toISOString().slice(0, 19).replace('T', ' '), | 99 | .toISOString().slice(0, 19).replace('T', ' '), |
100 | vendedor: $scope.notaPedido.vendedor.nombre, | 100 | vendedor: $scope.notaPedido.vendedor.nombre, |
101 | idCliente: $scope.notaPedido.cliente.id, | 101 | idCliente: $scope.notaPedido.cliente.id, |
102 | domicilio: $scope.notaPedido.domicilio, | 102 | domicilio: $scope.notaPedido.domicilio, |
103 | precioCondicion: $scope.notaPedido.precioCondicion, | 103 | precioCondicion: $scope.notaPedido.precioCondicion, |
104 | bomba: $scope.notaPedido.bomba, | 104 | bomba: $scope.notaPedido.bomba, |
105 | flete: $scope.notaPedido.flete, | 105 | flete: $scope.notaPedido.flete, |
106 | total: $scope.getTotal() | 106 | total: $scope.getTotal() |
107 | }; | 107 | }; |
108 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 108 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
109 | function(data) { | 109 | function(data) { |
110 | focaModalService.alert('Nota pedido creada'); | 110 | focaModalService.alert('Nota pedido creada'); |
111 | if($scope.notaPedido.flete === 1) { | 111 | if($scope.notaPedido.flete === 1) { |
112 | var flete = { | 112 | var flete = { |
113 | idNotaPedido: data.data.id, | 113 | idNotaPedido: data.data.id, |
114 | idTransportista: $scope.notaPedido.fleteId, | 114 | idTransportista: $scope.notaPedido.fleteId, |
115 | idChofer: $scope.notaPedido.chofer.id, | 115 | idChofer: $scope.notaPedido.chofer.id, |
116 | idVehiculo: $scope.notaPedido.vehiculo.id, | 116 | idVehiculo: $scope.notaPedido.vehiculo.id, |
117 | kilometros: $scope.notaPedido.kilometros, | 117 | kilometros: $scope.notaPedido.kilometros, |
118 | costoKilometro: $scope.notaPedido.costoUnitarioKmFlete | 118 | costoKilometro: $scope.notaPedido.costoUnitarioKmFlete |
119 | }; | 119 | }; |
120 | crearNotaPedidoService.crearFlete(flete); | 120 | crearNotaPedidoService.crearFlete(flete); |
121 | } | 121 | } |
122 | var articulosNotaPedido = $scope.articulosTabla; | 122 | var articulosNotaPedido = $scope.articulosTabla; |
123 | for(var i = 0; i < articulosNotaPedido.length; i++) { | 123 | for(var i = 0; i < articulosNotaPedido.length; i++) { |
124 | delete articulosNotaPedido[i].edit; | 124 | delete articulosNotaPedido[i].edit; |
125 | articulosNotaPedido[i].idNotaPedido = data.data.id; | 125 | articulosNotaPedido[i].idNotaPedido = data.data.id; |
126 | crearNotaPedidoService | 126 | crearNotaPedidoService |
127 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); | 127 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); |
128 | } | 128 | } |
129 | $scope.limpiarPantalla(); | 129 | $scope.limpiarPantalla(); |
130 | } | 130 | } |
131 | ); | 131 | ); |
132 | }; | 132 | }; |
133 | 133 | ||
134 | $scope.seleccionarArticulo = function() { | 134 | $scope.seleccionarArticulo = function() { |
135 | if (idLista === undefined) { | 135 | if (idLista === undefined) { |
136 | focaModalService.alert( | 136 | focaModalService.alert( |
137 | 'Primero seleccione una lista de precio y condicion'); | 137 | 'Primero seleccione una lista de precio y condicion'); |
138 | return; | 138 | return; |
139 | } | 139 | } |
140 | var modalInstance = $uibModal.open( | 140 | var modalInstance = $uibModal.open( |
141 | { | 141 | { |
142 | ariaLabelledBy: 'Busqueda de Productos', | 142 | ariaLabelledBy: 'Busqueda de Productos', |
143 | templateUrl: 'modal-busqueda-productos.html', | 143 | templateUrl: 'modal-busqueda-productos.html', |
144 | controller: 'modalBusquedaProductosCtrl', | 144 | controller: 'modalBusquedaProductosCtrl', |
145 | resolve: { idLista: function() { return idLista; } }, | 145 | resolve: { idLista: function() { return idLista; } }, |
146 | size: 'lg' | 146 | size: 'lg' |
147 | } | 147 | } |
148 | ); | 148 | ); |
149 | modalInstance.result.then( | 149 | modalInstance.result.then( |
150 | function(producto) { | 150 | function(producto) { |
151 | var newArt = | 151 | var newArt = |
152 | { | 152 | { |
153 | id: 0, | 153 | id: 0, |
154 | codigo: producto.codigo, | 154 | codigo: producto.codigo, |
155 | sector: producto.sector, | 155 | sector: producto.sector, |
156 | descripcion: producto.descripcion, | 156 | descripcion: producto.descripcion, |
157 | item: $scope.articulosTabla.length + 1, | 157 | item: $scope.articulosTabla.length + 1, |
158 | nombre: producto.descripcion, | 158 | nombre: producto.descripcion, |
159 | precio: producto.precio.toFixed(2), | 159 | precio: producto.precio.toFixed(2), |
160 | costoUnitario: producto.costo, | 160 | costoUnitario: producto.costo, |
161 | edit: false | 161 | edit: false |
162 | }; | 162 | }; |
163 | $scope.articuloACargar = newArt; | 163 | $scope.articuloACargar = newArt; |
164 | $scope.cargando = false; | 164 | $scope.cargando = false; |
165 | }, function() { | 165 | }, function() { |
166 | // funcion ejecutada cuando se cancela el modal | 166 | // funcion ejecutada cuando se cancela el modal |
167 | } | 167 | } |
168 | ); | 168 | ); |
169 | }; | 169 | }; |
170 | 170 | ||
171 | $scope.seleccionarVendedor = function() { | 171 | $scope.seleccionarVendedor = function() { |
172 | var modalInstance = $uibModal.open( | 172 | var modalInstance = $uibModal.open( |
173 | { | 173 | { |
174 | ariaLabelledBy: 'Busqueda de Vendedores', | 174 | ariaLabelledBy: 'Busqueda de Vendedores', |
175 | templateUrl: 'modal-vendedores.html', | 175 | templateUrl: 'modal-vendedores.html', |
176 | controller: 'modalVendedoresCtrl', | 176 | controller: 'modalVendedoresCtrl', |
177 | size: 'lg' | 177 | size: 'lg' |
178 | } | 178 | } |
179 | ); | 179 | ); |
180 | modalInstance.result.then( | 180 | modalInstance.result.then( |
181 | function(vendedor) { | 181 | function(vendedor) { |
182 | addCabecera('Vendedor:', vendedor.NomVen); | 182 | addCabecera('Vendedor:', vendedor.NomVen); |
183 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; | 183 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; |
184 | }, function() { | 184 | }, function() { |
185 | 185 | ||
186 | } | 186 | } |
187 | ); | 187 | ); |
188 | }; | 188 | }; |
189 | 189 | ||
190 | $scope.seleccionarPetrolera = function() { | 190 | $scope.seleccionarPetrolera = function() { |
191 | var modalInstance = $uibModal.open( | 191 | var modalInstance = $uibModal.open( |
192 | { | 192 | { |
193 | ariaLabelledBy: 'Busqueda de Petrolera', | 193 | ariaLabelledBy: 'Busqueda de Petrolera', |
194 | templateUrl: 'modal-petroleras.html', | 194 | templateUrl: 'modal-petroleras.html', |
195 | controller: 'modalPetrolerasCtrl', | 195 | controller: 'modalPetrolerasCtrl', |
196 | size: 'lg' | 196 | size: 'lg' |
197 | } | 197 | } |
198 | ); | 198 | ); |
199 | modalInstance.result.then( | 199 | modalInstance.result.then( |
200 | function(petrolera) { | 200 | function(petrolera) { |
201 | $scope.notaPedido.petrolera = petrolera.NOM; | 201 | $scope.notaPedido.petrolera = petrolera.NOM; |
202 | }, function() { | 202 | }, function() { |
203 | 203 | ||
204 | } | 204 | } |
205 | ); | 205 | ); |
206 | }; | 206 | }; |
207 | 207 | ||
208 | $scope.seleccionarCliente = function() { | 208 | $scope.seleccionarCliente = function() { |
209 | var modalInstance = $uibModal.open( | 209 | var modalInstance = $uibModal.open( |
210 | { | 210 | { |
211 | ariaLabelledBy: 'Busqueda de Cliente', | 211 | ariaLabelledBy: 'Busqueda de Cliente', |
212 | templateUrl: 'foca-busqueda-cliente-modal.html', | 212 | templateUrl: 'foca-busqueda-cliente-modal.html', |
213 | controller: 'focaBusquedaClienteModalController', | 213 | controller: 'focaBusquedaClienteModalController', |
214 | size: 'lg' | 214 | size: 'lg' |
215 | } | 215 | } |
216 | ); | 216 | ); |
217 | modalInstance.result.then( | 217 | modalInstance.result.then( |
218 | function(cliente) { | 218 | function(cliente) { |
219 | $scope.notaPedido.cliente.nombre = cliente.nom; | 219 | $scope.notaPedido.cliente.nombre = cliente.nom; |
220 | $scope.notaPedido.cliente.id = cliente.cod; | 220 | $scope.notaPedido.cliente.id = cliente.cod; |
221 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( | 221 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( |
222 | function(data) { | 222 | function(data) { |
223 | if(data.data.length === 0){ | 223 | if(data.data.length === 0){ |
224 | focaModalService | 224 | focaModalService |
225 | .alert('El cliente no tienen domicilios de entrega') | 225 | .alert('El cliente no tienen domicilios de entrega') |
226 | .then( | 226 | .then( |
227 | function() { | 227 | function() { |
228 | $scope.seleccionarCliente(); | 228 | $scope.seleccionarCliente(); |
229 | $scope.notaPedido.cliente = {nombre: ''}; | 229 | $scope.notaPedido.cliente = {nombre: ''}; |
230 | } | 230 | } |
231 | ); | 231 | ); |
232 | return; | 232 | return; |
233 | } | 233 | } |
234 | var modalInstanceDomicilio = $uibModal.open( | 234 | var modalInstanceDomicilio = $uibModal.open( |
235 | { | 235 | { |
236 | ariaLabelledBy: 'Busqueda de Domicilios', | 236 | ariaLabelledBy: 'Busqueda de Domicilios', |
237 | templateUrl: 'modal-domicilio.html', | 237 | templateUrl: 'modal-domicilio.html', |
238 | controller: 'focaModalDomicilioController', | 238 | controller: 'focaModalDomicilioController', |
239 | resolve: { idCliente: function() { return cliente.cod; }}, | 239 | resolve: { idCliente: function() { return cliente.cod; }}, |
240 | size: 'lg', | 240 | size: 'lg', |
241 | backdrop: 'static', | 241 | backdrop: 'static', |
242 | } | 242 | } |
243 | ); | 243 | ); |
244 | modalInstanceDomicilio.result.then( | 244 | modalInstanceDomicilio.result.then( |
245 | function(domicilio) { | 245 | function(domicilio) { |
246 | focaModalService.alert('Domicilio elegido' + domicilio.dom); | 246 | focaModalService.alert('Domicilio elegido' + domicilio.dom); |
247 | }, function() { | 247 | }, function() { |
248 | $scope.notaPedido.cliente.nombre = ''; | 248 | $scope.notaPedido.cliente.nombre = ''; |
249 | $scope.notaPedido.cliente.id = ''; | 249 | $scope.notaPedido.cliente.id = ''; |
250 | removeCabecera('Cliente:'); | 250 | removeCabecera('Cliente:'); |
251 | $scope.seleccionarCliente(); | 251 | $scope.seleccionarCliente(); |
252 | return; | 252 | return; |
253 | } | 253 | } |
254 | ); | 254 | ); |
255 | } | 255 | } |
256 | ); | 256 | ); |
257 | addCabecera('Cliente:', cliente.nom); | 257 | addCabecera('Cliente:', cliente.nom); |
258 | }, function() { | 258 | }, function() { |
259 | 259 | ||
260 | } | 260 | } |
261 | ); | 261 | ); |
262 | }; | 262 | }; |
263 | 263 | ||
264 | $scope.mostrarFichaCliente = function() { | 264 | $scope.mostrarFichaCliente = function() { |
265 | $uibModal.open( | 265 | $uibModal.open( |
266 | { | 266 | { |
267 | ariaLabelledBy: 'Datos del Cliente', | 267 | ariaLabelledBy: 'Datos del Cliente', |
268 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 268 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
269 | controller: 'focaCrearNotaPedidoFichaClienteController', | 269 | controller: 'focaCrearNotaPedidoFichaClienteController', |
270 | size: 'lg' | 270 | size: 'lg' |
271 | } | 271 | } |
272 | ); | 272 | ); |
273 | }; | 273 | }; |
274 | 274 | ||
275 | $scope.getTotal = function() { | 275 | $scope.getTotal = function() { |
276 | var total = 0; | 276 | var total = 0; |
277 | var arrayTempArticulos = $scope.articulosTabla; | 277 | var arrayTempArticulos = $scope.articulosTabla; |
278 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 278 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
279 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 279 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
280 | } | 280 | } |
281 | return total.toFixed(2); | 281 | return total.toFixed(2); |
282 | }; | 282 | }; |
283 | 283 | ||
284 | $scope.getSubTotal = function() { | 284 | $scope.getSubTotal = function() { |
285 | if($scope.articuloACargar) { | 285 | if($scope.articuloACargar) { |
286 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 286 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
287 | } | 287 | } |
288 | }; | 288 | }; |
289 | 289 | ||
290 | $scope.abrirModalListaPrecio = function() { | 290 | $scope.abrirModalListaPrecio = function() { |
291 | var modalInstance = $uibModal.open( | 291 | var modalInstance = $uibModal.open( |
292 | { | 292 | { |
293 | ariaLabelledBy: 'Busqueda de Precio Condición', | 293 | ariaLabelledBy: 'Busqueda de Precio Condición', |
294 | templateUrl: 'modal-precio-condicion.html', | 294 | templateUrl: 'modal-precio-condicion.html', |
295 | controller: 'focaModalPrecioCondicionController', | 295 | controller: 'focaModalPrecioCondicionController', |
296 | size: 'lg' | 296 | size: 'lg' |
297 | } | 297 | } |
298 | ); | 298 | ); |
299 | modalInstance.result.then( | 299 | modalInstance.result.then( |
300 | function(precioCondicion) { | 300 | function(precioCondicion) { |
301 | $scope.notaPedido.precioCondicion = precioCondicion.nombre; | 301 | $scope.notaPedido.precioCondicion = precioCondicion.nombre; |
302 | idLista = precioCondicion.idListaPrecio; | 302 | idLista = precioCondicion.idListaPrecio; |
303 | $scope.articulosTabla = []; | 303 | $scope.articulosTabla = []; |
304 | 304 | ||
305 | addCabecera('Precios y condiciones:', precioCondicion.nombre); | 305 | addCabecera('Precios y condiciones:', precioCondicion.nombre); |
306 | }, function() { | 306 | }, function() { |
307 | 307 | ||
308 | } | 308 | } |
309 | ); | 309 | ); |
310 | }; | 310 | }; |
311 | 311 | ||
312 | $scope.abrirModalFlete = function() { | 312 | $scope.abrirModalFlete = function() { |
313 | var modalInstance = $uibModal.open( | 313 | var modalInstance = $uibModal.open( |
314 | { | 314 | { |
315 | ariaLabelledBy: 'Busqueda de Flete', | 315 | ariaLabelledBy: 'Busqueda de Flete', |
316 | templateUrl: 'modal-flete.html', | 316 | templateUrl: 'modal-flete.html', |
317 | controller: 'focaModalFleteController', | 317 | controller: 'focaModalFleteController', |
318 | size: 'lg', | 318 | size: 'lg', |
319 | resolve: { | 319 | resolve: { |
320 | parametrosFlete: | 320 | parametrosFlete: |
321 | function() { | 321 | function() { |
322 | return { | 322 | return { |
323 | flete: $scope.notaPedido.flete, | 323 | flete: $scope.notaPedido.flete, |
324 | bomba: $scope.notaPedido.bomba, | 324 | bomba: $scope.notaPedido.bomba, |
325 | kilometros: $scope.notaPedido.kilometros | 325 | kilometros: $scope.notaPedido.kilometros |
326 | }; | 326 | }; |
327 | } | 327 | } |
328 | } | 328 | } |
329 | } | 329 | } |
330 | ); | 330 | ); |
331 | modalInstance.result.then( | 331 | modalInstance.result.then( |
332 | function(datos) { | 332 | function(datos) { |
333 | $scope.notaPedido.flete = datos.flete; | 333 | $scope.notaPedido.flete = datos.flete; |
334 | $scope.notaPedido.bomba = datos.bomba; | 334 | $scope.notaPedido.bomba = datos.bomba; |
335 | $scope.notaPedido.kilometros = datos.kilometros; | 335 | $scope.notaPedido.kilometros = datos.kilometros; |
336 | 336 | ||
337 | addCabecera('Flete:', datos.flete); | 337 | addCabecera('Flete:', datos.flete); |
338 | if(datos.flete === 'si') { | 338 | if(datos.flete === 'si') { |
339 | addCabecera('Bomba:', datos.bomba); | 339 | addCabecera('Bomba:', datos.bomba); |
340 | addCabecera('Kilometros:', datos.kilometros); | 340 | addCabecera('Kilometros:', datos.kilometros); |
341 | } else { | 341 | } else { |
342 | removeCabecera('Bomba:'); | 342 | removeCabecera('Bomba:'); |
343 | removeCabecera('Kilometros:'); | 343 | removeCabecera('Kilometros:'); |
344 | } | 344 | } |
345 | }, function() { | 345 | }, function() { |
346 | 346 | ||
347 | } | 347 | } |
348 | ); | 348 | ); |
349 | }; | 349 | }; |
350 | 350 | ||
351 | $scope.abrirModalMoneda = function() { | 351 | $scope.abrirModalMoneda = function() { |
352 | var modalInstance = $uibModal.open( | 352 | var modalInstance = $uibModal.open( |
353 | { | 353 | { |
354 | ariaLabelledBy: 'Busqueda de Moneda', | 354 | ariaLabelledBy: 'Busqueda de Moneda', |
355 | templateUrl: 'modal-moneda.html', | 355 | templateUrl: 'modal-moneda.html', |
356 | controller: 'focaModalMonedaController', | 356 | controller: 'focaModalMonedaController', |
357 | size: 'lg' | 357 | size: 'lg' |
358 | } | 358 | } |
359 | ); | 359 | ); |
360 | modalInstance.result.then( | 360 | modalInstance.result.then( |
361 | function(moneda) { | 361 | function(moneda) { |
362 | $scope.notaPedido.moneda = { | 362 | $scope.notaPedido.moneda = { |
363 | id: moneda.ID, | 363 | id: moneda.ID, |
364 | detalle: moneda.DETALLE, | 364 | detalle: moneda.DETALLE, |
365 | simbolo: moneda.SIMBOLO | 365 | simbolo: moneda.SIMBOLO |
366 | }; | 366 | }; |
367 | 367 | ||
368 | addCabecera('Moneda:', moneda.DETALLE); | 368 | addCabecera('Moneda:', moneda.DETALLE); |
369 | }, function() { | 369 | }, function() { |
370 | 370 | ||
371 | } | 371 | } |
372 | ); | 372 | ); |
373 | }; | 373 | }; |
374 | 374 | ||
375 | $scope.agregarATabla = function(key) { | 375 | $scope.agregarATabla = function(key) { |
376 | if(key === 13) { | 376 | if(key === 13) { |
377 | if($scope.articuloACargar.cantidad === undefined || | 377 | if($scope.articuloACargar.cantidad === undefined || |
378 | $scope.articuloACargar.cantidad === 0 || | 378 | $scope.articuloACargar.cantidad === 0 || |
379 | $scope.articuloACargar.cantidad === null ){ | 379 | $scope.articuloACargar.cantidad === null ){ |
380 | focaModalService.alert('El valor debe ser al menos 1'); | 380 | focaModalService.alert('El valor debe ser al menos 1'); |
381 | return; | 381 | return; |
382 | } | 382 | } |
383 | $scope.articulosTabla.unshift($scope.articuloACargar); | 383 | $scope.articulosTabla.unshift($scope.articuloACargar); |
384 | $scope.cargando = true; | 384 | $scope.cargando = true; |
385 | } | 385 | } |
386 | }; | 386 | }; |
387 | 387 | ||
388 | $scope.quitarArticulo = function(key) { | 388 | $scope.quitarArticulo = function(key) { |
389 | $scope.articulosTabla.splice(key, 1); | 389 | $scope.articulosTabla.splice(key, 1); |
390 | }; | 390 | }; |
391 | 391 | ||
392 | $scope.editarArticulo = function(key, articulo) { | 392 | $scope.editarArticulo = function(key, articulo) { |
393 | if(key === 13) { | 393 | if(key === 13) { |
394 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 394 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
395 | articulo.cantidad === undefined){ | 395 | articulo.cantidad === undefined){ |
396 | focaModalService.alert('El valor debe ser al menos 1'); | 396 | focaModalService.alert('El valor debe ser al menos 1'); |
397 | return; | 397 | return; |
398 | } | 398 | } |
399 | articulo.edit = false; | 399 | articulo.edit = false; |
400 | } | 400 | } |
401 | }; | 401 | }; |
402 | 402 | ||
403 | $scope.cambioEdit = function(articulo) { | 403 | $scope.cambioEdit = function(articulo) { |
404 | articulo.edit = true; | 404 | articulo.edit = true; |
405 | }; | 405 | }; |
406 | 406 | ||
407 | $scope.limpiarFlete = function() { | 407 | $scope.limpiarFlete = function() { |
408 | $scope.notaPedido.fleteNombre = ''; | 408 | $scope.notaPedido.fleteNombre = ''; |
409 | $scope.notaPedido.chofer = ''; | 409 | $scope.notaPedido.chofer = ''; |
410 | $scope.notaPedido.vehiculo = ''; | 410 | $scope.notaPedido.vehiculo = ''; |
411 | $scope.notaPedido.kilometros = ''; | 411 | $scope.notaPedido.kilometros = ''; |
412 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 412 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
413 | $scope.choferes = ''; | 413 | $scope.choferes = ''; |
414 | $scope.vehiculos = ''; | 414 | $scope.vehiculos = ''; |
415 | }; | 415 | }; |
416 | 416 | ||
417 | $scope.limpiarPantalla = function() { | 417 | $scope.limpiarPantalla = function() { |
418 | $scope.limpiarFlete(); | 418 | $scope.limpiarFlete(); |
419 | $scope.notaPedido.flete = '0'; | 419 | $scope.notaPedido.flete = '0'; |
420 | $scope.notaPedido.bomba = '0'; | 420 | $scope.notaPedido.bomba = '0'; |
421 | $scope.notaPedido.precioCondicion = ''; | 421 | $scope.notaPedido.precioCondicion = ''; |
422 | $scope.articulosTabla = []; | 422 | $scope.articulosTabla = []; |
423 | $scope.notaPedido.vendedor.nombre = ''; | 423 | $scope.notaPedido.vendedor.nombre = ''; |
424 | $scope.notaPedido.cliente = {nombre: ''}; | 424 | $scope.notaPedido.cliente = {nombre: ''}; |
425 | $scope.notaPedido.domicilio = {dom: ''}; | 425 | $scope.notaPedido.domicilio = {dom: ''}; |
426 | $scope.domiciliosCliente = []; | 426 | $scope.domiciliosCliente = []; |
427 | }; | 427 | }; |
428 | 428 | ||
429 | $scope.resetFilter = function() { | 429 | $scope.resetFilter = function() { |
430 | $scope.articuloACargar = {}; | 430 | $scope.articuloACargar = {}; |
431 | $scope.cargando = true; | 431 | $scope.cargando = true; |
432 | }; | 432 | }; |
433 | 433 | ||
434 | $scope.selectFocus = function($event) { | 434 | $scope.selectFocus = function($event) { |
435 | $event.target.select(); | 435 | $event.target.select(); |
436 | }; | 436 | }; |
437 | 437 | ||
438 | $scope.salir = function() { | 438 | $scope.salir = function() { |
439 | $location.path('/'); | 439 | $location.path('/'); |
440 | }; | 440 | }; |
441 | 441 | ||
442 | function addCabecera(label, valor) { | 442 | function addCabecera(label, valor) { |
443 | var propiedad = $filter('filter')($scope.cabecera, {label: label}); | 443 | var propiedad = $filter('filter')($scope.cabecera, {label: label}); |
444 | if(propiedad.length === 1) { | 444 | if(propiedad.length === 1) { |
445 | propiedad[0].valor = valor; | 445 | propiedad[0].valor = valor; |
446 | } else { | 446 | } else { |
447 | $scope.cabecera.push({label: label, valor: valor}); | 447 | $scope.cabecera.push({label: label, valor: valor}); |
448 | } | 448 | } |
449 | } | 449 | } |
450 | 450 | ||
451 | function removeCabecera(label) { | 451 | function removeCabecera(label) { |
452 | var propiedad = $filter('filter')($scope.cabecera, {label: label}); | 452 | var propiedad = $filter('filter')($scope.cabecera, {label: label}); |
453 | if(propiedad.length === 1){ | 453 | if(propiedad.length === 1){ |
454 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 454 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
455 | } | 455 | } |
456 | } | 456 | } |
457 | } | 457 | } |
458 | ] | 458 | ] |
459 | ) | 459 | ) |
460 | .controller('notaPedidoListaCtrl', [ | 460 | .controller('notaPedidoListaCtrl', [ |
461 | '$scope', | 461 | '$scope', |
462 | 'crearNotaPedidoService', | 462 | 'crearNotaPedidoService', |
463 | '$location', | 463 | '$location', |
464 | function($scope, crearNotaPedidoService, $location) { | 464 | function($scope, crearNotaPedidoService, $location) { |
465 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 465 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
466 | $scope.notaPedidos = datos.data; | 466 | $scope.notaPedidos = datos.data; |
467 | }); | 467 | }); |
468 | $scope.editar = function(notaPedido) { | 468 | $scope.editar = function(notaPedido) { |
469 | crearNotaPedidoService.setNotaPedido(notaPedido); | 469 | crearNotaPedidoService.setNotaPedido(notaPedido); |
470 | $location.path('/venta-nota-pedido/abm/'); | 470 | $location.path('/venta-nota-pedido/abm/'); |
471 | }; | 471 | }; |
472 | $scope.crearPedido = function() { | 472 | $scope.crearPedido = function() { |
473 | crearNotaPedidoService.clearNotaPedido(); | 473 | crearNotaPedidoService.clearNotaPedido(); |
474 | $location.path('/venta-nota-pedido/abm/'); | 474 | $location.path('/venta-nota-pedido/abm/'); |
475 | }; | 475 | }; |
476 | } | 476 | } |
477 | ]) | 477 | ]) |
478 | .controller('focaCrearNotaPedidoFichaClienteController', [ | 478 | .controller('focaCrearNotaPedidoFichaClienteController', [ |
479 | '$scope', | 479 | '$scope', |
480 | 'crearNotaPedidoService', | 480 | 'crearNotaPedidoService', |
481 | '$location', | 481 | '$location', |
482 | function($scope, crearNotaPedidoService, $location) { | 482 | function($scope, crearNotaPedidoService, $location) { |
483 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 483 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
484 | $scope.notaPedidos = datos.data; | 484 | $scope.notaPedidos = datos.data; |
485 | }); | 485 | }); |
486 | $scope.editar = function(notaPedido) { | 486 | $scope.editar = function(notaPedido) { |
487 | crearNotaPedidoService.setNotaPedido(notaPedido); | 487 | crearNotaPedidoService.setNotaPedido(notaPedido); |
488 | $location.path('/venta-nota-pedido/abm/'); | 488 | $location.path('/venta-nota-pedido/abm/'); |
489 | }; | 489 | }; |
490 | $scope.crearPedido = function() { | 490 | $scope.crearPedido = function() { |
491 | crearNotaPedidoService.clearNotaPedido(); | 491 | crearNotaPedidoService.clearNotaPedido(); |
492 | $location.path('/venta-nota-pedido/abm/'); | 492 | $location.path('/venta-nota-pedido/abm/'); |
493 | }; | 493 | }; |
494 | } | 494 | } |
495 | ]); | 495 | ]); |
src/views/nota-pedido.html
1 | <div class="crear-nota-pedido"> | 1 | <div class="crear-nota-pedido"> |
2 | <form name="formCrearNota" ng-submit="crearNotaPedido()"> | 2 | <form name="formCrearNota" ng-submit="crearNotaPedido()"> |
3 | <div class="row"> | 3 | <div class="row"> |
4 | <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2"> | 4 | <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2"> |
5 | <div class="row p-1 panel-informativo"> | 5 | <div class="row p-1 panel-informativo"> |
6 | <div class="col-12"> | 6 | <div class="col-12"> |
7 | <div class="row"> | 7 | <div class="row"> |
8 | <div class="col-3"> | 8 | <div class="col-5"> |
9 | {{ now | date:'dd/MM/yyyy HH:mm'}} | 9 | <div class="h4">NOTA DE PEDIDO</div> |
10 | </div> | 10 | </div> |
11 | <div class="col-6 text-center"> | 11 | <div class="col-3">Nº {{puntoVenta}}-{{comprobante}}</div> |
12 | <div class="h2">NOTA DE PEDIDO</div> | 12 | <div class="col-4 text-right"> |
13 | Fecha: {{ now | date:'dd/MM/yyyy HH:mm'}} | ||
13 | </div> | 14 | </div> |
14 | <div class="col-3 text-right">Nº {{puntoVenta}}-{{comprobante}}</div> | ||
15 | </div> | 15 | </div> |
16 | <div class="row"> | 16 | <div class="row"> |
17 | <div class="col-auto" ng-repeat="cab in cabecera"> | 17 | <div class="col-auto" ng-repeat="cab in cabecera"> |
18 | <span class="label" ng-bind="cab.label"></span> | 18 | <span class="label" ng-bind="cab.label"></span> |
19 | <span class="valor" ng-bind="cab.valor"></span> | 19 | <span class="valor" ng-bind="cab.valor"></span> |
20 | </div> | 20 | </div> |
21 | </div> | 21 | </div> |
22 | </div> | 22 | </div> |
23 | </div> | 23 | </div> |
24 | <div class="row p-1 botonera-secundaria"> | 24 | <div class="row p-1 botonera-secundaria"> |
25 | <div class="col-12"> | 25 | <div class="col-12"> |
26 | <div class="row"> | 26 | <div class="row"> |
27 | <div class="col-3 px-0 py-0" ng-repeat="boton in botonera"> | 27 | <div class="col-3 px-0 py-0" ng-repeat="boton in botonera"> |
28 | <button | 28 | <button |
29 | type="button" | 29 | type="button" |
30 | class="btn btn-default btn-block btn-xs text-left py-2" | 30 | class="btn btn-default btn-block btn-xs text-left py-2" |
31 | ng-click="boton.accion()" | 31 | ng-click="boton.accion()" |
32 | > | 32 | > |
33 | <i | 33 | <i |
34 | class="fa fa-arrow-circle-right" | 34 | class="fa fa-arrow-circle-right" |
35 | ng-show="boton.texto != ''" | 35 | ng-show="boton.texto != ''" |
36 | ></i> | 36 | ></i> |
37 | | 37 | |
38 | {{boton.texto}} | 38 | {{boton.texto}} |
39 | </button> | 39 | </button> |
40 | </div> | 40 | </div> |
41 | </div> | 41 | </div> |
42 | </div> | 42 | </div> |
43 | </div> | 43 | </div> |
44 | </div> | 44 | </div> |
45 | </div> | 45 | </div> |
46 | </form> | 46 | </form> |
47 | <div class="row"> | 47 | <div class="row"> |
48 | <div class="col-md-10 col-lg-8 offset-md-1 offset-lg-2"> | 48 | <div class="col-md-10 col-lg-8 offset-md-1 offset-lg-2"> |
49 | <div class="row grilla-articulos align-items-end"> | 49 | <div class="row grilla-articulos align-items-end"> |
50 | <table class="table table-striped table-sm table-dark"> | 50 | <table class="table table-striped table-sm table-dark"> |
51 | <thead> | 51 | <thead> |
52 | <tr> | 52 | <tr> |
53 | <th>Código</th> | 53 | <th>Código</th> |
54 | <th>Descripción</th> | 54 | <th>Descripción</th> |
55 | <th>Cantidad</th> | 55 | <th>Cantidad</th> |
56 | <th>Precio Unitario</th> | 56 | <th>Precio Unitario</th> |
57 | <th>SubTotal</th> | 57 | <th>SubTotal</th> |
58 | <th> | 58 | <th> |
59 | <button | 59 | <button |
60 | class="btn btn-outline-secondary selectable" | 60 | class="btn btn-outline-secondary selectable" |
61 | style="float: right;" | 61 | style="float: right;" |
62 | ng-click="show = !show; masMenos()" | 62 | ng-click="show = !show; masMenos()" |
63 | > | 63 | > |
64 | <i | 64 | <i |
65 | class="fa fa-chevron-down" | 65 | class="fa fa-chevron-down" |
66 | ng-hide="show" | 66 | ng-hide="show" |
67 | aria-hidden="true" | 67 | aria-hidden="true" |
68 | > | 68 | > |
69 | </i> | 69 | </i> |
70 | <i | 70 | <i |
71 | class="fa fa-chevron-up" | 71 | class="fa fa-chevron-up" |
72 | ng-show="show" | 72 | ng-show="show" |
73 | aria-hidden="true"> | 73 | aria-hidden="true"> |
74 | </i> | 74 | </i> |
75 | </button> | 75 | </button> |
76 | </th> | 76 | </th> |
77 | </tr> | 77 | </tr> |
78 | </thead> | 78 | </thead> |
79 | <tbody> | 79 | <tbody> |
80 | <tr ng-show="!cargando"> | 80 | <tr ng-show="!cargando"> |
81 | <td><input | 81 | <td><input |
82 | class="form-control" | 82 | class="form-control" |
83 | ng-model="articuloACargar.sector + '-' + articuloACargar.codigo" | 83 | ng-model="articuloACargar.sector + '-' + articuloACargar.codigo" |
84 | readonly></td> | 84 | readonly></td> |
85 | <td><input | 85 | <td><input |
86 | class="form-control" | 86 | class="form-control" |
87 | ng-model="articuloACargar.descripcion" | 87 | ng-model="articuloACargar.descripcion" |
88 | readonly></td> | 88 | readonly></td> |
89 | <td class="text-right"><input | 89 | <td class="text-right"><input |
90 | class="form-control" | 90 | class="form-control" |
91 | type="number" | 91 | type="number" |
92 | min="1" | 92 | min="1" |
93 | ng-model="articuloACargar.cantidad" | 93 | ng-model="articuloACargar.cantidad" |
94 | foca-focus="!cargando" | 94 | foca-focus="!cargando" |
95 | esc-key="resetFilter()" | 95 | esc-key="resetFilter()" |
96 | ng-keypress="agregarATabla($event.keyCode)"></td> | 96 | ng-keypress="agregarATabla($event.keyCode)"></td> |
97 | <td class="text-right"><input | 97 | <td class="text-right"><input |
98 | class="form-control" | 98 | class="form-control" |
99 | ng-value="articuloACargar.precio | currency: '$'" | 99 | ng-value="articuloACargar.precio | currency: '$'" |
100 | readonly></td> | 100 | readonly></td> |
101 | <td class="text-right"><input | 101 | <td class="text-right"><input |
102 | class="form-control" | 102 | class="form-control" |
103 | ng-value="getSubTotal() | currency: '$'" | 103 | ng-value="getSubTotal() | currency: '$'" |
104 | readonly></td> | 104 | readonly></td> |
105 | <td class="text-center"><button | 105 | <td class="text-center"><button |
106 | class="btn btn-outline-secondary btn-sm" | 106 | class="btn btn-outline-secondary btn-sm" |
107 | ng-click="agregarATabla(13)"> | 107 | ng-click="agregarATabla(13)"> |
108 | <i class="fa fa-save"></i> | 108 | <i class="fa fa-save"></i> |
109 | </button></td> | 109 | </button></td> |
110 | </tr> | 110 | </tr> |
111 | <tr | 111 | <tr |
112 | ng-repeat="(key, articulo) in articulosTabla" | 112 | ng-repeat="(key, articulo) in articulosTabla" |
113 | ng-show="show || key == 0" | 113 | ng-show="show || key == 0" |
114 | > | 114 | > |
115 | <td ng-bind="articulo.sector + '-' + articulo.codigo"></td> | 115 | <td ng-bind="articulo.sector + '-' + articulo.codigo"></td> |
116 | <td ng-bind="articulo.descripcion"></td> | 116 | <td ng-bind="articulo.descripcion"></td> |
117 | <td class="text-right"><input | 117 | <td class="text-right"><input |
118 | ng-show="articulo.edit" | 118 | ng-show="articulo.edit" |
119 | ng-model="articulo.cantidad" | 119 | ng-model="articulo.cantidad" |
120 | class="form-control" | 120 | class="form-control" |
121 | type="number" | 121 | type="number" |
122 | min="1" | 122 | min="1" |
123 | foca-focus="articulo.edit" | 123 | foca-focus="articulo.edit" |
124 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 124 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
125 | ng-focus="selectFocus($event)" | 125 | ng-focus="selectFocus($event)" |
126 | > | 126 | > |
127 | <i | 127 | <i |
128 | class="selectable" | 128 | class="selectable" |
129 | ng-click="cambioEdit(articulo)" | 129 | ng-click="cambioEdit(articulo)" |
130 | ng-hide="articulo.edit" | 130 | ng-hide="articulo.edit" |
131 | ng-bind="articulo.cantidad"> | 131 | ng-bind="articulo.cantidad"> |
132 | </i> | 132 | </i> |
133 | </td> | 133 | </td> |
134 | <td class="text-right" ng-bind="articulo.precio | currency: '$'"></td> | 134 | <td class="text-right" ng-bind="articulo.precio | currency: '$'"></td> |
135 | <td | 135 | <td |
136 | class="text-right" | 136 | class="text-right" |
137 | ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'"> | 137 | ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'"> |
138 | </td> | 138 | </td> |
139 | <td class="text-center"> | 139 | <td class="text-center"> |
140 | <button | 140 | <button |
141 | class="btn btn-outline-secondary btn-sm" | 141 | class="btn btn-outline-secondary btn-sm" |
142 | ng-click="quitarArticulo(key)" | 142 | ng-click="quitarArticulo(key)" |
143 | > | 143 | > |
144 | <i class="fa fa-trash"></i> | 144 | <i class="fa fa-trash"></i> |
145 | </button> | 145 | </button> |
146 | </td> | 146 | </td> |
147 | </tr> | 147 | </tr> |
148 | <tr ng-show="cargando"> | 148 | <tr ng-show="cargando"> |
149 | <td colspan="6"> | 149 | <td colspan="6"> |
150 | <input | 150 | <input |
151 | placeholder="Seleccione Articulo" | 151 | placeholder="Seleccione Articulo" |
152 | class="form-control form-control-sm" | 152 | class="form-control form-control-sm" |
153 | readonly | 153 | readonly |
154 | ng-click="seleccionarArticulo()" | 154 | ng-click="seleccionarArticulo()" |
155 | /> | 155 | /> |
156 | </td> | 156 | </td> |
157 | </tr> | 157 | </tr> |
158 | </tbody> | 158 | </tbody> |
159 | <tfoot> | 159 | <tfoot> |
160 | <tr class=""> | 160 | <tr class=""> |
161 | <td colspan="3"> | 161 | <td colspan="3"> |
162 | <strong>Cantidad Items:</strong> | 162 | <strong>Cantidad Items:</strong> |
163 | <a ng-bind="articulosTabla.length"></a> | 163 | <a ng-bind="articulosTabla.length"></a> |
164 | </td> | 164 | </td> |
165 | <td class="text-right table-celda-total"><h3>Total:</h3></td> | 165 | <td class="text-right table-celda-total"><h3>Total:</h3></td> |
166 | <td class="table-celda-total text-right" colspan="1"> | 166 | <td class="table-celda-total text-right" colspan="1"> |
167 | <h3>{{getTotal() | currency: '$'}}</h3> | 167 | <h3>{{getTotal() | currency: '$'}}</h3> |
168 | </td> | 168 | </td> |
169 | <td colspan="2"></td> | 169 | <td colspan="2" class="text-right"> |
170 | <button | ||
171 | type="button" | ||
172 | class="btn btn-default btn-sm" | ||
173 | > | ||
174 | Totales | ||
175 | </button> | ||
176 | </td> | ||
170 | </tr> | 177 | </tr> |
171 | </tfoot> | 178 | </tfoot> |
172 | </table> | 179 | </table> |
173 | </div> | 180 | </div> |
174 | </div> | 181 | </div> |
175 | <div class="col-auto my-2 col-lg-2 botonera-lateral"> | 182 | <div class="col-auto my-2 col-lg-2 botonera-lateral"> |
176 | <div class="row align-items-end"> | 183 | <div class="row align-items-end"> |
177 | <div class="col-12"> | 184 | <div class="col-12"> |
178 | <button | 185 | <button |
179 | ng-click="crearNotaPedido()" | 186 | ng-click="crearNotaPedido()" |
180 | type="submit" | 187 | type="submit" |
181 | title="Crear nota pedido" | 188 | title="Crear nota pedido" |
182 | class="btn btn-default btn-block mb-2"> | 189 | class="btn btn-default btn-block mb-2"> |
183 | Guardar | 190 | Guardar |
184 | </button> | 191 | </button> |
185 | <button | 192 | <button |
186 | ng-click="salir()" | 193 | ng-click="salir()" |
187 | type="button" | 194 | type="button" |
188 | title="Salir" | 195 | title="Salir" |
189 | class="btn btn-default btn-block"> | 196 | class="btn btn-default btn-block"> |
190 | Salir | 197 | Salir |
191 | </button> | 198 | </button> |
192 | </div> | 199 | </div> |
193 | </div> | 200 | </div> |
194 | </div> | 201 | </div> |
195 | </div> | 202 | </div> |
196 | </div> | 203 | </div> |
197 | <!-- | 204 | <!-- |
198 | <form name="formCrearNota"> | 205 | <form name="formCrearNota"> |
199 | <uib-tabset active="active"> | 206 | <uib-tabset active="active"> |
200 | <uib-tab index="0" heading="General"> | 207 | <uib-tab index="0" heading="General"> |
201 | <input type="hidden" name="id" ng-model="notaPedido.id" /> | 208 | <input type="hidden" name="id" ng-model="notaPedido.id" /> |
202 | <div> | 209 | <div> |
203 | <div class="col-auto my-2"> | 210 | <div class="col-auto my-2"> |
204 | <button type="submit" title="Siguiente" class="btn btn-primary float-right">Siguiente</button> | 211 | <button type="submit" title="Siguiente" class="btn btn-primary float-right">Siguiente</button> |
205 | </div> | 212 | </div> |
206 | </div> | 213 | </div> |
207 | <br> | 214 | <br> |
208 | <br> | 215 | <br> |
209 | <div class="row"> | 216 | <div class="row"> |
210 | <div class="col-md-2"> | 217 | <div class="col-md-2"> |
211 | <div class="col-auto"> | 218 | <div class="col-auto"> |
212 | <label>Fecha de carga</label> | 219 | <label>Fecha de carga</label> |
213 | </div> | 220 | </div> |
214 | </div> | 221 | </div> |
215 | <div class="col-md-3"> | 222 | <div class="col-md-3"> |
216 | <div class="col-auto"> | 223 | <div class="col-auto"> |
217 | <input type="date" class="form-control" ng-model="notaPedido.fechaCarga" ng-required="true"> | 224 | <input type="date" class="form-control" ng-model="notaPedido.fechaCarga" ng-required="true"> |
218 | </div> | 225 | </div> |
219 | </div> | 226 | </div> |
220 | <div class="col-md-2"> | 227 | <div class="col-md-2"> |
221 | <div class="col-auto"> | 228 | <div class="col-auto"> |
222 | <label>Kilómetros</label> | 229 | <label>Kilómetros</label> |
223 | </div> | 230 | </div> |
224 | </div> | 231 | </div> |
225 | <div class="col-md-3"> | 232 | <div class="col-md-3"> |
226 | <div class="col-auto"> | 233 | <div class="col-auto"> |
227 | <input type="number" min="0" step="0.01" class="form-control" placeholder="Kilómetros recorridos para la entrega en el cliente" | 234 | <input type="number" min="0" step="0.01" class="form-control" placeholder="Kilómetros recorridos para la entrega en el cliente" |
228 | ng-model="notaPedido.kilometros" ng-required="true"> | 235 | ng-model="notaPedido.kilometros" ng-required="true"> |
229 | </div> | 236 | </div> |
230 | </div> | 237 | </div> |
231 | </div> | 238 | </div> |
232 | <div class="row my-3"> | 239 | <div class="row my-3"> |
233 | <div class="col-md-2"> | 240 | <div class="col-md-2"> |
234 | <div class="col-auto"> | 241 | <div class="col-auto"> |
235 | <label>Jurisdicción de IIBB</label> | 242 | <label>Jurisdicción de IIBB</label> |
236 | </div> | 243 | </div> |
237 | </div> | 244 | </div> |
238 | <div class="col-md-3"> | 245 | <div class="col-md-3"> |
239 | <div class="col-auto"> | 246 | <div class="col-auto"> |
240 | <input type="text" class="form-control" placeholder="Jurisdicción de IIBB donde se realiza la entrega" | 247 | <input type="text" class="form-control" placeholder="Jurisdicción de IIBB donde se realiza la entrega" |
241 | ng-model="notaPedido.jurisdiccionIIBB" ng-required="true"> | 248 | ng-model="notaPedido.jurisdiccionIIBB" ng-required="true"> |
242 | </div> | 249 | </div> |
243 | </div> | 250 | </div> |
244 | <div class="col-md-2"> | 251 | <div class="col-md-2"> |
245 | <div class="col-auto"> | 252 | <div class="col-auto"> |
246 | <label>Costo de financiación</label> | 253 | <label>Costo de financiación</label> |
247 | </div> | 254 | </div> |
248 | </div> | 255 | </div> |
249 | <div class="col-md-3"> | 256 | <div class="col-md-3"> |
250 | <div class="col-auto"> | 257 | <div class="col-auto"> |
251 | <div class="input-group mb-2"> | 258 | <div class="input-group mb-2"> |
252 | <div class="input-group-prepend"> | 259 | <div class="input-group-prepend"> |
253 | <div class="input-group-text">$</div> | 260 | <div class="input-group-text">$</div> |
254 | </div> | 261 | </div> |
255 | <input type="number" min="0" step="0.01" class="form-control" placeholder="Costo de financiación" | 262 | <input type="number" min="0" step="0.01" class="form-control" placeholder="Costo de financiación" |
256 | ng-model="notaPedido.costoFinanciacion"> | 263 | ng-model="notaPedido.costoFinanciacion"> |
257 | </div> | 264 | </div> |
258 | </div> | 265 | </div> |
259 | </div> | 266 | </div> |
260 | </div> | 267 | </div> |
261 | <div class="row"> | 268 | <div class="row"> |
262 | <div class="col-md-2"> | 269 | <div class="col-md-2"> |
263 | <div class="col-auto"> | 270 | <div class="col-auto"> |
264 | <label>Bomba</label> | 271 | <label>Bomba</label> |
265 | </div> | 272 | </div> |
266 | </div> | 273 | </div> |
267 | <div class="col-md-1"> | 274 | <div class="col-md-1"> |
268 | <div class="col-auto"> | 275 | <div class="col-auto"> |
269 | <div class="form-check custom-radio custom-control-inline"> | 276 | <div class="form-check custom-radio custom-control-inline"> |
270 | <input class="form-check-input" type="radio" name="radioBomba" value="1" ng-model="notaPedido.bomba"> | 277 | <input class="form-check-input" type="radio" name="radioBomba" value="1" ng-model="notaPedido.bomba"> |
271 | <label class="form-check-label"> | 278 | <label class="form-check-label"> |
272 | Si | 279 | Si |
273 | </label> | 280 | </label> |
274 | </div> | 281 | </div> |
275 | <div class="form-check custom-radio custom-control-inline"> | 282 | <div class="form-check custom-radio custom-control-inline"> |
276 | <input class="form-check-input" type="radio" name="radioBomba" value="0" ng-model="notaPedido.bomba"> | 283 | <input class="form-check-input" type="radio" name="radioBomba" value="0" ng-model="notaPedido.bomba"> |
277 | <label class="form-check-label"> | 284 | <label class="form-check-label"> |
278 | No | 285 | No |
279 | </label> | 286 | </label> |
280 | </div> | 287 | </div> |
281 | </div> | 288 | </div> |
282 | </div> | 289 | </div> |
283 | <div class="col-md-1"> | 290 | <div class="col-md-1"> |
284 | <div class="col-auto"> | 291 | <div class="col-auto"> |
285 | <label>Flete</label> | 292 | <label>Flete</label> |
286 | </div> | 293 | </div> |
287 | </div> | 294 | </div> |
288 | <div class="col-md-1"> | 295 | <div class="col-md-1"> |
289 | <div class="col-auto"> | 296 | <div class="col-auto"> |
290 | <div class="form-check custom-radio custom-control-inline"> | 297 | <div class="form-check custom-radio custom-control-inline"> |
291 | <input class="form-check-input" type="radio" name="radioFlete" value="1" ng-model="notaPedido.flete"> | 298 | <input class="form-check-input" type="radio" name="radioFlete" value="1" ng-model="notaPedido.flete"> |
292 | <label class="form-check-label"> | 299 | <label class="form-check-label"> |
293 | Si | 300 | Si |
294 | </label> | 301 | </label> |
295 | </div> | 302 | </div> |
296 | <div class="form-check custom-radio custom-control-inline"> | 303 | <div class="form-check custom-radio custom-control-inline"> |
297 | <input class="form-check-input" type="radio" name="radioFlete" value="0" ng-model="notaPedido.flete"> | 304 | <input class="form-check-input" type="radio" name="radioFlete" value="0" ng-model="notaPedido.flete"> |
298 | <label class="form-check-label"> | 305 | <label class="form-check-label"> |
299 | FOB | 306 | FOB |
300 | </label> | 307 | </label> |
301 | </div> | 308 | </div> |
302 | </div> | 309 | </div> |
303 | </div> | 310 | </div> |
304 | <div class="col-md-2"> | 311 | <div class="col-md-2"> |
305 | <div class="col-auto"> | 312 | <div class="col-auto"> |
306 | <label>Costo unitario kilometro flete</label> | 313 | <label>Costo unitario kilometro flete</label> |
307 | </div> | 314 | </div> |
308 | </div> | 315 | </div> |
309 | <div class="col-md-3"> | 316 | <div class="col-md-3"> |
310 | <div class="col-auto"> | 317 | <div class="col-auto"> |
311 | <div class="input-group mb-2"> | 318 | <div class="input-group mb-2"> |
312 | <div class="input-group-prepend"> | 319 | <div class="input-group-prepend"> |
313 | <div class="input-group-text">$</div> | 320 | <div class="input-group-text">$</div> |
314 | </div> | 321 | </div> |
315 | <input type="number" min="0" step="0.01" class="form-control" placeholder="Costo unitario del kilometro del flete" | 322 | <input type="number" min="0" step="0.01" class="form-control" placeholder="Costo unitario del kilometro del flete" |
316 | ng-model="notaPedido.costoUnitarioKmFlete" ng-required="true"> | 323 | ng-model="notaPedido.costoUnitarioKmFlete" ng-required="true"> |
317 | </div> | 324 | </div> |
318 | </div> | 325 | </div> |
319 | </div> | 326 | </div> |
320 | </div> | 327 | </div> |
321 | <div class="row my-3"> | 328 | <div class="row my-3"> |
322 | <div class="col-md-2"> | 329 | <div class="col-md-2"> |
323 | <div class="col-auto"> | 330 | <div class="col-auto"> |
324 | <label>Vendedor</label> | 331 | <label>Vendedor</label> |
325 | </div> | 332 | </div> |
326 | </div> | 333 | </div> |
327 | <div class="col-md-3"> | 334 | <div class="col-md-3"> |
328 | <div class="col-auto"> | 335 | <div class="col-auto"> |
329 | <input type="text" class="form-control" placeholder="Seleccione vendedor" ng-model="notaPedido.vendedor" | 336 | <input type="text" class="form-control" placeholder="Seleccione vendedor" ng-model="notaPedido.vendedor" |
330 | ng-click="seleccionarVendedor()" readonly> | 337 | ng-click="seleccionarVendedor()" readonly> |
331 | </div> | 338 | </div> |
332 | </div> | 339 | </div> |
333 | <div class="col-md-2"> | 340 | <div class="col-md-2"> |
334 | <div class="col-auto"> | 341 | <div class="col-auto"> |
335 | <label>Petrolera</label> | 342 | <label>Petrolera</label> |
336 | </div> | 343 | </div> |
337 | </div> | 344 | </div> |
338 | <div class="col-md-3"> | 345 | <div class="col-md-3"> |
339 | <div class="col-auto"> | 346 | <div class="col-auto"> |
340 | <input type="text" class="form-control" placeholder="Seleccione petrolera" ng-model="notaPedido.petrolera" | 347 | <input type="text" class="form-control" placeholder="Seleccione petrolera" ng-model="notaPedido.petrolera" |
341 | ng-click="seleccionarPetrolera()" readonly> | 348 | ng-click="seleccionarPetrolera()" readonly> |
342 | </div> | 349 | </div> |
343 | </div> | 350 | </div> |
344 | </div> | 351 | </div> |
345 | </div> | 352 | </div> |
346 | <div class="row"> | 353 | <div class="row"> |
347 | <div class="col-md-2"> | 354 | <div class="col-md-2"> |
348 | <div class="col-auto"> | 355 | <div class="col-auto"> |
349 | <label>Cliente</label> | 356 | <label>Cliente</label> |
350 | </div> | 357 | </div> |
351 | </div> | 358 | </div> |
352 | <div class="col-md-3"> | 359 | <div class="col-md-3"> |
353 | <div class="col-auto"> | 360 | <div class="col-auto"> |
354 | <input type="text" class="form-control" placeholder="Seleccione cliente" ng-model="notaPedido.cliente" | 361 | <input type="text" class="form-control" placeholder="Seleccione cliente" ng-model="notaPedido.cliente" |
355 | ng-click="seleccionarCliente()" ng-change="obtenerDomicilios()" readonly> | 362 | ng-click="seleccionarCliente()" ng-change="obtenerDomicilios()" readonly> |
356 | </div> | 363 | </div> |
357 | </div> | 364 | </div> |
358 | <div class="col-md-2"> | 365 | <div class="col-md-2"> |
359 | <div class="col-auto"> | 366 | <div class="col-auto"> |
360 | <label>Domicilio</label> | 367 | <label>Domicilio</label> |
361 | </div> | 368 | </div> |
362 | </div> | 369 | </div> |
363 | <div class="col-md-4"> | 370 | <div class="col-md-4"> |
364 | <div class="col-md-12 row" ng-repeat="domicilio in notaPedido.domicilio"> | 371 | <div class="col-md-12 row" ng-repeat="domicilio in notaPedido.domicilio"> |
365 | <div class="col-auto"> | 372 | <div class="col-auto"> |
366 | <input type="text" ng-model="domicilio.dom" placeholder="Domicilio" uib-typeahead=" | 373 | <input type="text" ng-model="domicilio.dom" placeholder="Domicilio" uib-typeahead=" |
367 | domi.dom | 374 | domi.dom |
368 | for domi | 375 | for domi |
369 | in domiciliosCliente | 376 | in domiciliosCliente |
370 | " | 377 | " |
371 | typeahead-no-results="sinResultados" typeahead-min-length="0" typeahead-on-select="seleccionar($item)" | 378 | typeahead-no-results="sinResultados" typeahead-min-length="0" typeahead-on-select="seleccionar($item)" |
372 | class="form-control mb-2" ng-disabled="domicilio.id > 0" ng-required="true"> | 379 | class="form-control mb-2" ng-disabled="domicilio.id > 0" ng-required="true"> |
373 | <i ng-show="cargandoClientes" class="fas fa-sync"></i> | 380 | <i ng-show="cargandoClientes" class="fas fa-sync"></i> |
374 | <div ng-show="sinResultados"> | 381 | <div ng-show="sinResultados"> |
375 | No se encontraron resultados. | 382 | No se encontraron resultados. |
376 | </div> | 383 | </div> |
377 | </div> | 384 | </div> |
378 | <a class="btn" ng-click="removeNewChoice(domicilio)" ng-if="domicilio.id==0">-</a> | 385 | <a class="btn" ng-click="removeNewChoice(domicilio)" ng-if="domicilio.id==0">-</a> |
379 | <a class="btn" ng-click="addNewDom()">+</a> | 386 | <a class="btn" ng-click="addNewDom()">+</a> |
380 | </div> | 387 | </div> |
381 | </div> | 388 | </div> |
382 | </div> | 389 | </div> |
383 | </uib-tab> | 390 | </uib-tab> |
384 | <uib-tab index="1" heading="Producto" disable="formCrearNota.$invalid"> | 391 | <uib-tab index="1" heading="Producto" disable="formCrearNota.$invalid"> |
385 | <div> | 392 | <div> |
386 | <div class="col-auto my-2"> | 393 | <div class="col-auto my-2"> |
387 | <button ng-click="crearNotaPedido()" type="button" title="Crear nota pedido" class="btn btn-primary float-right">Crear</button> | 394 | <button ng-click="crearNotaPedido()" type="button" title="Crear nota pedido" class="btn btn-primary float-right">Crear</button> |
388 | </div> | 395 | </div> |
389 | </div> | 396 | </div> |
390 | <br> | 397 | <br> |
391 | <br> | 398 | <br> |
392 | <div class="row"> | 399 | <div class="row"> |
393 | <div class="col-md-2"> | 400 | <div class="col-md-2"> |
394 | <div class="col-auto"> | 401 | <div class="col-auto"> |
395 | <label>Precios y condiciones</label> | 402 | <label>Precios y condiciones</label> |
396 | </div> | 403 | </div> |
397 | </div> | 404 | </div> |
398 | <div class="col-md-4"> | 405 | <div class="col-md-4"> |
399 | <div class="col-auto"> | 406 | <div class="col-auto"> |
400 | <select class="form-control" ng-change="cargarArticulos()" ng-model="notaPedido.precioCondicion" ng-options="preCond.id as preCond.nombre for preCond in precioCondiciones"> | 407 | <select class="form-control" ng-change="cargarArticulos()" ng-model="notaPedido.precioCondicion" ng-options="preCond.id as preCond.nombre for preCond in precioCondiciones"> |
401 | </select> | 408 | </select> |
402 | </div> | 409 | </div> |
403 | </div> | 410 | </div> |
404 | <div class="col-md-2"> | 411 | <div class="col-md-2"> |
405 | <div class="col-auto"> | 412 | <div class="col-auto"> |
406 | <label>Producto</label> | 413 | <label>Producto</label> |
407 | </div> | 414 | </div> |
408 | </div> | 415 | </div> |
409 | <div class="col-md-4"> | 416 | <div class="col-md-4"> |
410 | <div class="col-auto"> | 417 | <div class="col-auto"> |
411 | <input type="text" class="form-control" placeholder="Seleccione producto" ng-model="notaPedido.producto" | 418 | <input type="text" class="form-control" placeholder="Seleccione producto" ng-model="notaPedido.producto" |
412 | ng-click="seleccionarArticulo()" readonly> | 419 | ng-click="seleccionarArticulo()" readonly> |
413 | </div> | 420 | </div> |
414 | </div> | 421 | </div> |
415 | </div> | 422 | </div> |
416 | <div class="col-md-12"> | 423 | <div class="col-md-12"> |
417 | <table class="table my-3 table-hover table-nonfluid"> | 424 | <table class="table my-3 table-hover table-nonfluid"> |
418 | <thead> | 425 | <thead> |
419 | <tr> | 426 | <tr> |
420 | <th>Código</th> | 427 | <th>Código</th> |
421 | <th>Nombre</th> | 428 | <th>Nombre</th> |
422 | <th>Precio unitario</th> | 429 | <th>Precio unitario</th> |
423 | <th>Costo unitario bruto</th> | 430 | <th>Costo unitario bruto</th> |
424 | <th>Cantidad</th> | 431 | <th>Cantidad</th> |
425 | <th>Subtotal</th> | 432 | <th>Subtotal</th> |
426 | </tr> | 433 | </tr> |
427 | </thead> | 434 | </thead> |
428 | <tbody> | 435 | <tbody> |
429 | <tr ng-repeat="articulo in articulosTabla"> | 436 | <tr ng-repeat="articulo in articulosTabla"> |
430 | <td ng-bind="articulo.codigo"></td> | 437 | <td ng-bind="articulo.codigo"></td> |
431 | <td ng-bind="articulo.nombre"></td> | 438 | <td ng-bind="articulo.nombre"></td> |
432 | <td ng-bind="articulo.precio"></td> | 439 | <td ng-bind="articulo.precio"></td> |
433 | <td ng-bind="articulo.costoUnitario"></td> | 440 | <td ng-bind="articulo.costoUnitario"></td> |
434 | <td><input ng-model="articulo.cantidad" class="form-control" type="number" min="0" value="1"></td> | 441 | <td><input ng-model="articulo.cantidad" class="form-control" type="number" min="0" value="1"></td> |
435 | <td ng-bind="getSubTotal(articulo.item)"></td> | 442 | <td ng-bind="getSubTotal(articulo.item)"></td> |
436 | </tr> | 443 | </tr> |
437 | </tbody> | 444 | </tbody> |
438 | </table> | 445 | </table> |
439 | </div> | 446 | </div> |
440 | </uib-tab> | 447 | </uib-tab> |
441 | </uib-tabset> | 448 | </uib-tabset> |