Skip to content

Commit

Permalink
patrons: restore fee count and refactoring patron history
Browse files Browse the repository at this point in the history
* Fixes count on fees tab and total on header.
* Uses the `operation logs` inex to display the patron history.
* Closes rero/rero-ils#2319.
* Closes rero/rero-ils#1902.
* Closes rero/rero-ils#1227.

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
  • Loading branch information
Garfield-fr committed Oct 14, 2021
1 parent d36099a commit a55d3ab
Show file tree
Hide file tree
Showing 38 changed files with 528 additions and 414 deletions.
43 changes: 41 additions & 2 deletions projects/admin/src/app/api/operation-logs-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,23 @@
import { Injectable } from '@angular/core';
import { Record, RecordService } from '@rero/ng-core';
import { Error } from '@rero/ng-core/lib/error/error';
import { BaseApi } from '@rero/shared';
import moment from 'moment';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

@Injectable({
providedIn: 'root'
})
export class OperationLogsApiService {
export class OperationLogsApiService extends BaseApi {

/**
* Constructor
* @param _recordService - RecordService
*/
constructor(private _recordService: RecordService) { }
constructor(private _recordService: RecordService) {
super();
}

/**
* Get Operation logs by resource type and resource pid
Expand Down Expand Up @@ -65,4 +70,38 @@ export class OperationLogsApiService {
undefined, undefined, undefined, sort
);
}

/**
* Get history
* @param patronPid - string
* @param page - number
* @param itemsPerPage - number
* @return Observable
*/
getCheckInHistory(patronPid: string, page: number, itemsPerPage: number = 10): Observable<Record | Error> {
const date = moment().subtract(6, 'months').utc().format('YYYY-MM-DDTHH:mm:ss');
const query = `_exists_:loan AND loan.patron.pid:${patronPid} AND loan.trigger:checkin AND date:[${date} TO *]`;
return this._recordService.getRecords(
'operation_logs', query, page, itemsPerPage,
undefined, undefined, BaseApi.reroJsonheaders, 'mostrecent'
);
}

/**
* Get history by load pid
* @param loanPid - string
* @param type - string
* @returns Observable
*/
getHistoryByLoanPid(loanPid: string, type: string = 'checkin'): Observable<Record | Error> {
const query = `_exists_:loan AND loan.pid:${loanPid} AND loan.trigger:${type}`;
return this._recordService.getRecords(
'operation_logs', query, 1, 1,
undefined, undefined, BaseApi.reroJsonheaders
).pipe(map((result: any) => {
return this._recordService.totalHits(result.hits.total) === 1
? result.hits.hits[0]
: {};
}));
}
}
12 changes: 7 additions & 5 deletions projects/admin/src/app/circulation/circulation.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ import { RequestedItemComponent } from './main-request/requested-item/requested-
import { RequestedItemsListComponent } from './main-request/requested-items-list/requested-items-list.component';
import { CardComponent } from './patron/card/card.component';
import { ChangePasswordFormComponent } from './patron/change-password-form/change-password-form.component';
import { HistoryItemComponent } from './patron/history/history-item/history-item.component';
import { HistoryLogLibraryComponent } from './patron/history/history-log-library/history-log-library.component';
import { HistoryLogComponent } from './patron/history/history-log/history-log.component';
import { HistoryComponent } from './patron/history/history.component';
import { FixedDateFormComponent } from './patron/loan/fixed-date-form/fixed-date-form.component';
import { LoanComponent } from './patron/loan/loan.component';
import { MainComponent } from './patron/main/main.component';
import { OverdueTransactionComponent } from './patron/patron-transactions/overdue-transaction/overdue-transaction.component';
import {
PatronTransactionEventFormComponent
} from './patron/patron-transactions/patron-transaction-event-form/patron-transaction-event-form.component';
Expand All @@ -55,8 +58,6 @@ import { PendingComponent } from './patron/pending/pending.component';
import { PickupItemComponent } from './patron/pickup/pickup-item/pickup-item.component';
import { PickupComponent } from './patron/pickup/pickup.component';
import { ProfileComponent } from './patron/profile/profile.component';
import { FixedDateFormComponent } from './patron/loan/fixed-date-form/fixed-date-form.component';
import { OverdueTransactionComponent } from './patron/patron-transactions/overdue-transaction/overdue-transaction.component';


@NgModule({
Expand All @@ -83,11 +84,12 @@ import { OverdueTransactionComponent } from './patron/patron-transactions/overdu
OverdueTransactionDetailComponent,
PatronTransactionEventFormComponent,
HistoryComponent,
HistoryItemComponent,
RequestedItemComponent,
ChangePasswordFormComponent,
FixedDateFormComponent,
OverdueTransactionComponent
OverdueTransactionComponent,
HistoryLogComponent,
HistoryLogLibraryComponent
],
imports: [
BsDropdownModule.forRoot(),
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
RERO ILS UI
Copyright (C) 2021 RERO
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<i class="fa fa-map-marker mr-1"></i>
<ng-container *ngIf="location.library; else noLibrary">
{{ location.library.name }}
</ng-container>
<ng-template #noLibrary>
{{ location.name }}
</ng-template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* RERO ILS UI
* Copyright (C) 2021 RERO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { ComponentFixture, TestBed } from '@angular/core/testing';
import { HistoryLogLibraryComponent } from './history-log-library.component';

describe('HistoryLogLibraryComponent', () => {
let component: HistoryLogLibraryComponent;
let fixture: ComponentFixture<HistoryLogLibraryComponent>;

const location = {
library: {
name: 'library name',
pid: '1'
}
};

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [HistoryLogLibraryComponent]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(HistoryLogLibraryComponent);
component = fixture.componentInstance;
component.location = location;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Loading

0 comments on commit a55d3ab

Please sign in to comment.