App-Office-Contacts-Donations

 view release on metacpan or  search on metacpan

lib/App/Office/Contacts/Donations/View/Role/Report.pm  view on Meta::CPAN

package App::Office::Contacts::Donations::View::Role::Report;

use JSON::XS;

use Moose::Role;

our $VERSION = '1.10';

# -----------------------------------------------

sub build_report_by_amount
{
	my($self, $donation, $organizations_table_id, $people_table_id) = @_;

	$self -> log(debug => 'Entered build_report_by_amount');

	my(%donation);
	my($item);
	my($name);
	my(%organization, $organization);
	my(%person, $person);
	my($type);

	for $item (@$donation)
	{
		if ($$item{'table_name_id'} == $organizations_table_id)
		{
			# Get name from cache, if possible.

			if ($organization{$$item{'table_id'} })
			{
				$name = $organization{$$item{'table_id'} };
				$type = 'organization';
			}
			else
			{
				$organization = $self -> db -> organization -> get_organization_via_id($$item{'table_id'});
				$name         = $organization{$$item{'table_id'} } = $$organization{'name'};
				$type         = 'organization';
			}
		}
		else
		{
			# Get name from cache, if possible.

			if ($person{$$item{'table_id'} })
			{
				$name = $person{$$item{'table_id'} };
				$type = 'person';
			}
			else
			{
				$person = $self -> db -> person -> get_person_via_id($$item{'table_id'});
				$name   = $person{$$item{'table_id'} } = $$person{'name'};
				$type   = 'person';
			}
		}

		if (! $donation{$name})
		{
			$donation{$name} =
			{
				amount => 0,



( run in 1.353 second using v1.01-cache-2.11-cpan-f56aa216473 )