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