Commit 56c85044dcef44fd6eb1930033a652604e511120
Exists in
master
Merge branch 'master' into 'master'
Master(efernandez) See merge request modulos-npm/foca-crear-remito!12
Showing
2 changed files
Show diff stats
.jshintrc
1 | { | 1 | { |
2 | /* | 2 | /* |
3 | * ENVIRONMENTS | 3 | * ENVIRONMENTS |
4 | * ================= | 4 | * ================= |
5 | */ | 5 | */ |
6 | 6 | ||
7 | // Define globals exposed by modern browsers. | 7 | // Define globals exposed by modern browsers. |
8 | "browser": true, | 8 | "browser": true, |
9 | 9 | ||
10 | // Define globals exposed by jQuery. | 10 | // Define globals exposed by jQuery. |
11 | "jquery": true, | 11 | "jquery": true, |
12 | 12 | ||
13 | // Define globals exposed by Node.js. | 13 | // Define globals exposed by Node.js. |
14 | "node": true, | 14 | "node": true, |
15 | 15 | ||
16 | // Allow ES6. | 16 | // Allow ES6. |
17 | "esversion": 6, | 17 | "esversion": 6, |
18 | 18 | ||
19 | /* | 19 | /* |
20 | * ENFORCING OPTIONS | 20 | * ENFORCING OPTIONS |
21 | * ================= | 21 | * ================= |
22 | */ | 22 | */ |
23 | 23 | ||
24 | // Force all variable names to use either camelCase style or UPPER_CASE | 24 | // Force all variable names to use either camelCase style or UPPER_CASE |
25 | // with underscores. | 25 | // with underscores. |
26 | "camelcase": true, | 26 | "camelcase": false, |
27 | 27 | ||
28 | // Prohibit use of == and != in favor of === and !==. | 28 | // Prohibit use of == and != in favor of === and !==. |
29 | "eqeqeq": true, | 29 | "eqeqeq": true, |
30 | 30 | ||
31 | // Enforce tab width of 2 spaces. | 31 | // Enforce tab width of 2 spaces. |
32 | "indent": 4, | 32 | "indent": 4, |
33 | 33 | ||
34 | // Prohibit use of a variable before it is defined. | 34 | // Prohibit use of a variable before it is defined. |
35 | "latedef": false, | 35 | "latedef": false, |
36 | 36 | ||
37 | // Enforce line length to 100 characters | 37 | // Enforce line length to 100 characters |
38 | "maxlen": 100, | 38 | "maxlen": 100, |
39 | 39 | ||
40 | // Require capitalized names for constructor functions. | 40 | // Require capitalized names for constructor functions. |
41 | "newcap": true, | 41 | "newcap": true, |
42 | 42 | ||
43 | // Enforce use of single quotation marks for strings. | 43 | // Enforce use of single quotation marks for strings. |
44 | "quotmark": "single", | 44 | "quotmark": "single", |
45 | 45 | ||
46 | // Enforce placing 'use strict' at the top function scope | 46 | // Enforce placing 'use strict' at the top function scope |
47 | "strict": false, | 47 | "strict": false, |
48 | 48 | ||
49 | // Prohibit use of explicitly undeclared variables. | 49 | // Prohibit use of explicitly undeclared variables. |
50 | "undef": true, | 50 | "undef": true, |
51 | 51 | ||
52 | // Warn when variables are defined but never used. | 52 | // Warn when variables are defined but never used. |
53 | "unused": true, | 53 | "unused": true, |
54 | 54 | ||
55 | // Para que funcione en angular | 55 | // Para que funcione en angular |
56 | "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], | 56 | "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], |
57 | /* | 57 | /* |
58 | * RELAXING OPTIONS | 58 | * RELAXING OPTIONS |
59 | * ================= | 59 | * ================= |
60 | */ | 60 | */ |
61 | 61 | ||
62 | // Suppress warnings about == null comparisons. | 62 | // Suppress warnings about == null comparisons. |
63 | "eqnull": true | 63 | "eqnull": true |
64 | } | 64 | } |
65 | 65 |
src/js/controller.js
1 | angular.module('focaCrearRemito') .controller('remitoController', | 1 | angular.module('focaCrearRemito') .controller('remitoController', |
2 | [ | 2 | [ |
3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', |
4 | 'focaModalService', 'remitoBusinessService', | 4 | 'focaModalService', 'remitoBusinessService', |
5 | function( | 5 | function( |
6 | $scope, $uibModal, $location, $filter, crearRemitoService, focaModalService, | 6 | $scope, $uibModal, $location, $filter, crearRemitoService, focaModalService, |
7 | remitoBusinessService | 7 | remitoBusinessService |
8 | ) { | 8 | ) { |
9 | $scope.botonera = [ | 9 | $scope.botonera = [ |
10 | {texto: 'Nota Pedido', accion: function() {$scope.seleccionarNotaPedido();}}, | 10 | {texto: 'Nota Pedido', accion: function() {$scope.seleccionarNotaPedido();}}, |
11 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, | 11 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, |
12 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | 12 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
13 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, | 13 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, |
14 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | 14 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, |
15 | { | 15 | { |
16 | texto: 'Precios y condiciones', | 16 | texto: 'Precios y condiciones', |
17 | accion: function() {$scope.abrirModalListaPrecio();}}, | 17 | accion: function() {$scope.abrirModalListaPrecio();}}, |
18 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | 18 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, |
19 | {texto: '', accion: function() {}} | 19 | {texto: '', accion: function() {}} |
20 | ]; | 20 | ]; |
21 | $scope.datepickerAbierto = false; | 21 | $scope.datepickerAbierto = false; |
22 | 22 | ||
23 | $scope.show = false; | 23 | $scope.show = false; |
24 | $scope.cargando = true; | 24 | $scope.cargando = true; |
25 | $scope.dateOptions = { | 25 | $scope.dateOptions = { |
26 | maxDate: new Date(), | 26 | maxDate: new Date(), |
27 | minDate: new Date(2010, 0, 1) | 27 | minDate: new Date(2010, 0, 1) |
28 | }; | 28 | }; |
29 | 29 | ||
30 | $scope.remito = { | 30 | $scope.remito = { |
31 | id: 0, | ||
31 | vendedor: {}, | 32 | vendedor: {}, |
32 | cliente: {}, | 33 | cliente: {}, |
33 | proveedor: {}, | 34 | proveedor: {}, |
34 | domicilio: {dom: ''}, | 35 | domicilio: {dom: ''}, |
35 | moneda: {}, | 36 | moneda: {}, |
36 | cotizacion: {} | 37 | cotizacion: {} |
37 | }; | 38 | }; |
38 | var monedaPorDefecto; | 39 | var monedaPorDefecto; |
39 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 40 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
40 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { | 41 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { |
41 | monedaPorDefecto = { | 42 | monedaPorDefecto = { |
42 | id: res.data[0].ID, | 43 | id: res.data[0].ID, |
43 | detalle: res.data[0].DETALLE, | 44 | detalle: res.data[0].DETALLE, |
44 | simbolo: res.data[0].SIMBOLO, | 45 | simbolo: res.data[0].SIMBOLO, |
45 | cotizaciones: res.data[0].cotizaciones | 46 | cotizaciones: res.data[0].cotizaciones |
46 | }; | 47 | }; |
47 | addCabecera('Moneda:', monedaPorDefecto.detalle); | 48 | addCabecera('Moneda:', monedaPorDefecto.detalle); |
48 | addCabecera('Fecha cotizacion:', | 49 | addCabecera('Fecha cotizacion:', |
49 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | 50 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); |
50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); | 51 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); |
51 | $scope.remito.moneda = monedaPorDefecto; | 52 | $scope.remito.moneda = monedaPorDefecto; |
52 | $scope.remito.cotizacion = monedaPorDefecto.cotizaciones[0]; | 53 | $scope.remito.cotizacion = monedaPorDefecto.cotizaciones[0]; |
53 | }); | 54 | }); |
54 | 55 | ||
55 | $scope.cabecera = []; | 56 | $scope.cabecera = []; |
56 | $scope.showCabecera = true; | 57 | $scope.showCabecera = true; |
57 | 58 | ||
58 | $scope.now = new Date(); | 59 | $scope.now = new Date(); |
59 | $scope.puntoVenta = rellenar(0, 4); | 60 | $scope.puntoVenta = rellenar(0, 4); |
60 | $scope.comprobante = rellenar(0, 8); | 61 | $scope.comprobante = rellenar(0, 8); |
61 | 62 | ||
62 | $scope.articulosTabla = []; | 63 | $scope.articulosTabla = []; |
63 | $scope.idLista = undefined; | 64 | $scope.idLista = undefined; |
64 | //La pantalla solo se usa para cargar remitos | 65 | //La pantalla solo se usa para cargar remitos |
65 | //var remitoTemp = crearRemitoService.getRemito(); | 66 | //var remitoTemp = crearRemitoService.getRemito(); |
66 | 67 | ||
67 | crearRemitoService.getPrecioCondicion().then( | 68 | crearRemitoService.getPrecioCondicion().then( |
68 | function(res) { | 69 | function(res) { |
69 | $scope.precioCondiciones = res.data; | 70 | $scope.precioCondiciones = res.data; |
70 | } | 71 | } |
71 | ); | 72 | ); |
72 | 73 | ||
73 | crearRemitoService.getNumeroRemito().then( | 74 | crearRemitoService.getNumeroRemito().then( |
74 | function(res) { | 75 | function(res) { |
75 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 76 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
76 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); | 77 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); |
77 | }, | 78 | }, |
78 | function(err) { | 79 | function(err) { |
79 | focaModalService.alert('La terminal no esta configurada correctamente'); | 80 | focaModalService.alert('La terminal no esta configurada correctamente'); |
80 | console.info(err); | 81 | console.info(err); |
81 | } | 82 | } |
82 | ); | 83 | ); |
83 | 84 | ||
84 | $scope.seleccionarNotaPedido = function() { | 85 | $scope.seleccionarNotaPedido = function() { |
85 | var modalInstance = $uibModal.open( | 86 | var modalInstance = $uibModal.open( |
86 | { | 87 | { |
87 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 88 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
88 | templateUrl: 'foca-modal-nota-pedido.html', | 89 | templateUrl: 'foca-modal-nota-pedido.html', |
89 | controller: 'focaModalNotaPedidoController', | 90 | controller: 'focaModalNotaPedidoController', |
90 | size: 'lg' | 91 | size: 'lg' |
91 | } | 92 | } |
92 | ); | 93 | ); |
93 | modalInstance.result.then( | 94 | modalInstance.result.then( |
94 | function(notaPedido) { | 95 | function(notaPedido) { |
95 | //añado cabeceras | 96 | //añado cabeceras |
96 | removeCabecera('Moneda:'); | 97 | removeCabecera('Moneda:'); |
97 | removeCabecera('Fecha cotizacion:'); | 98 | removeCabecera('Fecha cotizacion:'); |
98 | removeCabecera('Cotizacion:'); | 99 | removeCabecera('Cotizacion:'); |
99 | var cabeceras = [ | 100 | var cabeceras = [ |
100 | { | 101 | { |
101 | label: 'Moneda', | 102 | label: 'Moneda', |
102 | valor: notaPedido.cotizacion[0].moneda[0].DETALLE | 103 | valor: notaPedido.cotizacion[0].moneda[0].DETALLE |
103 | }, | 104 | }, |
104 | { | 105 | { |
105 | label: 'Fecha cotizacion', | 106 | label: 'Fecha cotizacion', |
106 | valor: $filter('date')(notaPedido.cotizacion[0].FECHA, | 107 | valor: $filter('date')(notaPedido.cotizacion[0].FECHA, |
107 | 'dd/MM/yyyy') | 108 | 'dd/MM/yyyy') |
108 | }, | 109 | }, |
109 | { | 110 | { |
110 | label: 'Cotizacion', | 111 | label: 'Cotizacion', |
111 | valor: notaPedido.cotizacion[0].VENDEDOR | 112 | valor: notaPedido.cotizacion[0].VENDEDOR |
112 | }, | 113 | }, |
113 | { | 114 | { |
114 | label: 'Cliente:', | 115 | label: 'Cliente:', |
115 | valor: notaPedido.cliente[0].NOM | 116 | valor: notaPedido.cliente[0].NOM |
116 | }, | 117 | }, |
117 | { | 118 | { |
119 | label: 'Domicilio:', | ||
120 | valor: notaPedido.domicilioStamp | ||
121 | }, | ||
122 | { | ||
118 | label: 'Vendedor:', | 123 | label: 'Vendedor:', |
119 | valor: notaPedido.vendedor[0].NomVen | 124 | valor: notaPedido.vendedor[0].NomVen |
120 | }, | 125 | }, |
121 | { | 126 | { |
122 | label: 'Proveedor:', | 127 | label: 'Proveedor:', |
123 | valor: notaPedido.proveedor[0].NOM | 128 | valor: notaPedido.proveedor[0].NOM |
124 | }, | 129 | }, |
125 | { | 130 | { |
126 | label: 'Flete:', | 131 | label: 'Flete:', |
127 | valor: notaPedido.flete === 1 ? 'Si' : 'No' | 132 | valor: notaPedido.flete === 1 ? 'Si' : 'No' |
128 | }, | 133 | }, |
129 | { | 134 | { |
130 | label: 'FOB:', | 135 | label: 'FOB:', |
131 | valor: notaPedido.fob === 1 ? 'Si' : 'No' | 136 | valor: notaPedido.fob === 1 ? 'Si' : 'No' |
132 | }, | 137 | }, |
133 | { | 138 | { |
134 | label: 'Precio condicion:', | 139 | label: 'Precio condicion:', |
135 | valor: valorPrecioCondicion() | 140 | valor: valorPrecioCondicion() |
136 | } | 141 | } |
137 | ]; | 142 | ]; |
138 | //TO DO CUANDO MOSTRAR PLAZOS | 143 | //TO DO CUANDO MOSTRAR PLAZOS |
139 | function valorPrecioCondicion() { | 144 | function valorPrecioCondicion() { |
140 | if(notaPedido.idPrecioCondicion > 0) { | 145 | if(notaPedido.idPrecioCondicion > 0) { |
141 | return notaPedido.precioCondicion[0].nombre; | 146 | return notaPedido.precioCondicion[0].nombre; |
142 | } else { | 147 | } else { |
143 | return 'Ingreso Manual'; | 148 | return 'Ingreso Manual'; |
144 | } | 149 | } |
145 | 150 | ||
146 | } | 151 | } |
147 | 152 | ||
148 | if(notaPedido.flete === 1) { | 153 | if(notaPedido.flete === 1) { |
149 | var cabeceraBomba = { | 154 | var cabeceraBomba = { |
150 | label: 'Bomba', | 155 | label: 'Bomba', |
151 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 156 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
152 | }; | 157 | }; |
153 | if(notaPedido.kilometros) { | 158 | if(notaPedido.kilometros) { |
154 | var cabeceraKilometros = { | 159 | var cabeceraKilometros = { |
155 | label: 'Kilometros', | 160 | label: 'Kilometros', |
156 | valor: notaPedido.kilometros | 161 | valor: notaPedido.kilometros |
157 | }; | 162 | }; |
158 | cabeceras.push(cabeceraKilometros); | 163 | cabeceras.push(cabeceraKilometros); |
159 | } | 164 | } |
160 | cabeceras.push(cabeceraBomba); | 165 | cabeceras.push(cabeceraBomba); |
161 | } | 166 | } |
162 | $scope.articulosTabla = notaPedido.articulosNotaPedido; | 167 | $scope.articulosTabla = notaPedido.articulosNotaPedido; |
163 | if(notaPedido.precioCondicion.length > 0) { | 168 | if(notaPedido.precioCondicion.length > 0) { |
164 | $scope.idLista = notaPedido.precioCondicion[0].idListaPrecio; | 169 | $scope.idLista = notaPedido.precioCondicion[0].idListaPrecio; |
165 | } else { | 170 | } else { |
166 | $scope.idLista = -1; | 171 | $scope.idLista = -1; |
167 | } | 172 | } |
173 | delete notaPedido.id; | ||
168 | $scope.remito = notaPedido; | 174 | $scope.remito = notaPedido; |
169 | $scope.remito.vendedor = notaPedido.vendedor[0]; | 175 | $scope.remito.vendedor = notaPedido.vendedor[0]; |
170 | $scope.remito.cliente = notaPedido.cliente[0]; | 176 | $scope.remito.cliente = notaPedido.cliente[0]; |
171 | $scope.remito.proveedor = notaPedido.proveedor[0]; | 177 | $scope.remito.proveedor = notaPedido.proveedor[0]; |
172 | $scope.remito.moneda = notaPedido.cotizacion[0].moneda[0]; | 178 | $scope.remito.moneda = notaPedido.cotizacion[0].moneda[0]; |
173 | $scope.remito.cotizacion = notaPedido.cotizacion[0]; | 179 | $scope.remito.cotizacion = notaPedido.cotizacion[0]; |
174 | addArrayCabecera(cabeceras); | 180 | addArrayCabecera(cabeceras); |
175 | 181 | ||
176 | }, function() { | 182 | }, function() { |
177 | // funcion ejecutada cuando se cancela el modal | 183 | // funcion ejecutada cuando se cancela el modal |
178 | } | 184 | } |
179 | ); | 185 | ); |
180 | }; | 186 | }; |
181 | 187 | ||
182 | $scope.seleccionarRemito = function() { | 188 | $scope.seleccionarRemito = function() { |
183 | var modalInstance = $uibModal.open( | 189 | var modalInstance = $uibModal.open( |
184 | { | 190 | { |
185 | ariaLabelledBy: 'Busqueda de Remito', | 191 | ariaLabelledBy: 'Busqueda de Remito', |
186 | templateUrl: 'foca-modal-remito.html', | 192 | templateUrl: 'foca-modal-remito.html', |
187 | controller: 'focaModalRemitoController', | 193 | controller: 'focaModalRemitoController', |
188 | size: 'lg' | 194 | size: 'lg' |
189 | } | 195 | } |
190 | ); | 196 | ); |
191 | modalInstance.result.then( | 197 | modalInstance.result.then( |
192 | function(remito) { | 198 | function(remito) { |
193 | //añado cabeceras | 199 | //añado cabeceras |
194 | removeCabecera('Moneda:'); | 200 | removeCabecera('Moneda:'); |
195 | removeCabecera('Fecha cotizacion:'); | 201 | removeCabecera('Fecha cotizacion:'); |
196 | removeCabecera('Cotizacion:'); | 202 | removeCabecera('Cotizacion:'); |
197 | var cabeceras = [ | 203 | var cabeceras = [ |
198 | { | 204 | { |
199 | label: 'Moneda', | 205 | label: 'Moneda', |
200 | valor: remito.cotizacion[0].moneda[0].DETALLE | 206 | valor: remito.cotizacion[0].moneda[0].DETALLE |
201 | }, | 207 | }, |
202 | { | 208 | { |
203 | label: 'Fecha cotizacion', | 209 | label: 'Fecha cotizacion', |
204 | valor: $filter('date')(remito.cotizacion[0].FECHA, | 210 | valor: $filter('date')(remito.cotizacion[0].FECHA, |
205 | 'dd/MM/yyyy') | 211 | 'dd/MM/yyyy') |
206 | }, | 212 | }, |
207 | { | 213 | { |
208 | label: 'Cotizacion', | 214 | label: 'Cotizacion', |
209 | valor: remito.cotizacion[0].VENDEDOR | 215 | valor: remito.cotizacion[0].VENDEDOR |
210 | }, | 216 | }, |
211 | { | 217 | { |
212 | label: 'Cliente:', | 218 | label: 'Cliente:', |
213 | valor: remito.cliente[0].NOM | 219 | valor: remito.cliente[0].NOM |
214 | }, | 220 | }, |
215 | { | 221 | { |
222 | label: 'Domicilio:', | ||
223 | valor: remito.domicilioStamp | ||
224 | }, | ||
225 | { | ||
216 | label: 'Vendedor:', | 226 | label: 'Vendedor:', |
217 | valor: remito.vendedor[0].NomVen | 227 | valor: remito.vendedor[0].NomVen |
218 | }, | 228 | }, |
219 | { | 229 | { |
220 | label: 'Proveedor:', | 230 | label: 'Proveedor:', |
221 | valor: remito.proveedor[0].NOM | 231 | valor: remito.proveedor[0].NOM |
222 | }, | 232 | }, |
223 | { | 233 | { |
224 | label: 'Flete:', | 234 | label: 'Flete:', |
225 | valor: remito.flete === 1 ? 'Si' : 'No' | 235 | valor: remito.flete === 1 ? 'Si' : 'No' |
226 | }, | 236 | }, |
227 | { | 237 | { |
228 | label: 'FOB:', | 238 | label: 'FOB:', |
229 | valor: remito.fob === 1 ? 'Si' : 'No' | 239 | valor: remito.fob === 1 ? 'Si' : 'No' |
230 | }, | 240 | }, |
231 | { | 241 | { |
232 | label: 'Precio condicion:', | 242 | label: 'Precio condicion:', |
233 | valor: valorPrecioCondicion() | 243 | valor: valorPrecioCondicion() |
234 | } | 244 | } |
235 | ]; | 245 | ]; |
236 | //TO DO CUANDO MOSTRAR PLAZOS | 246 | //TO DO CUANDO MOSTRAR PLAZOS |
237 | function valorPrecioCondicion() { | 247 | function valorPrecioCondicion() { |
238 | if(remito.idPrecioCondicion > 0) { | 248 | if(remito.idPrecioCondicion > 0) { |
239 | return remito.precioCondicion[0].nombre; | 249 | return remito.precioCondicion[0].nombre; |
240 | } else { | 250 | } else { |
241 | return 'Ingreso Manual'; | 251 | return 'Ingreso Manual'; |
242 | } | 252 | } |
243 | 253 | ||
244 | } | 254 | } |
245 | 255 | ||
246 | if(remito.flete === 1) { | 256 | if(remito.flete === 1) { |
247 | var cabeceraBomba = { | 257 | var cabeceraBomba = { |
248 | label: 'Bomba', | 258 | label: 'Bomba', |
249 | valor: remito.bomba === 1 ? 'Si' : 'No' | 259 | valor: remito.bomba === 1 ? 'Si' : 'No' |
250 | }; | 260 | }; |
251 | if(remito.kilometros) { | 261 | if(remito.kilometros) { |
252 | var cabeceraKilometros = { | 262 | var cabeceraKilometros = { |
253 | label: 'Kilometros', | 263 | label: 'Kilometros', |
254 | valor: remito.kilometros | 264 | valor: remito.kilometros |
255 | }; | 265 | }; |
256 | cabeceras.push(cabeceraKilometros); | 266 | cabeceras.push(cabeceraKilometros); |
257 | } | 267 | } |
258 | cabeceras.push(cabeceraBomba); | 268 | cabeceras.push(cabeceraBomba); |
259 | } | 269 | } |
260 | $scope.articulosTabla = remito.articulosRemito; | 270 | $scope.articulosTabla = remito.articulosRemito; |
261 | if(remito.precioCondicion.length > 0) { | 271 | if(remito.precioCondicion.length > 0) { |
262 | $scope.idLista = remito.precioCondicion[0].idListaPrecio; | 272 | $scope.idLista = remito.precioCondicion[0].idListaPrecio; |
263 | } else { | 273 | } else { |
264 | $scope.idLista = -1; | 274 | $scope.idLista = -1; |
265 | } | 275 | } |
276 | $scope.comprobante = rellenar(remito.numeroRemito, 8); | ||
266 | $scope.remito = remito; | 277 | $scope.remito = remito; |
267 | $scope.remito.vendedor = remito.vendedor[0]; | 278 | $scope.remito.vendedor = remito.vendedor[0]; |
268 | $scope.remito.cliente = remito.cliente[0]; | 279 | $scope.remito.cliente = remito.cliente[0]; |
269 | $scope.remito.proveedor = remito.proveedor[0]; | 280 | $scope.remito.proveedor = remito.proveedor[0]; |
270 | $scope.remito.moneda = remito.cotizacion[0].moneda[0]; | 281 | $scope.remito.moneda = remito.cotizacion[0].moneda[0]; |
271 | $scope.remito.cotizacion = remito.cotizacion[0]; | 282 | $scope.remito.cotizacion = remito.cotizacion[0]; |
272 | addArrayCabecera(cabeceras); | 283 | addArrayCabecera(cabeceras); |
273 | }, function() { | 284 | }, function() { |
274 | // funcion ejecutada cuando se cancela el modal | 285 | // funcion ejecutada cuando se cancela el modal |
275 | } | 286 | } |
276 | ); | 287 | ); |
277 | }; | 288 | }; |
278 | 289 | ||
279 | //La pantalla solo se usa para cargar remitos | 290 | //La pantalla solo se usa para cargar remitos |
280 | // if (remitoTemp !== undefined) { | 291 | // if (remitoTemp !== undefined) { |
281 | // remitoTemp.fechaCarga = new Date(remitoTemp.fechaCarga); | 292 | // remitoTemp.fechaCarga = new Date(remitoTemp.fechaCarga); |
282 | // $scope.remito = remitoTemp; | 293 | // $scope.remito = remitoTemp; |
283 | // $scope.remito.flete = ($scope.remito.flete).toString(); | 294 | // $scope.remito.flete = ($scope.remito.flete).toString(); |
284 | // $scope.remito.bomba = ($scope.remito.bomba).toString(); | 295 | // $scope.remito.bomba = ($scope.remito.bomba).toString(); |
285 | // $scope.idLista = $scope.remito.precioCondicion; | 296 | // $scope.idLista = $scope.remito.precioCondicion; |
286 | // crearRemitoService | 297 | // crearRemitoService |
287 | // .getArticulosByIdRemito($scope.remito.id).then( | 298 | // .getArticulosByIdRemito($scope.remito.id).then( |
288 | // function(res) { | 299 | // function(res) { |
289 | // $scope.articulosTabla = res.data; | 300 | // $scope.articulosTabla = res.data; |
290 | // } | 301 | // } |
291 | // ); | 302 | // ); |
292 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR REMITO | 303 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR REMITO |
293 | //(NO REQUERIDO EN ESTA VERSION) | 304 | //(NO REQUERIDO EN ESTA VERSION) |
294 | // crearRemitoService.getDomiciliosByIdRemito($scope.remito.id).then( | 305 | // crearRemitoService.getDomiciliosByIdRemito($scope.remito.id).then( |
295 | // function(res) { | 306 | // function(res) { |
296 | // $scope.remito.domicilio = res.data; | 307 | // $scope.remito.domicilio = res.data; |
297 | // } | 308 | // } |
298 | // ); | 309 | // ); |
299 | // } else { | 310 | // } else { |
300 | // $scope.remito.fechaCarga = new Date(); | 311 | // $scope.remito.fechaCarga = new Date(); |
301 | // $scope.remito.bomba = '0'; | 312 | // $scope.remito.bomba = '0'; |
302 | // $scope.remito.flete = '0'; | 313 | // $scope.remito.flete = '0'; |
303 | // $scope.idLista = undefined; | 314 | // $scope.idLista = undefined; |
304 | // } | 315 | // } |
305 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 316 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
306 | // $scope.addNewDom = function() { | 317 | // $scope.addNewDom = function() { |
307 | // $scope.remito.domicilio.push({ 'id': 0 }); | 318 | // $scope.remito.domicilio.push({ 'id': 0 }); |
308 | // }; | 319 | // }; |
309 | // $scope.removeNewChoice = function(choice) { | 320 | // $scope.removeNewChoice = function(choice) { |
310 | // if ($scope.remito.domicilio.length > 1) { | 321 | // if ($scope.remito.domicilio.length > 1) { |
311 | // $scope.remito.domicilio.splice($scope.remito.domicilio.findIndex( | 322 | // $scope.remito.domicilio.splice($scope.remito.domicilio.findIndex( |
312 | // function(c) { | 323 | // function(c) { |
313 | // return c.$$hashKey === choice.$$hashKey; | 324 | // return c.$$hashKey === choice.$$hashKey; |
314 | // } | 325 | // } |
315 | // ), 1); | 326 | // ), 1); |
316 | // } | 327 | // } |
317 | // }; | 328 | // }; |
318 | //validacion por domicilio y por plazo pago | 329 | //validacion por domicilio y por plazo pago |
319 | $scope.crearRemito = function() { | 330 | $scope.crearRemito = function() { |
320 | if(!$scope.remito.vendedor) { | 331 | if(!$scope.remito.vendedor) { |
321 | focaModalService.alert('Ingrese Vendedor'); | 332 | focaModalService.alert('Ingrese Vendedor'); |
322 | return; | 333 | return; |
323 | } else if(!$scope.remito.cliente) { | 334 | } else if(!$scope.remito.cliente) { |
324 | focaModalService.alert('Ingrese Cliente'); | 335 | focaModalService.alert('Ingrese Cliente'); |
325 | return; | 336 | return; |
326 | } else if(!$scope.remito.proveedor) { | 337 | } else if(!$scope.remito.proveedor) { |
327 | focaModalService.alert('Ingrese Proveedor'); | 338 | focaModalService.alert('Ingrese Proveedor'); |
328 | return; | 339 | return; |
329 | } else if(!$scope.remito.moneda.ID) { | 340 | } else if(!$scope.remito.moneda.ID) { |
330 | focaModalService.alert('Ingrese Moneda'); | 341 | focaModalService.alert('Ingrese Moneda'); |
331 | return; | 342 | return; |
332 | } else if(!$scope.remito.cotizacion.ID) { | 343 | } else if(!$scope.remito.cotizacion.ID) { |
333 | focaModalService.alert('Ingrese Cotización'); | 344 | focaModalService.alert('Ingrese Cotización'); |
334 | return; | 345 | return; |
335 | } else if( | 346 | } else if( |
336 | $scope.remito.flete === undefined || $scope.remito.flete === null) | 347 | $scope.remito.flete === undefined || $scope.remito.flete === null) |
337 | { | 348 | { |
338 | focaModalService.alert('Ingrese Flete'); | 349 | focaModalService.alert('Ingrese Flete'); |
339 | return; | 350 | return; |
340 | } else if($scope.articulosTabla.length === 0) { | 351 | } else if($scope.articulosTabla.length === 0) { |
341 | focaModalService.alert('Debe cargar al menos un articulo'); | 352 | focaModalService.alert('Debe cargar al menos un articulo'); |
342 | return; | 353 | return; |
343 | } | 354 | } |
344 | var date = new Date(); | 355 | var date = new Date(); |
345 | var remito = { | 356 | var remito = { |
346 | id: 0, | 357 | id: $scope.remito.id, |
347 | fechaRemito: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 358 | fechaRemito: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
348 | .toISOString().slice(0, 19).replace('T', ' '),//TODO$filter | 359 | .toISOString().slice(0, 19).replace('T', ' '),//TODO$filter |
349 | idCliente: $scope.remito.idCliente, | 360 | idCliente: $scope.remito.cliente.COD, |
350 | nombreCliente: $scope.remito.nombreCliente, | 361 | nombreCliente: $scope.remito.cliente.NOM, |
351 | cuitCliente: $scope.remito.cuitCliente, | 362 | cuitCliente: $scope.remito.cliente.CUIT, |
352 | responsabilidadIvaCliente: 0,//TODO, | 363 | responsabilidadIvaCliente: 0,//TODO, |
353 | descuento: 0,//TODO, | 364 | descuento: 0,//TODO, |
354 | importeNeto: 0,//TODO | 365 | importeNeto: 0,//TODO |
355 | importeExento: 0,//TODO | 366 | importeExento: 0,//TODO |
356 | importeIva: 0,//TODO | 367 | importeIva: 0,//TODO |
357 | importeIvaServicios: 0,//TODO | 368 | importeIvaServicios: 0,//TODO |
358 | importeImpuestoInterno: 0,//TODO | 369 | importeImpuestoInterno: 0,//TODO |
359 | importeImpuestoInterno1: 0,//TODO | 370 | importeImpuestoInterno1: 0,//TODO |
360 | importeImpuestoInterno2: 0,//TODO | 371 | importeImpuestoInterno2: 0,//TODO |
361 | percepcion: 0,//TODO | 372 | percepcion: 0,//TODO |
362 | percepcionIva: 0,//TODO | 373 | percepcionIva: 0,//TODO |
363 | redondeo: 0,//TODO | 374 | redondeo: 0,//TODO |
364 | total: $scope.getTotal(), | 375 | total: $scope.getTotal(), |
365 | numeroNotaPedido: $scope.remito.numeroNotaPedido, | 376 | numeroNotaPedido: $scope.remito.numeroNotaPedido, |
366 | anulado: false, | 377 | anulado: false, |
367 | planilla: 0,//TODO | 378 | planilla: 0,//TODO |
368 | lugar: 0,//TODO | 379 | lugar: 0,//TODO |
369 | cuentaMadre: 0,// | 380 | cuentaMadre: 0,// |
370 | cuentaContable: 0,//TODO | 381 | cuentaContable: 0,//TODO |
371 | asiento: 0,//TODO | 382 | asiento: 0,//TODO |
372 | e_hd: '',//TODO | 383 | e_hd: '',//TODO |
373 | c_hd: '', | 384 | c_hd: '', |
374 | numeroLiquidoProducto: 0,//TODO | 385 | numeroLiquidoProducto: 0,//TODO |
375 | idVendedor: $scope.remito.idVendedor, | 386 | idVendedor: $scope.remito.idVendedor, |
376 | idProveedor: $scope.remito.idProveedor, | 387 | idProveedor: $scope.remito.idProveedor, |
377 | idDomicilio: 0,//TODO | 388 | idDomicilio: 0,//TODO |
378 | idCotizacion: $scope.remito.idCotizacion, | 389 | domicilioStamp: $scope.remito.domicilioStamp, |
390 | idCotizacion: $scope.remito.cotizacion.ID, | ||
379 | idPrecioCondicion: $scope.remito.idPrecioCondicion, | 391 | idPrecioCondicion: $scope.remito.idPrecioCondicion, |
380 | flete: $scope.remito.flete, | 392 | flete: $scope.remito.flete, |
381 | fob: $scope.remito.fob, | 393 | fob: $scope.remito.fob, |
382 | bomba: $scope.remito.bomba, | 394 | bomba: $scope.remito.bomba, |
383 | kilometros: $scope.remito.kilometros, | 395 | kilometros: $scope.remito.kilometros, |
384 | estado: 0,//TODO | 396 | estado: 0,//TODO |
385 | destinoVenta: 0,//TODO | 397 | destinoVenta: 0,//TODO |
386 | operacionTipo: 0//TODO | 398 | operacionTipo: 0//TODO |
387 | }; | 399 | }; |
388 | crearRemitoService.crearRemito(remito).then( | 400 | crearRemitoService.crearRemito(remito).then( |
389 | function(data) { | 401 | function(data) { |
390 | remitoBusinessService.addArticulos($scope.articulosTabla, | 402 | remitoBusinessService.addArticulos($scope.articulosTabla, |
391 | data.data.id, $scope.remito.cotizacion.COTIZACION); | 403 | data.data.id, $scope.remito.cotizacion.COTIZACION); |
392 | 404 | ||
393 | focaModalService.alert('Nota remito creada'); | 405 | focaModalService.alert('Nota remito creada'); |
394 | $scope.cabecera = []; | 406 | $scope.cabecera = []; |
395 | addCabecera('Moneda:', $scope.remito.moneda.detalle); | 407 | addCabecera('Moneda:', $scope.remito.moneda.DETALLE); |
396 | addCabecera( | 408 | addCabecera( |
397 | 'Fecha cotizacion:', | 409 | 'Fecha cotizacion:', |
398 | $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') | 410 | $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') |
399 | ); | 411 | ); |
400 | addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); | 412 | addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); |
401 | $scope.remito.vendedor = {}; | 413 | $scope.remito.vendedor = {}; |
402 | $scope.remito.cliente = {}; | 414 | $scope.remito.cliente = {}; |
403 | $scope.remito.proveedor = {}; | 415 | $scope.remito.proveedor = {}; |
404 | $scope.remito.domicilio = {}; | 416 | $scope.remito.domicilio = {}; |
405 | $scope.remito.flete = null; | 417 | $scope.remito.flete = null; |
406 | $scope.remito.fob = null; | 418 | $scope.remito.fob = null; |
407 | $scope.remito.bomba = null; | 419 | $scope.remito.bomba = null; |
408 | $scope.remito.kilometros = null; | 420 | $scope.remito.kilometros = null; |
409 | $scope.articulosTabla = []; | 421 | $scope.articulosTabla = []; |
422 | crearRemitoService.getNumeroRemito().then( | ||
423 | function(res) { | ||
424 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | ||
425 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); | ||
426 | }, | ||
427 | function(err) { | ||
428 | focaModalService | ||
429 | .alert('La terminal no esta configurada correctamente'); | ||
430 | console.info(err); | ||
431 | } | ||
432 | ); | ||
410 | } | 433 | } |
411 | ); | 434 | ); |
412 | }; | 435 | }; |
413 | 436 | ||
414 | $scope.seleccionarArticulo = function() { | 437 | $scope.seleccionarArticulo = function() { |
415 | if ($scope.idLista === undefined) { | 438 | if ($scope.idLista === undefined) { |
416 | focaModalService.alert( | 439 | focaModalService.alert( |
417 | 'Primero seleccione una lista de precio y condicion'); | 440 | 'Primero seleccione una lista de precio y condicion'); |
418 | return; | 441 | return; |
419 | } | 442 | } |
420 | var modalInstance = $uibModal.open( | 443 | var modalInstance = $uibModal.open( |
421 | { | 444 | { |
422 | ariaLabelledBy: 'Busqueda de Productos', | 445 | ariaLabelledBy: 'Busqueda de Productos', |
423 | templateUrl: 'modal-busqueda-productos.html', | 446 | templateUrl: 'modal-busqueda-productos.html', |
424 | controller: 'modalBusquedaProductosCtrl', | 447 | controller: 'modalBusquedaProductosCtrl', |
425 | resolve: { | 448 | resolve: { |
426 | parametroProducto: { | 449 | parametroProducto: { |
427 | idLista: $scope.idLista, | 450 | idLista: $scope.idLista, |
428 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 451 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
429 | simbolo: $scope.remito.moneda.simbolo | 452 | simbolo: $scope.remito.moneda.simbolo |
430 | } | 453 | } |
431 | }, | 454 | }, |
432 | size: 'lg' | 455 | size: 'lg' |
433 | } | 456 | } |
434 | ); | 457 | ); |
435 | modalInstance.result.then( | 458 | modalInstance.result.then( |
436 | function(producto) { | 459 | function(producto) { |
437 | var newArt = | 460 | var newArt = |
438 | { | 461 | { |
439 | id: 0, | 462 | id: 0, |
440 | codigo: producto.codigo, | 463 | codigo: producto.codigo, |
441 | sector: producto.sector, | 464 | sector: producto.sector, |
442 | sectorCodigo: producto.sector + '-' + producto.codigo, | 465 | sectorCodigo: producto.sector + '-' + producto.codigo, |
443 | descripcion: producto.descripcion, | 466 | descripcion: producto.descripcion, |
444 | item: $scope.articulosTabla.length + 1, | 467 | item: $scope.articulosTabla.length + 1, |
445 | nombre: producto.descripcion, | 468 | nombre: producto.descripcion, |
446 | precio: parseFloat(producto.precio.toFixed(4)), | 469 | precio: parseFloat(producto.precio.toFixed(4)), |
447 | costoUnitario: producto.costo, | 470 | costoUnitario: producto.costo, |
448 | editCantidad: false, | 471 | editCantidad: false, |
449 | editPrecio: false | 472 | editPrecio: false |
450 | }; | 473 | }; |
451 | $scope.articuloACargar = newArt; | 474 | $scope.articuloACargar = newArt; |
452 | $scope.cargando = false; | 475 | $scope.cargando = false; |
453 | }, function() { | 476 | }, function() { |
454 | // funcion ejecutada cuando se cancela el modal | 477 | // funcion ejecutada cuando se cancela el modal |
455 | } | 478 | } |
456 | ); | 479 | ); |
457 | }; | 480 | }; |
458 | 481 | ||
459 | $scope.seleccionarVendedor = function() { | 482 | $scope.seleccionarVendedor = function() { |
460 | var modalInstance = $uibModal.open( | 483 | var modalInstance = $uibModal.open( |
461 | { | 484 | { |
462 | ariaLabelledBy: 'Busqueda de Vendedores', | 485 | ariaLabelledBy: 'Busqueda de Vendedores', |
463 | templateUrl: 'modal-vendedores.html', | 486 | templateUrl: 'modal-vendedores.html', |
464 | controller: 'modalVendedoresCtrl', | 487 | controller: 'modalVendedoresCtrl', |
465 | size: 'lg' | 488 | size: 'lg' |
466 | } | 489 | } |
467 | ); | 490 | ); |
468 | modalInstance.result.then( | 491 | modalInstance.result.then( |
469 | function(vendedor) { | 492 | function(vendedor) { |
470 | addCabecera('Vendedor:', vendedor.NomVen); | 493 | addCabecera('Vendedor:', vendedor.NomVen); |
471 | $scope.remito.vendedor.codigo = vendedor.CodVen; | 494 | $scope.remito.idVendedor = vendedor.CodVen; |
472 | }, function() { | 495 | }, function() { |
473 | 496 | ||
474 | } | 497 | } |
475 | ); | 498 | ); |
476 | }; | 499 | }; |
477 | 500 | ||
478 | $scope.seleccionarProveedor = function() { | 501 | $scope.seleccionarProveedor = function() { |
479 | var modalInstance = $uibModal.open( | 502 | var modalInstance = $uibModal.open( |
480 | { | 503 | { |
481 | ariaLabelledBy: 'Busqueda de Proveedor', | 504 | ariaLabelledBy: 'Busqueda de Proveedor', |
482 | templateUrl: 'modal-proveedor.html', | 505 | templateUrl: 'modal-proveedor.html', |
483 | controller: 'focaModalProveedorCtrl', | 506 | controller: 'focaModalProveedorCtrl', |
484 | size: 'lg', | 507 | size: 'lg', |
485 | resolve: { | 508 | resolve: { |
486 | transportista: function() { | 509 | transportista: function() { |
487 | return false; | 510 | return false; |
488 | } | 511 | } |
489 | } | 512 | } |
490 | } | 513 | } |
491 | ); | 514 | ); |
492 | modalInstance.result.then( | 515 | modalInstance.result.then( |
493 | function(proveedor) { | 516 | function(proveedor) { |
494 | $scope.remito.proveedor.codigo = proveedor.COD; | 517 | $scope.remito.idProveedor = proveedor.COD; |
495 | addCabecera('Proveedor:', proveedor.NOM); | 518 | addCabecera('Proveedor:', proveedor.NOM); |
496 | }, function() { | 519 | }, function() { |
497 | 520 | ||
498 | } | 521 | } |
499 | ); | 522 | ); |
500 | }; | 523 | }; |
501 | 524 | ||
502 | $scope.seleccionarCliente = function() { | 525 | $scope.seleccionarCliente = function() { |
503 | 526 | ||
504 | var modalInstance = $uibModal.open( | 527 | var modalInstance = $uibModal.open( |
505 | { | 528 | { |
506 | ariaLabelledBy: 'Busqueda de Cliente', | 529 | ariaLabelledBy: 'Busqueda de Cliente', |
507 | templateUrl: 'foca-busqueda-cliente-modal.html', | 530 | templateUrl: 'foca-busqueda-cliente-modal.html', |
508 | controller: 'focaBusquedaClienteModalController', | 531 | controller: 'focaBusquedaClienteModalController', |
509 | size: 'lg' | 532 | size: 'lg' |
510 | } | 533 | } |
511 | ); | 534 | ); |
512 | modalInstance.result.then( | 535 | modalInstance.result.then( |
513 | function(cliente) { | 536 | function(cliente) { |
514 | $scope.abrirModalDomicilios(cliente); | 537 | $scope.abrirModalDomicilios(cliente); |
515 | }, function() { | 538 | }, function() { |
516 | 539 | ||
517 | } | 540 | } |
518 | ); | 541 | ); |
519 | }; | 542 | }; |
520 | 543 | ||
521 | $scope.abrirModalDomicilios = function(cliente) { | 544 | $scope.abrirModalDomicilios = function(cliente) { |
522 | var modalInstanceDomicilio = $uibModal.open( | 545 | var modalInstanceDomicilio = $uibModal.open( |
523 | { | 546 | { |
524 | ariaLabelledBy: 'Busqueda de Domicilios', | 547 | ariaLabelledBy: 'Busqueda de Domicilios', |
525 | templateUrl: 'modal-domicilio.html', | 548 | templateUrl: 'modal-domicilio.html', |
526 | controller: 'focaModalDomicilioController', | 549 | controller: 'focaModalDomicilioController', |
527 | resolve: { idCliente: function() { return cliente.cod; }}, | 550 | resolve: { idCliente: function() { return cliente.cod; }}, |
528 | size: 'lg', | 551 | size: 'lg', |
529 | } | 552 | } |
530 | ); | 553 | ); |
531 | modalInstanceDomicilio.result.then( | 554 | modalInstanceDomicilio.result.then( |
532 | function(domicilio) { | 555 | function(domicilio) { |
533 | $scope.remito.domicilio.id = domicilio.nivel2; | 556 | //$scope.remito.domicilio.id = domicilio.nivel2; |
534 | $scope.remito.cliente = cliente; | 557 | $scope.remito.cliente = { |
558 | COD: cliente.cod, | ||
559 | CUIT: cliente.cuit, | ||
560 | NOM: cliente.nom | ||
561 | }; | ||
535 | 562 | ||
536 | addCabecera('Cliente:', cliente.nom); | 563 | addCabecera('Cliente:', cliente.nom); |
537 | addCabecera('Domicilio:', domicilio.dom); | 564 | var domicilioStamp = |
565 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | ||
566 | domicilio.Localidad + ', ' + domicilio.Provincia; | ||
567 | $scope.remito.domicilioStamp = domicilioStamp; | ||
568 | addCabecera('Domicilio:', domicilioStamp); | ||
538 | }, function() { | 569 | }, function() { |
539 | $scope.seleccionarCliente(); | 570 | $scope.seleccionarCliente(); |
540 | return; | 571 | return; |
541 | } | 572 | } |
542 | ); | 573 | ); |
543 | }; | 574 | }; |
544 | 575 | ||
545 | $scope.mostrarFichaCliente = function() { | 576 | $scope.mostrarFichaCliente = function() { |
546 | $uibModal.open( | 577 | $uibModal.open( |
547 | { | 578 | { |
548 | ariaLabelledBy: 'Datos del Cliente', | 579 | ariaLabelledBy: 'Datos del Cliente', |
549 | templateUrl: 'foca-crear-remito-ficha-cliente.html', | 580 | templateUrl: 'foca-crear-remito-ficha-cliente.html', |
550 | controller: 'focaCrearRemitoFichaClienteController', | 581 | controller: 'focaCrearRemitoFichaClienteController', |
551 | size: 'lg' | 582 | size: 'lg' |
552 | } | 583 | } |
553 | ); | 584 | ); |
554 | }; | 585 | }; |
555 | 586 | ||
556 | $scope.getTotal = function() { | 587 | $scope.getTotal = function() { |
557 | var total = 0; | 588 | var total = 0; |
558 | var arrayTempArticulos = $scope.articulosTabla; | 589 | var arrayTempArticulos = $scope.articulosTabla; |
559 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 590 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
560 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 591 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
561 | } | 592 | } |
562 | return parseFloat(total.toFixed(2)); | 593 | return parseFloat(total.toFixed(2)); |
563 | }; | 594 | }; |
564 | 595 | ||
565 | $scope.getSubTotal = function() { | 596 | $scope.getSubTotal = function() { |
566 | if($scope.articuloACargar) { | 597 | if($scope.articuloACargar) { |
567 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 598 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
568 | } | 599 | } |
569 | }; | 600 | }; |
570 | 601 | ||
571 | $scope.abrirModalListaPrecio = function() { | 602 | $scope.abrirModalListaPrecio = function() { |
572 | var modalInstance = $uibModal.open( | 603 | var modalInstance = $uibModal.open( |
573 | { | 604 | { |
574 | ariaLabelledBy: 'Busqueda de Precio Condición', | 605 | ariaLabelledBy: 'Busqueda de Precio Condición', |
575 | templateUrl: 'modal-precio-condicion.html', | 606 | templateUrl: 'modal-precio-condicion.html', |
576 | controller: 'focaModalPrecioCondicionController', | 607 | controller: 'focaModalPrecioCondicionController', |
577 | size: 'lg' | 608 | size: 'lg' |
578 | } | 609 | } |
579 | ); | 610 | ); |
580 | modalInstance.result.then( | 611 | modalInstance.result.then( |
581 | function(precioCondicion) { | 612 | function(precioCondicion) { |
582 | var cabecera = ''; | 613 | var cabecera = ''; |
583 | var plazosConcat = ''; | 614 | var plazosConcat = ''; |
584 | if(!Array.isArray(precioCondicion)) { | 615 | if(!Array.isArray(precioCondicion)) { |
585 | $scope.remito.idPrecioCondicion = precioCondicion.id; | 616 | $scope.remito.idPrecioCondicion = precioCondicion.id; |
586 | $scope.plazosPagos = precioCondicion.plazoPago; | 617 | $scope.plazosPagos = precioCondicion.plazoPago; |
587 | $scope.idLista = precioCondicion.idListaPrecio; | 618 | $scope.idLista = precioCondicion.idListaPrecio; |
588 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 619 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
589 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 620 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
590 | } | 621 | } |
591 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 622 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
592 | } else { //Cuando se ingresan los plazos manualmente | 623 | } else { //Cuando se ingresan los plazos manualmente |
593 | $scope.remito.idPrecioCondicion = 0; | 624 | $scope.remito.idPrecioCondicion = 0; |
594 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 625 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
595 | $scope.plazosPagos = precioCondicion; | 626 | $scope.plazosPagos = precioCondicion; |
596 | for(var j = 0; j < precioCondicion.length; j++) { | 627 | for(var j = 0; j < precioCondicion.length; j++) { |
597 | plazosConcat += precioCondicion[j].dias + ' '; | 628 | plazosConcat += precioCondicion[j].dias + ' '; |
598 | } | 629 | } |
599 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 630 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
600 | } | 631 | } |
601 | $scope.articulosTabla = []; | 632 | $scope.articulosTabla = []; |
602 | addCabecera('Precios y condiciones:', cabecera); | 633 | addCabecera('Precios y condiciones:', cabecera); |
603 | }, function() { | 634 | }, function() { |
604 | 635 | ||
605 | } | 636 | } |
606 | ); | 637 | ); |
607 | }; | 638 | }; |
608 | 639 | ||
609 | $scope.abrirModalFlete = function() { | 640 | $scope.abrirModalFlete = function() { |
610 | var modalInstance = $uibModal.open( | 641 | var modalInstance = $uibModal.open( |
611 | { | 642 | { |
612 | ariaLabelledBy: 'Busqueda de Flete', | 643 | ariaLabelledBy: 'Busqueda de Flete', |
613 | templateUrl: 'modal-flete.html', | 644 | templateUrl: 'modal-flete.html', |
614 | controller: 'focaModalFleteController', | 645 | controller: 'focaModalFleteController', |
615 | size: 'lg', | 646 | size: 'lg', |
616 | resolve: { | 647 | resolve: { |
617 | parametrosFlete: | 648 | parametrosFlete: |
618 | function() { | 649 | function() { |
619 | return { | 650 | return { |
620 | flete: $scope.remito.flete ? '1' : | 651 | flete: $scope.remito.flete ? '1' : |
621 | ($scope.remito.fob ? 'FOB' : | 652 | ($scope.remito.fob ? 'FOB' : |
622 | ($scope.remito.flete === undefined ? null : '0')), | 653 | ($scope.remito.flete === undefined ? null : '0')), |
623 | bomba: $scope.remito.bomba ? '1' : | 654 | bomba: $scope.remito.bomba ? '1' : |
624 | ($scope.remito.bomba === undefined ? null : '0'), | 655 | ($scope.remito.bomba === undefined ? null : '0'), |
625 | kilometros: $scope.remito.kilometros | 656 | kilometros: $scope.remito.kilometros |
626 | }; | 657 | }; |
627 | } | 658 | } |
628 | } | 659 | } |
629 | } | 660 | } |
630 | ); | 661 | ); |
631 | modalInstance.result.then( | 662 | modalInstance.result.then( |
632 | function(datos) { | 663 | function(datos) { |
633 | $scope.remito.flete = datos.flete; | 664 | $scope.remito.flete = datos.flete; |
634 | $scope.remito.fob = datos.FOB; | 665 | $scope.remito.fob = datos.FOB; |
635 | $scope.remito.bomba = datos.bomba; | 666 | $scope.remito.bomba = datos.bomba; |
636 | $scope.remito.kilometros = datos.kilometros; | 667 | $scope.remito.kilometros = datos.kilometros; |
637 | 668 | ||
638 | addCabecera('Flete:', datos.flete ? 'Si' : | 669 | addCabecera('Flete:', datos.flete ? 'Si' : |
639 | ($scope.remito.fob ? 'FOB' : 'No')); | 670 | ($scope.remito.fob ? 'FOB' : 'No')); |
640 | if(datos.flete) { | 671 | if(datos.flete) { |
641 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | 672 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); |
642 | addCabecera('Kilometros:', datos.kilometros); | 673 | addCabecera('Kilometros:', datos.kilometros); |
643 | } else { | 674 | } else { |
644 | removeCabecera('Bomba:'); | 675 | removeCabecera('Bomba:'); |
645 | removeCabecera('Kilometros:'); | 676 | removeCabecera('Kilometros:'); |
646 | $scope.remito.fob = false; | 677 | $scope.remito.fob = false; |
647 | $scope.remito.bomba = false; | 678 | $scope.remito.bomba = false; |
648 | $scope.remito.kilometros = null; | 679 | $scope.remito.kilometros = null; |
649 | } | 680 | } |
650 | }, function() { | 681 | }, function() { |
651 | 682 | ||
652 | } | 683 | } |
653 | ); | 684 | ); |
654 | }; | 685 | }; |
655 | 686 | ||
656 | $scope.abrirModalMoneda = function() { | 687 | $scope.abrirModalMoneda = function() { |
657 | var modalInstance = $uibModal.open( | 688 | var modalInstance = $uibModal.open( |
658 | { | 689 | { |
659 | ariaLabelledBy: 'Busqueda de Moneda', | 690 | ariaLabelledBy: 'Busqueda de Moneda', |
660 | templateUrl: 'modal-moneda.html', | 691 | templateUrl: 'modal-moneda.html', |
661 | controller: 'focaModalMonedaController', | 692 | controller: 'focaModalMonedaController', |
662 | size: 'lg' | 693 | size: 'lg' |
663 | } | 694 | } |
664 | ); | 695 | ); |
665 | modalInstance.result.then( | 696 | modalInstance.result.then( |
666 | function(moneda) { | 697 | function(moneda) { |
667 | $scope.abrirModalCotizacion(moneda); | 698 | $scope.abrirModalCotizacion(moneda); |
668 | }, function() { | 699 | }, function() { |
669 | 700 | ||
670 | } | 701 | } |
671 | ); | 702 | ); |
672 | }; | 703 | }; |
673 | 704 | ||
674 | $scope.abrirModalCotizacion = function(moneda) { | 705 | $scope.abrirModalCotizacion = function(moneda) { |
675 | var modalInstance = $uibModal.open( | 706 | var modalInstance = $uibModal.open( |
676 | { | 707 | { |
677 | ariaLabelledBy: 'Busqueda de Cotización', | 708 | ariaLabelledBy: 'Busqueda de Cotización', |
678 | templateUrl: 'modal-cotizacion.html', | 709 | templateUrl: 'modal-cotizacion.html', |
679 | controller: 'focaModalCotizacionController', | 710 | controller: 'focaModalCotizacionController', |
680 | size: 'lg', | 711 | size: 'lg', |
681 | resolve: {idMoneda: function() {return moneda.ID;}} | 712 | resolve: {idMoneda: function() {return moneda.ID;}} |
682 | } | 713 | } |
683 | ); | 714 | ); |
684 | modalInstance.result.then( | 715 | modalInstance.result.then( |
685 | function(cotizacion) { | 716 | function(cotizacion) { |
686 | var articulosTablaTemp = $scope.articulosTabla; | 717 | var articulosTablaTemp = $scope.articulosTabla; |
687 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 718 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
688 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 719 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
689 | $scope.remito.cotizacion.COTIZACION; | 720 | $scope.remito.cotizacion.COTIZACION; |
690 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 721 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
691 | cotizacion.COTIZACION; | 722 | cotizacion.COTIZACION; |
692 | } | 723 | } |
693 | $scope.articulosTabla = articulosTablaTemp; | 724 | $scope.articulosTabla = articulosTablaTemp; |
694 | $scope.remito.moneda = { | 725 | $scope.remito.moneda = { |
695 | id: moneda.ID, | 726 | id: moneda.ID, |
696 | detalle: moneda.DETALLE, | 727 | detalle: moneda.DETALLE, |
697 | simbolo: moneda.SIMBOLO | 728 | simbolo: moneda.SIMBOLO |
698 | }; | 729 | }; |
699 | $scope.remito.cotizacion = { | 730 | $scope.remito.cotizacion = { |
700 | ID: cotizacion.ID, | 731 | ID: cotizacion.ID, |
701 | COTIZACION: cotizacion.COTIZACION, | 732 | COTIZACION: cotizacion.COTIZACION, |
702 | FECHA: cotizacion.FECHA | 733 | FECHA: cotizacion.FECHA |
703 | }; | 734 | }; |
704 | addCabecera('Moneda:', moneda.DETALLE); | 735 | addCabecera('Moneda:', moneda.DETALLE); |
705 | addCabecera( | 736 | addCabecera( |
706 | 'Fecha cotizacion:', | 737 | 'Fecha cotizacion:', |
707 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 738 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
708 | ); | 739 | ); |
709 | addCabecera('Cotizacion:', cotizacion.COTIZACION); | 740 | addCabecera('Cotizacion:', cotizacion.COTIZACION); |
710 | }, function() { | 741 | }, function() { |
711 | 742 | ||
712 | } | 743 | } |
713 | ); | 744 | ); |
714 | }; | 745 | }; |
715 | 746 | ||
716 | $scope.agregarATabla = function(key) { | 747 | $scope.agregarATabla = function(key) { |
717 | if(key === 13) { | 748 | if(key === 13) { |
718 | if($scope.articuloACargar.cantidad === undefined || | 749 | if($scope.articuloACargar.cantidad === undefined || |
719 | $scope.articuloACargar.cantidad === 0 || | 750 | $scope.articuloACargar.cantidad === 0 || |
720 | $scope.articuloACargar.cantidad === null ) { | 751 | $scope.articuloACargar.cantidad === null ) { |
721 | focaModalService.alert('El valor debe ser al menos 1'); | 752 | focaModalService.alert('El valor debe ser al menos 1'); |
722 | return; | 753 | return; |
723 | } | 754 | } |
724 | delete $scope.articuloACargar.sectorCodigo; | 755 | delete $scope.articuloACargar.sectorCodigo; |
725 | $scope.articulosTabla.push($scope.articuloACargar); | 756 | $scope.articulosTabla.push($scope.articuloACargar); |
726 | $scope.cargando = true; | 757 | $scope.cargando = true; |
727 | } | 758 | } |
728 | }; | 759 | }; |
729 | 760 | ||
730 | $scope.quitarArticulo = function(key) { | 761 | $scope.quitarArticulo = function(key) { |
731 | $scope.articulosTabla.splice(key, 1); | 762 | $scope.articulosTabla.splice(key, 1); |
732 | }; | 763 | }; |
733 | 764 | ||
734 | $scope.editarArticulo = function(key, articulo) { | 765 | $scope.editarArticulo = function(key, articulo) { |
735 | if(key === 13) { | 766 | if(key === 13) { |
736 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 767 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
737 | articulo.cantidad === undefined) { | 768 | articulo.cantidad === undefined) { |
738 | focaModalService.alert('El valor debe ser al menos 1'); | 769 | focaModalService.alert('El valor debe ser al menos 1'); |
739 | return; | 770 | return; |
740 | } | 771 | } |
741 | articulo.editCantidad = false; | 772 | articulo.editCantidad = false; |
742 | articulo.editPrecio = false; | 773 | articulo.editPrecio = false; |
743 | } | 774 | } |
744 | }; | 775 | }; |
745 | 776 | ||
746 | $scope.cambioEdit = function(articulo, propiedad) { | 777 | $scope.cambioEdit = function(articulo, propiedad) { |
747 | if(propiedad === 'cantidad') { | 778 | if(propiedad === 'cantidad') { |
748 | articulo.editCantidad = true; | 779 | articulo.editCantidad = true; |
749 | } else if(propiedad === 'precio') { | 780 | } else if(propiedad === 'precio') { |
750 | articulo.editPrecio = true; | 781 | articulo.editPrecio = true; |
751 | } | 782 | } |
752 | }; | 783 | }; |
753 | 784 | ||
754 | $scope.limpiarFlete = function() { | 785 | $scope.limpiarFlete = function() { |
755 | $scope.remito.fleteNombre = ''; | 786 | $scope.remito.fleteNombre = ''; |
756 | $scope.remito.chofer = ''; | 787 | $scope.remito.chofer = ''; |
757 | $scope.remito.vehiculo = ''; | 788 | $scope.remito.vehiculo = ''; |
758 | $scope.remito.kilometros = ''; | 789 | $scope.remito.kilometros = ''; |
759 | $scope.remito.costoUnitarioKmFlete = ''; | 790 | $scope.remito.costoUnitarioKmFlete = ''; |
760 | $scope.choferes = ''; | 791 | $scope.choferes = ''; |
761 | $scope.vehiculos = ''; | 792 | $scope.vehiculos = ''; |
762 | }; | 793 | }; |
763 | 794 | ||
764 | $scope.limpiarPantalla = function() { | 795 | $scope.limpiarPantalla = function() { |
765 | $scope.limpiarFlete(); | 796 | $scope.limpiarFlete(); |
766 | $scope.remito.flete = '0'; | 797 | $scope.remito.flete = '0'; |
767 | $scope.remito.bomba = '0'; | 798 | $scope.remito.bomba = '0'; |
768 | $scope.remito.precioCondicion = ''; | 799 | $scope.remito.precioCondicion = ''; |
769 | $scope.articulosTabla = []; | 800 | $scope.articulosTabla = []; |
770 | $scope.remito.vendedor.nombre = ''; | 801 | $scope.remito.vendedor.nombre = ''; |
771 | $scope.remito.cliente = {nombre: ''}; | 802 | $scope.remito.cliente = {nombre: ''}; |
772 | $scope.remito.domicilio = {dom: ''}; | 803 | $scope.remito.domicilio = {dom: ''}; |
773 | $scope.domiciliosCliente = []; | 804 | $scope.domiciliosCliente = []; |
774 | }; | 805 | }; |
775 | 806 | ||
776 | $scope.resetFilter = function() { | 807 | $scope.resetFilter = function() { |
777 | $scope.articuloACargar = {}; | 808 | $scope.articuloACargar = {}; |
778 | $scope.cargando = true; | 809 | $scope.cargando = true; |
779 | }; | 810 | }; |
780 | 811 | ||
781 | $scope.selectFocus = function($event) { | 812 | $scope.selectFocus = function($event) { |
782 | $event.target.select(); | 813 | $event.target.select(); |
783 | }; | 814 | }; |
784 | 815 | ||
785 | $scope.salir = function() { | 816 | $scope.salir = function() { |
786 | $location.path('/'); | 817 | $location.path('/'); |
787 | }; | 818 | }; |
788 | function addArrayCabecera(array) { | 819 | function addArrayCabecera(array) { |
789 | for(var i = 0; i < array.length; i++) { | 820 | for(var i = 0; i < array.length; i++) { |
790 | addCabecera(array[i].label, array[i].valor); | 821 | addCabecera(array[i].label, array[i].valor); |
791 | } | 822 | } |
792 | } | 823 | } |
793 | 824 | ||
794 | function addCabecera(label, valor) { | 825 | function addCabecera(label, valor) { |
795 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 826 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
796 | if(propiedad.length === 1) { | 827 | if(propiedad.length === 1) { |
797 | propiedad[0].valor = valor; | 828 | propiedad[0].valor = valor; |
798 | } else { | 829 | } else { |
799 | $scope.cabecera.push({label: label, valor: valor}); | 830 | $scope.cabecera.push({label: label, valor: valor}); |
800 | } | 831 | } |
801 | } | 832 | } |
802 | 833 | ||
803 | function removeCabecera(label) { | 834 | function removeCabecera(label) { |
804 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 835 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
805 | if(propiedad.length === 1) { | 836 | if(propiedad.length === 1) { |
806 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 837 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
807 | } | 838 | } |
808 | } | 839 | } |
809 | 840 | ||
810 | function rellenar(relleno, longitud) { | 841 | function rellenar(relleno, longitud) { |
811 | relleno = '' + relleno; | 842 | relleno = '' + relleno; |
812 | while (relleno.length < longitud) { | 843 | while (relleno.length < longitud) { |
813 | relleno = '0' + relleno; | 844 | relleno = '0' + relleno; |
814 | } | 845 | } |
815 | 846 | ||
816 | return relleno; | 847 | return relleno; |
817 | } | 848 | } |
818 | } | 849 | } |
819 | ] | 850 | ] |
820 | ) | 851 | ) |
821 | .controller('remitoListaCtrl', [ | 852 | .controller('remitoListaCtrl', [ |
822 | '$scope', | 853 | '$scope', |
823 | 'crearRemitoService', | 854 | 'crearRemitoService', |
824 | '$location', | 855 | '$location', |
825 | function($scope, crearRemitoService, $location) { | 856 | function($scope, crearRemitoService, $location) { |
826 | crearRemitoService.obtenerRemito().then(function(datos) { | 857 | crearRemitoService.obtenerRemito().then(function(datos) { |
827 | $scope.remitos = datos.data; | 858 | $scope.remitos = datos.data; |
828 | }); | 859 | }); |
829 | $scope.editar = function(remito) { | 860 | $scope.editar = function(remito) { |
830 | crearRemitoService.setRemito(remito); | 861 | crearRemitoService.setRemito(remito); |
831 | $location.path('/venta-nota-remito/abm/'); | 862 | $location.path('/venta-nota-remito/abm/'); |
832 | }; | 863 | }; |
833 | $scope.crearRemito = function() { | 864 | $scope.crearRemito = function() { |
834 | crearRemitoService.clearRemito(); | 865 | crearRemitoService.clearRemito(); |
835 | $location.path('/venta-nota-remito/abm/'); | 866 | $location.path('/venta-nota-remito/abm/'); |
836 | }; | 867 | }; |
837 | } | 868 | } |
838 | ]) | 869 | ]) |
839 | .controller('focaCrearRemitoFichaClienteController', [ | 870 | .controller('focaCrearRemitoFichaClienteController', [ |
840 | '$scope', | 871 | '$scope', |
841 | 'crearRemitoService', | 872 | 'crearRemitoService', |
842 | '$location', | 873 | '$location', |
843 | function($scope, crearRemitoService, $location) { | 874 | function($scope, crearRemitoService, $location) { |
844 | crearRemitoService.obtenerRemito().then(function(datos) { | 875 | crearRemitoService.obtenerRemito().then(function(datos) { |
845 | $scope.remitos = datos.data; | 876 | $scope.remitos = datos.data; |
846 | }); | 877 | }); |
847 | $scope.editar = function(remito) { | 878 | $scope.editar = function(remito) { |
848 | crearRemitoService.setRemito(remito); | 879 | crearRemitoService.setRemito(remito); |
849 | $location.path('/venta-nota-remito/abm/'); | 880 | $location.path('/venta-nota-remito/abm/'); |
850 | }; | 881 | }; |
851 | $scope.crearRemito = function() { | 882 | $scope.crearRemito = function() { |
852 | crearRemitoService.clearRemito(); | 883 | crearRemitoService.clearRemito(); |
853 | $location.path('/venta-nota-remito/abm/'); | 884 | $location.path('/venta-nota-remito/abm/'); |
854 | }; | 885 | }; |
855 | } | 886 | } |
856 | ]); | 887 | ]); |
857 | 888 |