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