From: Galen Charlton Date: Tue, 14 Dec 2021 22:56:53 +0000 (-0500) Subject: LP#1942220: implement LI search action apply claim policy X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=8c176b9373bef59c868f084397b466a00243e27f;p=working%2FEvergreen.git LP#1942220: implement LI search action apply claim policy Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.html index 8d6af1b0bf..d348ba34f5 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.html @@ -3,6 +3,10 @@ defaultSearchSetting="eg.acq.search.default.lineitems"> + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.ts index b0667f3cbd..2cb7b675bc 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.ts @@ -10,9 +10,12 @@ import {GridComponent} from '@eg/share/grid/grid.component'; import {GridDataSource, GridCellTextGenerator} from '@eg/share/grid/grid'; import {AcqSearchService, AcqSearchTerm, AcqSearch} from './acq-search.service'; import {LineitemService} from '../lineitem/lineitem.service'; +import {ToastService} from '@eg/share/toast/toast.service'; import {ExportAttributesDialogComponent} from '../lineitem/export-attributes-dialog.component'; import {AcqSearchFormComponent} from './acq-search-form.component'; +import {StringComponent} from '@eg/share/string/string.component'; import {AlertDialogComponent} from '@eg/share/dialog/alert.component'; +import {ClaimPolicyDialogComponent} from '../lineitem/claim-policy-dialog.component'; @Component({ selector: 'eg-lineitem-results', @@ -26,6 +29,8 @@ export class LineitemResultsComponent implements OnInit { @ViewChild('acqSearchForm', { static: true}) acqSearchForm: AcqSearchFormComponent; @ViewChild('acqSearchLineitemsGrid', { static: true }) lineitemResultsGrid: GridComponent; @ViewChild('exportAttributesDialog') exportAttributesDialog: ExportAttributesDialogComponent; + @ViewChild('claimPolicyDialog') claimPolicyDialog: ClaimPolicyDialogComponent; + @ViewChild('claimPolicyAppliedString', { static: false }) claimPolicyAppliedString: StringComponent; @ViewChild('noActionableLIs', { static: true }) private noActionableLIs: AlertDialogComponent; noSelectedRows: (rows: IdlObject[]) => boolean; @@ -37,6 +42,7 @@ export class LineitemResultsComponent implements OnInit { private route: ActivatedRoute, private net: NetService, private auth: AuthService, + private toast: ToastService, private liService: LineitemService, private acqSearch: AcqSearchService) { } @@ -81,7 +87,45 @@ export class LineitemResultsComponent implements OnInit { '/lineitem/' + row.id() + '/worksheet', '_blank'); } + applyClaimPolicy(rows: IdlObject[]) { + // must be attached to a PO; while this is not + // strictly necessary, seems to make sense that + // a claim policy is relevant only once you know + // who the vendor is + const lis = rows.filter(l => l.purchase_order()); + if (lis.length === 0) { + this.noActionableLIs.open(); + return; + } + const ids = lis.map(x => Number(x.id())); + + this.claimPolicyDialog.ids = ids; + this.claimPolicyDialog.open().subscribe(claimPolicy => { + if (!claimPolicy) { return; } + + const lisToUpdate: IdlObject[] = []; + this.liService.getFleshedLineitems(ids, { fromCache: true }).subscribe( + liStruct => { + liStruct.lineitem.claim_policy(claimPolicy); + lisToUpdate.push(liStruct.lineitem); + }, + err => { }, + () => { + this.net.request( + 'open-ils.acq', + 'open-ils.acq.lineitem.update', + this.auth.token(), lisToUpdate + ).toPromise().then(resp => { + this.claimPolicyAppliedString.current() + .then(str => this.toast.success(str)); + }); + } + ); + }); + } + createPurchaseOrder(rows: IdlObject[]) { + // must not be already attached to a PO const lis = rows.filter(l => !l.purchase_order()); if (lis.length === 0) { this.noActionableLIs.open();