Compare View

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