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