Bigtop

 view release on metacpan or  search on metacpan

examples/Billing-Finished/lib/Bigtop/Example/Billing/Invoice.pm  view on Meta::CPAN

package Bigtop::Example::Billing::Invoice;

use strict;

use base 'Bigtop::Example::Billing::GEN::Invoice';

use PDF::API2;

use Gantry::Plugins::AutoCRUD qw(
    do_add
    do_edit
    do_delete
    form_name
);

use Bigtop::Example::Billing::Model::invoice qw(
    $INVOICE
);
use Bigtop::Example::Billing::Model;
use Bigtop::Example::Billing::Model::line_item qw( $LINE_ITEM );

sub schema_base_class { return 'Bigtop::Example::Billing::Model'; }
use Gantry::Plugins::DBIxClassConn qw( get_schema );
use Gantry::Plugins::Calendar qw(
    do_calendar_month
    calendar_month_js
);

#-----------------------------------------------------------------
# $self->do_pdf( $id )
#-----------------------------------------------------------------
sub do_pdf {
    my $self = shift;
#    $self->do_fake_pdf( @_ );
    $self->do_real_pdf( @_ );
}

#-----------------------------------------------------------------
# $self->do_fake_pdf( $id )
#-----------------------------------------------------------------
sub do_fake_pdf {
    my ( $self, $id ) = @_;

    # pull variables out of invoice row ready for here doc
    my $invoice     = $INVOICE->gfind( $self, $id );
    my $invoice_num = $invoice->number;
    my $sent        = $invoice->sent;
    my $description = $invoice->description || '';

    $description    = "\n$description\n" if $description;

    # my company data
    my %corp_data;

    foreach my $column qw( name address city state zip contact_phone ) {
        $corp_data{ $column } = $invoice->my_company->$column();
    }

    # customer data
    my %cust_data;
    foreach my $column
            qw( name address city state zip contact_phone contact_name )
    {
        $cust_data{ $column } = $invoice->customer->$column();
    }

    # tasks, pass the buck
    my ( $task_output, $total ) = $self->_task_output( $id );

    my $retval = << "EO_Invoice";
Billed By:
$corp_data{ name }
$corp_data{ address }
$corp_data{ city }, $corp_data{ state } $corp_data{ zip }
$corp_data{ contact_phone }

Billed To:
$cust_data{ name }
$cust_data{ address }
$cust_data{ city }, $cust_data{ state } $cust_data{ zip }
$cust_data{ contact_phone }
Attn: $cust_data{ contact_name }

Invoice Number: $invoice_num Invoice Date: $sent $description

Date         Hours    Rate/hr    Total   Task



( run in 1.387 second using v1.01-cache-2.11-cpan-d8267643d1d )