Commit 68473ec2f2c418775ed11a89a6d18212ea330947

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'develop'

Master

See merge request !66
src/js/controller.js
... ... @@ -22,16 +22,11 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
22 22 minDate: new Date(2010, 0, 1)
23 23 };
24 24  
25   - var monedaPorDefecto;
26 25 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
27 26 focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) {
28   - monedaPorDefecto = res.data[0];
29   -
30   - $scope.cobranza.cotizacion = Object.assign(
31   - {moneda: monedaPorDefecto}, monedaPorDefecto.cotizaciones[0]
32   - );
33   - $scope.inicial.cotizacion = $scope.cobranza.cotizacion;
34   -
  27 + var moneda = res.data[0];
  28 + moneda.cotizacion = moneda.cotizaciones[0];
  29 + $scope.cobranza.moneda = $scope.inicial.moneda = moneda;
35 30 });
36 31  
37 32 $timeout(function() {
... ... @@ -52,8 +47,8 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
52 47 function init() {
53 48 $scope.$broadcast('cleanCabecera');
54 49 $scope.cobranza = {
55   - fecha: new Date(),
56   - cotizacion: {},
  50 + FEC: new Date(),
  51 + moneda: {},
57 52 facturas: [],
58 53 cobros: [],
59 54 cliente: {},
... ... @@ -117,12 +112,11 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
117 112 focaModalService.alert('Ingrese al menos una factura');
118 113 return;
119 114 }
120   - if ($scope.getTotalCobrado() + $scope.getTotalDeuda() !== 0) {
  115 + if ($scope.getTotalCobrado() + (Math.abs($scope.getTotalDeuda()) * -1) !== 0) {
121 116 focaModalService.alert('La diferencia debe ser ' +
122   - $scope.cobranza.cotizacion.moneda.SIMBOLO + '0,00');
  117 + $scope.cobranza.moneda.SIMBOLO + '0,00');
123 118 return;
124 119 }
125   -
126 120 var cobranza = {};
127 121 var cheques = [];
128 122 var cuerpos = [];
... ... @@ -141,11 +135,12 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
141 135 NCO: $scope.comprobante,
142 136 LOP: 'L',
143 137 TIL: $scope.cobranza.facturas[i].TCO,
144   - COM: $scope.cobranza.facturas[i].numeroFactura + '-' +
  138 + COM: $scope.cobranza.facturas[i].COM + '-' +
145 139 $filter('rellenarDigitos')($scope.cobranza.facturas[i].NCU,2),
146   - FEC: new Date($scope.cobranza.fecha)
  140 + FEC: new Date($scope.cobranza.FEC)
147 141 .toISOString().slice(0, 19).replace('T', ' '),
148   - IMP: Math.abs($scope.cobranza.facturas[i].IPA),
  142 + IMP: Math.abs($scope.cobranza.facturas[i].IMP ||
  143 + $scope.cobranza.facturas[i].IPA),
149 144 RES: 0,//caja de tesorería
150 145 SUBM: 0,
151 146 NCU: $scope.cobranza.facturas[i].NCU
... ... @@ -164,14 +159,14 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
164 159 PVE: $scope.puntoVenta,
165 160 NCO: $scope.comprobante,
166 161 LOP: 'P',
167   - TIL: $scope.cobranza.cobros[j].til,
168   - COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : $scope.cobranza.cobros[j].tipo,
  162 + TIL: $scope.cobranza.cobros[j].TIL,
  163 + COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : $scope.cobranza.cobros[j].COM,
169 164 FEC: !$scope.cobranza.cobros[j].fechaPresentacion ?
170   - new Date($scope.cobranza.cobros[j].fecha)
  165 + new Date($scope.cobranza.cobros[j].FEC)
171 166 .toISOString().slice(0, 19).replace('T', ' ') :
172 167 new Date($scope.cobranza.cobros[j].fechaPresentacion)
173 168 .toISOString().slice(0, 19).replace('T', ' '),
174   - IMP: Math.abs($scope.cobranza.cobros[j].importe),
  169 + IMP: Math.abs($scope.cobranza.cobros[j].IMP),
175 170 RES: 0,//caja de tesorería
176 171 SUBM: 0
177 172 };
... ... @@ -237,14 +232,14 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
237 232 TCO: 'RC',
238 233 PVE: $scope.puntoVenta, //Sucursar, punto de venta
239 234 NCO: $scope.comprobante, //Numero de comprobante
240   - FEC: new Date($scope.cobranza.fecha)
  235 + FEC: new Date($scope.cobranza.FEC)
241 236 .toISOString().slice(0, 19).replace('T', ' '),
242 237 CLI: $scope.cobranza.cliente.COD,
243 238 ATO: 0, //número de asiento
244 239 CFE: $scope.cobranza.cobrador.NOM,
245 240 PLA: '',//Numero de planilla, sin uso
246   - ID_MONEDA: $scope.cobranza.cotizacion.moneda.ID,
247   - COTIZACION: $scope.cobranza.cotizacion.VENDEDOR,
  241 + ID_MONEDA: $scope.cobranza.moneda.ID,
  242 + COTIZACION: $scope.cobranza.moneda.cotizacion.VENDEDOR,
248 243 idCobrador: $scope.cobranza.cobrador.id
249 244 },
250 245 cuerpo: cuerpos,
... ... @@ -252,7 +247,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
252 247 acobypag: {
253 248 CYV: 'V',
254 249 COD: $scope.cobranza.cliente.COD,
255   - FEP: new Date($scope.cobranza.fecha)
  250 + FEP: new Date($scope.cobranza.FEC)
256 251 .toISOString().slice(0, 19).replace('T', ' '),
257 252 TIP: 'C',
258 253 TCO: 'RC',
... ... @@ -269,7 +264,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
269 264 REM: 0,
270 265 FRE: null,//??
271 266 PRO: 'N',
272   - FEV: new Date($scope.cobranza.fecha)
  267 + FEV: new Date($scope.cobranza.FEC)
273 268 .toISOString().slice(0, 19).replace('T', ' ')
274 269 },
275 270 datosCobrador: {
... ... @@ -278,7 +273,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
278 273 NUM: $scope.comprobante,
279 274 EST: 'C',
280 275 OBS: 'RC: ' + $scope.comprobante + '-' +
281   - new Date($scope.cobranza.fecha).toLocaleDateString(),
  276 + new Date($scope.cobranza.FEC).toLocaleDateString(),
282 277 DAT1: 'C',
283 278 CLI: $scope.cobranza.cliente.COD
284 279 },
... ... @@ -336,7 +331,10 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
336 331 size: 'lg'
337 332 }
338 333 );
339   - modalInstance.result.then(setearCobranza);
  334 + modalInstance.result.then(function(cobranza) {
  335 + cobranza.moneda.cotizacion = cobranza.moneda.cotizaciones[0];
  336 + setearCobranza(cobranza);
  337 + });
340 338 };
341 339  
342 340 $scope.seleccionarResumenDeCuenta = function() {
... ... @@ -458,9 +456,9 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
458 456 parametrosFactura: function() {
459 457 return {
460 458 cliente: $scope.cobranza.cliente,
461   - simbolo: $scope.cobranza.cotizacion.moneda.SIMBOLO,
462   - cotizacion: $scope.cobranza.cotizacion.VENDEDOR,
463   - moneda: $scope.cobranza.cotizacion.moneda.ID
  459 + simbolo: $scope.cobranza.moneda.SIMBOLO,
  460 + cotizacion: $scope.cobranza.moneda,
  461 + moneda: $scope.cobranza.moneda.ID
464 462 };
465 463 }
466 464 }
... ... @@ -501,19 +499,19 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
501 499 modalInstance.result.then(
502 500 function(cheque) {
503 501 var cobro = {
504   - tipo: 'ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco,
  502 + COM: 'ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco,
505 503 numero: cheque.numero,
506 504 banco: cheque.banco,
507   - fecha: cheque.fechaEmision.toLocaleDateString() + '-' +
  505 + FEC: cheque.fechaEmision.toLocaleDateString() + '-' +
508 506 cheque.fechaPresentacion.toLocaleDateString(),
509 507 fechaPresentacion: cheque.fechaPresentacion,
510 508 fechaEmision: cheque.fechaEmision,
511   - importe: cheque.importe * $scope.cobranza.cotizacion.VENDEDOR,
  509 + IMP: cheque.importe * $scope.cobranza.moneda.cotizacion.VENDEDOR,
512 510 localidad: cheque.localidad,
513 511 librador: cheque.librador,
514 512 provincia: cheque.provincia,
515 513 observaciones: cheque.observaciones,
516   - til: 'EF'
  514 + TIL: 'EF'
517 515 };
518 516 $scope.cobranza.cobros.push(cobro);
519 517 }, function() {
... ... @@ -531,7 +529,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
531 529 size: 'sm',
532 530 resolve: {
533 531 sugerido: function() {
534   - var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado();
  532 + var sugerido = $scope.getTotalDeuda() - $scope.getTotalCobrado();
535 533 return sugerido < 0 ? sugerido : null;
536 534 }
537 535 }
... ... @@ -540,10 +538,10 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
540 538 modalInstance.result.then(
541 539 function(efectivo) {
542 540 var cobro = {
543   - tipo: 'Efectivo',
544   - fecha: new Date(),
545   - importe: efectivo * $scope.cobranza.cotizacion.VENDEDOR,
546   - til: 'EF'
  541 + COM: 'Efectivo',
  542 + FEC: new Date(),
  543 + IMP: efectivo * $scope.cobranza.moneda.cotizacion.VENDEDOR,
  544 + TIL: 'EF'
547 545 };
548 546 $scope.cobranza.cobros = $scope.cobranza.cobros.filter(function(a) {
549 547 return a.tipo !== 'Efectivo';
... ... @@ -573,11 +571,11 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
573 571 modalInstance.result.then(
574 572 function(detalles) {
575 573 var cobro = {
576   - tipo: 'de(COBRO POR DETALLES)',
577   - fecha: new Date(),
578   - importe: detalles.monto * $scope.cobranza.cotizacion.VENDEDOR,
  574 + COM: 'de(COBRO POR DETALLES)',
  575 + FEC: new Date(),
  576 + IMP: detalles.monto * $scope.cobranza.moneda.cotizacion.VENDEDOR,
579 577 imgs: detalles.imgs,
580   - til: 'DE',
  578 + TIL: 'DE',
581 579 observacion: detalles.observacion
582 580 };
583 581 var existe = false;
... ... @@ -632,8 +630,8 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
632 630 );
633 631 modalInstance.result.then(
634 632 function(cotizacion) {
635   - $scope.cobranza.cotizacion = cotizacion;
636   - $scope.cobranza.cotizacion.moneda = moneda;
  633 + $scope.cobranza.moneda = moneda;
  634 + $scope.cobranza.moneda.cotizacion = cotizacion;
637 635 if (moneda.DETALLE === 'PESOS ARGENTINOS') {
638 636 $scope.$broadcast('removeCabecera', 'Moneda:');
639 637 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
... ... @@ -652,6 +650,7 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
652 650 valor: $filter('number')(cotizacion.VENDEDOR, '2')
653 651 });
654 652 }
  653 +
655 654 }, function() {
656 655  
657 656 }
... ... @@ -661,7 +660,7 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
661 660 $scope.getTotalDeuda = function() {
662 661 var total = 0;
663 662 for (var i = 0; i < $scope.cobranza.facturas.length; i++) {
664   - total += $scope.cobranza.facturas[i].IPA;
  663 + total += $scope.cobranza.facturas[i].IMP || $scope.cobranza.facturas[i].IPA;
665 664 }
666 665 return parseFloat(total.toFixed(2));
667 666 };
... ... @@ -669,7 +668,7 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
669 668 $scope.getTotalCobrado = function() {
670 669 var total = 0;
671 670 for (var i = 0; i < $scope.cobranza.cobros.length; i++) {
672   - total += $scope.cobranza.cobros[i].importe;
  671 + total += $scope.cobranza.cobros[i].IMP;
673 672 }
674 673 return parseFloat(total.toFixed(2));
675 674 };
src/views/cobranza.html
... ... @@ -2,7 +2,7 @@
2 2 <foca-cabecera-facturador
3 3 titulo="'Recibo de cobranza'"
4 4 numero="puntoVenta + '-' + comprobante"
5   - fecha="cobranza.fecha"
  5 + fecha="cobranza.FEC"
6 6 class="mb-0 col-lg-12"
7 7 busqueda="seleccionarCobranza"
8 8 ></foca-cabecera-facturador>
... ... @@ -51,12 +51,12 @@
51 51 ng-show="show || key == cobranza.facturas.length - 1"
52 52 >
53 53 <td ng-bind="key + 1" class="col-auto"></td>
54   - <td class="col" ng-bind="factura.numeroFactura"
  54 + <td class="col" ng-bind="factura.COM || factura.numeroFactura"
55 55 ></td>
56   - <td class="col" ng-bind="factura.FEP | date : 'dd/MM/yyyy'"></td>
  56 + <td class="col" ng-bind="factura.FEC || factura.FEP | date : 'dd/MM/yyyy'"></td>
57 57 <td
58 58 class="col"
59   - ng-bind="(factura.IPA / cobranza.cotizacion.VENDEDOR) |
  59 + ng-bind="((factura.IMP ||factura.IPA) / cobranza.moneda.cotizacion.VENDEDOR) |
60 60 number: 4"></td>
61 61 <td class="text-center col-auto">
62 62 <button
... ... @@ -86,22 +86,22 @@
86 86 <strong>Cancela:</strong>
87 87 </td>
88 88 <td class="table-celda-total text-right no-border-top">
89   - <strong>{{(getTotalDeuda() / cobranza.cotizacion.VENDEDOR) |
90   - currency: cobranza.cotizacion.moneda.SIMBOLO}}</strong>
  89 + <strong>{{(getTotalDeuda() / cobranza.moneda.cotizacion.VENDEDOR) |
  90 + currency: cobranza.moneda.SIMBOLO}}</strong>
91 91 </td>
92 92 <td class="text-right ml-auto table-celda-total no-border-top">
93 93 <strong>Total Cobrado:</strong>
94 94 </td>
95 95 <td class="table-celda-total text-right no-border-top">
96   - <strong>{{(getTotalCobrado() / cobranza.cotizacion.VENDEDOR) |
97   - currency: cobranza.cotizacion.moneda.SIMBOLO}}</strong>
  96 + <strong>{{(getTotalCobrado() / cobranza.moneda.cotizacion.VENDEDOR) |
  97 + currency: cobranza.moneda.SIMBOLO}}</strong>
98 98 </td>
99 99 <td class="text-right ml-auto table-celda-total no-border-top">
100 100 <strong>DF:</strong>
101 101 </td>
102 102 <td class="table-celda-total text-right no-border-top mr-1">
103 103 <strong>{{((getTotalCobrado() + getTotalDeuda()) /
104   - cobranza.cotizacion.VENDEDOR) | currency: cobranza.cotizacion.moneda.SIMBOLO}}
  104 + cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}
105 105 </strong>
106 106 </td>
107 107 </tr>
... ... @@ -144,11 +144,11 @@
144 144 ng-show="show || key == cobranza.cobros.length - 1"
145 145 >
146 146 <td ng-bind="key + 1" class="col-auto"></td>
147   - <td class="col" ng-bind="cobro.tipo"></td>
148   - <td class="col" ng-bind="cobro.fecha | date : 'dd/MM/yyyy'"></td>
  147 + <td class="col" ng-bind="cobro.COM"></td>
  148 + <td class="col" ng-bind="cobro.FEC | date : 'dd/MM/yyyy'"></td>
149 149 <td
150 150 class="col"
151   - ng-bind="(cobro.importe / cobranza.cotizacion.VENDEDOR) |
  151 + ng-bind="(cobro.IMP / cobranza.moneda.cotizacion.VENDEDOR) |
152 152 currency: cobranza.moneda.SIMBOLO : 4"></td>
153 153 <td class="text-center col-auto">
154 154 <button
... ... @@ -190,22 +190,22 @@
190 190 <strong>Cancela:</strong>
191 191 </td>
192 192 <td class="table-celda-total text-right no-border-top">
193   - <strong>{{(getTotalDeuda() / cobranza.cotizacion.VENDEDOR) |
194   - currency: cobranza.cotizacion.moneda.SIMBOLO}}</strong>
  193 + <strong>{{(getTotalDeuda() / cobranza.moneda.cotizacion.VENDEDOR) |
  194 + currency: cobranza.moneda.SIMBOLO}}</strong>
195 195 </td>
196 196 <td class="text-right ml-auto table-celda-total no-border-top">
197 197 <strong>Total Cobrado:</strong>
198 198 </td>
199 199 <td class="table-celda-total text-right no-border-top">
200   - <strong>{{(getTotalCobrado() / cobranza.cotizacion.VENDEDOR) |
201   - currency: cobranza.cotizacion.moneda.SIMBOLO}}</strong>
  200 + <strong>{{(getTotalCobrado() / cobranza.moneda.cotizacion.VENDEDOR) |
  201 + currency: cobranza.moneda.SIMBOLO}}</strong>
202 202 </td>
203 203 <td class="text-right ml-auto table-celda-total no-border-top">
204 204 <strong>DF:</strong>
205 205 </td>
206 206 <td class="table-celda-total text-right no-border-top mr-1">
207 207 <strong>{{((getTotalCobrado() + getTotalDeuda()) /
208   - cobranza.cotizacion.VENDEDOR) | currency: cobranza.cotizacion.moneda.SIMBOLO}}
  208 + cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}
209 209 </strong>
210 210 </td>
211 211 </tr>
... ... @@ -243,15 +243,15 @@
243 243 <div class="col px-0">
244 244 <div class="d-flex">
245 245 <div class="col-4 p-1">
246   - <span ng-bind="factura.numeroFactura"
  246 + <span ng-bind="factura.COM"
247 247 ></span>
248 248 </div>
249 249 <div class="col-4 p-1">
250   - <span ng-bind="factura.FEP | date : 'dd/MM/yyyy'"></span>
  250 + <span ng-bind="factura.FEC | date : 'dd/MM/yyyy'"></span>
251 251 </div>
252 252 <div class="col-4 p-1">
253 253 <span
254   - ng-bind="(factura.IPA / cobranza.cotizacion.VENDEDOR) |
  254 + ng-bind="(factura.IMP / cobranza.COTIZACION) |
255 255 currency:cobranza.moneda.SIMBOLO : 4"></span>
256 256 </div>
257 257 </div>
... ... @@ -347,7 +347,7 @@
347 347 </div>
348 348 <div class="col-4 p-1">
349 349 <span
350   - ng-bind="(cobro.importe / cobranza.cotizacion.VENDEDOR) |
  350 + ng-bind="(cobro.importe / cobranza.moneda.cotizacion.VENDEDOR) |
351 351 currency: cobranza.moneda.SIMBOLO : 4"></span>
352 352 </div>
353 353 </div>
... ... @@ -435,13 +435,13 @@
435 435 <strong>Diferencia:</strong>
436 436 </td>
437 437 <td class="table-celda-total text-center no-border-top col-4">
438   - <strong>{{(getTotalDeuda() / cobranza.cotizacion.VENDEDOR) | currency: cobranza.cotizacion.moneda.SIMBOLO}}</strong>
  438 + <strong>{{(getTotalDeuda() / cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong>
439 439 </td>
440 440 <td class="table-celda-total text-center no-border-top col-4">
441   - <strong>{{(getTotalCobrado() / cobranza.cotizacion.VENDEDOR) | currency: cobranza.cotizacion.moneda.SIMBOLO}}</strong>
  441 + <strong>{{(getTotalCobrado() / cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong>
442 442 </td>
443 443 <td class="table-celda-total text-center no-border-top col-4">
444   - <strong>{{((getTotalCobrado() + getTotalDeuda()) / cobranza.cotizacion.VENDEDOR) | currency: cobranza.cotizacion.moneda.SIMBOLO}}</strong>
  444 + <strong>{{((getTotalCobrado() + getTotalDeuda()) / cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong>
445 445 </td>
446 446 </tr>
447 447 </table>