- } else {
- push @newitems, $item;
- }
- }
- @items = @newitems;
-
- } while ( $lessflag );
-
- #and now that we've fallen out of the loop, distribute the rest equally...
-
- # should cust_bill_pay_pkg and cust_credit_bill_pkg amount columns
- # become real instead of numeric(10,2) ??? no..
- my $applyeach = sprintf("%.2f", $applytotal / scalar(@items) );
-
- my @equi_apply = map { [ $_, $applyeach ] } @items;
-
- # or should we futz with pennies instead? yes, bah!
- my $diff =
- sprintf('%.0f', 100 * ( $applytotal - $applyeach * scalar(@items) ) );
- $diff = 0 if $diff eq '-0'; #yay ieee fp
- if ( abs($diff) > scalar(@items) ) {
- #we must have done something really wrong, the difference is more than
- #a penny an item
- return 'Error distributing pennies applying '. $self->_app_source_name.
- " - can't distribute difference of $diff pennies".
- ' among '. scalar(@items). ' line items';
- }