LP1904036 Claims returned
authorBill Erickson <berickxx@gmail.com>
Fri, 26 Feb 2021 20:59:34 +0000 (15:59 -0500)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:24 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/circ/patron/items.component.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/summary.component.html
Open-ILS/src/eg2/src/app/staff/share/circ/claims-returned-dialog.component.html
Open-ILS/src/eg2/src/app/staff/share/circ/claims-returned-dialog.component.ts

index 170f84f..40ee8fd 100644 (file)
@@ -135,7 +135,7 @@ export class ItemsComponent implements OnInit, AfterViewInit {
     // Determine which grid ('checkouts' or 'other') a circ should appear in.
     promoteCircs(list: number[], displayCode: number, xactOpen?: boolean) {
         if (xactOpen) {
-            if (1 & displayCode) { // bitflag 1 == top list
+            if (1 & displayCode) { // bitflag 1 == main list
                 this.mainList = this.mainList.concat(list);
             } else {
                 this.altList = this.altList.concat(list);
index 1105f49..9c28ee7 100644 (file)
@@ -143,12 +143,12 @@ export class PatronComponent implements OnInit, AfterViewInit {
     }
 
     routeToAlertsPane() {
-        console.log('testing route change for alerts');
         if (this.patronTab !== 'search' &&
             this.context.patron &&
             this.context.alerts.hasAlerts() &&
-           !this.context.patronAlertsShown()) {
-           this.router.navigate(['/staff/circ/patron', this.patronId, 'alerts'])
+            !this.context.patronAlertsShown()) {
+
+           this.router.navigate(['/staff/circ/patron', this.patronId, 'alerts']);
         }
     }
 
index 4b6e162..4708178 100644 (file)
@@ -7,7 +7,7 @@
     {{patronService.namePart(context.patron, 'second_given_name')}}
   </h3>
 
-  <div class="row mb-1 alert alert-danger p-0" *ngIf="context.accountExpiresSoon">
+  <div class="row mb-1 alert alert-danger p-0" *ngIf="context.alerts.accountExpiresSoon">
     <div class="col-lg-12" i18n>
       Patron account will expire soon.  Please renew.
     </div>
@@ -49,7 +49,7 @@
     <div class="col-lg-5" i18n>Create Date</div>
     <div class="col-lg-7">{{context.patron.create_date() | date:'shortDate'}}</div>
   </div>
-  <div class="row" [ngClass]="{'alert alert-danger p-0': context.accountExpired}">
+  <div class="row" [ngClass]="{'alert alert-danger p-0': context.alerts.accountExpired}">
     <div class="col-lg-5" i18n>Expire Date</div>
     <div class="col-lg-7">{{context.patron.expire_date() | date:'shortDate'}}</div>
   </div>
index 4f43fd1..ea3c8ec 100644 (file)
         </eg-datetime-select>
       </div>
     </div>
-    <div *ngIf="patronExceeds" class="row">
-      <div class="col-lg-9 alert alert-danger" i18n>
+    <div *ngIf="patronExceeds" class="row mt-3 mb-3 d-flex">
+      <div class="flex-1 p-2 mr-2 alert alert-danger" i18n>
         Patron exceeds claims returned count.  Force this action?
       </div>
-      <div class="col-lg-3">
-        <button class="btn btn-warn" (click)="confirmExceeds()" i18n>Confirm</button>
+      <div>
+        <button class="btn btn-warning mr-2" 
+          (click)="confirmExceeds()" i18n>Confirm</button>
       </div>
     </div>
   </div>
index be32a10..2580d14 100644 (file)
@@ -1,6 +1,11 @@
 import {Component, OnInit, Output, Input, ViewChild, EventEmitter} from '@angular/core';
-import {Observable, empty, of, from} from 'rxjs';
+import {Observable, empty, of, from, throwError} from 'rxjs';
+import {concatMap, mergeMap, map} from 'rxjs/operators';
+import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap';
 import {DialogComponent} from '@eg/share/dialog/dialog.component';
+import {NetService} from '@eg/core/net.service';
+import {AuthService} from '@eg/core/auth.service';
+import {EventService} from '@eg/core/event.service';
 
 @Component({
   templateUrl: 'claims-returned-dialog.component.html',
@@ -12,18 +17,60 @@ export class ClaimsReturnedDialogComponent
     barcodes: string[];
     returnDate: string;
     patronExceeds: boolean;
+    completed: {[barcode: string]: boolean} = {};
+
+    constructor(
+        private modal: NgbModal,
+        private net: NetService,
+        private auth: AuthService,
+        private evt: EventService
+    ) { super(modal); }
 
     ngOnInit() {
         this.onOpen$.subscribe(_ => {
-            this.returnDate = new Date().toISOString()
+            this.returnDate = new Date().toISOString();
             this.patronExceeds = false;
+            this.completed = {};
         });
     }
 
-    modifyBatch() {
+    modifyBatch(override?: boolean) {
+
+        let method = 'open-ils.circ.circulation.set_claims_returned';
+        if (override) { method += '.override'; }
+
+        from(this.barcodes).pipe(concatMap(barcode => {
+
+            return this.net.request(
+                'open-ils.circ', method, this.auth.token(),
+                {barcode: barcode, backdate: this.returnDate}
+            ).pipe(mergeMap(response => {
+
+                if (Number(response) === 1) { return of(true); }
+
+                console.warn(response);
+
+                const evt = this.evt.parse(response);
+
+                if (evt &&
+                    evt.textcode === 'PATRON_EXCEEDS_CLAIMS_RETURN_COUNT') {
+                    this.patronExceeds = true;
+                    return throwError('Patron Exceeds Count'); // stop it all
+                }
+
+                return of(false);
+            }));
+        }))
+        .subscribe(
+            null,
+            err => console.log('Claims returned stopped with', err),
+            () => this.close(Object.keys(this.completed).length)
+        );
     }
 
     confirmExceeds() {
+        this.barcodes = this.barcodes.filter(b => !this.completed[b]);
+        this.modifyBatch(true);
     }
 }