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