Skip to content

Commit

Permalink
Added a pretty_id() method to Invoice. Used it.
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Aug 3, 2015
1 parent dcce62d commit 8aadd15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions lib/Magnum/Schema/Result/Invoice.pm
Expand Up @@ -261,10 +261,15 @@ sub grand_total {
sub filename {
my $self = shift;

return sprintf('inv%05d', $self->id);
return 'inv' . $self->pretty_id;
}

sub pretty_id {
my $self = shift;

return sprintf('%05d', $self->id);
}

1;


# You can replace this text with custom code or comments, and it will be preserved on regeneration
Expand Down
4 changes: 2 additions & 2 deletions tt_lib/invoice.tt
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf8" />
<title>Invoice [% inv.id | format('%05d') %]</title>
<title>Invoice [% inv.pretty_id %]</title>
<link rel="stylesheet" type="text/css" href="css/invoice.css" />
</head>
<body>
Expand All @@ -16,7 +16,7 @@ accounts@mag-sol.com</div>
[% line %]<br />
[% END -%]</div>

<div id="refs">Invoice&nbsp;No:&nbsp;[% inv.id | format('%05d') -%]
<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>

Expand Down

0 comments on commit 8aadd15

Please sign in to comment.