Skip to content

Commit

Permalink
Nicer handling of customer references.
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Sep 10, 2015
1 parent 5d9df90 commit 48cade6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions lib/Magnum/Schema/Result/Invoice.pm
Expand Up @@ -278,7 +278,33 @@ sub pretty_id {
return sprintf('%05d', $self->id);
}

sub has_cust_ref_desc {
my $self = shift;

return !! $self->get_cust_ref_desc;
}

sub get_cust_ref_desc {
my $self = shift;

return $self->cust_ref_desc if $self->cust_ref_desc;
return unless $self->contract;
return $self->contract->cust_ref_desc;
}

sub has_cust_ref {
my $self = shift;

return !! $self->get_cust_ref;
}

sub get_cust_ref {
my $self = shift;

return $self->cust_ref if $self->cust_ref;
return unless $self->contract;
return $self->contract->cust_ref;
}

# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable;
Expand Down
2 changes: 1 addition & 1 deletion tt_lib/invoice.tt
Expand Up @@ -18,7 +18,7 @@ accounts@mag-sol.com</div>

<div id="refs">Invoice&nbsp;No:&nbsp;[% inv.pretty_id -%]
[% IF inv.contract %] (covers [% inv.date.strftime('%B %Y') %])[% END -%]
[% IF inv.cust_ref || inv.contract.cust_ref %] <br/> [% inv.contract.cust_ref_desc || 'PO Number' %]: [% inv.cust_ref || inv.contract.cust_ref; END; IF inv.contract && inv.contract.cust_contact %] <br /> [% inv.contract.cust_contact_desc || 'Customer Contact' %]: [% inv.contract.cust_contact; END %]</div>
[% IF inv.has_cust_ref %] <br/> [% inv.get_cust_ref_desc || 'PO Number' %]: [% inv.get_cust_ref; END; IF inv.contract && inv.contract.cust_contact %] <br /> [% inv.contract.cust_contact_desc || 'Customer Contact' %]: [% inv.contract.cust_contact; END %]</div>

<table id="lines">
[% IF inv.has_vat_lines;
Expand Down

0 comments on commit 48cade6

Please sign in to comment.