Business-AU-Ledger

 view release on metacpan or  search on metacpan

lib/Business/AU/Ledger/View/Receipt.pm  view on Meta::CPAN

package Business::AU::Ledger::View::Receipt;

use Business::AU::Ledger::Util::Validate;

use Date::Simple;

use JSON::XS;

use Moose;

extends 'Business::AU::Ledger::View::Base';

has field_width => (is => 'rw', isa => 'HashRef');
has row_count   => (is => 'rw', isa => 'Int');

use namespace::autoclean;

our $VERSION = '0.88';

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

sub BUILD
{
	my($self) = @_;

	$self -> field_width
	(
	 {
		 amount      => 12,
		 bank_amount => 12,
		 comment     => 20,
		 day         =>  5, # For 'Total'.
		 gst_amount  => 12,
		 reference   => 10,
	 }
	);
	$self -> row_count(0);

} # End of BUILD;

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

sub format
{
	my($self, $output) = @_;

	my($field);
	my($row, @row);

	for $row (@$output)
	{
		$field = $self -> format_fields($row);

		push @row, $field;
	}

	$self -> log(__PACKAGE__ . '. Leaving format');

	return [@row];

} # End of format.

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

sub format_fields
{
	my($self, $default) = @_;
	$default            ||= {};

	# Ensure all fields, except menus, have defaults.

	for (qw/amount bank_amount comment day error gst_amount reference timestamp/)
	{
		if (! defined $$default{$_})
		{
			$$default{$_} = '';



( run in 3.254 seconds using v1.01-cache-2.11-cpan-63c85eba8c4 )