<eg-acq-claim-policy-dialog #claimPolicyDialog></eg-acq-claim-policy-dialog>
<eg-string #claimPolicyAppliedString i18n-text text="Claim Policy Applied to Selected Line Item(s)"></eg-string>
+<eg-string #lineItemsReceivedString i18n-text text="Line Item(s) Received"></eg-string>
+<eg-string #lineItemsUnReceivedString i18n-text text="Line Item(s) Un-Received"></eg-string>
<eg-alert-dialog #noActionableLIs i18n-dialogBody
dialogBody="None of the selected line items are suitable for the action.">
(onClick)="applyClaimPolicy($event)" [disableOnRows]="noSelectedRows">
</eg-grid-toolbar-action>
<eg-grid-toolbar-action label="Mark Selected Line Items as Received" i18n-label
- (onClick)="markAsReceived($event)" [disableOnRows]="noSelectedRows">
+ (onClick)="markReceived($event)" [disableOnRows]="noSelectedRows">
</eg-grid-toolbar-action>
<eg-grid-toolbar-action label="Un-receive Selected Line Items" i18n-label
- (onClick)="unReceive($event)" [disableOnRows]="noSelectedRows">
+ (onClick)="markUnReceived($event)" [disableOnRows]="noSelectedRows">
</eg-grid-toolbar-action>
<eg-grid-toolbar-action label="Create Invoice from Selected Line Items" i18n-label
(onClick)="createInvoice($event)" [disableOnRows]="noSelectedRows">
@ViewChild('exportAttributesDialog') exportAttributesDialog: ExportAttributesDialogComponent;
@ViewChild('claimPolicyDialog') claimPolicyDialog: ClaimPolicyDialogComponent;
@ViewChild('claimPolicyAppliedString', { static: false }) claimPolicyAppliedString: StringComponent;
+ @ViewChild('lineItemsReceivedString', { static: false }) lineItemsReceivedString: StringComponent;
+ @ViewChild('lineItemsUnReceivedString', { static: false }) lineItemsUnReceivedString: StringComponent;
@ViewChild('noActionableLIs', { static: true }) private noActionableLIs: AlertDialogComponent;
noSelectedRows: (rows: IdlObject[]) => boolean;
this.liService.doExportSingleAttributeList(ids, attr);
});
}
+
+ markReceived(rows: IdlObject[]) {
+ // must be on-order
+ const lis = rows.filter(l => l.state() === 'on-order');
+ if (lis.length === 0) {
+ this.noActionableLIs.open();
+ return;
+ }
+
+ const ids = rows.map(x => Number(x.id()));
+ this.net.request(
+ 'open-ils.acq',
+ 'open-ils.acq.lineitem.receive.batch',
+ this.auth.token(), ids
+ ).toPromise().then(resp => {
+ this.lineItemsReceivedString.current()
+ .then(str => this.toast.success(str));
+ this.lineitemResultsGrid.reload();
+ });
+ }
+
+ markUnReceived(rows: IdlObject[]) {
+ // must be received
+ const lis = rows.filter(l => l.state() === 'received');
+ if (lis.length === 0) {
+ this.noActionableLIs.open();
+ return;
+ }
+
+ const ids = rows.map(x => Number(x.id()));
+ this.net.request(
+ 'open-ils.acq',
+ 'open-ils.acq.lineitem.receive.rollback.batch',
+ this.auth.token(), ids
+ ).toPromise().then(resp => {
+ this.lineItemsUnReceivedString.current()
+ .then(str => this.toast.success(str));
+ this.lineitemResultsGrid.reload();
+ });
+ }
+
}