<eg-acq-export-attributes-dialog #exportAttributesDialog></eg-acq-export-attributes-dialog>
<eg-acq-claim-policy-dialog #claimPolicyDialog></eg-acq-claim-policy-dialog>
+<eg-acq-cancel-dialog #cancelDialog></eg-acq-cancel-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-string #lineItemsCancelledString i18n-text text="Line Item(s) Canceled"></eg-string>
<eg-alert-dialog #noActionableLIs i18n-dialogBody
dialogBody="None of the selected line items are suitable for the action.">
import {StringComponent} from '@eg/share/string/string.component';
import {AlertDialogComponent} from '@eg/share/dialog/alert.component';
import {ClaimPolicyDialogComponent} from '../lineitem/claim-policy-dialog.component';
+import {CancelDialogComponent} from '../lineitem/cancel-dialog.component';
@Component({
selector: 'eg-lineitem-results',
@ViewChild('acqSearchLineitemsGrid', { static: true }) lineitemResultsGrid: GridComponent;
@ViewChild('exportAttributesDialog') exportAttributesDialog: ExportAttributesDialogComponent;
@ViewChild('claimPolicyDialog') claimPolicyDialog: ClaimPolicyDialogComponent;
+ @ViewChild('cancelDialog') cancelDialog: CancelDialogComponent;
@ViewChild('claimPolicyAppliedString', { static: false }) claimPolicyAppliedString: StringComponent;
@ViewChild('lineItemsReceivedString', { static: false }) lineItemsReceivedString: StringComponent;
@ViewChild('lineItemsUnReceivedString', { static: false }) lineItemsUnReceivedString: StringComponent;
+ @ViewChild('lineItemsCancelledString', { static: false }) lineItemsCancelledString: StringComponent;
@ViewChild('noActionableLIs', { static: true }) private noActionableLIs: AlertDialogComponent;
noSelectedRows: (rows: IdlObject[]) => boolean;
});
}
+ cancelLineitems(rows: IdlObject[]) {
+ // must be attached to a PO and have a state of
+ // either 'on-order' or 'cancelled'
+ const lis = rows.filter(l =>
+ l.purchase_order() && ['on-order', 'cancelled'].includes(l.state())
+ );
+ if (lis.length === 0) {
+ this.noActionableLIs.open();
+ return;
+ }
+ const ids = lis.map(x => Number(x.id()));
+ this.cancelDialog.open().subscribe(reason => {
+ if (!reason) { return; }
+
+ this.net.request('open-ils.acq',
+ 'open-ils.acq.lineitem.cancel.batch',
+ this.auth.token(), ids, reason
+ ).toPromise().then(resp => {
+ this.lineItemsCancelledString.current()
+ .then(str => this.toast.success(str));
+ this.lineitemResultsGrid.reload();
+ });
+ });
+ }
+
createPurchaseOrder(rows: IdlObject[]) {
// must not be already attached to a PO
const lis = rows.filter(l => !l.purchase_order());