sub user_transaction_history {
- my( $self, $conn, $auth, $userid, $type ) = @_;
+ my( $self, $conn, $auth, $userid, $type, $filter ) = @_;
+ $filter ||= {};
# run inside of a transaction to prevent replication delays
my $e = new_editor(authtoken=>$auth);
my $mbts = $e->search_money_billable_transaction_summary(
[
- { usr => $userid, @xact_finish },
+ { usr => $userid, @xact_finish, %$filter },
{ order_by => { mbt => 'xact_start DESC' } }
]
);
}
my $payment_ids = $e->json_query($query);
- $conn->respond($e->retrieve_money_payment($_->{id})) for @$payment_ids;
+ for my $pid (@$payment_ids) {
+ my $pay = $e->retrieve_money_payment([
+ $pid->{id},
+ { flesh => 6,
+ flesh_fields => {
+ mp => ['xact'],
+ mbt => ['summary', 'circulation', 'grocery'],
+ circ => ['target_copy'],
+ acp => ['call_number'],
+ acn => ['record']
+ }
+ }
+ ]);
+
+ my $resp = {
+ mp => $pay,
+ xact_type => $pay->xact->summary->xact_type,
+ last_billing_type => $pay->xact->summary->last_billing_type,
+ };
+
+ if($pay->xact->summary->xact_type eq 'circulation') {
+ $resp->{barcode} = $pay->xact->circulation->target_copy->barcode;
+ $resp->{title} = $U->record_to_mvr($pay->xact->circulation->target_copy->call_number->record)->title;
+ }
+
+ $pay->xact($pay->xact->id); # de-flesh
+ $conn->respond($resp);
+ }
return undef;
}