3 Business::BatchPayment::Batch
7 A Business::BatchPayment::Batch object represents a group of payment
8 requests or confirmations (L<Business::BatchPayment::Item>) submitted
9 to a bank (or returned from a bank) as a batch.
15 =item incoming - Flag for one-way batches. The processor must set
16 this if the batch was originated by the gateway.
18 =item batch_id - Batch identifier. The format is processor-specific
19 but usually must be a positive integer, if it's used at all.
21 Processor modules may include C<batch_id> in a reply batch ONLY if
22 it is guaranteed to match the batch_id of a request batch AND all
23 the items in the reply batch come from that request batch. Otherwise,
24 C<batch_id> must be undef. It must always be undef when using one-way
25 (receive-only) workflow, since there are no request batches.
27 =item process_date - The intended processing date for a request batch.
28 If not set, it will default to the start of the next day; if that's
29 not what you want, set it explicitly.
31 =item items - An arrayref of L<Business::BatchPayment::Item> objects
32 included in the batch.
36 If your processor uses C<format_header> and C<format_item>, this will
37 be set to 0 by C<format_header> and incremented every time C<format_item>
38 is called. Convenient for formats that require record numbers.
48 Returns a hash containing 'credit_count', 'credit_sum', 'payment_count',
49 and 'payment_sum'. These are the number of credits, sum of credit amounts,
50 number of payments, and sum of payment amounts.
54 package Business::BatchPayment::Batch;
58 use Moose::Util::TypeConstraints;
75 isa => 'ArrayRef[Business::BatchPayment::Item]',
78 elements => 'elements',
81 default => sub { [] },
84 class_type 'DateTime';
85 coerce 'DateTime', from 'Int', via { DateTime->from_epoch($_) };
92 # warn "No batch process date set; assuming tomorrow.\n";
93 DateTime->today->add(days => 1);
104 my %totals = map {$_ => 0}
105 qw(credit_count credit_sum payment_count payment_sum);
106 foreach ($self->elements) {
107 if ($_->action eq 'credit') {
108 $totals{credit_count}++;
109 $totals{credit_sum} += $_->amount;
110 } elsif ( $_->action eq 'payment') {
111 $totals{payment_count}++;
112 $totals{payment_sum} += $_->amount;