Commit 63a10250d34bd5e9ee3a4043b5c0008e7f4b011c
1 parent
dc9232fb85
Exists in
master
Arreglo de busqueda de notas
Showing
1 changed file
with
3 additions
and
3 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaCrearRemito').controller('remitoController', | 1 | angular.module('focaCrearRemito').controller('remitoController', |
2 | [ | 2 | [ |
3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout', |
4 | 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', | 4 | 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', |
5 | '$localStorage', | 5 | '$localStorage', |
6 | function ( | 6 | function ( |
7 | $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService, | 7 | $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService, |
8 | remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) { | 8 | remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) { |
9 | config(); | 9 | config(); |
10 | 10 | ||
11 | var cotizacionPArgentino = {}; | 11 | var cotizacionPArgentino = {}; |
12 | 12 | ||
13 | function config() { | 13 | function config() { |
14 | $scope.tmpCantidad = Number; | 14 | $scope.tmpCantidad = Number; |
15 | $scope.tmpPrecio = Number; | 15 | $scope.tmpPrecio = Number; |
16 | $scope.botonera = crearRemitoService.getBotonera(); | 16 | $scope.botonera = crearRemitoService.getBotonera(); |
17 | $scope.isNumber = angular.isNumber; | 17 | $scope.isNumber = angular.isNumber; |
18 | $scope.datepickerAbierto = false; | 18 | $scope.datepickerAbierto = false; |
19 | $scope.show = false; | 19 | $scope.show = false; |
20 | $scope.cargando = true; | 20 | $scope.cargando = true; |
21 | $scope.now = new Date(); | 21 | $scope.now = new Date(); |
22 | $scope.puntoVenta = rellenar(0, 4); | 22 | $scope.puntoVenta = rellenar(0, 4); |
23 | $scope.comprobante = rellenar(0, 8); | 23 | $scope.comprobante = rellenar(0, 8); |
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 | crearRemitoService.getParametros().then(function (res) { | 29 | crearRemitoService.getParametros().then(function (res) { |
30 | var parametros = JSON.parse(res.data[0].jsonText); | 30 | var parametros = JSON.parse(res.data[0].jsonText); |
31 | if ($localStorage.remito) { | 31 | if ($localStorage.remito) { |
32 | $timeout(function () { getLSRemito(); }); | 32 | $timeout(function () { getLSRemito(); }); |
33 | } else { | 33 | } else { |
34 | for (var property in parametros) { | 34 | for (var property in parametros) { |
35 | $scope.remito[property] = parametros[property]; | 35 | $scope.remito[property] = parametros[property]; |
36 | $scope.inicial[property] = parametros[property]; | 36 | $scope.inicial[property] = parametros[property]; |
37 | } | 37 | } |
38 | setearRemito($scope.remito); | 38 | setearRemito($scope.remito); |
39 | } | 39 | } |
40 | }); | 40 | }); |
41 | 41 | ||
42 | //SETEO BOTONERA LATERAL | 42 | //SETEO BOTONERA LATERAL |
43 | $timeout(function () { | 43 | $timeout(function () { |
44 | focaBotoneraLateralService.showSalir(false); | 44 | focaBotoneraLateralService.showSalir(false); |
45 | focaBotoneraLateralService.showPausar(true); | 45 | focaBotoneraLateralService.showPausar(true); |
46 | focaBotoneraLateralService.showGuardar(true, $scope.crearRemito); | 46 | focaBotoneraLateralService.showGuardar(true, $scope.crearRemito); |
47 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 47 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
48 | }); | 48 | }); |
49 | 49 | ||
50 | init(); | 50 | init(); |
51 | 51 | ||
52 | } | 52 | } |
53 | 53 | ||
54 | function init() { | 54 | function init() { |
55 | $scope.$broadcast('cleanCabecera'); | 55 | $scope.$broadcast('cleanCabecera'); |
56 | $scope.remito = { | 56 | $scope.remito = { |
57 | id: 0, | 57 | id: 0, |
58 | estado: 0, | 58 | estado: 0, |
59 | vendedor: {}, | 59 | vendedor: {}, |
60 | cliente: {}, | 60 | cliente: {}, |
61 | proveedor: {}, | 61 | proveedor: {}, |
62 | domicilio: { dom: '' }, | 62 | domicilio: { dom: '' }, |
63 | moneda: {}, | 63 | moneda: {}, |
64 | cotizacion: $scope.cotizacionPorDefecto || {}, | 64 | cotizacion: $scope.cotizacionPorDefecto || {}, |
65 | articulosRemito: [], | 65 | articulosRemito: [], |
66 | remitoPuntoDescarga: [] | 66 | remitoPuntoDescarga: [] |
67 | }; | 67 | }; |
68 | 68 | ||
69 | $scope.notaPedido = { | 69 | $scope.notaPedido = { |
70 | id: 0 | 70 | id: 0 |
71 | }; | 71 | }; |
72 | 72 | ||
73 | $scope.remito.articulosRemito = []; | 73 | $scope.remito.articulosRemito = []; |
74 | $scope.idLista = undefined; | 74 | $scope.idLista = undefined; |
75 | 75 | ||
76 | crearRemitoService.getNumeroRemito().then( | 76 | crearRemitoService.getNumeroRemito().then( |
77 | function (res) { | 77 | function (res) { |
78 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 78 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
79 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); | 79 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); |
80 | }, | 80 | }, |
81 | function (err) { | 81 | function (err) { |
82 | focaModalService.alert('La terminal no esta configurada correctamente'); | 82 | focaModalService.alert('La terminal no esta configurada correctamente'); |
83 | console.info(err); | 83 | console.info(err); |
84 | } | 84 | } |
85 | ); | 85 | ); |
86 | 86 | ||
87 | $scope.inicial = angular.copy($scope.remito); | 87 | $scope.inicial = angular.copy($scope.remito); |
88 | } | 88 | } |
89 | 89 | ||
90 | $scope.$watch('remito', function (newValue) { | 90 | $scope.$watch('remito', function (newValue) { |
91 | focaBotoneraLateralService.setPausarData({ | 91 | focaBotoneraLateralService.setPausarData({ |
92 | label: 'remito', | 92 | label: 'remito', |
93 | val: newValue | 93 | val: newValue |
94 | }); | 94 | }); |
95 | }, true); | 95 | }, true); |
96 | 96 | ||
97 | $scope.seleccionarNotaPedido = function () { | 97 | $scope.seleccionarNotaPedido = function () { |
98 | if ($scope.remitoIsDirty) { | 98 | if ($scope.remitoIsDirty) { |
99 | focaModalService.confirm('¿Desea continuar? Se perderan los cambios') | 99 | focaModalService.confirm('¿Desea continuar? Se perderan los cambios') |
100 | .then(function () { | 100 | .then(function () { |
101 | $scope.getNotaPedidoModal(); | 101 | $scope.getNotaPedidoModal(); |
102 | }); | 102 | }); |
103 | } else { | 103 | } else { |
104 | $scope.getNotaPedidoModal(); | 104 | $scope.getNotaPedidoModal(); |
105 | } | 105 | } |
106 | }; | 106 | }; |
107 | 107 | ||
108 | $scope.getNotaPedidoModal = function () { | 108 | $scope.getNotaPedidoModal = function () { |
109 | if (varlidarRemitoFacturado()) { | 109 | if (varlidarRemitoFacturado()) { |
110 | var modalInstance = $uibModal.open( | 110 | var modalInstance = $uibModal.open( |
111 | { | 111 | { |
112 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 112 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
113 | templateUrl: 'foca-modal-nota-pedido.html', | 113 | templateUrl: 'foca-modal-nota-pedido.html', |
114 | controller: 'focaModalNotaPedidoController', | 114 | controller: 'focaModalNotaPedidoController', |
115 | size: 'lg', | 115 | size: 'lg', |
116 | resolve: { | 116 | resolve: { |
117 | usadoPor: function () { return 'remito'; }, | 117 | usadoPor: function () { return 'remito'; }, |
118 | idVendedor: function () { return null; } | 118 | idVendedor: function () { return null; } |
119 | } | 119 | } |
120 | } | 120 | } |
121 | ); | 121 | ); |
122 | modalInstance.result.then( | 122 | modalInstance.result.then( |
123 | function (notaPedido) { | 123 | function (notaPedido) { |
124 | //añado cabeceras | 124 | //añado cabeceras |
125 | $scope.remitoIsDirty = true; | 125 | $scope.remitoIsDirty = true; |
126 | $scope.notaPedido = notaPedido; | 126 | $scope.notaPedido = notaPedido; |
127 | $scope.notaPedido.id = notaPedido.id; | ||
128 | $scope.cliente = notaPedido.cliente; | 127 | $scope.cliente = notaPedido.cliente; |
129 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 128 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
130 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 129 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
131 | var puntosDescarga = []; | 130 | var puntosDescarga = []; |
132 | notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedido) { | 131 | notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedido) { |
133 | puntosDescarga.push(notaPedido.puntoDescarga); | 132 | puntosDescarga.push(notaPedido.puntoDescarga); |
134 | }); | 133 | }); |
135 | var cabeceras = [ | 134 | var cabeceras = [ |
136 | { | 135 | { |
137 | label: 'Moneda:', | 136 | label: 'Moneda:', |
138 | valor: notaPedido.cotizacion.moneda.DETALLE | 137 | valor: notaPedido.cotizacion.moneda.DETALLE |
139 | }, | 138 | }, |
140 | { | 139 | { |
141 | label: 'Fecha cotizacion:', | 140 | label: 'Fecha cotizacion:', |
142 | valor: $filter('date')(notaPedido.cotizacion.FECHA, | 141 | valor: $filter('date')(notaPedido.cotizacion.FECHA, |
143 | 'dd/MM/yyyy') | 142 | 'dd/MM/yyyy') |
144 | }, | 143 | }, |
145 | { | 144 | { |
146 | label: 'Cotizacion:', | 145 | label: 'Cotizacion:', |
147 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, | 146 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, |
148 | '2') | 147 | '2') |
149 | }, | 148 | }, |
150 | { | 149 | { |
151 | label: 'Cliente:', | 150 | label: 'Cliente:', |
152 | valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + | 151 | valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + |
153 | ' - ' + notaPedido.cliente.NOM | 152 | ' - ' + notaPedido.cliente.NOM |
154 | }, | 153 | }, |
155 | { | 154 | { |
156 | label: 'Domicilio:', | 155 | label: 'Domicilio:', |
157 | valor: notaPedido.domicilioStamp | 156 | valor: notaPedido.domicilioStamp |
158 | }, | 157 | }, |
159 | { | 158 | { |
160 | label: 'Vendedor:', | 159 | label: 'Vendedor:', |
161 | valor: $filter('rellenarDigitos')( | 160 | valor: $filter('rellenarDigitos')( |
162 | notaPedido.vendedor.NUM, 3 | 161 | notaPedido.vendedor.NUM, 3 |
163 | ) + ' - ' + notaPedido.vendedor.NOM | 162 | ) + ' - ' + notaPedido.vendedor.NOM |
164 | }, | 163 | }, |
165 | { | 164 | { |
166 | label: 'Proveedor:', | 165 | label: 'Proveedor:', |
167 | valor: $filter('rellenarDigitos') | 166 | valor: $filter('rellenarDigitos') |
168 | (notaPedido.proveedor.COD, 5) + ' - ' + | 167 | (notaPedido.proveedor.COD, 5) + ' - ' + |
169 | notaPedido.proveedor.NOM | 168 | notaPedido.proveedor.NOM |
170 | }, | 169 | }, |
171 | { | 170 | { |
172 | label: 'Precios y condiciones:', | 171 | label: 'Precios y condiciones:', |
173 | valor: valorPrecioCondicion() + ' ' + | 172 | valor: valorPrecioCondicion() + ' ' + |
174 | remitoBusinessService | 173 | remitoBusinessService |
175 | .plazoToString(notaPedido.notaPedidoPlazo) | 174 | .plazoToString(notaPedido.notaPedidoPlazo) |
176 | }, | 175 | }, |
177 | { | 176 | { |
178 | label: 'Flete:', | 177 | label: 'Flete:', |
179 | valor: notaPedido.fob === 1 ? 'FOB' : ( | 178 | valor: notaPedido.fob === 1 ? 'FOB' : ( |
180 | notaPedido.flete === 1 ? 'Si' : 'No') | 179 | notaPedido.flete === 1 ? 'Si' : 'No') |
181 | }, | 180 | }, |
182 | { | 181 | { |
183 | label: 'Puntos de descarga: ', | 182 | label: 'Puntos de descarga: ', |
184 | valor: $filter('rellenarDigitos')( | 183 | valor: $filter('rellenarDigitos')( |
185 | getCabeceraPuntoDescarga(puntosDescarga)) | 184 | getCabeceraPuntoDescarga(puntosDescarga)) |
186 | } | 185 | } |
187 | ]; | 186 | ]; |
188 | 187 | ||
189 | // Seteo checked en cabeceras | 188 | // Seteo checked en cabeceras |
190 | $filter('filter')($scope.botonera, | 189 | $filter('filter')($scope.botonera, |
191 | { label: 'Cliente' })[0].checked = true; | 190 | { label: 'Cliente' })[0].checked = true; |
192 | $filter('filter')($scope.botonera, | 191 | $filter('filter')($scope.botonera, |
193 | { label: 'Proveedor' })[0].checked = true; | 192 | { label: 'Proveedor' })[0].checked = true; |
194 | $filter('filter')($scope.botonera, | 193 | $filter('filter')($scope.botonera, |
195 | { label: 'Moneda' })[0].checked = true; | 194 | { label: 'Moneda' })[0].checked = true; |
196 | $filter('filter')($scope.botonera, | 195 | $filter('filter')($scope.botonera, |
197 | { label: 'Nota pedido' })[0].checked = true; | 196 | { label: 'Nota pedido' })[0].checked = true; |
198 | $filter('filter')($scope.botonera, | 197 | $filter('filter')($scope.botonera, |
199 | { label: 'Precios y condiciones' })[0].checked = true; | 198 | { label: 'Precios y condiciones' })[0].checked = true; |
200 | $filter('filter')($scope.botonera, | 199 | $filter('filter')($scope.botonera, |
201 | { label: 'Domicilio de Entrega' })[0].checked = true; | 200 | { label: 'Domicilio de Entrega' })[0].checked = true; |
202 | 201 | ||
203 | if (notaPedido.observaciones) { | 202 | if (notaPedido.observaciones) { |
204 | $filter('filter')($scope.botonera, | 203 | $filter('filter')($scope.botonera, |
205 | { label: 'Observaciones' })[0].checked = true; | 204 | { label: 'Observaciones' })[0].checked = true; |
206 | } | 205 | } |
207 | 206 | ||
208 | function valorPrecioCondicion() { | 207 | function valorPrecioCondicion() { |
209 | if (notaPedido.idPrecioCondicion > 0) { | 208 | if (notaPedido.idPrecioCondicion > 0) { |
210 | return notaPedido.precioCondicion.nombre; | 209 | return notaPedido.precioCondicion.nombre; |
211 | } else { | 210 | } else { |
212 | return 'Ingreso Manual'; | 211 | return 'Ingreso Manual'; |
213 | } | 212 | } |
214 | } | 213 | } |
215 | 214 | ||
216 | if (notaPedido.flete === 1) { | 215 | if (notaPedido.flete === 1) { |
217 | var cabeceraBomba = { | 216 | var cabeceraBomba = { |
218 | label: 'Bomba:', | 217 | label: 'Bomba:', |
219 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 218 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
220 | }; | 219 | }; |
221 | if (notaPedido.kilometros) { | 220 | if (notaPedido.kilometros) { |
222 | var cabeceraKilometros = { | 221 | var cabeceraKilometros = { |
223 | label: 'Kilometros:', | 222 | label: 'Kilometros:', |
224 | valor: notaPedido.kilometros | 223 | valor: notaPedido.kilometros |
225 | }; | 224 | }; |
226 | cabeceras.push(cabeceraKilometros); | 225 | cabeceras.push(cabeceraKilometros); |
227 | } | 226 | } |
228 | cabeceras.push(cabeceraBomba); | 227 | cabeceras.push(cabeceraBomba); |
229 | } | 228 | } |
230 | 229 | ||
231 | $scope.remito = notaPedido; | 230 | $scope.remito = angular.copy(notaPedido); |
232 | $scope.remito.id = notaPedido.id; | 231 | $scope.remito.id = 0; |
233 | $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; | 232 | $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; |
234 | $scope.remito.remitoPuntoDescarga = notaPedido.notaPedidoPuntoDescarga; | 233 | $scope.remito.remitoPuntoDescarga = notaPedido.notaPedidoPuntoDescarga; |
235 | 234 | ||
236 | notaPedido.articulosNotaPedido.forEach(function (articulo) { | 235 | notaPedido.articulosNotaPedido.forEach(function (articulo) { |
237 | articulo.id = 0; | 236 | articulo.id = 0; |
238 | articulo.idRemito = 0; | 237 | articulo.idRemito = 0; |
239 | articulo.precio = | 238 | articulo.precio = |
240 | (articulo.precio / notaPedido.cotizacion.VENDEDOR).toFixed(4); | 239 | (articulo.precio / notaPedido.cotizacion.VENDEDOR).toFixed(4); |
241 | }); | 240 | }); |
242 | 241 | ||
243 | $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; | 242 | $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; |
244 | 243 | ||
245 | if (notaPedido.idPrecioCondicion > 0) { | 244 | if (notaPedido.idPrecioCondicion > 0) { |
246 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | 245 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; |
247 | } else { | 246 | } else { |
248 | $scope.idLista = -1; | 247 | $scope.idLista = -1; |
249 | } | 248 | } |
250 | 249 | ||
251 | enableObservaciones(notaPedido.observaciones ? true : false); | 250 | enableObservaciones(notaPedido.observaciones ? true : false); |
252 | addArrayCabecera(cabeceras); | 251 | addArrayCabecera(cabeceras); |
253 | 252 | ||
254 | }, function () { | 253 | }, function () { |
255 | // funcion ejecutada cuando se cancela el modal | 254 | // funcion ejecutada cuando se cancela el modal |
256 | } | 255 | } |
257 | ); | 256 | ); |
258 | } | 257 | } |
259 | }; | 258 | }; |
260 | 259 | ||
261 | $scope.seleccionarRemito = function () { | 260 | $scope.seleccionarRemito = function () { |
262 | if ($scope.remitoIsDirty) { | 261 | if ($scope.remitoIsDirty) { |
263 | focaModalService.confirm('¿Desea continuar? Se perderan los cambios') | 262 | focaModalService.confirm('¿Desea continuar? Se perderan los cambios') |
264 | .then(function () { | 263 | .then(function () { |
265 | $scope.getRemitoModal(); | 264 | $scope.getRemitoModal(); |
266 | }); | 265 | }); |
267 | } else { | 266 | } else { |
268 | $scope.getRemitoModal(); | 267 | $scope.getRemitoModal(); |
269 | } | 268 | } |
270 | }; | 269 | }; |
271 | $scope.getRemitoModal = function () { | 270 | $scope.getRemitoModal = function () { |
272 | var modalInstance = $uibModal.open( | 271 | var modalInstance = $uibModal.open( |
273 | { | 272 | { |
274 | ariaLabelledBy: 'Busqueda de Remito', | 273 | ariaLabelledBy: 'Busqueda de Remito', |
275 | templateUrl: 'foca-modal-remito.html', | 274 | templateUrl: 'foca-modal-remito.html', |
276 | controller: 'focaModalRemitoController', | 275 | controller: 'focaModalRemitoController', |
277 | size: 'lg', | 276 | size: 'lg', |
278 | resolve: { usadoPor: function () { return 'remito'; } } | 277 | resolve: { usadoPor: function () { return 'remito'; } } |
279 | } | 278 | } |
280 | ); | 279 | ); |
281 | modalInstance.result.then( | 280 | modalInstance.result.then( |
282 | setearRemito, function () { | 281 | setearRemito, function () { |
283 | // funcion ejecutada cuando se cancela el modal | 282 | // funcion ejecutada cuando se cancela el modal |
284 | } | 283 | } |
285 | ); | 284 | ); |
286 | }; | 285 | }; |
287 | //validacion por domicilio y por plazo pago | 286 | //validacion por domicilio y por plazo pago |
288 | $scope.crearRemito = function () { | 287 | $scope.crearRemito = function () { |
289 | if (!$scope.remito.vendedor.NUM) { | 288 | if (!$scope.remito.vendedor.NUM) { |
290 | focaModalService.alert('Ingrese Vendedor'); | 289 | focaModalService.alert('Ingrese Vendedor'); |
291 | return; | 290 | return; |
292 | } else if (!$scope.remito.cliente.COD) { | 291 | } else if (!$scope.remito.cliente.COD) { |
293 | focaModalService.alert('Ingrese Cliente'); | 292 | focaModalService.alert('Ingrese Cliente'); |
294 | return; | 293 | return; |
295 | } else if (!$scope.remito.proveedor.COD) { | 294 | } else if (!$scope.remito.proveedor.COD) { |
296 | focaModalService.alert('Ingrese Proveedor'); | 295 | focaModalService.alert('Ingrese Proveedor'); |
297 | return; | 296 | return; |
298 | } else if (!$scope.remito.cotizacion.moneda.id && | 297 | } else if (!$scope.remito.cotizacion.moneda.id && |
299 | !$scope.remito.cotizacion.moneda.ID) { | 298 | !$scope.remito.cotizacion.moneda.ID) { |
300 | focaModalService.alert('Ingrese Moneda'); | 299 | focaModalService.alert('Ingrese Moneda'); |
301 | return; | 300 | return; |
302 | } else if (!$scope.remito.cotizacion.ID) { | 301 | } else if (!$scope.remito.cotizacion.ID) { |
303 | focaModalService.alert('Ingrese Cotización'); | 302 | focaModalService.alert('Ingrese Cotización'); |
304 | return; | 303 | return; |
305 | } else if ($scope.remito.flete === undefined || $scope.remito.flete === null) { | 304 | } else if ($scope.remito.flete === undefined || $scope.remito.flete === null) { |
306 | focaModalService.alert('Ingrese Flete'); | 305 | focaModalService.alert('Ingrese Flete'); |
307 | return; | 306 | return; |
308 | } else if ($scope.articulosFiltro().length === 0) { | 307 | } else if ($scope.articulosFiltro().length === 0) { |
309 | focaModalService.alert('Debe cargar al menos un articulo'); | 308 | focaModalService.alert('Debe cargar al menos un articulo'); |
310 | return; | 309 | return; |
311 | } | 310 | } |
312 | 311 | ||
313 | focaBotoneraLateralService.startGuardar(); | 312 | focaBotoneraLateralService.startGuardar(); |
314 | $scope.saveLoading = true; | 313 | $scope.saveLoading = true; |
315 | var save = { | 314 | var save = { |
316 | remito: { | 315 | remito: { |
317 | id: $scope.remito.id, | 316 | id: $scope.remito.id, |
318 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | 317 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), |
319 | idCliente: $scope.remito.cliente.COD, | 318 | idCliente: $scope.remito.cliente.COD, |
320 | nombreCliente: $scope.remito.cliente.NOM, | 319 | nombreCliente: $scope.remito.cliente.NOM, |
321 | cuitCliente: $scope.remito.cliente.CUIT, | 320 | cuitCliente: $scope.remito.cliente.CUIT, |
322 | total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR, | 321 | total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR, |
323 | numeroNotaPedido: $scope.remito.numeroNotaPedido, | 322 | numeroNotaPedido: $scope.remito.numeroNotaPedido, |
324 | idVendedor: $scope.remito.vendedor.NUM, | 323 | idVendedor: $scope.remito.vendedor.NUM, |
325 | idProveedor: $scope.remito.proveedor.COD, | 324 | idProveedor: $scope.remito.proveedor.COD, |
326 | idDomicilio: $scope.remito.idDomicilio || $scope.remito.domicilio.id, | 325 | idDomicilio: $scope.remito.idDomicilio || $scope.remito.domicilio.id, |
327 | idCotizacion: $scope.remito.cotizacion.ID, | 326 | idCotizacion: $scope.remito.cotizacion.ID, |
328 | idListaPrecio: $scope.idLista, | 327 | idListaPrecio: $scope.idLista, |
329 | flete: $scope.remito.flete, | 328 | flete: $scope.remito.flete, |
330 | fob: $scope.remito.fob, | 329 | fob: $scope.remito.fob, |
331 | bomba: $scope.remito.bomba, | 330 | bomba: $scope.remito.bomba, |
332 | kilometros: $scope.remito.kilometros, | 331 | kilometros: $scope.remito.kilometros, |
333 | domicilioStamp: $scope.remito.domicilioStamp, | 332 | domicilioStamp: $scope.remito.domicilioStamp, |
334 | observaciones: $scope.remito.observaciones, | 333 | observaciones: $scope.remito.observaciones, |
335 | numeroRemito: parseInt($scope.comprobante), | 334 | numeroRemito: parseInt($scope.comprobante), |
336 | sucursal: parseInt($scope.puntoVenta), | 335 | sucursal: parseInt($scope.puntoVenta), |
337 | responsabilidadIvaCliente: $scope.remito.cliente.IVA, | 336 | responsabilidadIvaCliente: $scope.remito.cliente.IVA, |
338 | descuento: 0,//TODO, | 337 | descuento: 0,//TODO, |
339 | importeNeto: getImporte('netoUnitario'), | 338 | importeNeto: getImporte('netoUnitario'), |
340 | importeExento: getImporte('exentoUnitario'), | 339 | importeExento: getImporte('exentoUnitario'), |
341 | importeIva: getImporte('ivaUnitario'), | 340 | importeIva: getImporte('ivaUnitario'), |
342 | importeIvaServicios: 0,//TODO | 341 | importeIvaServicios: 0,//TODO |
343 | importeImpuestoInterno: getImporte('impuestoInternoUnitario'), | 342 | importeImpuestoInterno: getImporte('impuestoInternoUnitario'), |
344 | importeImpuestoInterno1: getImporte('impuestoInterno1Unitario'), | 343 | importeImpuestoInterno1: getImporte('impuestoInterno1Unitario'), |
345 | importeImpuestoInterno2: getImporte('impuestoInterno2Unitario'), | 344 | importeImpuestoInterno2: getImporte('impuestoInterno2Unitario'), |
346 | percepcion: 0,//TODO | 345 | percepcion: 0,//TODO |
347 | percepcionIva: 0,//TODO | 346 | percepcionIva: 0,//TODO |
348 | redondeo: 0,//TODO | 347 | redondeo: 0,//TODO |
349 | anulado: false, | 348 | anulado: false, |
350 | planilla: $filter('date')($scope.now, 'ddMMyyyy'), | 349 | planilla: $filter('date')($scope.now, 'ddMMyyyy'), |
351 | lugar: parseInt($scope.puntoVenta), | 350 | lugar: parseInt($scope.puntoVenta), |
352 | cuentaMadre: 0,//TODO | 351 | cuentaMadre: 0,//TODO |
353 | cuentaContable: 0,//TODO | 352 | cuentaContable: 0,//TODO |
354 | asiento: 0,//TODO | 353 | asiento: 0,//TODO |
355 | e_hd: '',//TODO | 354 | e_hd: '',//TODO |
356 | c_hd: '', | 355 | c_hd: '', |
357 | numeroLiquidoProducto: 0,//TODO | 356 | numeroLiquidoProducto: 0,//TODO |
358 | estado: 0, | 357 | estado: 0, |
359 | destinoVenta: 0,//TODO | 358 | destinoVenta: 0,//TODO |
360 | operacionTipo: 0, //TODO | 359 | operacionTipo: 0, //TODO |
361 | }, | 360 | }, |
362 | notaPedido: $scope.notaPedido | 361 | notaPedido: $scope.notaPedido |
363 | }; | 362 | }; |
364 | crearRemitoService.crearRemito(save).then( | 363 | crearRemitoService.crearRemito(save).then( |
365 | function (data) { | 364 | function (data) { |
366 | 365 | ||
367 | focaBotoneraLateralService.endGuardar(true); | 366 | focaBotoneraLateralService.endGuardar(true); |
368 | $scope.saveLoading = false; | 367 | $scope.saveLoading = false; |
369 | 368 | ||
370 | $scope.remito.numeroRemito = data.data.numero; | 369 | $scope.remito.numeroRemito = data.data.numero; |
371 | 370 | ||
372 | if ($scope.remito.remitoPuntoDescarga.length > 0) { | 371 | if ($scope.remito.remitoPuntoDescarga.length > 0) { |
373 | remitoBusinessService.addPuntosDescarga(data.data.id, | 372 | remitoBusinessService.addPuntosDescarga(data.data.id, |
374 | $scope.remito.remitoPuntoDescarga); | 373 | $scope.remito.remitoPuntoDescarga); |
375 | } | 374 | } |
376 | 375 | ||
377 | if (data.status === 500) { | 376 | if (data.status === 500) { |
378 | focaModalService.alert(data.data); | 377 | focaModalService.alert(data.data); |
379 | return; | 378 | return; |
380 | } | 379 | } |
381 | 380 | ||
382 | // TODO: updatear plazos | 381 | // TODO: updatear plazos |
383 | if ($scope.remito.id == 0) { | 382 | if ($scope.remito.id == 0) { |
384 | 383 | ||
385 | remitoBusinessService.addArticulos($scope.remito.articulosRemito, | 384 | remitoBusinessService.addArticulos($scope.remito.articulosRemito, |
386 | data.data.id, $scope.remito.cotizacion.VENDEDOR); | 385 | data.data.id, $scope.remito.cotizacion.VENDEDOR); |
387 | 386 | ||
388 | var plazos = $scope.remito.remitoPlazo; | 387 | var plazos = $scope.remito.remitoPlazo; |
389 | 388 | ||
390 | for (var j = 0; j < plazos.length; j++) { | 389 | for (var j = 0; j < plazos.length; j++) { |
391 | var json = { | 390 | var json = { |
392 | idRemito: data.data.id, | 391 | idRemito: data.data.id, |
393 | dias: plazos[j].dias | 392 | dias: plazos[j].dias |
394 | }; | 393 | }; |
395 | crearRemitoService.crearPlazosParaRemito(json); | 394 | crearRemitoService.crearPlazosParaRemito(json); |
396 | } | 395 | } |
397 | } | 396 | } |
398 | abrirModalMail(data.data.id, | 397 | abrirModalMail(data.data.id, |
399 | $scope.remito.cliente, | 398 | $scope.remito.cliente, |
400 | $filter('comprobante')([ | 399 | $filter('comprobante')([ |
401 | $scope.puntoVenta, | 400 | $scope.puntoVenta, |
402 | $scope.remito.numeroRemito | 401 | $scope.remito.numeroRemito |
403 | ]) | 402 | ]) |
404 | ); | 403 | ); |
405 | 404 | ||
406 | config(); | 405 | config(); |
407 | 406 | ||
408 | }, function (error) { | 407 | }, function (error) { |
409 | focaModalService.alert(error.data || 'Hubo un error al crear el remito'); | 408 | focaModalService.alert(error.data || 'Hubo un error al crear el remito'); |
410 | focaBotoneraLateralService.endGuardar(); | 409 | focaBotoneraLateralService.endGuardar(); |
411 | $scope.saveLoading = false; | 410 | $scope.saveLoading = false; |
412 | console.info(error); | 411 | console.info(error); |
413 | } | 412 | } |
414 | ); | 413 | ); |
415 | }; | 414 | }; |
416 | 415 | ||
417 | $scope.seleccionarProductos = function () { | 416 | $scope.seleccionarProductos = function () { |
418 | if ($scope.idLista === undefined) { | 417 | if ($scope.idLista === undefined) { |
419 | focaModalService.alert( | 418 | focaModalService.alert( |
420 | 'Primero seleccione una lista de precio y condicion'); | 419 | 'Primero seleccione una lista de precio y condicion'); |
421 | return; | 420 | return; |
422 | } | 421 | } |
423 | var modalInstance = $uibModal.open( | 422 | var modalInstance = $uibModal.open( |
424 | { | 423 | { |
425 | ariaLabelledBy: 'Busqueda de Productos', | 424 | ariaLabelledBy: 'Busqueda de Productos', |
426 | templateUrl: 'modal-busqueda-productos.html', | 425 | templateUrl: 'modal-busqueda-productos.html', |
427 | controller: 'modalBusquedaProductosCtrl', | 426 | controller: 'modalBusquedaProductosCtrl', |
428 | resolve: { | 427 | resolve: { |
429 | parametroProducto: { | 428 | parametroProducto: { |
430 | idLista: $scope.idLista, | 429 | idLista: $scope.idLista, |
431 | cotizacion: $scope.remito.cotizacion.VENDEDOR, | 430 | cotizacion: $scope.remito.cotizacion.VENDEDOR, |
432 | simbolo: $scope.remito.cotizacion.moneda.SIMBOLO | 431 | simbolo: $scope.remito.cotizacion.moneda.SIMBOLO |
433 | } | 432 | } |
434 | }, | 433 | }, |
435 | size: 'lg' | 434 | size: 'lg' |
436 | } | 435 | } |
437 | ); | 436 | ); |
438 | modalInstance.result.then( | 437 | modalInstance.result.then( |
439 | function (producto) { | 438 | function (producto) { |
440 | var newArt = | 439 | var newArt = |
441 | { | 440 | { |
442 | id: 0, | 441 | id: 0, |
443 | idRemito: 0, | 442 | idRemito: 0, |
444 | codigo: producto.codigo, | 443 | codigo: producto.codigo, |
445 | sector: producto.sector, | 444 | sector: producto.sector, |
446 | sectorCodigo: producto.sector + '-' + producto.codigo, | 445 | sectorCodigo: producto.sector + '-' + producto.codigo, |
447 | descripcion: producto.descripcion, | 446 | descripcion: producto.descripcion, |
448 | item: $scope.remito.articulosRemito.length + 1, | 447 | item: $scope.remito.articulosRemito.length + 1, |
449 | nombre: producto.descripcion, | 448 | nombre: producto.descripcion, |
450 | precio: parseFloat(producto.precio.toFixed(4)), | 449 | precio: parseFloat(producto.precio.toFixed(4)), |
451 | costoUnitario: producto.costo, | 450 | costoUnitario: producto.costo, |
452 | editCantidad: false, | 451 | editCantidad: false, |
453 | editPrecio: false, | 452 | editPrecio: false, |
454 | rubro: producto.CodRub, | 453 | rubro: producto.CodRub, |
455 | ivaUnitario: producto.IMPIVA, | 454 | ivaUnitario: producto.IMPIVA, |
456 | impuestoInternoUnitario: producto.ImpInt, | 455 | impuestoInternoUnitario: producto.ImpInt, |
457 | impuestoInterno1Unitario: producto.ImpInt2, | 456 | impuestoInterno1Unitario: producto.ImpInt2, |
458 | impuestoInterno2Unitario: producto.ImpInt3, | 457 | impuestoInterno2Unitario: producto.ImpInt3, |
459 | precioLista: producto.precio, | 458 | precioLista: producto.precio, |
460 | combustible: 1, | 459 | combustible: 1, |
461 | facturado: 0, | 460 | facturado: 0, |
462 | idArticulo: producto.id, | 461 | idArticulo: producto.id, |
463 | tasaIva: producto.tasaIVA | 462 | tasaIva: producto.tasaIVA |
464 | }; | 463 | }; |
465 | 464 | ||
466 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : producto.neto; | 465 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : producto.neto; |
467 | newArt.netoUnitario = newArt.ivaUnitario ? producto.neto : 0; | 466 | newArt.netoUnitario = newArt.ivaUnitario ? producto.neto : 0; |
468 | 467 | ||
469 | $scope.articuloACargar = newArt; | 468 | $scope.articuloACargar = newArt; |
470 | $scope.cargando = false; | 469 | $scope.cargando = false; |
471 | }, function () { | 470 | }, function () { |
472 | // funcion ejecutada cuando se cancela el modal | 471 | // funcion ejecutada cuando se cancela el modal |
473 | } | 472 | } |
474 | ); | 473 | ); |
475 | }; | 474 | }; |
475 | |||
476 | $scope.seleccionarPuntosDeDescarga = function () { | 476 | $scope.seleccionarPuntosDeDescarga = function () { |
477 | if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { | 477 | if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { |
478 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 478 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
479 | return; | 479 | return; |
480 | } else { | 480 | } else { |
481 | var modalInstance = $uibModal.open( | 481 | var modalInstance = $uibModal.open( |
482 | { | 482 | { |
483 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', | 483 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
484 | templateUrl: 'modal-punto-descarga.html', | 484 | templateUrl: 'modal-punto-descarga.html', |
485 | controller: 'focaModalPuntoDescargaController', | 485 | controller: 'focaModalPuntoDescargaController', |
486 | size: 'lg', | 486 | size: 'lg', |
487 | resolve: { | 487 | resolve: { |
488 | filters: { | 488 | filters: { |
489 | idDomicilio: $scope.remito.domicilio.id, | 489 | idDomicilio: $scope.remito.domicilio.id, |
490 | idCliente: $scope.remito.cliente.COD, | 490 | idCliente: $scope.remito.cliente.COD, |
491 | articulos: $scope.remito.articulosRemito, | 491 | articulos: $scope.remito.articulosRemito, |
492 | puntosDescarga: $scope.remito.remitoPuntoDescarga, | 492 | puntosDescarga: $scope.remito.remitoPuntoDescarga, |
493 | domicilio: $scope.remito.domicilio | 493 | domicilio: $scope.remito.domicilio |
494 | } | 494 | } |
495 | } | 495 | } |
496 | } | 496 | } |
497 | ); | 497 | ); |
498 | modalInstance.result.then( | 498 | modalInstance.result.then( |
499 | function (puntosDescarga) { | 499 | function (puntosDescarga) { |
500 | 500 | ||
501 | puntosDescarga.forEach(function (punto) { | 501 | puntosDescarga.forEach(function (punto) { |
502 | $scope.remito.remitoPuntoDescarga.push( | 502 | $scope.remito.remitoPuntoDescarga.push( |
503 | { | 503 | { |
504 | puntoDescarga: punto | 504 | puntoDescarga: punto |
505 | } | 505 | } |
506 | ); | 506 | ); |
507 | }); | 507 | }); |
508 | 508 | ||
509 | $scope.$broadcast('addCabecera', { | 509 | $scope.$broadcast('addCabecera', { |
510 | label: 'Puntos de descarga:', | 510 | label: 'Puntos de descarga:', |
511 | valor: getCabeceraPuntoDescarga(puntosDescarga) | 511 | valor: getCabeceraPuntoDescarga(puntosDescarga) |
512 | }); | 512 | }); |
513 | }, function () { | 513 | }, function () { |
514 | $scope.abrirModalDomicilios($scope.cliente); | 514 | $scope.abrirModalDomicilios($scope.cliente); |
515 | } | 515 | } |
516 | ); | 516 | ); |
517 | } | 517 | } |
518 | }; | 518 | }; |
519 | 519 | ||
520 | $scope.seleccionarCliente = function () { | 520 | $scope.seleccionarCliente = function () { |
521 | if (varlidarRemitoFacturado()) { | 521 | if (varlidarRemitoFacturado()) { |
522 | var modalInstance = $uibModal.open( | 522 | var modalInstance = $uibModal.open( |
523 | { | 523 | { |
524 | ariaLabelledBy: 'Busqueda de Cliente', | 524 | ariaLabelledBy: 'Busqueda de Cliente', |
525 | templateUrl: 'foca-busqueda-cliente-modal.html', | 525 | templateUrl: 'foca-busqueda-cliente-modal.html', |
526 | controller: 'focaBusquedaClienteModalController', | 526 | controller: 'focaBusquedaClienteModalController', |
527 | resolve: { | 527 | resolve: { |
528 | vendedor: function () { return null; }, | 528 | vendedor: function () { return null; }, |
529 | cobrador: function () { return null; } | 529 | cobrador: function () { return null; } |
530 | }, | 530 | }, |
531 | size: 'lg' | 531 | size: 'lg' |
532 | } | 532 | } |
533 | ); | 533 | ); |
534 | modalInstance.result.then( | 534 | modalInstance.result.then( |
535 | function (cliente) { | 535 | function (cliente) { |
536 | $scope.abrirModalDomicilios(cliente); | 536 | $scope.abrirModalDomicilios(cliente); |
537 | $scope.cliente = cliente; | 537 | $scope.cliente = cliente; |
538 | }, function () { | 538 | }, function () { |
539 | } | 539 | } |
540 | ); | 540 | ); |
541 | } | 541 | } |
542 | }; | 542 | }; |
543 | 543 | ||
544 | $scope.seleccionarEliminarRemito = function () { | 544 | $scope.seleccionarEliminarRemito = function () { |
545 | focaModalService.confirm('¿Desea eliminar este remito?').then(function (data) { | 545 | focaModalService.confirm('¿Desea eliminar este remito?').then(function (data) { |
546 | if (data) { | 546 | if (data) { |
547 | $scope.remito.anulado = true; | 547 | $scope.remito.anulado = true; |
548 | delete $scope.remito.remitoPlazo; | 548 | delete $scope.remito.remitoPlazo; |
549 | delete $scope.remito.vendedor; | 549 | delete $scope.remito.vendedor; |
550 | delete $scope.remito.proveedor; | 550 | delete $scope.remito.proveedor; |
551 | delete $scope.remito.cliente; | 551 | delete $scope.remito.cliente; |
552 | delete $scope.remito.cotizacion; | 552 | delete $scope.remito.cotizacion; |
553 | delete $scope.remito.remitoPuntoDescarga; | 553 | delete $scope.remito.remitoPuntoDescarga; |
554 | delete $scope.remito.articulosRemito; | 554 | delete $scope.remito.articulosRemito; |
555 | delete $scope.remito.fechaRemito; | 555 | delete $scope.remito.fechaRemito; |
556 | crearRemitoService.eliminarRemito($scope.remito); | 556 | crearRemitoService.eliminarRemito($scope.remito); |
557 | } | 557 | } |
558 | config(); | 558 | config(); |
559 | }); | 559 | }); |
560 | }; | 560 | }; |
561 | 561 | ||
562 | $scope.seleccionarProveedor = function () { | 562 | $scope.seleccionarProveedor = function () { |
563 | if (varlidarRemitoFacturado()) { | 563 | if (varlidarRemitoFacturado()) { |
564 | var parametrosModal = { | 564 | var parametrosModal = { |
565 | titulo: 'Búsqueda de Proveedor', | 565 | titulo: 'Búsqueda de Proveedor', |
566 | query: '/proveedor', | 566 | query: '/proveedor', |
567 | columnas: [ | 567 | columnas: [ |
568 | { | 568 | { |
569 | nombre: 'Código', | 569 | nombre: 'Código', |
570 | propiedad: 'COD', | 570 | propiedad: 'COD', |
571 | filtro: { | 571 | filtro: { |
572 | nombre: 'rellenarDigitos', | 572 | nombre: 'rellenarDigitos', |
573 | parametro: 5 | 573 | parametro: 5 |
574 | } | 574 | } |
575 | }, | 575 | }, |
576 | { | 576 | { |
577 | nombre: 'Nombre', | 577 | nombre: 'Nombre', |
578 | propiedad: 'NOM' | 578 | propiedad: 'NOM' |
579 | }, | 579 | }, |
580 | { | 580 | { |
581 | nombre: 'CUIT', | 581 | nombre: 'CUIT', |
582 | propiedad: 'CUIT' | 582 | propiedad: 'CUIT' |
583 | } | 583 | } |
584 | ], | 584 | ], |
585 | tipo: 'POST', | 585 | tipo: 'POST', |
586 | json: { razonCuitCod: '' } | 586 | json: { razonCuitCod: '' } |
587 | }; | 587 | }; |
588 | focaModalService.modal(parametrosModal).then( | 588 | focaModalService.modal(parametrosModal).then( |
589 | function (proveedor) { | 589 | function (proveedor) { |
590 | $scope.seleccionarFlete(proveedor); | 590 | $scope.seleccionarFlete(proveedor); |
591 | }, function () { } | 591 | }, function () { } |
592 | ); | 592 | ); |
593 | } | 593 | } |
594 | }; | 594 | }; |
595 | 595 | ||
596 | $scope.seleccionarDomicilioDeEntrega = function () { | 596 | $scope.seleccionarDomicilioDeEntrega = function () { |
597 | if (!$scope.remito.cliente.COD) { | 597 | if (!$scope.remito.cliente.COD) { |
598 | focaModalService.alert('Seleccione un Cliente'); | 598 | focaModalService.alert('Seleccione un Cliente'); |
599 | return; | 599 | return; |
600 | } else { | 600 | } else { |
601 | $scope.abrirModalDomicilios($scope.cliente); | 601 | $scope.abrirModalDomicilios($scope.cliente); |
602 | } | 602 | } |
603 | }; | 603 | }; |
604 | 604 | ||
605 | $scope.abrirModalDomicilios = function (cliente) { | 605 | $scope.abrirModalDomicilios = function (cliente) { |
606 | var modalInstanceDomicilio = $uibModal.open( | 606 | var modalInstanceDomicilio = $uibModal.open( |
607 | { | 607 | { |
608 | ariaLabelledBy: 'Busqueda de Domicilios', | 608 | ariaLabelledBy: 'Busqueda de Domicilios', |
609 | templateUrl: 'modal-domicilio.html', | 609 | templateUrl: 'modal-domicilio.html', |
610 | controller: 'focaModalDomicilioController', | 610 | controller: 'focaModalDomicilioController', |
611 | size: 'lg', | 611 | size: 'lg', |
612 | resolve: { | 612 | resolve: { |
613 | idCliente: function () { return $scope.notaPedido.cliente ? $scope.notaPedido.cliente.COD : | 613 | idCliente: function () { return $scope.notaPedido.cliente ? $scope.notaPedido.cliente.COD : |
614 | cliente.cod; }, | 614 | cliente.cod; }, |
615 | esNuevo: function () { return cliente.esNuevo; } | 615 | esNuevo: function () { return cliente.esNuevo; } |
616 | } | 616 | } |
617 | } | 617 | } |
618 | ); | 618 | ); |
619 | modalInstanceDomicilio.result.then( | 619 | modalInstanceDomicilio.result.then( |
620 | function (domicilio) { | 620 | function (domicilio) { |
621 | $scope.remito.domicilio = domicilio; | 621 | $scope.remito.domicilio = domicilio; |
622 | $scope.remito.cliente = { | 622 | $scope.remito.cliente = { |
623 | COD: cliente.cod, | 623 | COD: cliente.cod, |
624 | CUIT: cliente.cuit, | 624 | CUIT: cliente.cuit, |
625 | NOM: cliente.nom, | 625 | NOM: cliente.nom, |
626 | MAIL: cliente.mail, | 626 | MAIL: cliente.mail, |
627 | MOD: cliente.mod, | 627 | MOD: cliente.mod, |
628 | IVA: cliente.iva, | 628 | IVA: cliente.iva, |
629 | VEN: cliente.ven | 629 | VEN: cliente.ven |
630 | }; | 630 | }; |
631 | crearRemitoService.getVendedorById($scope.remito.cliente.VEN) | 631 | crearRemitoService.getVendedorById($scope.remito.cliente.VEN) |
632 | .then(function (res) { | 632 | .then(function (res) { |
633 | if (res.data !== '') { | 633 | if (res.data !== '') { |
634 | $scope.remito.vendedor = res.data; | 634 | $scope.remito.vendedor = res.data; |
635 | $scope.$broadcast('addCabecera', { | 635 | $scope.$broadcast('addCabecera', { |
636 | label: 'Vendedor:', | 636 | label: 'Vendedor:', |
637 | valor: $filter('rellenarDigitos')($scope.remito.vendedor | 637 | valor: $filter('rellenarDigitos')($scope.remito.vendedor |
638 | .NUM, 3) + ' - ' + $scope.remito.vendedor.NOM | 638 | .NUM, 3) + ' - ' + $scope.remito.vendedor.NOM |
639 | }); | 639 | }); |
640 | } | 640 | } |
641 | var domicilioStamp = | 641 | var domicilioStamp = |
642 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 642 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
643 | domicilio.Localidad + ', ' + domicilio.Provincia; | 643 | domicilio.Localidad + ', ' + domicilio.Provincia; |
644 | $scope.remito.domicilioStamp = domicilioStamp; | 644 | $scope.remito.domicilioStamp = domicilioStamp; |
645 | $scope.$broadcast('addCabecera', { | 645 | $scope.$broadcast('addCabecera', { |
646 | label: 'Cliente:', | 646 | label: 'Cliente:', |
647 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + | 647 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + |
648 | ' - ' + cliente.nom | 648 | ' - ' + cliente.nom |
649 | }); | 649 | }); |
650 | $scope.$broadcast('addCabecera', { | 650 | $scope.$broadcast('addCabecera', { |
651 | label: 'Domicilio:', | 651 | label: 'Domicilio:', |
652 | valor: domicilioStamp | 652 | valor: domicilioStamp |
653 | }); | 653 | }); |
654 | 654 | ||
655 | if (domicilio.verPuntos) { | 655 | if (domicilio.verPuntos) { |
656 | delete $scope.remito.domicilio.verPuntos; | 656 | delete $scope.remito.domicilio.verPuntos; |
657 | $scope.seleccionarPuntosDeDescarga(); | 657 | $scope.seleccionarPuntosDeDescarga(); |
658 | } else { | 658 | } else { |
659 | crearRemitoService | 659 | crearRemitoService |
660 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | 660 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
661 | .then(function (res) { | 661 | .then(function (res) { |
662 | if (res.data.length) { | 662 | if (res.data.length) { |
663 | $scope.seleccionarPuntosDeDescarga(); | 663 | $scope.seleccionarPuntosDeDescarga(); |
664 | } | 664 | } |
665 | }); | 665 | }); |
666 | } | 666 | } |
667 | 667 | ||
668 | $filter('filter')($scope.botonera, | 668 | $filter('filter')($scope.botonera, |
669 | { label: 'Cliente' })[0].checked = true; | 669 | { label: 'Cliente' })[0].checked = true; |
670 | $filter('filter')($scope.botonera, | 670 | $filter('filter')($scope.botonera, |
671 | { label: 'Domicilio de Entrega' })[0].checked = true; | 671 | { label: 'Domicilio de Entrega' })[0].checked = true; |
672 | }) | 672 | }) |
673 | .catch(function (e) { console.log(e); }); | 673 | .catch(function (e) { console.log(e); }); |
674 | }, function () { | 674 | }, function () { |
675 | $scope.seleccionarCliente(true); | 675 | $scope.seleccionarCliente(true); |
676 | return; | 676 | return; |
677 | } | 677 | } |
678 | ); | 678 | ); |
679 | }; | 679 | }; |
680 | 680 | ||
681 | $scope.getTotal = function () { | 681 | $scope.getTotal = function () { |
682 | var total = 0; | 682 | var total = 0; |
683 | var arrayTempArticulos = $scope.articulosFiltro(); | 683 | var arrayTempArticulos = $scope.articulosFiltro(); |
684 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 684 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
685 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 685 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
686 | } | 686 | } |
687 | return parseFloat(total.toFixed(2)); | 687 | return parseFloat(total.toFixed(2)); |
688 | }; | 688 | }; |
689 | 689 | ||
690 | $scope.getSubTotal = function () { | 690 | $scope.getSubTotal = function () { |
691 | if ($scope.articuloACargar) { | 691 | if ($scope.articuloACargar) { |
692 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 692 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
693 | } | 693 | } |
694 | }; | 694 | }; |
695 | 695 | ||
696 | $scope.seleccionarPreciosYCondiciones = function () { | 696 | $scope.seleccionarPreciosYCondiciones = function () { |
697 | if (!$scope.remito.cliente.COD) { | 697 | if (!$scope.remito.cliente.COD) { |
698 | focaModalService.alert('Primero seleccione un cliente'); | 698 | focaModalService.alert('Primero seleccione un cliente'); |
699 | return; | 699 | return; |
700 | } | 700 | } |
701 | 701 | ||
702 | if ($scope.remito.articulosRemito.length !== 0) { | 702 | if ($scope.remito.articulosRemito.length !== 0) { |
703 | focaModalService.confirm('Se perderan los productos ingresados') | 703 | focaModalService.confirm('Se perderan los productos ingresados') |
704 | .then(function (data) { | 704 | .then(function (data) { |
705 | if (data && varlidarRemitoFacturado()) { | 705 | if (data && varlidarRemitoFacturado()) { |
706 | abrirModal(); | 706 | abrirModal(); |
707 | } | 707 | } |
708 | }); | 708 | }); |
709 | } else { | 709 | } else { |
710 | abrirModal(); | 710 | abrirModal(); |
711 | } | 711 | } |
712 | 712 | ||
713 | function abrirModal() { | 713 | function abrirModal() { |
714 | var modalInstance = $uibModal.open( | 714 | var modalInstance = $uibModal.open( |
715 | { | 715 | { |
716 | ariaLabelledBy: 'Busqueda de Precio Condición', | 716 | ariaLabelledBy: 'Busqueda de Precio Condición', |
717 | templateUrl: 'modal-precio-condicion.html', | 717 | templateUrl: 'modal-precio-condicion.html', |
718 | controller: 'focaModalPrecioCondicionController', | 718 | controller: 'focaModalPrecioCondicionController', |
719 | size: 'lg', | 719 | size: 'lg', |
720 | resolve: { | 720 | resolve: { |
721 | idListaPrecio: function () { return $scope.remito.cliente.MOD || null; }, | 721 | idListaPrecio: function () { return $scope.remito.cliente.MOD || null; }, |
722 | idCliente: function () { return $scope.remito.cliente.COD; } | 722 | idCliente: function () { return $scope.remito.cliente.COD; } |
723 | } | 723 | } |
724 | } | 724 | } |
725 | ); | 725 | ); |
726 | modalInstance.result.then( | 726 | modalInstance.result.then( |
727 | function (precioCondicion) { | 727 | function (precioCondicion) { |
728 | var cabecera = ''; | 728 | var cabecera = ''; |
729 | var plazosConcat = ''; | 729 | var plazosConcat = ''; |
730 | if (!Array.isArray(precioCondicion)) { | 730 | if (!Array.isArray(precioCondicion)) { |
731 | $scope.remito.idPrecioCondicion = precioCondicion.listaPrecio.ID; | 731 | $scope.remito.idPrecioCondicion = precioCondicion.listaPrecio.ID; |
732 | $scope.remito.remitoPlazo = precioCondicion.plazoPago; | 732 | $scope.remito.remitoPlazo = precioCondicion.plazoPago; |
733 | $scope.idLista = parseInt(precioCondicion.listaPrecio.ID) ? | 733 | $scope.idLista = parseInt(precioCondicion.listaPrecio.ID) ? |
734 | parseInt(precioCondicion.listaPrecio.ID) : -1; | 734 | parseInt(precioCondicion.listaPrecio.ID) : -1; |
735 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | 735 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { |
736 | plazosConcat += precioCondicion.plazoPago[i].dias + ', '; | 736 | plazosConcat += precioCondicion.plazoPago[i].dias + ', '; |
737 | } | 737 | } |
738 | plazosConcat = plazosConcat.substring(0, plazosConcat.length - 2); | 738 | plazosConcat = plazosConcat.substring(0, plazosConcat.length - 2); |
739 | cabecera = $filter('rellenarDigitos')(parseInt(precioCondicion.listaPrecio.ID), 4) + | 739 | cabecera = $filter('rellenarDigitos')(parseInt(precioCondicion.listaPrecio.ID), 4) + |
740 | ' - ' + precioCondicion.listaPrecio.DES + ' ' + plazosConcat.trim(); | 740 | ' - ' + precioCondicion.listaPrecio.DES + ' ' + plazosConcat.trim(); |
741 | } else { //Cuando se ingresan los plazos manualmente | 741 | } else { //Cuando se ingresan los plazos manualmente |
742 | $scope.remito.idPrecioCondicion = 0; | 742 | $scope.remito.idPrecioCondicion = 0; |
743 | //-1, el modal productos busca todos los productos | 743 | //-1, el modal productos busca todos los productos |
744 | $scope.idLista = -1; | 744 | $scope.idLista = -1; |
745 | $scope.remito.remitoPlazo = precioCondicion; | 745 | $scope.remito.remitoPlazo = precioCondicion; |
746 | for (var j = 0; j < precioCondicion.length; j++) { | 746 | for (var j = 0; j < precioCondicion.length; j++) { |
747 | plazosConcat += precioCondicion[j].dias + ' '; | 747 | plazosConcat += precioCondicion[j].dias + ' '; |
748 | } | 748 | } |
749 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 749 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
750 | } | 750 | } |
751 | $scope.remito.articulosRemito = []; | 751 | $scope.remito.articulosRemito = []; |
752 | $scope.$broadcast('addCabecera', { | 752 | $scope.$broadcast('addCabecera', { |
753 | label: 'Precios y condiciones:', | 753 | label: 'Precios y condiciones:', |
754 | valor: cabecera | 754 | valor: cabecera |
755 | }); | 755 | }); |
756 | $scope.remito.precioCondicion = precioCondicion; | 756 | $scope.remito.precioCondicion = precioCondicion; |
757 | 757 | ||
758 | $filter('filter')($scope.botonera, | 758 | $filter('filter')($scope.botonera, |
759 | { label: 'Precios y Condiciones' })[0].checked = true; | 759 | { label: 'Precios y Condiciones' })[0].checked = true; |
760 | }, function () { | 760 | }, function () { |
761 | 761 | ||
762 | } | 762 | } |
763 | ); | 763 | ); |
764 | } | 764 | } |
765 | }; | 765 | }; |
766 | 766 | ||
767 | $scope.seleccionarFlete = function (proveedor) { | 767 | $scope.seleccionarFlete = function (proveedor) { |
768 | if (varlidarRemitoFacturado()) { | 768 | if (varlidarRemitoFacturado()) { |
769 | var modalInstance = $uibModal.open( | 769 | var modalInstance = $uibModal.open( |
770 | { | 770 | { |
771 | ariaLabelledBy: 'Busqueda de Flete', | 771 | ariaLabelledBy: 'Busqueda de Flete', |
772 | templateUrl: 'modal-flete.html', | 772 | templateUrl: 'modal-flete.html', |
773 | controller: 'focaModalFleteController', | 773 | controller: 'focaModalFleteController', |
774 | size: 'lg', | 774 | size: 'lg', |
775 | resolve: { | 775 | resolve: { |
776 | parametrosFlete: | 776 | parametrosFlete: |
777 | function () { | 777 | function () { |
778 | return { | 778 | return { |
779 | flete: $scope.remito.flete ? '1' : | 779 | flete: $scope.remito.flete ? '1' : |
780 | ($scope.remito.fob ? 'FOB' : | 780 | ($scope.remito.fob ? 'FOB' : |
781 | ($scope.remito.flete === undefined ? | 781 | ($scope.remito.flete === undefined ? |
782 | null : '0')), | 782 | null : '0')), |
783 | bomba: $scope.remito.bomba ? '1' : | 783 | bomba: $scope.remito.bomba ? '1' : |
784 | ($scope.remito.bomba === undefined ? | 784 | ($scope.remito.bomba === undefined ? |
785 | null : '0'), | 785 | null : '0'), |
786 | kilometros: $scope.remito.kilometros | 786 | kilometros: $scope.remito.kilometros |
787 | }; | 787 | }; |
788 | } | 788 | } |
789 | } | 789 | } |
790 | } | 790 | } |
791 | ); | 791 | ); |
792 | modalInstance.result.then( | 792 | modalInstance.result.then( |
793 | function (datos) { | 793 | function (datos) { |
794 | $scope.remitoIsDirty = true; | 794 | $scope.remitoIsDirty = true; |
795 | $scope.remito.proveedor = proveedor; | 795 | $scope.remito.proveedor = proveedor; |
796 | $scope.remito.idProveedor = proveedor.COD; | 796 | $scope.remito.idProveedor = proveedor.COD; |
797 | $scope.$broadcast('addCabecera', { | 797 | $scope.$broadcast('addCabecera', { |
798 | label: 'Proveedor:', | 798 | label: 'Proveedor:', |
799 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 799 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
800 | proveedor.NOM | 800 | proveedor.NOM |
801 | }); | 801 | }); |
802 | 802 | ||
803 | $scope.remito.flete = datos.flete; | 803 | $scope.remito.flete = datos.flete; |
804 | $scope.remito.fob = datos.FOB; | 804 | $scope.remito.fob = datos.FOB; |
805 | $scope.remito.bomba = datos.bomba; | 805 | $scope.remito.bomba = datos.bomba; |
806 | $scope.remito.kilometros = datos.kilometros; | 806 | $scope.remito.kilometros = datos.kilometros; |
807 | 807 | ||
808 | $scope.$broadcast('addCabecera', { | 808 | $scope.$broadcast('addCabecera', { |
809 | label: 'Flete:', | 809 | label: 'Flete:', |
810 | valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') | 810 | valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') |
811 | }); | 811 | }); |
812 | if (datos.flete) { | 812 | if (datos.flete) { |
813 | $scope.$broadcast('addCabecera', { | 813 | $scope.$broadcast('addCabecera', { |
814 | label: 'Bomba:', | 814 | label: 'Bomba:', |
815 | valor: datos.bomba ? 'Si' : 'No' | 815 | valor: datos.bomba ? 'Si' : 'No' |
816 | }); | 816 | }); |
817 | $scope.$broadcast('addCabecera', { | 817 | $scope.$broadcast('addCabecera', { |
818 | label: 'Kilometros:', | 818 | label: 'Kilometros:', |
819 | valor: datos.kilometros | 819 | valor: datos.kilometros |
820 | }); | 820 | }); |
821 | } else { | 821 | } else { |
822 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 822 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
823 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 823 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
824 | $scope.remito.bomba = false; | 824 | $scope.remito.bomba = false; |
825 | $scope.remito.kilometros = null; | 825 | $scope.remito.kilometros = null; |
826 | } | 826 | } |
827 | 827 | ||
828 | $filter('filter')($scope.botonera, | 828 | $filter('filter')($scope.botonera, |
829 | { label: 'Proveedor' })[0].checked = true; | 829 | { label: 'Proveedor' })[0].checked = true; |
830 | }, function () { | 830 | }, function () { |
831 | $scope.seleccionarTransportista(); | 831 | $scope.seleccionarTransportista(); |
832 | } | 832 | } |
833 | ); | 833 | ); |
834 | } | 834 | } |
835 | }; | 835 | }; |
836 | 836 | ||
837 | $scope.seleccionarMoneda = function () { | 837 | $scope.seleccionarMoneda = function () { |
838 | if (varlidarRemitoFacturado()) { | 838 | if (varlidarRemitoFacturado()) { |
839 | var parametrosModal = { | 839 | var parametrosModal = { |
840 | titulo: 'Búsqueda de monedas', | 840 | titulo: 'Búsqueda de monedas', |
841 | query: '/moneda', | 841 | query: '/moneda', |
842 | columnas: [ | 842 | columnas: [ |
843 | { | 843 | { |
844 | propiedad: 'DETALLE', | 844 | propiedad: 'DETALLE', |
845 | nombre: 'Nombre' | 845 | nombre: 'Nombre' |
846 | }, | 846 | }, |
847 | { | 847 | { |
848 | propiedad: 'SIMBOLO', | 848 | propiedad: 'SIMBOLO', |
849 | nombre: 'Símbolo' | 849 | nombre: 'Símbolo' |
850 | } | 850 | } |
851 | ], | 851 | ], |
852 | size: 'md' | 852 | size: 'md' |
853 | }; | 853 | }; |
854 | focaModalService.modal(parametrosModal).then( | 854 | focaModalService.modal(parametrosModal).then( |
855 | function (moneda) { | 855 | function (moneda) { |
856 | 856 | ||
857 | if (moneda.ID !== 1) { | 857 | if (moneda.ID !== 1) { |
858 | $scope.abrirModalCotizacion(moneda); | 858 | $scope.abrirModalCotizacion(moneda); |
859 | return; | 859 | return; |
860 | } | 860 | } |
861 | 861 | ||
862 | crearRemitoService.getCotizacionByIdMoneda(1) | 862 | crearRemitoService.getCotizacionByIdMoneda(1) |
863 | .then(function (res) { | 863 | .then(function (res) { |
864 | 864 | ||
865 | cotizacionPArgentino = res.data[0].cotizaciones[0]; | 865 | cotizacionPArgentino = res.data[0].cotizaciones[0]; |
866 | cotizacionPArgentino.moneda = moneda; | 866 | cotizacionPArgentino.moneda = moneda; |
867 | 867 | ||
868 | actualizarCabeceraMoneda(cotizacionPArgentino); | 868 | actualizarCabeceraMoneda(cotizacionPArgentino); |
869 | 869 | ||
870 | $scope.remito.cotizacion = cotizacionPArgentino; | 870 | $scope.remito.cotizacion = cotizacionPArgentino; |
871 | }); | 871 | }); |
872 | }, function () { | 872 | }, function () { |
873 | 873 | ||
874 | } | 874 | } |
875 | ); | 875 | ); |
876 | } | 876 | } |
877 | }; | 877 | }; |
878 | 878 | ||
879 | $scope.seleccionarObservaciones = function () { | 879 | $scope.seleccionarObservaciones = function () { |
880 | focaModalService | 880 | focaModalService |
881 | .prompt({ | 881 | .prompt({ |
882 | titulo: 'Observaciones', | 882 | titulo: 'Observaciones', |
883 | value: $scope.remito.observaciones, | 883 | value: $scope.remito.observaciones, |
884 | textarea: true, | 884 | textarea: true, |
885 | readonly: true | 885 | readonly: true |
886 | }) | 886 | }) |
887 | .then(function (observaciones) { | 887 | .then(function (observaciones) { |
888 | $scope.remito.observaciones = observaciones; | 888 | $scope.remito.observaciones = observaciones; |
889 | }); | 889 | }); |
890 | }; | 890 | }; |
891 | 891 | ||
892 | $scope.abrirModalCotizacion = function (moneda) { | 892 | $scope.abrirModalCotizacion = function (moneda) { |
893 | var modalInstance = $uibModal.open( | 893 | var modalInstance = $uibModal.open( |
894 | { | 894 | { |
895 | ariaLabelledBy: 'Busqueda de Cotización', | 895 | ariaLabelledBy: 'Busqueda de Cotización', |
896 | templateUrl: 'modal-cotizacion.html', | 896 | templateUrl: 'modal-cotizacion.html', |
897 | controller: 'focaModalCotizacionController', | 897 | controller: 'focaModalCotizacionController', |
898 | size: 'lg', | 898 | size: 'lg', |
899 | resolve: { idMoneda: function () { return moneda.ID; } } | 899 | resolve: { idMoneda: function () { return moneda.ID; } } |
900 | } | 900 | } |
901 | ); | 901 | ); |
902 | modalInstance.result.then( | 902 | modalInstance.result.then( |
903 | function (cotizacion) { | 903 | function (cotizacion) { |
904 | cotizacion.moneda = moneda; | 904 | cotizacion.moneda = moneda; |
905 | $scope.remitoIsDirty = true; | 905 | $scope.remitoIsDirty = true; |
906 | actualizarCabeceraMoneda(cotizacion); | 906 | actualizarCabeceraMoneda(cotizacion); |
907 | $scope.remito.cotizacion = cotizacion; | 907 | $scope.remito.cotizacion = cotizacion; |
908 | }, function () { | 908 | }, function () { |
909 | 909 | ||
910 | } | 910 | } |
911 | ); | 911 | ); |
912 | }; | 912 | }; |
913 | 913 | ||
914 | function actualizarCabeceraMoneda(cotizacion) { | 914 | function actualizarCabeceraMoneda(cotizacion) { |
915 | 915 | ||
916 | $scope.remito.articulosRemito.forEach(function (art) { | 916 | $scope.remito.articulosRemito.forEach(function (art) { |
917 | art.precio = (art.precio * $scope.remito.cotizacion.VENDEDOR).toFixed(4); | 917 | art.precio = (art.precio * $scope.remito.cotizacion.VENDEDOR).toFixed(4); |
918 | art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4); | 918 | art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4); |
919 | }); | 919 | }); |
920 | 920 | ||
921 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { | 921 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { |
922 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 922 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
923 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 923 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
924 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 924 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
925 | } else { | 925 | } else { |
926 | $scope.$broadcast('addCabecera', { | 926 | $scope.$broadcast('addCabecera', { |
927 | label: 'Moneda:', | 927 | label: 'Moneda:', |
928 | valor: cotizacion.moneda.DETALLE | 928 | valor: cotizacion.moneda.DETALLE |
929 | }); | 929 | }); |
930 | $scope.$broadcast('addCabecera', { | 930 | $scope.$broadcast('addCabecera', { |
931 | label: 'Fecha cotizacion:', | 931 | label: 'Fecha cotizacion:', |
932 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 932 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
933 | }); | 933 | }); |
934 | $scope.$broadcast('addCabecera', { | 934 | $scope.$broadcast('addCabecera', { |
935 | label: 'Cotizacion:', | 935 | label: 'Cotizacion:', |
936 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 936 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
937 | }); | 937 | }); |
938 | } | 938 | } |
939 | } | 939 | } |
940 | 940 | ||
941 | $scope.agregarATabla = function (key) { | 941 | $scope.agregarATabla = function (key) { |
942 | if (key === 13) { | 942 | if (key === 13) { |
943 | if (!$scope.articuloACargar.cantidad || !$scope.articuloACargar.precio) { | 943 | if (!$scope.articuloACargar.cantidad || !$scope.articuloACargar.precio) { |
944 | focaModalService.alert('El valor debe ser al menos 1'); | 944 | focaModalService.alert('El valor debe ser al menos 1'); |
945 | return; | 945 | return; |
946 | } | 946 | } |
947 | delete $scope.articuloACargar.sectorCodigo; | 947 | delete $scope.articuloACargar.sectorCodigo; |
948 | $scope.remito.articulosRemito.push($scope.articuloACargar); | 948 | $scope.remito.articulosRemito.push($scope.articuloACargar); |
949 | $scope.cargando = true; | 949 | $scope.cargando = true; |
950 | } | 950 | } |
951 | }; | 951 | }; |
952 | 952 | ||
953 | $scope.quitarArticulo = function (articulo) { | 953 | $scope.quitarArticulo = function (articulo) { |
954 | articulo.idRemito = -1; | 954 | articulo.idRemito = -1; |
955 | }; | 955 | }; |
956 | 956 | ||
957 | $scope.articulosFiltro = function () { | 957 | $scope.articulosFiltro = function () { |
958 | 958 | ||
959 | var result = $scope.remito.articulosRemito.filter(function (articulo) { | 959 | var result = $scope.remito.articulosRemito.filter(function (articulo) { |
960 | return articulo.idRemito >= 0; | 960 | return articulo.idRemito >= 0; |
961 | }); | 961 | }); |
962 | 962 | ||
963 | // Agrego checked en cabecera si hay datos | 963 | // Agrego checked en cabecera si hay datos |
964 | if (result.length) { | 964 | if (result.length) { |
965 | $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = true; | 965 | $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = true; |
966 | } else { | 966 | } else { |
967 | $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = false; | 967 | $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = false; |
968 | } | 968 | } |
969 | return result; | 969 | return result; |
970 | }; | 970 | }; |
971 | 971 | ||
972 | $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) { | 972 | $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) { |
973 | if (key === 13) { | 973 | if (key === 13) { |
974 | if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) { | 974 | if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) { |
975 | focaModalService.alert('Los valores deben ser al menos 1'); | 975 | focaModalService.alert('Los valores deben ser al menos 1'); |
976 | return; | 976 | return; |
977 | } else if (tmpCantidad === "0" || tmpPrecio === "0") { | 977 | } else if (tmpCantidad === "0" || tmpPrecio === "0") { |
978 | focaModalService.alert('Esta ingresando un producto con valor 0'); | 978 | focaModalService.alert('Esta ingresando un producto con valor 0'); |
979 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { | 979 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { |
980 | focaModalService.alert('Los valores no pueden ser negativos'); | 980 | focaModalService.alert('Los valores no pueden ser negativos'); |
981 | return; | 981 | return; |
982 | } | 982 | } |
983 | articulo.cantidad = tmpCantidad; | 983 | articulo.cantidad = tmpCantidad; |
984 | articulo.precio = tmpPrecio; | 984 | articulo.precio = tmpPrecio; |
985 | $scope.getTotal(); | 985 | $scope.getTotal(); |
986 | articulo.editCantidad = articulo.editPrecio = false; | 986 | articulo.editCantidad = articulo.editPrecio = false; |
987 | } | 987 | } |
988 | }; | 988 | }; |
989 | 989 | ||
990 | $scope.cancelarEditar = function (articulo) { | 990 | $scope.cancelarEditar = function (articulo) { |
991 | $scope.tmpCantidad = articulo.cantidad; | 991 | $scope.tmpCantidad = articulo.cantidad; |
992 | $scope.tmpPrecio = articulo.precio; | 992 | $scope.tmpPrecio = articulo.precio; |
993 | articulo.editCantidad = articulo.editPrecio = false; | 993 | articulo.editCantidad = articulo.editPrecio = false; |
994 | }; | 994 | }; |
995 | 995 | ||
996 | $scope.cambioEdit = function (articulo, propiedad) { | 996 | $scope.cambioEdit = function (articulo, propiedad) { |
997 | if (propiedad === 'cantidad') { | 997 | if (propiedad === 'cantidad') { |
998 | articulo.editCantidad = true; | 998 | articulo.editCantidad = true; |
999 | } else if (propiedad === 'precio') { | 999 | } else if (propiedad === 'precio') { |
1000 | articulo.editPrecio = true; | 1000 | articulo.editPrecio = true; |
1001 | } | 1001 | } |
1002 | }; | 1002 | }; |
1003 | 1003 | ||
1004 | $scope.resetFilter = function () { | 1004 | $scope.resetFilter = function () { |
1005 | $scope.articuloACargar = {}; | 1005 | $scope.articuloACargar = {}; |
1006 | $scope.cargando = true; | 1006 | $scope.cargando = true; |
1007 | }; | 1007 | }; |
1008 | //Recibe aviso si el teclado está en uso | 1008 | //Recibe aviso si el teclado está en uso |
1009 | $rootScope.$on('usarTeclado', function (event, data) { | 1009 | $rootScope.$on('usarTeclado', function (event, data) { |
1010 | if (data) { | 1010 | if (data) { |
1011 | $scope.mostrarTeclado = true; | 1011 | $scope.mostrarTeclado = true; |
1012 | return; | 1012 | return; |
1013 | } | 1013 | } |
1014 | $scope.mostrarTeclado = false; | 1014 | $scope.mostrarTeclado = false; |
1015 | }); | 1015 | }); |
1016 | 1016 | ||
1017 | $scope.selectFocus = function ($event) { | 1017 | $scope.selectFocus = function ($event) { |
1018 | // Si el teclado esta en uso no selecciona el valor | 1018 | // Si el teclado esta en uso no selecciona el valor |
1019 | if ($scope.mostrarTeclado) { | 1019 | if ($scope.mostrarTeclado) { |
1020 | return; | 1020 | return; |
1021 | } | 1021 | } |
1022 | $event.target.select(); | 1022 | $event.target.select(); |
1023 | }; | 1023 | }; |
1024 | 1024 | ||
1025 | function addArrayCabecera(array) { | 1025 | function addArrayCabecera(array) { |
1026 | for (var i = 0; i < array.length; i++) { | 1026 | for (var i = 0; i < array.length; i++) { |
1027 | $scope.$broadcast('addCabecera', { | 1027 | $scope.$broadcast('addCabecera', { |
1028 | label: array[i].label, | 1028 | label: array[i].label, |
1029 | valor: array[i].valor | 1029 | valor: array[i].valor |
1030 | }); | 1030 | }); |
1031 | } | 1031 | } |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | function rellenar(relleno, longitud) { | 1034 | function rellenar(relleno, longitud) { |
1035 | relleno = '' + relleno; | 1035 | relleno = '' + relleno; |
1036 | while (relleno.length < longitud) { | 1036 | while (relleno.length < longitud) { |
1037 | relleno = '0' + relleno; | 1037 | relleno = '0' + relleno; |
1038 | } | 1038 | } |
1039 | return relleno; | 1039 | return relleno; |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | function varlidarRemitoFacturado() { | 1042 | function varlidarRemitoFacturado() { |
1043 | if ($scope.remito.estado !== 5) { | 1043 | if ($scope.remito.estado !== 5) { |
1044 | return true; | 1044 | return true; |
1045 | } else { | 1045 | } else { |
1046 | focaModalService.alert('No se puede editar un remito facturado'); | 1046 | focaModalService.alert('No se puede editar un remito facturado'); |
1047 | return false(); | 1047 | return false(); |
1048 | } | 1048 | } |
1049 | } | 1049 | } |
1050 | 1050 | ||
1051 | function salir() { | 1051 | function salir() { |
1052 | var confirmacion = false; | 1052 | var confirmacion = false; |
1053 | 1053 | ||
1054 | if (!angular.equals($scope.remito, $scope.inicial)) { | 1054 | if (!angular.equals($scope.remito, $scope.inicial)) { |
1055 | confirmacion = true; | 1055 | confirmacion = true; |
1056 | } | 1056 | } |
1057 | 1057 | ||
1058 | if (confirmacion) { | 1058 | if (confirmacion) { |
1059 | focaModalService.confirm( | 1059 | focaModalService.confirm( |
1060 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 1060 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
1061 | ).then(function (data) { | 1061 | ).then(function (data) { |
1062 | if (data) { | 1062 | if (data) { |
1063 | $location.path('/'); | 1063 | $location.path('/'); |
1064 | } | 1064 | } |
1065 | }); | 1065 | }); |
1066 | } else { | 1066 | } else { |
1067 | $location.path('/'); | 1067 | $location.path('/'); |
1068 | } | 1068 | } |
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | function enableObservaciones(val) { | 1071 | function enableObservaciones(val) { |
1072 | var boton = $scope.botonera.filter(function (botonObs) { | 1072 | var boton = $scope.botonera.filter(function (botonObs) { |
1073 | return botonObs.label === 'Observaciones'; | 1073 | return botonObs.label === 'Observaciones'; |
1074 | }); | 1074 | }); |
1075 | boton[0].disable = !val; | 1075 | boton[0].disable = !val; |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | function setearRemito(remito) { | 1078 | function setearRemito(remito) { |
1079 | //añado cabeceras | 1079 | //añado cabeceras |
1080 | if (remito.estado !== 5 && remito.id) { | 1080 | if (remito.estado !== 5 && remito.id) { |
1081 | 1081 | ||
1082 | $scope.botonera.forEach(function(boton) { | 1082 | $scope.botonera.forEach(function(boton) { |
1083 | 1083 | ||
1084 | if (boton.label === 'Eliminar Remito') { | 1084 | if (boton.label === 'Eliminar Remito') { |
1085 | boton.disable = false; | 1085 | boton.disable = false; |
1086 | } | 1086 | } |
1087 | }); | 1087 | }); |
1088 | } | 1088 | } |
1089 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 1089 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
1090 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 1090 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
1091 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 1091 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
1092 | $scope.$broadcast('removeCabecera', 'Vendedor:'); | 1092 | $scope.$broadcast('removeCabecera', 'Vendedor:'); |
1093 | 1093 | ||
1094 | var cabeceras = []; | 1094 | var cabeceras = []; |
1095 | 1095 | ||
1096 | if (remito.cotizacion && remito.cotizacion.moneda.CODIGO_AFIP !== 'PES') { | 1096 | if (remito.cotizacion && remito.cotizacion.moneda.CODIGO_AFIP !== 'PES') { |
1097 | cabeceras.push({ | 1097 | cabeceras.push({ |
1098 | label: 'Moneda:', | 1098 | label: 'Moneda:', |
1099 | valor: remito.cotizacion.moneda.DETALLE | 1099 | valor: remito.cotizacion.moneda.DETALLE |
1100 | }); | 1100 | }); |
1101 | cabeceras.push({ | 1101 | cabeceras.push({ |
1102 | label: 'Fecha cotizacion:', | 1102 | label: 'Fecha cotizacion:', |
1103 | valor: $filter('date')(remito.cotizacion.FECHA, | 1103 | valor: $filter('date')(remito.cotizacion.FECHA, |
1104 | 'dd/MM/yyyy') | 1104 | 'dd/MM/yyyy') |
1105 | }); | 1105 | }); |
1106 | cabeceras.push({ | 1106 | cabeceras.push({ |
1107 | label: 'Cotizacion:', | 1107 | label: 'Cotizacion:', |
1108 | valor: $filter('number')(remito.cotizacion.VENDEDOR, | 1108 | valor: $filter('number')(remito.cotizacion.VENDEDOR, |
1109 | '2') | 1109 | '2') |
1110 | }); | 1110 | }); |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | if (remito.cotizacion && remito.cotizacion.moneda) { | 1113 | if (remito.cotizacion && remito.cotizacion.moneda) { |
1114 | $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; | 1114 | $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; |
1115 | } | 1115 | } |
1116 | 1116 | ||
1117 | if (remito.cliente && remito.cliente.COD) { | 1117 | if (remito.cliente && remito.cliente.COD) { |
1118 | cabeceras.push({ | 1118 | cabeceras.push({ |
1119 | label: 'Cliente:', | 1119 | label: 'Cliente:', |
1120 | valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + | 1120 | valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + |
1121 | remito.cliente.NOM | 1121 | remito.cliente.NOM |
1122 | }); | 1122 | }); |
1123 | cabeceras.push({ | 1123 | cabeceras.push({ |
1124 | label: 'Domicilio:', | 1124 | label: 'Domicilio:', |
1125 | valor: remito.domicilioStamp | 1125 | valor: remito.domicilioStamp |
1126 | }); | 1126 | }); |
1127 | 1127 | ||
1128 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; | 1128 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; |
1129 | } | 1129 | } |
1130 | if (remito.vendedor && remito.vendedor.NUM) { | 1130 | if (remito.vendedor && remito.vendedor.NUM) { |
1131 | cabeceras.push({ | 1131 | cabeceras.push({ |
1132 | label: 'Vendedor:', | 1132 | label: 'Vendedor:', |
1133 | valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + | 1133 | valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + |
1134 | ' - ' + remito.vendedor.NOM | 1134 | ' - ' + remito.vendedor.NOM |
1135 | }); | 1135 | }); |
1136 | } | 1136 | } |
1137 | if (remito.proveedor && remito.proveedor.COD) { | 1137 | if (remito.proveedor && remito.proveedor.COD) { |
1138 | cabeceras.push({ | 1138 | cabeceras.push({ |
1139 | label: 'Proveedor:', | 1139 | label: 'Proveedor:', |
1140 | valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + | 1140 | valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + |
1141 | ' - ' + remito.proveedor.NOM | 1141 | ' - ' + remito.proveedor.NOM |
1142 | }); | 1142 | }); |
1143 | 1143 | ||
1144 | $filter('filter')($scope.botonera, { label: 'Proveedor' })[0].checked = true; | 1144 | $filter('filter')($scope.botonera, { label: 'Proveedor' })[0].checked = true; |
1145 | } | 1145 | } |
1146 | if (remito.flete !== undefined && remito.fob !== undefined) { | 1146 | if (remito.flete !== undefined && remito.fob !== undefined) { |
1147 | cabeceras.push({ | 1147 | cabeceras.push({ |
1148 | label: 'Flete:', | 1148 | label: 'Flete:', |
1149 | valor: remito.fob ? 'FOB' : ( | 1149 | valor: remito.fob ? 'FOB' : ( |
1150 | remito.flete ? 'Si' : 'No') | 1150 | remito.flete ? 'Si' : 'No') |
1151 | }); | 1151 | }); |
1152 | } | 1152 | } |
1153 | if (remito.remitoPlazo) { | 1153 | if (remito.remitoPlazo) { |
1154 | cabeceras.push({ | 1154 | cabeceras.push({ |
1155 | label: 'Precio condicion:', | 1155 | label: 'Precio condicion:', |
1156 | valor: valorPrecioCondicion() + ' ' + | 1156 | valor: valorPrecioCondicion() + ' ' + |
1157 | remitoBusinessService.plazoToString(remito.remitoPlazo) | 1157 | remitoBusinessService.plazoToString(remito.remitoPlazo) |
1158 | }); | 1158 | }); |
1159 | 1159 | ||
1160 | $filter('filter')($scope.botonera, | 1160 | $filter('filter')($scope.botonera, |
1161 | { label: 'Precios y condiciones' })[0].checked = true; | 1161 | { label: 'Precios y condiciones' })[0].checked = true; |
1162 | } | 1162 | } |
1163 | function valorPrecioCondicion() { | 1163 | function valorPrecioCondicion() { |
1164 | if (remito.idPrecioCondicion > 0) { | 1164 | if (remito.idPrecioCondicion > 0) { |
1165 | return remito.precioCondicion.nombre; | 1165 | return remito.precioCondicion.nombre; |
1166 | } else { | 1166 | } else { |
1167 | return 'Ingreso Manual'; | 1167 | return 'Ingreso Manual'; |
1168 | } | 1168 | } |
1169 | } | 1169 | } |
1170 | if (remito.flete === 1) { | 1170 | if (remito.flete === 1) { |
1171 | var cabeceraBomba = { | 1171 | var cabeceraBomba = { |
1172 | label: 'Bomba', | 1172 | label: 'Bomba', |
1173 | valor: remito.bomba === 1 ? 'Si' : 'No' | 1173 | valor: remito.bomba === 1 ? 'Si' : 'No' |
1174 | }; | 1174 | }; |
1175 | if (remito.kilometros) { | 1175 | if (remito.kilometros) { |
1176 | var cabeceraKilometros = { | 1176 | var cabeceraKilometros = { |
1177 | label: 'Kilometros', | 1177 | label: 'Kilometros', |
1178 | valor: remito.kilometros | 1178 | valor: remito.kilometros |
1179 | }; | 1179 | }; |
1180 | cabeceras.push(cabeceraKilometros); | 1180 | cabeceras.push(cabeceraKilometros); |
1181 | } | 1181 | } |
1182 | cabeceras.push(cabeceraBomba); | 1182 | cabeceras.push(cabeceraBomba); |
1183 | } | 1183 | } |
1184 | 1184 | ||
1185 | if (remito.idPrecioCondicion > 0) { | 1185 | if (remito.idPrecioCondicion > 0) { |
1186 | $scope.idLista = remito.precioCondicion.idListaPrecio; | 1186 | $scope.idLista = remito.precioCondicion.idListaPrecio; |
1187 | } else if (remito.idPrecioCondicion) { | 1187 | } else if (remito.idPrecioCondicion) { |
1188 | $scope.idLista = -1; | 1188 | $scope.idLista = -1; |
1189 | } | 1189 | } |
1190 | $scope.puntoVenta = rellenar(remito.sucursal, 4); | 1190 | $scope.puntoVenta = rellenar(remito.sucursal, 4); |
1191 | $scope.comprobante = rellenar(remito.numeroRemito, 8); | 1191 | $scope.comprobante = rellenar(remito.numeroRemito, 8); |
1192 | $scope.remito = remito; | 1192 | $scope.remito = remito; |
1193 | if ($scope.remito.remitoPuntoDescarga.length) { | 1193 | if ($scope.remito.remitoPuntoDescarga.length) { |
1194 | var puntoDescarga = []; | 1194 | var puntoDescarga = []; |
1195 | 1195 | ||
1196 | $scope.remito.remitoPuntoDescarga.forEach(function (remitoPuntoDescarga) { | 1196 | $scope.remito.remitoPuntoDescarga.forEach(function (remitoPuntoDescarga) { |
1197 | puntoDescarga.push(remitoPuntoDescarga.puntoDescarga); | 1197 | puntoDescarga.push(remitoPuntoDescarga.puntoDescarga); |
1198 | }); | 1198 | }); |
1199 | 1199 | ||
1200 | cabeceras.push({ | 1200 | cabeceras.push({ |
1201 | label: 'Puntos de descarga: ', | 1201 | label: 'Puntos de descarga: ', |
1202 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntoDescarga)) | 1202 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntoDescarga)) |
1203 | }); | 1203 | }); |
1204 | } | 1204 | } |
1205 | $scope.remitoIsDirty = false; | 1205 | $scope.remitoIsDirty = false; |
1206 | 1206 | ||
1207 | if (remito.articulosRemito && $scope.remito.articulosRemito.length) { | 1207 | if (remito.articulosRemito && $scope.remito.articulosRemito.length) { |
1208 | $scope.remito.articulosRemito.forEach(function (articulo) { | 1208 | $scope.remito.articulosRemito.forEach(function (articulo) { |
1209 | articulo.precio = | 1209 | articulo.precio = |
1210 | (articulo.precio / $scope.remito.cotizacion.VENDEDOR).toFixed(4); | 1210 | (articulo.precio / $scope.remito.cotizacion.VENDEDOR).toFixed(4); |
1211 | }); | 1211 | }); |
1212 | } | 1212 | } |
1213 | 1213 | ||
1214 | addArrayCabecera(cabeceras); | 1214 | addArrayCabecera(cabeceras); |
1215 | } | 1215 | } |
1216 | 1216 | ||
1217 | function getLSRemito() { | 1217 | function getLSRemito() { |
1218 | var remito = JSON.parse($localStorage.remito || null); | 1218 | var remito = JSON.parse($localStorage.remito || null); |
1219 | if (remito) { | 1219 | if (remito) { |
1220 | setearRemito(remito); | 1220 | setearRemito(remito); |
1221 | delete $localStorage.remito; | 1221 | delete $localStorage.remito; |
1222 | } | 1222 | } |
1223 | } | 1223 | } |
1224 | 1224 | ||
1225 | function getCabeceraPuntoDescarga(puntosDescarga) { | 1225 | function getCabeceraPuntoDescarga(puntosDescarga) { |
1226 | var puntosStamp = ''; | 1226 | var puntosStamp = ''; |
1227 | puntosDescarga.forEach(function (punto, idx, arr) { | 1227 | puntosDescarga.forEach(function (punto, idx, arr) { |
1228 | puntosStamp += punto.descripcion; | 1228 | puntosStamp += punto.descripcion; |
1229 | if ((idx + 1) !== arr.length) puntosStamp += ', '; | 1229 | if ((idx + 1) !== arr.length) puntosStamp += ', '; |
1230 | }); | 1230 | }); |
1231 | return puntosStamp; | 1231 | return puntosStamp; |
1232 | } | 1232 | } |
1233 | 1233 | ||
1234 | function abrirModalMail(id, cliente, numeroRemito) { | 1234 | function abrirModalMail(id, cliente, numeroRemito) { |
1235 | focaModalService.mail( | 1235 | focaModalService.mail( |
1236 | { | 1236 | { |
1237 | titulo: 'Comprobante de remito Nº ' + numeroRemito, | 1237 | titulo: 'Comprobante de remito Nº ' + numeroRemito, |
1238 | descarga: { | 1238 | descarga: { |
1239 | nombre: numeroRemito + '.pdf', | 1239 | nombre: numeroRemito + '.pdf', |
1240 | url: '/remito/comprobante', | 1240 | url: '/remito/comprobante', |
1241 | }, | 1241 | }, |
1242 | envio: { | 1242 | envio: { |
1243 | mailCliente: cliente.MAIL, | 1243 | mailCliente: cliente.MAIL, |
1244 | url: '/remito/mail', | 1244 | url: '/remito/mail', |
1245 | }, | 1245 | }, |
1246 | options: { | 1246 | options: { |
1247 | idRemito: id | 1247 | idRemito: id |
1248 | } | 1248 | } |
1249 | } | 1249 | } |
1250 | ) | 1250 | ) |
1251 | .then(function (res) { | 1251 | .then(function (res) { |
1252 | if (res === false) { | 1252 | if (res === false) { |
1253 | abrirModalMail(id); | 1253 | abrirModalMail(id); |
1254 | focaModalService.alert('Descarga o envíe su remito ' + | 1254 | focaModalService.alert('Descarga o envíe su remito ' + |
1255 | 'antes de cerrar esta ventana'); | 1255 | 'antes de cerrar esta ventana'); |
1256 | } | 1256 | } |
1257 | }); | 1257 | }); |
1258 | } | 1258 | } |
1259 | //recibo la propiedad por la cual quiero obtener el valor | 1259 | //recibo la propiedad por la cual quiero obtener el valor |
1260 | function getImporte(propiedad) { | 1260 | function getImporte(propiedad) { |
1261 | var importe = 0; | 1261 | var importe = 0; |
1262 | 1262 | ||
1263 | $scope.articulosFiltro().forEach(function (articulo) { | 1263 | $scope.articulosFiltro().forEach(function (articulo) { |
1264 | 1264 | ||
1265 | if (articulo[propiedad]) { | 1265 | if (articulo[propiedad]) { |
1266 | importe += articulo[propiedad] * articulo.cantidad; | 1266 | importe += articulo[propiedad] * articulo.cantidad; |
1267 | } | 1267 | } |
1268 | return; | 1268 | return; |
1269 | 1269 | ||
1270 | }); | 1270 | }); |
1271 | 1271 | ||
1272 | return importe; | 1272 | return importe; |
1273 | } | 1273 | } |
1274 | } | 1274 | } |
1275 | ]); | 1275 | ]); |