Commit df5db9d1485ae68900fc8ae0587479306d7c85a6
1 parent
0fb9e9af2f
Exists in
master
and in
1 other branch
Todos los precios usan simbolo elegido por moneda
los articulos se guardan con el precio original
Showing
3 changed files
with
33 additions
and
27 deletions
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() {$scope.seleccionarProveedor();}}, | 11 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, |
12 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | 12 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, |
13 | { | 13 | { |
14 | texto: 'Precios y condiciones', | 14 | texto: 'Precios y condiciones', |
15 | accion: function() {$scope.abrirModalListaPrecio();}}, | 15 | accion: function() {$scope.abrirModalListaPrecio();}}, |
16 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | 16 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, |
17 | {texto: '', accion: function() {}}, | 17 | {texto: '', accion: function() {}}, |
18 | {texto: '', accion: function() {}} | 18 | {texto: '', accion: function() {}} |
19 | ]; | 19 | ]; |
20 | $scope.datepickerAbierto = false; | 20 | $scope.datepickerAbierto = false; |
21 | 21 | ||
22 | $scope.show = false; | 22 | $scope.show = false; |
23 | $scope.cargando = true; | 23 | $scope.cargando = true; |
24 | $scope.dateOptions = { | 24 | $scope.dateOptions = { |
25 | maxDate: new Date(), | 25 | maxDate: new Date(), |
26 | minDate: new Date(2010, 0, 1) | 26 | minDate: new Date(2010, 0, 1) |
27 | }; | 27 | }; |
28 | 28 | ||
29 | $scope.notaPedido = { | 29 | $scope.notaPedido = { |
30 | vendedor: {}, | 30 | vendedor: {}, |
31 | cliente: {}, | 31 | cliente: {}, |
32 | proveedor: {}, | 32 | proveedor: {}, |
33 | domicilio: {dom: ''}, | 33 | domicilio: {dom: ''}, |
34 | moneda: {}, | 34 | moneda: {}, |
35 | cotizacion: {} | 35 | cotizacion: {} |
36 | }; | 36 | }; |
37 | var monedaPorDefecto; | 37 | var monedaPorDefecto; |
38 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 38 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
39 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | 39 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { |
40 | monedaPorDefecto = { | 40 | monedaPorDefecto = { |
41 | id: res.data[0].ID, | 41 | id: res.data[0].ID, |
42 | detalle: res.data[0].DETALLE, | 42 | detalle: res.data[0].DETALLE, |
43 | simbolo: res.data[0].SIMBOLO, | 43 | simbolo: res.data[0].SIMBOLO, |
44 | cotizaciones: res.data[0].cotizaciones | 44 | cotizaciones: res.data[0].cotizaciones |
45 | }; | 45 | }; |
46 | addCabecera('Moneda:', monedaPorDefecto.detalle); | 46 | addCabecera('Moneda:', monedaPorDefecto.detalle); |
47 | addCabecera('Fecha cotizacion:', | 47 | addCabecera('Fecha cotizacion:', |
48 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | 48 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); |
49 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); | 49 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); |
50 | $scope.notaPedido.moneda = monedaPorDefecto; | 50 | $scope.notaPedido.moneda = monedaPorDefecto; |
51 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; | 51 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; |
52 | }); | 52 | }); |
53 | 53 | ||
54 | $scope.cabecera = []; | 54 | $scope.cabecera = []; |
55 | $scope.showCabecera = true; | 55 | $scope.showCabecera = true; |
56 | 56 | ||
57 | $scope.now = new Date(); | 57 | $scope.now = new Date(); |
58 | $scope.puntoVenta = Math.round(Math.random() * 10000); | 58 | $scope.puntoVenta = Math.round(Math.random() * 10000); |
59 | $scope.comprobante = Math.round(Math.random() * 1000000); | 59 | $scope.comprobante = Math.round(Math.random() * 1000000); |
60 | 60 | ||
61 | $scope.articulosTabla = []; | 61 | $scope.articulosTabla = []; |
62 | $scope.idLista = undefined; | 62 | $scope.idLista = undefined; |
63 | //La pantalla solo se usa para cargar pedidos | 63 | //La pantalla solo se usa para cargar pedidos |
64 | //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | 64 | //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
65 | 65 | ||
66 | crearNotaPedidoService.getPrecioCondicion().then( | 66 | crearNotaPedidoService.getPrecioCondicion().then( |
67 | function(res) { | 67 | function(res) { |
68 | $scope.precioCondiciones = res.data; | 68 | $scope.precioCondiciones = res.data; |
69 | } | 69 | } |
70 | ); | 70 | ); |
71 | //La pantalla solo se usa para cargar pedidos | 71 | //La pantalla solo se usa para cargar pedidos |
72 | // if (notaPedidoTemp !== undefined) { | 72 | // if (notaPedidoTemp !== undefined) { |
73 | // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | 73 | // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
74 | // $scope.notaPedido = notaPedidoTemp; | 74 | // $scope.notaPedido = notaPedidoTemp; |
75 | // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | 75 | // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
76 | // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | 76 | // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
77 | // $scope.idLista = $scope.notaPedido.precioCondicion; | 77 | // $scope.idLista = $scope.notaPedido.precioCondicion; |
78 | // crearNotaPedidoService | 78 | // crearNotaPedidoService |
79 | // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | 79 | // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
80 | // function(res) { | 80 | // function(res) { |
81 | // $scope.articulosTabla = res.data; | 81 | // $scope.articulosTabla = res.data; |
82 | // } | 82 | // } |
83 | // ); | 83 | // ); |
84 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | 84 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
85 | //(NO REQUERIDO EN ESTA VERSION) | 85 | //(NO REQUERIDO EN ESTA VERSION) |
86 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 86 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
87 | // function(res) { | 87 | // function(res) { |
88 | // $scope.notaPedido.domicilio = res.data; | 88 | // $scope.notaPedido.domicilio = res.data; |
89 | // } | 89 | // } |
90 | // ); | 90 | // ); |
91 | // } else { | 91 | // } else { |
92 | // $scope.notaPedido.fechaCarga = new Date(); | 92 | // $scope.notaPedido.fechaCarga = new Date(); |
93 | // $scope.notaPedido.bomba = '0'; | 93 | // $scope.notaPedido.bomba = '0'; |
94 | // $scope.notaPedido.flete = '0'; | 94 | // $scope.notaPedido.flete = '0'; |
95 | // $scope.idLista = undefined; | 95 | // $scope.idLista = undefined; |
96 | // } | 96 | // } |
97 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 97 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
98 | // $scope.addNewDom = function() { | 98 | // $scope.addNewDom = function() { |
99 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); | 99 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); |
100 | // }; | 100 | // }; |
101 | // $scope.removeNewChoice = function(choice) { | 101 | // $scope.removeNewChoice = function(choice) { |
102 | // if ($scope.notaPedido.domicilio.length > 1) { | 102 | // if ($scope.notaPedido.domicilio.length > 1) { |
103 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | 103 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
104 | // function(c) { | 104 | // function(c) { |
105 | // return c.$$hashKey === choice.$$hashKey; | 105 | // return c.$$hashKey === choice.$$hashKey; |
106 | // } | 106 | // } |
107 | // ), 1); | 107 | // ), 1); |
108 | // } | 108 | // } |
109 | // }; | 109 | // }; |
110 | 110 | ||
111 | $scope.crearNotaPedido = function() { | 111 | $scope.crearNotaPedido = function() { |
112 | if(!$scope.notaPedido.vendedor.codigo) { | 112 | if(!$scope.notaPedido.vendedor.codigo) { |
113 | focaModalService.alert('Ingrese Vendedor'); | 113 | focaModalService.alert('Ingrese Vendedor'); |
114 | return; | 114 | return; |
115 | } else if(!$scope.notaPedido.cliente.id) { | 115 | } else if(!$scope.notaPedido.cliente.id) { |
116 | focaModalService.alert('Ingrese Cliente'); | 116 | focaModalService.alert('Ingrese Cliente'); |
117 | return; | 117 | return; |
118 | } else if(!$scope.notaPedido.proveedor.codigo) { | 118 | } else if(!$scope.notaPedido.proveedor.codigo) { |
119 | focaModalService.alert('Ingrese Proveedor'); | 119 | focaModalService.alert('Ingrese Proveedor'); |
120 | return; | 120 | return; |
121 | } else if(!$scope.notaPedido.moneda.id) { | 121 | } else if(!$scope.notaPedido.moneda.id) { |
122 | focaModalService.alert('Ingrese Moneda'); | 122 | focaModalService.alert('Ingrese Moneda'); |
123 | return; | 123 | return; |
124 | } else if(!$scope.notaPedido.cotizacion.ID) { | 124 | } else if(!$scope.notaPedido.cotizacion.ID) { |
125 | focaModalService.alert('Ingrese Cotización'); | 125 | focaModalService.alert('Ingrese Cotización'); |
126 | return; | 126 | return; |
127 | } else if(!$scope.plazosPagos) { | 127 | } else if(!$scope.plazosPagos) { |
128 | focaModalService.alert('Ingrese Precios y Condiciones'); | 128 | focaModalService.alert('Ingrese Precios y Condiciones'); |
129 | return; | 129 | return; |
130 | } else if(!$scope.notaPedido.flete) { | 130 | } else if(!$scope.notaPedido.flete) { |
131 | focaModalService.alert('Ingrese Flete'); | 131 | focaModalService.alert('Ingrese Flete'); |
132 | return; | 132 | return; |
133 | } else if(!$scope.notaPedido.domicilio.id) { | 133 | } else if(!$scope.notaPedido.domicilio.id) { |
134 | focaModalService.aler('Ingrese Domicilio'); | 134 | focaModalService.aler('Ingrese Domicilio'); |
135 | return; | 135 | return; |
136 | } else if($scope.articulosTabla.length === 0) { | 136 | } else if($scope.articulosTabla.length === 0) { |
137 | focaModalService.alert('Debe cargar al menos un articulo'); | 137 | focaModalService.alert('Debe cargar al menos un articulo'); |
138 | return; | 138 | return; |
139 | } | 139 | } |
140 | var date = new Date(); | 140 | var date = new Date(); |
141 | var notaPedido = { | 141 | var notaPedido = { |
142 | id: 0, | 142 | id: 0, |
143 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 143 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
144 | .toISOString().slice(0, 19).replace('T', ' '), | 144 | .toISOString().slice(0, 19).replace('T', ' '), |
145 | idVendedor: $scope.notaPedido.vendedor.codigo, | 145 | idVendedor: $scope.notaPedido.vendedor.codigo, |
146 | idCliente: $scope.notaPedido.cliente.id, | 146 | idCliente: $scope.notaPedido.cliente.id, |
147 | idProveedor: $scope.notaPedido.proveedor.codigo, | 147 | idProveedor: $scope.notaPedido.proveedor.codigo, |
148 | idDomicilio: $scope.notaPedido.domicilio.id, | 148 | idDomicilio: $scope.notaPedido.domicilio.id, |
149 | idCotizacion: $scope.notaPedido.cotizacion.ID, | 149 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
150 | flete: $scope.notaPedido.flete, | 150 | flete: $scope.notaPedido.flete, |
151 | fob: $scope.notaPedido.fob, | 151 | fob: $scope.notaPedido.fob, |
152 | bomba: $scope.notaPedido.bomba, | 152 | bomba: $scope.notaPedido.bomba, |
153 | kilometros: $scope.notaPedido.kilometros, | 153 | kilometros: $scope.notaPedido.kilometros, |
154 | total: $scope.getTotal() | 154 | total: $scope.getTotal() |
155 | }; | 155 | }; |
156 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 156 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
157 | function(data) { | 157 | function(data) { |
158 | crearNotaPedidoService.addArticulos($scope.articulosTabla, | ||
159 | data.data.id, $scope.notaPedido.cotizacion.COTIZACION); | ||
158 | 160 | ||
159 | var articulosNotaPedido = $scope.articulosTabla; | ||
160 | for(var i = 0; i < articulosNotaPedido.length; i++) { | ||
161 | delete articulosNotaPedido[i].editCantidad; | ||
162 | delete articulosNotaPedido[i].editPrecio; | ||
163 | articulosNotaPedido[i].idNotaPedido = data.data.id; | ||
164 | crearNotaPedidoService | ||
165 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); | ||
166 | } | ||
167 | var plazos = $scope.plazosPagos; | 161 | var plazos = $scope.plazosPagos; |
168 | for(var j = 0; j < plazos.length; j++) { | 162 | for(var j = 0; j < plazos.length; j++) { |
169 | var json = { | 163 | var json = { |
170 | idPedido: data.data.id, | 164 | idPedido: data.data.id, |
171 | dias: plazos[j].dias | 165 | dias: plazos[j].dias |
172 | }; | 166 | }; |
173 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); | 167 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); |
174 | } | 168 | } |
175 | focaModalService.alert('Nota pedido creada'); | 169 | focaModalService.alert('Nota pedido creada'); |
176 | $scope.cabecera = []; | 170 | $scope.cabecera = []; |
177 | addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); | 171 | addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); |
178 | addCabecera( | 172 | addCabecera( |
179 | 'Fecha cotizacion:', | 173 | 'Fecha cotizacion:', |
180 | $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') | 174 | $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') |
181 | ); | 175 | ); |
182 | addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.cotizacion); | 176 | addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.COTIZACION); |
183 | $scope.notaPedido.vendedor = {}; | 177 | $scope.notaPedido.vendedor = {}; |
184 | $scope.notaPedido.cliente = {}; | 178 | $scope.notaPedido.cliente = {}; |
185 | $scope.notaPedido.proveedor = {}; | 179 | $scope.notaPedido.proveedor = {}; |
186 | $scope.notaPedido.domicilio = {}; | 180 | $scope.notaPedido.domicilio = {}; |
187 | $scope.notaPedido.flete = null; | 181 | $scope.notaPedido.flete = null; |
188 | $scope.notaPedido.fob = null; | 182 | $scope.notaPedido.fob = null; |
189 | $scope.notaPedido.bomba = null; | 183 | $scope.notaPedido.bomba = null; |
190 | $scope.notaPedido.kilometros = null; | 184 | $scope.notaPedido.kilometros = null; |
191 | $scope.articulosTabla = []; | 185 | $scope.articulosTabla = []; |
192 | } | 186 | } |
193 | ); | 187 | ); |
194 | }; | 188 | }; |
195 | 189 | ||
196 | $scope.seleccionarArticulo = function() { | 190 | $scope.seleccionarArticulo = function() { |
197 | if ($scope.idLista === undefined) { | 191 | if ($scope.idLista === undefined) { |
198 | focaModalService.alert( | 192 | focaModalService.alert( |
199 | 'Primero seleccione una lista de precio y condicion'); | 193 | 'Primero seleccione una lista de precio y condicion'); |
200 | return; | 194 | return; |
201 | } | 195 | } |
202 | var modalInstance = $uibModal.open( | 196 | var modalInstance = $uibModal.open( |
203 | { | 197 | { |
204 | ariaLabelledBy: 'Busqueda de Productos', | 198 | ariaLabelledBy: 'Busqueda de Productos', |
205 | templateUrl: 'modal-busqueda-productos.html', | 199 | templateUrl: 'modal-busqueda-productos.html', |
206 | controller: 'modalBusquedaProductosCtrl', | 200 | controller: 'modalBusquedaProductosCtrl', |
207 | resolve: { | 201 | resolve: { |
208 | idLista: function() { return $scope.idLista; }, | 202 | parametroProducto: { |
209 | cotizacion: $scope.notaPedido.cotizacion.COTIZACION | 203 | idLista: $scope.idLista, |
204 | cotizacion: $scope.notaPedido.cotizacion.COTIZACION, | ||
205 | simbolo: $scope.notaPedido.moneda.simbolo | ||
206 | } | ||
210 | }, | 207 | }, |
211 | size: 'lg' | 208 | size: 'lg' |
212 | } | 209 | } |
213 | ); | 210 | ); |
214 | modalInstance.result.then( | 211 | modalInstance.result.then( |
215 | function(producto) { | 212 | function(producto) { |
216 | var newArt = | 213 | var newArt = |
217 | { | 214 | { |
218 | id: 0, | 215 | id: 0, |
219 | codigo: producto.codigo, | 216 | codigo: producto.codigo, |
220 | sector: producto.sector, | 217 | sector: producto.sector, |
221 | sectorCodigo: producto.sector + '-' + producto.codigo, | 218 | sectorCodigo: producto.sector + '-' + producto.codigo, |
222 | descripcion: producto.descripcion, | 219 | descripcion: producto.descripcion, |
223 | item: $scope.articulosTabla.length + 1, | 220 | item: $scope.articulosTabla.length + 1, |
224 | nombre: producto.descripcion, | 221 | nombre: producto.descripcion, |
225 | precio: parseFloat(producto.precio.toFixed(2)), | 222 | precio: parseFloat(producto.precio.toFixed(4)), |
226 | costoUnitario: producto.costo, | 223 | costoUnitario: producto.costo, |
227 | editCantidad: false, | 224 | editCantidad: false, |
228 | editPrecio: false | 225 | editPrecio: false |
229 | }; | 226 | }; |
230 | $scope.articuloACargar = newArt; | 227 | $scope.articuloACargar = newArt; |
231 | $scope.cargando = false; | 228 | $scope.cargando = false; |
232 | }, function() { | 229 | }, function() { |
233 | // funcion ejecutada cuando se cancela el modal | 230 | // funcion ejecutada cuando se cancela el modal |
234 | } | 231 | } |
235 | ); | 232 | ); |
236 | }; | 233 | }; |
237 | 234 | ||
238 | $scope.seleccionarVendedor = function() { | 235 | $scope.seleccionarVendedor = function() { |
239 | var modalInstance = $uibModal.open( | 236 | var modalInstance = $uibModal.open( |
240 | { | 237 | { |
241 | ariaLabelledBy: 'Busqueda de Vendedores', | 238 | ariaLabelledBy: 'Busqueda de Vendedores', |
242 | templateUrl: 'modal-vendedores.html', | 239 | templateUrl: 'modal-vendedores.html', |
243 | controller: 'modalVendedoresCtrl', | 240 | controller: 'modalVendedoresCtrl', |
244 | size: 'lg' | 241 | size: 'lg' |
245 | } | 242 | } |
246 | ); | 243 | ); |
247 | modalInstance.result.then( | 244 | modalInstance.result.then( |
248 | function(vendedor) { | 245 | function(vendedor) { |
249 | addCabecera('Vendedor:', vendedor.NomVen); | 246 | addCabecera('Vendedor:', vendedor.NomVen); |
250 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; | 247 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; |
251 | }, function() { | 248 | }, function() { |
252 | 249 | ||
253 | } | 250 | } |
254 | ); | 251 | ); |
255 | }; | 252 | }; |
256 | 253 | ||
257 | $scope.seleccionarProveedor = function() { | 254 | $scope.seleccionarProveedor = function() { |
258 | var modalInstance = $uibModal.open( | 255 | var modalInstance = $uibModal.open( |
259 | { | 256 | { |
260 | ariaLabelledBy: 'Busqueda de Proveedor', | 257 | ariaLabelledBy: 'Busqueda de Proveedor', |
261 | templateUrl: 'modal-proveedor.html', | 258 | templateUrl: 'modal-proveedor.html', |
262 | controller: 'focaModalProveedorCtrl', | 259 | controller: 'focaModalProveedorCtrl', |
263 | size: 'lg' | 260 | size: 'lg' |
264 | } | 261 | } |
265 | ); | 262 | ); |
266 | modalInstance.result.then( | 263 | modalInstance.result.then( |
267 | function(proveedor) { | 264 | function(proveedor) { |
268 | $scope.notaPedido.proveedor.codigo = proveedor.COD; | 265 | $scope.notaPedido.proveedor.codigo = proveedor.COD; |
269 | addCabecera('Proveedor:', proveedor.NOM); | 266 | addCabecera('Proveedor:', proveedor.NOM); |
270 | }, function() { | 267 | }, function() { |
271 | 268 | ||
272 | } | 269 | } |
273 | ); | 270 | ); |
274 | }; | 271 | }; |
275 | 272 | ||
276 | $scope.seleccionarCliente = function() { | 273 | $scope.seleccionarCliente = function() { |
277 | 274 | ||
278 | var modalInstance = $uibModal.open( | 275 | var modalInstance = $uibModal.open( |
279 | { | 276 | { |
280 | ariaLabelledBy: 'Busqueda de Cliente', | 277 | ariaLabelledBy: 'Busqueda de Cliente', |
281 | templateUrl: 'foca-busqueda-cliente-modal.html', | 278 | templateUrl: 'foca-busqueda-cliente-modal.html', |
282 | controller: 'focaBusquedaClienteModalController', | 279 | controller: 'focaBusquedaClienteModalController', |
283 | size: 'lg' | 280 | size: 'lg' |
284 | } | 281 | } |
285 | ); | 282 | ); |
286 | modalInstance.result.then( | 283 | modalInstance.result.then( |
287 | function(cliente) { | 284 | function(cliente) { |
288 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( | 285 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( |
289 | function(data) { | 286 | function(data) { |
290 | if(data.data.length === 0){ | 287 | if(data.data.length === 0){ |
291 | focaModalService | 288 | focaModalService |
292 | .alert('El cliente no tienen domicilios de entrega') | 289 | .alert('El cliente no tienen domicilios de entrega') |
293 | .then( | 290 | .then( |
294 | function() { | 291 | function() { |
295 | $scope.seleccionarCliente(); | 292 | $scope.seleccionarCliente(); |
296 | } | 293 | } |
297 | ); | 294 | ); |
298 | return; | 295 | return; |
299 | } | 296 | } |
300 | $scope.abrirModalDomicilios(cliente); | 297 | $scope.abrirModalDomicilios(cliente); |
301 | } | 298 | } |
302 | ); | 299 | ); |
303 | }, function() { | 300 | }, function() { |
304 | 301 | ||
305 | } | 302 | } |
306 | ); | 303 | ); |
307 | }; | 304 | }; |
308 | 305 | ||
309 | $scope.abrirModalDomicilios = function(cliente) { | 306 | $scope.abrirModalDomicilios = function(cliente) { |
310 | var modalInstanceDomicilio = $uibModal.open( | 307 | var modalInstanceDomicilio = $uibModal.open( |
311 | { | 308 | { |
312 | ariaLabelledBy: 'Busqueda de Domicilios', | 309 | ariaLabelledBy: 'Busqueda de Domicilios', |
313 | templateUrl: 'modal-domicilio.html', | 310 | templateUrl: 'modal-domicilio.html', |
314 | controller: 'focaModalDomicilioController', | 311 | controller: 'focaModalDomicilioController', |
315 | resolve: { idCliente: function() { return cliente.cod; }}, | 312 | resolve: { idCliente: function() { return cliente.cod; }}, |
316 | size: 'lg', | 313 | size: 'lg', |
317 | } | 314 | } |
318 | ); | 315 | ); |
319 | modalInstanceDomicilio.result.then( | 316 | modalInstanceDomicilio.result.then( |
320 | function(domicilio) { | 317 | function(domicilio) { |
321 | $scope.notaPedido.domicilio.id = domicilio.id; | 318 | $scope.notaPedido.domicilio.id = domicilio.id; |
322 | $scope.notaPedido.cliente.id = cliente.cod; | 319 | $scope.notaPedido.cliente.id = cliente.cod; |
323 | addCabecera('Cliente:', cliente.nom); | 320 | addCabecera('Cliente:', cliente.nom); |
324 | addCabecera('Domicilio:', domicilio.dom); | 321 | addCabecera('Domicilio:', domicilio.dom); |
325 | }, function() { | 322 | }, function() { |
326 | $scope.seleccionarCliente(); | 323 | $scope.seleccionarCliente(); |
327 | return; | 324 | return; |
328 | } | 325 | } |
329 | ); | 326 | ); |
330 | }; | 327 | }; |
331 | 328 | ||
332 | $scope.mostrarFichaCliente = function() { | 329 | $scope.mostrarFichaCliente = function() { |
333 | $uibModal.open( | 330 | $uibModal.open( |
334 | { | 331 | { |
335 | ariaLabelledBy: 'Datos del Cliente', | 332 | ariaLabelledBy: 'Datos del Cliente', |
336 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 333 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
337 | controller: 'focaCrearNotaPedidoFichaClienteController', | 334 | controller: 'focaCrearNotaPedidoFichaClienteController', |
338 | size: 'lg' | 335 | size: 'lg' |
339 | } | 336 | } |
340 | ); | 337 | ); |
341 | }; | 338 | }; |
342 | 339 | ||
343 | $scope.getTotal = function() { | 340 | $scope.getTotal = function() { |
344 | var total = 0; | 341 | var total = 0; |
345 | var arrayTempArticulos = $scope.articulosTabla; | 342 | var arrayTempArticulos = $scope.articulosTabla; |
346 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 343 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
347 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 344 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
348 | } | 345 | } |
349 | return parseFloat(total.toFixed(2)); | 346 | return parseFloat(total.toFixed(2)); |
350 | }; | 347 | }; |
351 | 348 | ||
352 | $scope.getSubTotal = function() { | 349 | $scope.getSubTotal = function() { |
353 | if($scope.articuloACargar) { | 350 | if($scope.articuloACargar) { |
354 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 351 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
355 | } | 352 | } |
356 | }; | 353 | }; |
357 | 354 | ||
358 | $scope.abrirModalListaPrecio = function() { | 355 | $scope.abrirModalListaPrecio = function() { |
359 | var modalInstance = $uibModal.open( | 356 | var modalInstance = $uibModal.open( |
360 | { | 357 | { |
361 | ariaLabelledBy: 'Busqueda de Precio Condición', | 358 | ariaLabelledBy: 'Busqueda de Precio Condición', |
362 | templateUrl: 'modal-precio-condicion.html', | 359 | templateUrl: 'modal-precio-condicion.html', |
363 | controller: 'focaModalPrecioCondicionController', | 360 | controller: 'focaModalPrecioCondicionController', |
364 | size: 'lg' | 361 | size: 'lg' |
365 | } | 362 | } |
366 | ); | 363 | ); |
367 | modalInstance.result.then( | 364 | modalInstance.result.then( |
368 | function(precioCondicion) { | 365 | function(precioCondicion) { |
369 | var cabecera = ''; | 366 | var cabecera = ''; |
370 | var plazosConcat = ''; | 367 | var plazosConcat = ''; |
371 | if(!Array.isArray(precioCondicion)) { | 368 | if(!Array.isArray(precioCondicion)) { |
372 | $scope.plazosPagos = precioCondicion.plazoPago; | 369 | $scope.plazosPagos = precioCondicion.plazoPago; |
373 | $scope.idLista = precioCondicion.idListaPrecio; | 370 | $scope.idLista = precioCondicion.idListaPrecio; |
374 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 371 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
375 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 372 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
376 | } | 373 | } |
377 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 374 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
378 | } else { //Cuando se ingresan los plazos manualmente | 375 | } else { //Cuando se ingresan los plazos manualmente |
379 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 376 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
380 | $scope.plazosPagos = precioCondicion; | 377 | $scope.plazosPagos = precioCondicion; |
381 | for(var j = 0; j < precioCondicion.length; j++) { | 378 | for(var j = 0; j < precioCondicion.length; j++) { |
382 | plazosConcat += precioCondicion[j].dias + ' '; | 379 | plazosConcat += precioCondicion[j].dias + ' '; |
383 | } | 380 | } |
384 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 381 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
385 | } | 382 | } |
386 | $scope.articulosTabla = []; | 383 | $scope.articulosTabla = []; |
387 | addCabecera('Precios y condiciones:', cabecera); | 384 | addCabecera('Precios y condiciones:', cabecera); |
388 | }, function() { | 385 | }, function() { |
389 | 386 | ||
390 | } | 387 | } |
391 | ); | 388 | ); |
392 | }; | 389 | }; |
393 | 390 | ||
394 | $scope.abrirModalFlete = function() { | 391 | $scope.abrirModalFlete = function() { |
395 | var modalInstance = $uibModal.open( | 392 | var modalInstance = $uibModal.open( |
396 | { | 393 | { |
397 | ariaLabelledBy: 'Busqueda de Flete', | 394 | ariaLabelledBy: 'Busqueda de Flete', |
398 | templateUrl: 'modal-flete.html', | 395 | templateUrl: 'modal-flete.html', |
399 | controller: 'focaModalFleteController', | 396 | controller: 'focaModalFleteController', |
400 | size: 'lg', | 397 | size: 'lg', |
401 | resolve: { | 398 | resolve: { |
402 | parametrosFlete: | 399 | parametrosFlete: |
403 | function() { | 400 | function() { |
404 | return { | 401 | return { |
405 | flete: $scope.notaPedido.flete ? '1' : | 402 | flete: $scope.notaPedido.flete ? '1' : |
406 | ($scope.notaPedido.fob ? 'FOB' : | 403 | ($scope.notaPedido.fob ? 'FOB' : |
407 | ($scope.notaPedido.flete === undefined ? null : '0')), | 404 | ($scope.notaPedido.flete === undefined ? null : '0')), |
408 | bomba: $scope.notaPedido.bomba ? '1' : | 405 | bomba: $scope.notaPedido.bomba ? '1' : |
409 | ($scope.notaPedido.bomba === undefined ? null : '0'), | 406 | ($scope.notaPedido.bomba === undefined ? null : '0'), |
410 | kilometros: $scope.notaPedido.kilometros | 407 | kilometros: $scope.notaPedido.kilometros |
411 | }; | 408 | }; |
412 | } | 409 | } |
413 | } | 410 | } |
414 | } | 411 | } |
415 | ); | 412 | ); |
416 | modalInstance.result.then( | 413 | modalInstance.result.then( |
417 | function(datos) { | 414 | function(datos) { |
418 | $scope.notaPedido.flete = datos.flete; | 415 | $scope.notaPedido.flete = datos.flete; |
419 | $scope.notaPedido.fob = datos.FOB; | 416 | $scope.notaPedido.fob = datos.FOB; |
420 | $scope.notaPedido.bomba = datos.bomba; | 417 | $scope.notaPedido.bomba = datos.bomba; |
421 | $scope.notaPedido.kilometros = datos.kilometros; | 418 | $scope.notaPedido.kilometros = datos.kilometros; |
422 | 419 | ||
423 | addCabecera('Flete:', datos.flete ? 'Si' : | 420 | addCabecera('Flete:', datos.flete ? 'Si' : |
424 | ($scope.notaPedido.fob ? 'FOB' : 'No')); | 421 | ($scope.notaPedido.fob ? 'FOB' : 'No')); |
425 | if(datos.flete) { | 422 | if(datos.flete) { |
426 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | 423 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); |
427 | addCabecera('Kilometros:', datos.kilometros ? 'Si' : 'No'); | 424 | addCabecera('Kilometros:', datos.kilometros); |
428 | } else { | 425 | } else { |
429 | removeCabecera('Bomba:'); | 426 | removeCabecera('Bomba:'); |
430 | removeCabecera('Kilometros:'); | 427 | removeCabecera('Kilometros:'); |
431 | $scope.notaPedido.fob = false; | 428 | $scope.notaPedido.fob = false; |
432 | $scope.notaPedido.bomba = false; | 429 | $scope.notaPedido.bomba = false; |
433 | $scope.notaPedido.kilometros = null; | 430 | $scope.notaPedido.kilometros = null; |
434 | } | 431 | } |
435 | }, function() { | 432 | }, function() { |
436 | 433 | ||
437 | } | 434 | } |
438 | ); | 435 | ); |
439 | }; | 436 | }; |
440 | 437 | ||
441 | $scope.abrirModalMoneda = function() { | 438 | $scope.abrirModalMoneda = function() { |
442 | var modalInstance = $uibModal.open( | 439 | var modalInstance = $uibModal.open( |
443 | { | 440 | { |
444 | ariaLabelledBy: 'Busqueda de Moneda', | 441 | ariaLabelledBy: 'Busqueda de Moneda', |
445 | templateUrl: 'modal-moneda.html', | 442 | templateUrl: 'modal-moneda.html', |
446 | controller: 'focaModalMonedaController', | 443 | controller: 'focaModalMonedaController', |
447 | size: 'lg' | 444 | size: 'lg' |
448 | } | 445 | } |
449 | ); | 446 | ); |
450 | modalInstance.result.then( | 447 | modalInstance.result.then( |
451 | function(moneda) { | 448 | function(moneda) { |
452 | $scope.abrirModalCotizacion(moneda); | 449 | $scope.abrirModalCotizacion(moneda); |
453 | }, function() { | 450 | }, function() { |
454 | 451 | ||
455 | } | 452 | } |
456 | ); | 453 | ); |
457 | }; | 454 | }; |
458 | 455 | ||
459 | $scope.abrirModalCotizacion = function(moneda) { | 456 | $scope.abrirModalCotizacion = function(moneda) { |
460 | var modalInstance = $uibModal.open( | 457 | var modalInstance = $uibModal.open( |
461 | { | 458 | { |
462 | ariaLabelledBy: 'Busqueda de Cotización', | 459 | ariaLabelledBy: 'Busqueda de Cotización', |
463 | templateUrl: 'modal-cotizacion.html', | 460 | templateUrl: 'modal-cotizacion.html', |
464 | controller: 'focaModalCotizacionController', | 461 | controller: 'focaModalCotizacionController', |
465 | size: 'lg', | 462 | size: 'lg', |
466 | resolve: {idMoneda: function() {return moneda.ID;}} | 463 | resolve: {idMoneda: function() {return moneda.ID;}} |
467 | } | 464 | } |
468 | ); | 465 | ); |
469 | modalInstance.result.then( | 466 | modalInstance.result.then( |
470 | function(cotizacion) { | 467 | function(cotizacion) { |
471 | var articulosTablaTemp = $scope.articulosTabla; | 468 | var articulosTablaTemp = $scope.articulosTabla; |
472 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 469 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
473 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 470 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
474 | $scope.notaPedido.cotizacion.COTIZACION; | 471 | $scope.notaPedido.cotizacion.COTIZACION; |
475 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 472 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
476 | cotizacion.COTIZACION; | 473 | cotizacion.COTIZACION; |
477 | } | 474 | } |
478 | $scope.articulosTabla = articulosTablaTemp; | 475 | $scope.articulosTabla = articulosTablaTemp; |
479 | $scope.notaPedido.moneda = { | 476 | $scope.notaPedido.moneda = { |
480 | id: moneda.ID, | 477 | id: moneda.ID, |
481 | detalle: moneda.DETALLE, | 478 | detalle: moneda.DETALLE, |
482 | simbolo: moneda.SIMBOLO | 479 | simbolo: moneda.SIMBOLO |
483 | }; | 480 | }; |
484 | $scope.notaPedido.cotizacion = { | 481 | $scope.notaPedido.cotizacion = { |
485 | ID: cotizacion.ID, | 482 | ID: cotizacion.ID, |
486 | COTIZACION: cotizacion.COTIZACION, | 483 | COTIZACION: cotizacion.COTIZACION, |
487 | FECHA: cotizacion.fecha | 484 | FECHA: cotizacion.FECHA |
488 | }; | 485 | }; |
489 | addCabecera('Moneda:', moneda.DETALLE); | 486 | addCabecera('Moneda:', moneda.DETALLE); |
490 | addCabecera( | 487 | addCabecera( |
491 | 'Fecha cotizacion:', | 488 | 'Fecha cotizacion:', |
492 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 489 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
493 | ); | 490 | ); |
494 | addCabecera('Cotizacion:', cotizacion.COTIZACION); | 491 | addCabecera('Cotizacion:', cotizacion.COTIZACION); |
495 | }, function() { | 492 | }, function() { |
496 | 493 | ||
497 | } | 494 | } |
498 | ); | 495 | ); |
499 | }; | 496 | }; |
500 | 497 | ||
501 | $scope.agregarATabla = function(key) { | 498 | $scope.agregarATabla = function(key) { |
502 | if(key === 13) { | 499 | if(key === 13) { |
503 | if($scope.articuloACargar.cantidad === undefined || | 500 | if($scope.articuloACargar.cantidad === undefined || |
504 | $scope.articuloACargar.cantidad === 0 || | 501 | $scope.articuloACargar.cantidad === 0 || |
505 | $scope.articuloACargar.cantidad === null ){ | 502 | $scope.articuloACargar.cantidad === null ){ |
506 | focaModalService.alert('El valor debe ser al menos 1'); | 503 | focaModalService.alert('El valor debe ser al menos 1'); |
507 | return; | 504 | return; |
508 | } | 505 | } |
509 | delete $scope.articuloACargar.sectorCodigo; | 506 | delete $scope.articuloACargar.sectorCodigo; |
510 | $scope.articulosTabla.push($scope.articuloACargar); | 507 | $scope.articulosTabla.push($scope.articuloACargar); |
511 | $scope.cargando = true; | 508 | $scope.cargando = true; |
512 | } | 509 | } |
513 | }; | 510 | }; |
514 | 511 | ||
515 | $scope.quitarArticulo = function(key) { | 512 | $scope.quitarArticulo = function(key) { |
516 | $scope.articulosTabla.splice(key, 1); | 513 | $scope.articulosTabla.splice(key, 1); |
517 | }; | 514 | }; |
518 | 515 | ||
519 | $scope.editarArticulo = function(key, articulo) { | 516 | $scope.editarArticulo = function(key, articulo) { |
520 | if(key === 13) { | 517 | if(key === 13) { |
521 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 518 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
522 | articulo.cantidad === undefined){ | 519 | articulo.cantidad === undefined){ |
523 | focaModalService.alert('El valor debe ser al menos 1'); | 520 | focaModalService.alert('El valor debe ser al menos 1'); |
524 | return; | 521 | return; |
525 | } | 522 | } |
526 | articulo.editCantidad = false; | 523 | articulo.editCantidad = false; |
527 | articulo.editPrecio = false; | 524 | articulo.editPrecio = false; |
528 | } | 525 | } |
529 | }; | 526 | }; |
530 | 527 | ||
531 | $scope.cambioEdit = function(articulo, propiedad) { | 528 | $scope.cambioEdit = function(articulo, propiedad) { |
532 | if(propiedad === 'cantidad') { | 529 | if(propiedad === 'cantidad') { |
533 | articulo.editCantidad = true; | 530 | articulo.editCantidad = true; |
534 | } else if(propiedad === 'precio') { | 531 | } else if(propiedad === 'precio') { |
535 | articulo.editPrecio = true; | 532 | articulo.editPrecio = true; |
536 | } | 533 | } |
537 | }; | 534 | }; |
538 | 535 | ||
539 | $scope.limpiarFlete = function() { | 536 | $scope.limpiarFlete = function() { |
540 | $scope.notaPedido.fleteNombre = ''; | 537 | $scope.notaPedido.fleteNombre = ''; |
541 | $scope.notaPedido.chofer = ''; | 538 | $scope.notaPedido.chofer = ''; |
542 | $scope.notaPedido.vehiculo = ''; | 539 | $scope.notaPedido.vehiculo = ''; |
543 | $scope.notaPedido.kilometros = ''; | 540 | $scope.notaPedido.kilometros = ''; |
544 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 541 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
545 | $scope.choferes = ''; | 542 | $scope.choferes = ''; |
546 | $scope.vehiculos = ''; | 543 | $scope.vehiculos = ''; |
547 | }; | 544 | }; |
548 | 545 | ||
549 | $scope.limpiarPantalla = function() { | 546 | $scope.limpiarPantalla = function() { |
550 | $scope.limpiarFlete(); | 547 | $scope.limpiarFlete(); |
551 | $scope.notaPedido.flete = '0'; | 548 | $scope.notaPedido.flete = '0'; |
552 | $scope.notaPedido.bomba = '0'; | 549 | $scope.notaPedido.bomba = '0'; |
553 | $scope.notaPedido.precioCondicion = ''; | 550 | $scope.notaPedido.precioCondicion = ''; |
554 | $scope.articulosTabla = []; | 551 | $scope.articulosTabla = []; |
555 | $scope.notaPedido.vendedor.nombre = ''; | 552 | $scope.notaPedido.vendedor.nombre = ''; |
556 | $scope.notaPedido.cliente = {nombre: ''}; | 553 | $scope.notaPedido.cliente = {nombre: ''}; |
557 | $scope.notaPedido.domicilio = {dom: ''}; | 554 | $scope.notaPedido.domicilio = {dom: ''}; |
558 | $scope.domiciliosCliente = []; | 555 | $scope.domiciliosCliente = []; |
559 | }; | 556 | }; |
560 | 557 | ||
561 | $scope.resetFilter = function() { | 558 | $scope.resetFilter = function() { |
562 | $scope.articuloACargar = {}; | 559 | $scope.articuloACargar = {}; |
563 | $scope.cargando = true; | 560 | $scope.cargando = true; |
564 | }; | 561 | }; |
565 | 562 | ||
566 | $scope.selectFocus = function($event) { | 563 | $scope.selectFocus = function($event) { |
567 | $event.target.select(); | 564 | $event.target.select(); |
568 | }; | 565 | }; |
569 | 566 | ||
570 | $scope.salir = function() { | 567 | $scope.salir = function() { |
571 | $location.path('/'); | 568 | $location.path('/'); |
572 | }; | 569 | }; |
573 | 570 | ||
574 | function addCabecera(label, valor) { | 571 | function addCabecera(label, valor) { |
575 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 572 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
576 | if(propiedad.length === 1) { | 573 | if(propiedad.length === 1) { |
577 | propiedad[0].valor = valor; | 574 | propiedad[0].valor = valor; |
578 | } else { | 575 | } else { |
579 | $scope.cabecera.push({label: label, valor: valor}); | 576 | $scope.cabecera.push({label: label, valor: valor}); |
580 | } | 577 | } |
581 | } | 578 | } |
582 | 579 | ||
583 | function removeCabecera(label) { | 580 | function removeCabecera(label) { |
584 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 581 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
585 | if(propiedad.length === 1){ | 582 | if(propiedad.length === 1){ |
586 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 583 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
587 | } | 584 | } |
588 | } | 585 | } |
589 | } | 586 | } |
590 | ] | 587 | ] |
591 | ) | 588 | ) |
592 | .controller('notaPedidoListaCtrl', [ | 589 | .controller('notaPedidoListaCtrl', [ |
593 | '$scope', | 590 | '$scope', |
594 | 'crearNotaPedidoService', | 591 | 'crearNotaPedidoService', |
595 | '$location', | 592 | '$location', |
596 | function($scope, crearNotaPedidoService, $location) { | 593 | function($scope, crearNotaPedidoService, $location) { |
597 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 594 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
598 | $scope.notaPedidos = datos.data; | 595 | $scope.notaPedidos = datos.data; |
599 | }); | 596 | }); |
600 | $scope.editar = function(notaPedido) { | 597 | $scope.editar = function(notaPedido) { |
601 | crearNotaPedidoService.setNotaPedido(notaPedido); | 598 | crearNotaPedidoService.setNotaPedido(notaPedido); |
602 | $location.path('/venta-nota-pedido/abm/'); | 599 | $location.path('/venta-nota-pedido/abm/'); |
603 | }; | 600 | }; |
604 | $scope.crearPedido = function() { | 601 | $scope.crearPedido = function() { |
605 | crearNotaPedidoService.clearNotaPedido(); | 602 | crearNotaPedidoService.clearNotaPedido(); |
606 | $location.path('/venta-nota-pedido/abm/'); | 603 | $location.path('/venta-nota-pedido/abm/'); |
607 | }; | 604 | }; |
608 | } | 605 | } |
609 | ]) | 606 | ]) |
610 | .controller('focaCrearNotaPedidoFichaClienteController', [ | 607 | .controller('focaCrearNotaPedidoFichaClienteController', [ |
611 | '$scope', | 608 | '$scope', |
612 | 'crearNotaPedidoService', | 609 | 'crearNotaPedidoService', |
613 | '$location', | 610 | '$location', |
614 | function($scope, crearNotaPedidoService, $location) { | 611 | function($scope, crearNotaPedidoService, $location) { |
615 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 612 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
616 | $scope.notaPedidos = datos.data; | 613 | $scope.notaPedidos = datos.data; |
617 | }); | 614 | }); |
618 | $scope.editar = function(notaPedido) { | 615 | $scope.editar = function(notaPedido) { |
619 | crearNotaPedidoService.setNotaPedido(notaPedido); | 616 | crearNotaPedidoService.setNotaPedido(notaPedido); |
620 | $location.path('/venta-nota-pedido/abm/'); | 617 | $location.path('/venta-nota-pedido/abm/'); |
621 | }; | 618 | }; |
622 | $scope.crearPedido = function() { | 619 | $scope.crearPedido = function() { |
623 | crearNotaPedidoService.clearNotaPedido(); | 620 | crearNotaPedidoService.clearNotaPedido(); |
src/js/service.js
1 | angular.module('focaCrearNotaPedido') | 1 | angular.module('focaCrearNotaPedido') |
2 | .service('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | 2 | .service('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { |
3 | var route = API_ENDPOINT.URL; | 3 | var route = API_ENDPOINT.URL; |
4 | return { | 4 | return { |
5 | crearNotaPedido: function(notaPedido) { | 5 | crearNotaPedido: function(notaPedido) { |
6 | return $http.post(route + '/nota-pedido', {notaPedido: notaPedido}); | 6 | return $http.post(route + '/nota-pedido', {notaPedido: notaPedido}); |
7 | }, | 7 | }, |
8 | obtenerNotaPedido: function() { | 8 | obtenerNotaPedido: function() { |
9 | return $http.get(route +'/nota-pedido'); | 9 | return $http.get(route +'/nota-pedido'); |
10 | }, | 10 | }, |
11 | setNotaPedido: function(notaPedido) { | 11 | setNotaPedido: function(notaPedido) { |
12 | this.notaPedido = notaPedido; | 12 | this.notaPedido = notaPedido; |
13 | }, | 13 | }, |
14 | clearNotaPedido: function() { | 14 | clearNotaPedido: function() { |
15 | this.notaPedido = undefined; | 15 | this.notaPedido = undefined; |
16 | }, | 16 | }, |
17 | getNotaPedido: function() { | 17 | getNotaPedido: function() { |
18 | return this.notaPedido; | 18 | return this.notaPedido; |
19 | }, | 19 | }, |
20 | getArticulosByIdNotaPedido: function(id) { | 20 | getArticulosByIdNotaPedido: function(id) { |
21 | return $http.get(route+'/articulos/nota-pedido/'+id); | 21 | return $http.get(route+'/articulos/nota-pedido/'+id); |
22 | }, | 22 | }, |
23 | crearArticulosParaNotaPedido: function(articuloNotaPedido) { | 23 | crearArticulosParaNotaPedido: function(articuloNotaPedido) { |
24 | return $http.post(route + '/articulos/nota-pedido', | 24 | return $http.post(route + '/articulos/nota-pedido', |
25 | {articuloNotaPedido: articuloNotaPedido}); | 25 | {articuloNotaPedido: articuloNotaPedido}); |
26 | }, | 26 | }, |
27 | getDomiciliosByIdNotaPedido: function(id) { | 27 | getDomiciliosByIdNotaPedido: function(id) { |
28 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); | 28 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); |
29 | }, | 29 | }, |
30 | getDomiciliosByIdCliente: function(id) { | 30 | getDomiciliosByIdCliente: function(id) { |
31 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) | 31 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) |
32 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); | 32 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); |
33 | }, | 33 | }, |
34 | getPrecioCondicion: function() { | 34 | getPrecioCondicion: function() { |
35 | return $http.get(route + '/precio-condicion'); | 35 | return $http.get(route + '/precio-condicion'); |
36 | }, | 36 | }, |
37 | getPrecioCondicionById: function(id) { | 37 | getPrecioCondicionById: function(id) { |
38 | return $http.get(route + '/precio-condicion/' + id); | 38 | return $http.get(route + '/precio-condicion/' + id); |
39 | }, | 39 | }, |
40 | getPlazoPagoByPrecioCondicion: function(id) { | 40 | getPlazoPagoByPrecioCondicion: function(id) { |
41 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); | 41 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); |
42 | }, | 42 | }, |
43 | crearFlete: function(flete) { | 43 | crearFlete: function(flete) { |
44 | return $http.post(route + '/flete', {flete : flete}); | 44 | return $http.post(route + '/flete', {flete : flete}); |
45 | }, | 45 | }, |
46 | crearPlazosParaNotaPedido: function(plazos) { | 46 | crearPlazosParaNotaPedido: function(plazos) { |
47 | return $http.post(route + '/plazo-pago/nota-pedido', plazos); | 47 | return $http.post(route + '/plazo-pago/nota-pedido', plazos); |
48 | }, | 48 | }, |
49 | getCotizacionByIdMoneda: function(id) { | 49 | getCotizacionByIdMoneda: function(id) { |
50 | return $http.get(route + '/moneda/' + id); | 50 | return $http.get(route + '/moneda/' + id); |
51 | }, | ||
52 | addArticulos: function(articulosNotaPedido, idNotaPedido, cotizacion) { | ||
53 | for(var i = 0; i < articulosNotaPedido.length; i++) { | ||
54 | delete articulosNotaPedido[i].editCantidad; | ||
55 | delete articulosNotaPedido[i].editPrecio; | ||
56 | articulosNotaPedido[i].idNotaPedido = idNotaPedido; | ||
57 | articulosNotaPedido[i].precio = articulosNotaPedido[i].precio * cotizacion; | ||
58 | this.crearArticulosParaNotaPedido(articulosNotaPedido[i]); | ||
59 | } | ||
51 | } | 60 | } |
52 | }; | 61 | }; |
53 | }]); | 62 | }]); |
54 | 63 |
src/views/nota-pedido.html
1 | <div class="crear-nota-pedido"> | 1 | <div class="crear-nota-pedido"> |
2 | <form name="formCrearNota" ng-submit="crearNotaPedido()" class="mb-0"> | 2 | <form name="formCrearNota" ng-submit="crearNotaPedido()" class="mb-0"> |
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-12 col-sm-4 nota-pedido"> | 8 | <div class="col-12 col-sm-4 nota-pedido"> |
9 | <h5>NOTA DE PEDIDO</h5> | 9 | <h5>NOTA DE PEDIDO</h5> |
10 | </div> | 10 | </div> |
11 | <div class="col-5 col-sm-4 numero-pedido" | 11 | <div class="col-5 col-sm-4 numero-pedido" |
12 | >Nº {{puntoVenta}}-{{comprobante}} | 12 | >Nº {{puntoVenta}}-{{comprobante}} |
13 | </div> | 13 | </div> |
14 | <div class="col-7 col-sm-4 text-right"> | 14 | <div class="col-7 col-sm-4 text-right"> |
15 | Fecha: | 15 | Fecha: |
16 | <span | 16 | <span |
17 | ng-show="!datepickerAbierto" | 17 | ng-show="!datepickerAbierto" |
18 | ng-bind="now | date:'dd/MM/yyyy HH:mm'" | 18 | ng-bind="now | date:'dd/MM/yyyy HH:mm'" |
19 | ng-click="datepickerAbierto = true" | 19 | ng-click="datepickerAbierto = true" |
20 | > | 20 | > |
21 | </span> | 21 | </span> |
22 | <input | 22 | <input |
23 | ng-show="datepickerAbierto" | 23 | ng-show="datepickerAbierto" |
24 | type="date" | 24 | type="date" |
25 | ng-model="now" | 25 | ng-model="now" |
26 | ng-change="datepickerAbierto = false" | 26 | ng-change="datepickerAbierto = false" |
27 | ng-blur="datepickerAbierto = false" | 27 | ng-blur="datepickerAbierto = false" |
28 | class="form-control form-control-sm col-8 float-right" | 28 | class="form-control form-control-sm col-8 float-right" |
29 | foca-focus="datepickerAbierto" | 29 | foca-focus="datepickerAbierto" |
30 | hasta-hoy | 30 | hasta-hoy |
31 | /> | 31 | /> |
32 | </div> | 32 | </div> |
33 | </div> | 33 | </div> |
34 | <div class="row"> | 34 | <div class="row"> |
35 | <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> | 35 | <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> |
36 | <span class="label" ng-bind="cab.label"></span> | 36 | <span class="label" ng-bind="cab.label"></span> |
37 | <span class="valor" ng-bind="cab.valor"></span> | 37 | <span class="valor" ng-bind="cab.valor"></span> |
38 | </div> | 38 | </div> |
39 | <a | 39 | <a |
40 | class="btn col-12 btn-secondary d-sm-none" | 40 | class="btn col-12 btn-secondary d-sm-none" |
41 | ng-show="cabecera.length > 0" | 41 | ng-show="cabecera.length > 0" |
42 | ng-click="showCabecera = !showCabecera" | 42 | ng-click="showCabecera = !showCabecera" |
43 | > | 43 | > |
44 | <i | 44 | <i |
45 | class="fa fa-chevron-down" | 45 | class="fa fa-chevron-down" |
46 | ng-hide="showCabecera" | 46 | ng-hide="showCabecera" |
47 | aria-hidden="true" | 47 | aria-hidden="true" |
48 | > | 48 | > |
49 | </i> | 49 | </i> |
50 | <i | 50 | <i |
51 | class="fa fa-chevron-up" | 51 | class="fa fa-chevron-up" |
52 | ng-show="showCabecera" | 52 | ng-show="showCabecera" |
53 | aria-hidden="true"> | 53 | aria-hidden="true"> |
54 | </i> | 54 | </i> |
55 | </a> | 55 | </a> |
56 | </div> | 56 | </div> |
57 | </div> | 57 | </div> |
58 | </div> | 58 | </div> |
59 | <div class="row p-1 botonera-secundaria"> | 59 | <div class="row p-1 botonera-secundaria"> |
60 | <div class="col-12"> | 60 | <div class="col-12"> |
61 | <div class="row"> | 61 | <div class="row"> |
62 | <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera"> | 62 | <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera"> |
63 | <button | 63 | <button |
64 | type="button" | 64 | type="button" |
65 | class="btn btn-default btn-block btn-xs text-left py-2" | 65 | class="btn btn-default btn-block btn-xs text-left py-2" |
66 | ng-click="boton.accion()" | 66 | ng-click="boton.accion()" |
67 | ng-class="{'d-none d-sm-block': boton.texto == ''}" | 67 | ng-class="{'d-none d-sm-block': boton.texto == ''}" |
68 | > | 68 | > |
69 | <i | 69 | <i |
70 | class="fa fa-arrow-circle-right" | 70 | class="fa fa-arrow-circle-right" |
71 | ng-show="boton.texto != ''" | 71 | ng-show="boton.texto != ''" |
72 | ></i> | 72 | ></i> |
73 | | 73 | |
74 | {{boton.texto}} | 74 | {{boton.texto}} |
75 | </button> | 75 | </button> |
76 | </div> | 76 | </div> |
77 | </div> | 77 | </div> |
78 | </div> | 78 | </div> |
79 | </div> | 79 | </div> |
80 | </div> | 80 | </div> |
81 | </div> | 81 | </div> |
82 | </form> | 82 | </form> |
83 | <div class="row"> | 83 | <div class="row"> |
84 | <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> | 84 | <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> |
85 | <!-- PC --> | 85 | <!-- PC --> |
86 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> | 86 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> |
87 | <table class="table tabla-articulo table-striped table-sm table-dark"> | 87 | <table class="table tabla-articulo table-striped table-sm table-dark"> |
88 | <thead> | 88 | <thead> |
89 | <tr class="d-flex"> | 89 | <tr class="d-flex"> |
90 | <th class="">#</th> | 90 | <th class="">#</th> |
91 | <th class="col">Código</th> | 91 | <th class="col">Código</th> |
92 | <th class="col-4">Descripción</th> | 92 | <th class="col-4">Descripción</th> |
93 | <th class="col text-right">Cantidad</th> | 93 | <th class="col text-right">Cantidad</th> |
94 | <th class="col text-right">Precio Unitario</th> | 94 | <th class="col text-right">Precio Unitario</th> |
95 | <th class="col text-right">SubTotal</th> | 95 | <th class="col text-right">SubTotal</th> |
96 | <th class="text-right"> | 96 | <th class="text-right"> |
97 | <button | 97 | <button |
98 | class="btn btn-outline-secondary selectable" | 98 | class="btn btn-outline-secondary selectable" |
99 | ng-click="show = !show; masMenos()" | 99 | ng-click="show = !show; masMenos()" |
100 | > | 100 | > |
101 | <i | 101 | <i |
102 | class="fa fa-chevron-down" | 102 | class="fa fa-chevron-down" |
103 | ng-show="show" | 103 | ng-show="show" |
104 | aria-hidden="true" | 104 | aria-hidden="true" |
105 | > | 105 | > |
106 | </i> | 106 | </i> |
107 | <i | 107 | <i |
108 | class="fa fa-chevron-up" | 108 | class="fa fa-chevron-up" |
109 | ng-hide="show" | 109 | ng-hide="show" |
110 | aria-hidden="true"> | 110 | aria-hidden="true"> |
111 | </i> | 111 | </i> |
112 | </button> | 112 | </button> |
113 | </th> | 113 | </th> |
114 | </tr> | 114 | </tr> |
115 | </thead> | 115 | </thead> |
116 | <tbody class="tabla-articulo-body"> | 116 | <tbody class="tabla-articulo-body"> |
117 | <tr | 117 | <tr |
118 | ng-repeat="(key, articulo) in articulosTabla" | 118 | ng-repeat="(key, articulo) in articulosTabla" |
119 | ng-show="show || key == (articulosTabla.length - 1)" | 119 | ng-show="show || key == (articulosTabla.length - 1)" |
120 | class="d-flex" | 120 | class="d-flex" |
121 | > | 121 | > |
122 | <td ng-bind="key + 1"></td> | 122 | <td ng-bind="key + 1"></td> |
123 | <td | 123 | <td |
124 | class="col" | 124 | class="col" |
125 | ng-bind="articulo.sector + '-' + articulo.codigo" | 125 | ng-bind="articulo.sector + '-' + articulo.codigo" |
126 | ></td> | 126 | ></td> |
127 | <td | 127 | <td |
128 | class="col-4" | 128 | class="col-4" |
129 | ng-bind="articulo.descripcion" | 129 | ng-bind="articulo.descripcion" |
130 | ></td> | 130 | ></td> |
131 | <td class="col text-right"> | 131 | <td class="col text-right"> |
132 | <input | 132 | <input |
133 | ng-show="articulo.editCantidad" | 133 | ng-show="articulo.editCantidad" |
134 | ng-model="articulo.cantidad" | 134 | ng-model="articulo.cantidad" |
135 | class="form-control" | 135 | class="form-control" |
136 | type="number" | 136 | type="number" |
137 | min="1" | 137 | min="1" |
138 | foca-focus="articulo.editCantidad" | 138 | foca-focus="articulo.editCantidad" |
139 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 139 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
140 | ng-focus="selectFocus($event)" | 140 | ng-focus="selectFocus($event)" |
141 | > | 141 | > |
142 | <i | 142 | <i |
143 | class="selectable" | 143 | class="selectable" |
144 | ng-click="cambioEdit(articulo, 'cantidad')" | 144 | ng-click="cambioEdit(articulo, 'cantidad')" |
145 | ng-hide="articulo.editCantidad" | 145 | ng-hide="articulo.editCantidad" |
146 | ng-bind="articulo.cantidad"> | 146 | ng-bind="articulo.cantidad"> |
147 | </i> | 147 | </i> |
148 | </td> | 148 | </td> |
149 | <td class="col text-right"> | 149 | <td class="col text-right"> |
150 | <input | 150 | <input |
151 | ng-show="articulo.editPrecio" | 151 | ng-show="articulo.editPrecio" |
152 | ng-model="articulo.precio" | 152 | ng-model="articulo.precio" |
153 | class="form-control" | 153 | class="form-control" |
154 | type="number" | 154 | type="number" |
155 | min="1" | 155 | min="1" |
156 | step="0.01" | 156 | step="0.0001" |
157 | foca-focus="articulo.editPrecio" | 157 | foca-focus="articulo.editPrecio" |
158 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 158 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
159 | ng-focus="selectFocus($event)" | 159 | ng-focus="selectFocus($event)" |
160 | > | 160 | > |
161 | <i | 161 | <i |
162 | class="selectable" | 162 | class="selectable" |
163 | ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" | 163 | ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" |
164 | ng-hide="articulo.editPrecio" | 164 | ng-hide="articulo.editPrecio" |
165 | ng-bind="articulo.precio | currency: '$'"> | 165 | ng-bind="articulo.precio | currency: notaPedido.moneda.simbolo : 4"> |
166 | </i> | 166 | </i> |
167 | </td> | 167 | </td> |
168 | <td | 168 | <td |
169 | class="col text-right" | 169 | class="col text-right" |
170 | ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'"> | 170 | ng-bind="(articulo.precio * articulo.cantidad) | currency: notaPedido.moneda.simbolo"> |
171 | </td> | 171 | </td> |
172 | <td class="text-center"> | 172 | <td class="text-center"> |
173 | <button | 173 | <button |
174 | class="btn btn-outline-secondary" | 174 | class="btn btn-outline-secondary" |
175 | ng-click="quitarArticulo(key)" | 175 | ng-click="quitarArticulo(key)" |
176 | > | 176 | > |
177 | <i class="fa fa-trash"></i> | 177 | <i class="fa fa-trash"></i> |
178 | </button> | 178 | </button> |
179 | </td> | 179 | </td> |
180 | </tr> | 180 | </tr> |
181 | </tbody> | 181 | </tbody> |
182 | <tfoot> | 182 | <tfoot> |
183 | <tr ng-show="!cargando" class="d-flex"> | 183 | <tr ng-show="!cargando" class="d-flex"> |
184 | <td | 184 | <td |
185 | class="align-middle" | 185 | class="align-middle" |
186 | ng-bind="articulosTabla.length + 1" | 186 | ng-bind="articulosTabla.length + 1" |
187 | ></td> | 187 | ></td> |
188 | <td class="col"> | 188 | <td class="col"> |
189 | <input | 189 | <input |
190 | class="form-control" | 190 | class="form-control" |
191 | ng-model="articuloACargar.sectorCodigo" | 191 | ng-model="articuloACargar.sectorCodigo" |
192 | readonly | 192 | readonly |
193 | > | 193 | > |
194 | </td> | 194 | </td> |
195 | <td class="col-4 tabla-articulo-descripcion"> | 195 | <td class="col-4 tabla-articulo-descripcion"> |
196 | <input | 196 | <input |
197 | class="form-control" | 197 | class="form-control" |
198 | ng-model="articuloACargar.descripcion" | 198 | ng-model="articuloACargar.descripcion" |
199 | readonly | 199 | readonly |
200 | > | 200 | > |
201 | </td> | 201 | </td> |
202 | <td class="col text-right"> | 202 | <td class="col text-right"> |
203 | <input | 203 | <input |
204 | class="form-control" | 204 | class="form-control" |
205 | type="number" | 205 | type="number" |
206 | min="1" | 206 | min="1" |
207 | ng-model="articuloACargar.cantidad" | 207 | ng-model="articuloACargar.cantidad" |
208 | foca-focus="!cargando" | 208 | foca-focus="!cargando" |
209 | esc-key="resetFilter()" | 209 | esc-key="resetFilter()" |
210 | ng-keypress="agregarATabla($event.keyCode)" | 210 | ng-keypress="agregarATabla($event.keyCode)" |
211 | > | 211 | > |
212 | </td> | 212 | </td> |
213 | <td class="col text-right"> | 213 | <td class="col text-right"> |
214 | <input | 214 | <input |
215 | class="form-control" | 215 | class="form-control" |
216 | ng-value="articuloACargar.precio | currency: '$'" | 216 | ng-value="articuloACargar.precio | currency: notaPedido.moneda.simbolo : 4" |
217 | ng-show="idLista != -1" | 217 | ng-show="idLista != -1" |
218 | readonly | 218 | readonly |
219 | > | 219 | > |
220 | <input | 220 | <input |
221 | class="form-control" | 221 | class="form-control" |
222 | type="number" | 222 | type="number" |
223 | step="0.01" | 223 | step="0.0001" |
224 | ng-model="articuloACargar.precio" | 224 | ng-model="articuloACargar.precio" |
225 | esc-key="resetFilter()" | 225 | esc-key="resetFilter()" |
226 | ng-keypress="agregarATabla($event.keyCode)" | 226 | ng-keypress="agregarATabla($event.keyCode)" |
227 | ng-show="idLista == -1" | 227 | ng-show="idLista == -1" |
228 | > | 228 | > |
229 | </td> | 229 | </td> |
230 | <td class="col text-right"> | 230 | <td class="col text-right"> |
231 | <input | 231 | <input |
232 | class="form-control" | 232 | class="form-control" |
233 | ng-value="getSubTotal() | currency: '$'" | 233 | ng-value="getSubTotal() | currency: notaPedido.moneda.simbolo" |
234 | readonly | 234 | readonly |
235 | ></td> | 235 | ></td> |
236 | <td class="text-center align-middle"> | 236 | <td class="text-center align-middle"> |
237 | <button | 237 | <button |
238 | class="btn btn-outline-secondary" | 238 | class="btn btn-outline-secondary" |
239 | ng-click="agregarATabla(13)" | 239 | ng-click="agregarATabla(13)" |
240 | > | 240 | > |
241 | <i class="fa fa-save"></i> | 241 | <i class="fa fa-save"></i> |
242 | </button> | 242 | </button> |
243 | </td> | 243 | </td> |
244 | </tr> | 244 | </tr> |
245 | <tr ng-show="cargando" class="d-flex"> | 245 | <tr ng-show="cargando" class="d-flex"> |
246 | <td colspan="7" class="col-12"> | 246 | <td colspan="7" class="col-12"> |
247 | <input | 247 | <input |
248 | placeholder="Seleccione Articulo" | 248 | placeholder="Seleccione Articulo" |
249 | class="form-control form-control-sm" | 249 | class="form-control form-control-sm" |
250 | readonly | 250 | readonly |
251 | ng-click="seleccionarArticulo()" | 251 | ng-click="seleccionarArticulo()" |
252 | /> | 252 | /> |
253 | </td> | 253 | </td> |
254 | </tr> | 254 | </tr> |
255 | <tr class="d-flex"> | 255 | <tr class="d-flex"> |
256 | <td colspan="4" class="no-border-top"> | 256 | <td colspan="4" class="no-border-top"> |
257 | <strong>Items:</strong> | 257 | <strong>Items:</strong> |
258 | <a ng-bind="articulosTabla.length"></a> | 258 | <a ng-bind="articulosTabla.length"></a> |
259 | </td> | 259 | </td> |
260 | <td class="text-right ml-auto table-celda-total no-border-top"> | 260 | <td class="text-right ml-auto table-celda-total no-border-top"> |
261 | <h3>Total:</h3> | 261 | <h3>Total:</h3> |
262 | </td> | 262 | </td> |
263 | <td class="table-celda-total text-right no-border-top" colspan="1"> | 263 | <td class="table-celda-total text-right no-border-top" colspan="1"> |
264 | <h3>{{getTotal() | currency: '$'}}</h3> | 264 | <h3>{{getTotal() | currency: notaPedido.moneda.simbolo}}</h3> |
265 | </td> | 265 | </td> |
266 | <td class="text-right no-border-top"> | 266 | <td class="text-right no-border-top"> |
267 | <button | 267 | <button |
268 | type="button" | 268 | type="button" |
269 | class="btn btn-default btn-sm" | 269 | class="btn btn-default btn-sm" |
270 | > | 270 | > |
271 | Totales | 271 | Totales |
272 | </button> | 272 | </button> |
273 | </td> | 273 | </td> |
274 | </tr> | 274 | </tr> |
275 | </tfoot> | 275 | </tfoot> |
276 | </table> | 276 | </table> |
277 | </div> | 277 | </div> |
278 | 278 | ||
279 | <!-- MOBILE --> | 279 | <!-- MOBILE --> |
280 | <div class="row d-sm-none"> | 280 | <div class="row d-sm-none"> |
281 | <table class="table table-sm table-striped table-dark margin-bottom-mobile"> | 281 | <table class="table table-sm table-striped table-dark margin-bottom-mobile"> |
282 | <thead> | 282 | <thead> |
283 | <tr class="d-flex"> | 283 | <tr class="d-flex"> |
284 | <th class="">#</th> | 284 | <th class="">#</th> |
285 | <th class="col px-0"> | 285 | <th class="col px-0"> |
286 | <div class="d-flex"> | 286 | <div class="d-flex"> |
287 | <div class="col-4 px-1">Código</div> | 287 | <div class="col-4 px-1">Código</div> |
288 | <div class="col-8 px-1">Descripción</div> | 288 | <div class="col-8 px-1">Descripción</div> |
289 | </div> | 289 | </div> |
290 | <div class="d-flex"> | 290 | <div class="d-flex"> |
291 | <div class="col-3 px-1">Cantidad</div> | 291 | <div class="col-3 px-1">Cantidad</div> |
292 | <div class="col px-1 text-right">P. Uni.</div> | 292 | <div class="col px-1 text-right">P. Uni.</div> |
293 | <div class="col px-1 text-right">Subtotal</div> | 293 | <div class="col px-1 text-right">Subtotal</div> |
294 | </div> | 294 | </div> |
295 | </th> | 295 | </th> |
296 | <th class="text-center tamaño-boton"> | 296 | <th class="text-center tamaño-boton"> |
297 | | 297 | |
298 | </th> | 298 | </th> |
299 | </tr> | 299 | </tr> |
300 | </thead> | 300 | </thead> |
301 | <tbody> | 301 | <tbody> |
302 | <tr | 302 | <tr |
303 | ng-repeat="(key, articulo) in articulosTabla" | 303 | ng-repeat="(key, articulo) in articulosTabla" |
304 | ng-show="show || key == articulosTabla.length - 1" | 304 | ng-show="show || key == articulosTabla.length - 1" |
305 | > | 305 | > |
306 | <td class="w-100 align-middle d-flex p-0"> | 306 | <td class="w-100 align-middle d-flex p-0"> |
307 | <div class="align-middle p-1"> | 307 | <div class="align-middle p-1"> |
308 | <span ng-bind="key+1" class="align-middle"></span> | 308 | <span ng-bind="key+1" class="align-middle"></span> |
309 | </div> | 309 | </div> |
310 | <div class="col px-0"> | 310 | <div class="col px-0"> |
311 | <div class="d-flex"> | 311 | <div class="d-flex"> |
312 | <div class="col-4 px-1"> | 312 | <div class="col-4 px-1"> |
313 | <span | 313 | <span |
314 | ng-bind="articulo.sector + '-' + articulo.codigo" | 314 | ng-bind="articulo.sector + '-' + articulo.codigo" |
315 | ></span> | 315 | ></span> |
316 | </div> | 316 | </div> |
317 | <div class="col-8 px-1"> | 317 | <div class="col-8 px-1"> |
318 | <span ng-bind="articulo.descripcion"></span> | 318 | <span ng-bind="articulo.descripcion"></span> |
319 | </div> | 319 | </div> |
320 | </div> | 320 | </div> |
321 | <div class="d-flex"> | 321 | <div class="d-flex"> |
322 | <div class="col-3 px-1"> | 322 | <div class="col-3 px-1"> |
323 | <span ng-bind="'x' + articulo.cantidad"></span> | 323 | <span ng-bind="'x' + articulo.cantidad"></span> |
324 | </div> | 324 | </div> |
325 | <div class="col-3 px-1 text-right"> | 325 | <div class="col-3 px-1 text-right"> |
326 | <span ng-bind="articulo.precio | currency: '$'"></span> | 326 | <span ng-bind="articulo.precio | currency: notaPedido.moneda.simbolo : 4"></span> |
327 | </div> | 327 | </div> |
328 | <div class="col px-1 text-right"> | 328 | <div class="col px-1 text-right"> |
329 | <span | 329 | <span |
330 | ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'" | 330 | ng-bind="(articulo.precio * articulo.cantidad) | currency: notaPedido.moneda.simbolo" |
331 | > | 331 | > |
332 | </span> | 332 | </span> |
333 | </div> | 333 | </div> |
334 | </div> | 334 | </div> |
335 | </div> | 335 | </div> |
336 | <div class="align-middle p-1"> | 336 | <div class="align-middle p-1"> |
337 | <button | 337 | <button |
338 | class="btn btn-outline-secondary" | 338 | class="btn btn-outline-secondary" |
339 | ng-click="quitarArticulo(key)" | 339 | ng-click="quitarArticulo(key)" |
340 | > | 340 | > |
341 | <i class="fa fa-trash"></i> | 341 | <i class="fa fa-trash"></i> |
342 | </button> | 342 | </button> |
343 | </div> | 343 | </div> |
344 | </td> | 344 | </td> |
345 | </tr> | 345 | </tr> |
346 | </tbody> | 346 | </tbody> |
347 | <tfoot> | 347 | <tfoot> |
348 | <!-- CARGANDO ITEM --> | 348 | <!-- CARGANDO ITEM --> |
349 | <tr ng-show="!cargando" class="d-flex"> | 349 | <tr ng-show="!cargando" class="d-flex"> |
350 | <td | 350 | <td |
351 | class="align-middle p-1" | 351 | class="align-middle p-1" |
352 | ng-bind="articulosTabla.length + 1" | 352 | ng-bind="articulosTabla.length + 1" |
353 | ></td> | 353 | ></td> |
354 | <td class="col p-0"> | 354 | <td class="col p-0"> |
355 | <div class="d-flex"> | 355 | <div class="d-flex"> |
356 | <div class="col-4 px-1"> | 356 | <div class="col-4 px-1"> |
357 | <span | 357 | <span |
358 | ng-bind="articuloACargar.sectorCodigo" | 358 | ng-bind="articuloACargar.sectorCodigo" |
359 | ></span> | 359 | ></span> |
360 | </div> | 360 | </div> |
361 | <div class="col-8 px-1"> | 361 | <div class="col-8 px-1"> |
362 | <span ng-bind="articuloACargar.descripcion"></span> | 362 | <span ng-bind="articuloACargar.descripcion"></span> |
363 | </div> | 363 | </div> |
364 | </div> | 364 | </div> |
365 | <div class="d-flex"> | 365 | <div class="d-flex"> |
366 | <div class="col-3 px-1 m-1"> | 366 | <div class="col-3 px-1 m-1"> |
367 | <input | 367 | <input |
368 | class="form-control p-1" | 368 | class="form-control p-1" |
369 | type="number" | 369 | type="number" |
370 | min="1" | 370 | min="1" |
371 | ng-model="articuloACargar.cantidad" | 371 | ng-model="articuloACargar.cantidad" |
372 | foca-focus="!cargando" | 372 | foca-focus="!cargando" |
373 | ng-keypress="agregarATabla($event.keyCode)" | 373 | ng-keypress="agregarATabla($event.keyCode)" |
374 | style="height: auto; line-height: 1.1em" | 374 | style="height: auto; line-height: 1.1em" |
375 | > | 375 | > |
376 | </div> | 376 | </div> |
377 | <div class="col-3 px-1 text-right"> | 377 | <div class="col-3 px-1 text-right"> |
378 | <span ng-bind="articuloACargar.precio | currency: '$'"></span> | 378 | <span ng-bind="articuloACargar.precio | currency: notaPedido.moneda.simbolo : 4"></span> |
379 | </div> | 379 | </div> |
380 | <div class="col px-1 text-right"> | 380 | <div class="col px-1 text-right"> |
381 | <span | 381 | <span |
382 | ng-bind="getSubTotal() | currency: '$'" | 382 | ng-bind="getSubTotal() | currency: notaPedido.moneda.simbolo" |
383 | > | 383 | > |
384 | </span> | 384 | </span> |
385 | </div> | 385 | </div> |
386 | </div> | 386 | </div> |
387 | </td> | 387 | </td> |
388 | <td class="text-center align-middle"> | 388 | <td class="text-center align-middle"> |
389 | <button | 389 | <button |
390 | class="btn btn-outline-secondary" | 390 | class="btn btn-outline-secondary" |
391 | ng-click="agregarATabla(13)" | 391 | ng-click="agregarATabla(13)" |
392 | > | 392 | > |
393 | <i class="fa fa-save"></i> | 393 | <i class="fa fa-save"></i> |
394 | </button> | 394 | </button> |
395 | </td> | 395 | </td> |
396 | </tr> | 396 | </tr> |
397 | <!-- SELECCIONAR PRODUCTO --> | 397 | <!-- SELECCIONAR PRODUCTO --> |
398 | <tr ng-show="cargando" class="d-flex"> | 398 | <tr ng-show="cargando" class="d-flex"> |
399 | <td class="col-12"> | 399 | <td class="col-12"> |
400 | <input | 400 | <input |
401 | placeholder="Seleccione Articulo" | 401 | placeholder="Seleccione Articulo" |
402 | class="form-control form-control-sm" | 402 | class="form-control form-control-sm" |
403 | readonly | 403 | readonly |
404 | ng-click="seleccionarArticulo()" | 404 | ng-click="seleccionarArticulo()" |
405 | /> | 405 | /> |
406 | </td> | 406 | </td> |
407 | </tr> | 407 | </tr> |
408 | <!-- TOOGLE EXPANDIR --> | 408 | <!-- TOOGLE EXPANDIR --> |
409 | <tr> | 409 | <tr> |
410 | <td class="col"> | 410 | <td class="col"> |
411 | <button | 411 | <button |
412 | class="btn btn-outline-secondary selectable w-100" | 412 | class="btn btn-outline-secondary selectable w-100" |
413 | ng-click="show = !show; masMenos()" | 413 | ng-click="show = !show; masMenos()" |
414 | ng-show="articulosTabla.length > 0" | 414 | ng-show="articulosTabla.length > 0" |
415 | > | 415 | > |
416 | <i | 416 | <i |
417 | class="fa fa-chevron-down" | 417 | class="fa fa-chevron-down" |
418 | ng-hide="show" | 418 | ng-hide="show" |
419 | aria-hidden="true" | 419 | aria-hidden="true" |
420 | > | 420 | > |
421 | </i> | 421 | </i> |
422 | <i | 422 | <i |
423 | class="fa fa-chevron-up" | 423 | class="fa fa-chevron-up" |
424 | ng-show="show" | 424 | ng-show="show" |
425 | aria-hidden="true"> | 425 | aria-hidden="true"> |
426 | </i> | 426 | </i> |
427 | </button> | 427 | </button> |
428 | </td> | 428 | </td> |
429 | </tr> | 429 | </tr> |
430 | <!-- FOOTER --> | 430 | <!-- FOOTER --> |
431 | <tr class="d-flex"> | 431 | <tr class="d-flex"> |
432 | <td class="align-middle no-border-top" colspan="2"> | 432 | <td class="align-middle no-border-top" colspan="2"> |
433 | <strong>Cantidad Items:</strong> | 433 | <strong>Cantidad Items:</strong> |
434 | <a ng-bind="articulosTabla.length"></a> | 434 | <a ng-bind="articulosTabla.length"></a> |
435 | </td> | 435 | </td> |
436 | <td class="text-right ml-auto table-celda-total no-border-top"> | 436 | <td class="text-right ml-auto table-celda-total no-border-top"> |
437 | <h3>Total:</h3> | 437 | <h3>Total:</h3> |
438 | </td> | 438 | </td> |
439 | <td class="table-celda-total text-right no-border-top"> | 439 | <td class="table-celda-total text-right no-border-top"> |
440 | <h3>{{getTotal() | currency: '$'}}</h3> | 440 | <h3>{{getTotal() | currency: notaPedido.moneda.simbolo}}</h3> |
441 | </td> | 441 | </td> |
442 | </tr> | 442 | </tr> |
443 | </tfoot> | 443 | </tfoot> |
444 | </table> | 444 | </table> |
445 | </div> | 445 | </div> |
446 | </div> | 446 | </div> |
447 | <div class="col-auto my-2 col-lg-2 botonera-lateral d-none d-md-block"> | 447 | <div class="col-auto my-2 col-lg-2 botonera-lateral d-none d-md-block"> |
448 | <div class="row align-items-end"> | 448 | <div class="row align-items-end"> |
449 | <div class="col-12"> | 449 | <div class="col-12"> |
450 | <button | 450 | <button |
451 | ng-click="crearNotaPedido()" | 451 | ng-click="crearNotaPedido()" |
452 | type="submit" | 452 | type="submit" |
453 | title="Crear nota pedido" | 453 | title="Crear nota pedido" |
454 | class="btn btn-default btn-block mb-2"> | 454 | class="btn btn-default btn-block mb-2"> |
455 | Guardar | 455 | Guardar |
456 | </button> | 456 | </button> |
457 | <button | 457 | <button |
458 | ng-click="salir()" | 458 | ng-click="salir()" |
459 | type="button" | 459 | type="button" |
460 | title="Salir" | 460 | title="Salir" |
461 | class="btn btn-default btn-block"> | 461 | class="btn btn-default btn-block"> |
462 | Salir | 462 | Salir |
463 | </button> | 463 | </button> |
464 | </div> | 464 | </div> |
465 | </div> | 465 | </div> |
466 | </div> | 466 | </div> |
467 | </div> | 467 | </div> |
468 | <div class="row d-md-none fixed-bottom"> | 468 | <div class="row d-md-none fixed-bottom"> |
469 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> | 469 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> |
470 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> | 470 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> |
471 | <span class="mr-3 ml-auto" ng-click="crearNotaPedido()">Guardar</span> | 471 | <span class="mr-3 ml-auto" ng-click="crearNotaPedido()">Guardar</span> |
472 | </div> | 472 | </div> |
473 | </div> | 473 | </div> |
474 | </div> | 474 | </div> |
475 | 475 |