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