<li class="list-group-item">
<eg-progress-inline min="0" max="0" #progress></eg-progress-inline>
</li>
+ <li class="list-group-item" *ngFor="let li of receiveResponse.lineitems">
+ {{li.lids.length}} item(s) received for line item
+ <a target="_blank" fragment="{{li.id}}"
+ routerLink="/staff/acq/po/{{li.po}}">#{{li.id}}</a>.
+ </li>
</ul>
</div>
+ <div class="card-footer d-flex">
+ <div class="flex-1"></div>
+ <button (click)="clearReceiving()" class="btn btn-outline-dark" i18n>
+ Close
+ </button>
+ </div>
</div>
</div>
</div>
import {GridComponent} from '@eg/share/grid/grid.component';
import {ProgressInlineComponent} from '@eg/share/dialog/progress-inline.component';
+interface ReceiveResponse {
+ progress: number;
+ lineitems: any[];
+ complete: boolean;
+ po: number;
+}
+
@Component({
templateUrl: 'receive.component.html'
})
container: IdlObject;
entries: IdlObject[] = [];
containers: IdlObject[] = [];
+ receiveResponse: ReceiveResponse;
@ViewChild('grid') private grid: GridComponent;
@ViewChild('progress') private progress: ProgressInlineComponent;
}
findContainer() {
+ this.receiving = false;
this.container = null;
this.containers = [];
this.entries = [];
this.receiving = true;
this.dryRun = dryRun;
+ this.receiveResponse = {
+ progress: 0,
+ lineitems: [],
+ complete: false,
+ po: null
+ };
+
setTimeout(() => // Allow time to render
- this.progress.update({value: 0, max: this.entries.length}));
+ this.progress.update({value: 0, max: this.affectedItemsCount()}));
let method = 'open-ils.acq.shipment_notification.receive_items';
if (dryRun) { method += '.dry_run'; }
method, this.auth.token(), this.container.id())
.subscribe(
resp => {
+ this.progress.update({value: resp.progress});
console.debug("ASN Receive returned", resp);
+ this.receiveResponse = resp;
},
err => {},
() => {
}
);
}
+
+ clearReceiving() {
+ this.receiving = false;
+ this.findContainer();
+ }
}
my $e = new_editor(xact => 1, authtoken => $auth);
return $e->die_event unless $e->checkauth;
- my $mgr =
- OpenILS::Application::Acq::BatchManager->new(editor => $e, conn => $client);
+ my $mgr = OpenILS::Application::Acq::BatchManager->new(
+ editor => $e, conn => $client, throttle => 1);
my $asn = $e->retrieve_acq_shipment_notification([$asn_id,
{flesh => 1, flesh_fields => {acqsn => ['provider', 'entries']}}
return $e->die_event unless
$e->allowed('MANAGE_SHIPMENT_NOTIFICATION', $asn->provider->owner);
- for my $entry (@{$asn->entries}) {
+ my $resp = {
+ lineitems => [],
+ progress => 0,
+ };
+
+ my @entries = sort {$a->lineitem cmp $b->lineitem} @{$asn->entries};
+
+ for my $entry (@entries) {
+
+ my $li = $e->retrieve_acq_lineitem($entry->lineitem)
+ or return $e->die_event;
+
+ my $li_resp = {
+ id => $entry->lineitem,
+ po => $li->purchase_order,
+ lids => []
+ };
- my $lid_ids = $e->search_acq_lineitem_detail([
- { lineitem => $entry->lineitem,
+ push(@{$resp->{lineitems}}, $li_resp);
+
+ my $lid_ids = $e->search_acq_lineitem_detail(
+ [{ lineitem => $entry->lineitem,
recv_time => undef,
cancel_reason => undef # TODO delayed?
}, {
for my $li_id (@$lid_ids) {
return $e->die_event unless receive_lineitem_detail($mgr, $li_id);
- $mgr->respond;
+
+ my $lid = $e->retrieve_acq_lineitem_detail($li_id);
+
+ my $note = $lid->note ? $lid->note . "\n" : '';
+ $note .= "Received via shipment notification #$asn_id";
+ $lid->note($note);
+
+ $e->update_acq_lineitem_detail($lid) or return $e->die_event;
+
+ push(@{$li_resp->{lids}}, $li_id);
+ $resp->{progress}++;
+ $client->respond($resp);
}
}
$e->commit;
}
- $mgr->respond_complete;
+ $resp->{complete} = 1;
+ $client->respond_complete($resp);
undef;
}