1 package SL::Presenter::Invoice;
5 use parent qw(Exporter);
7 use Exporter qw(import);
8 our @EXPORT = qw(sales_invoice ar_transaction purchase_invoice ap_transaction);
13 my ($self, $invoice, %params) = @_;
15 return _is_ir_record($self, $invoice, 'is', %params);
19 my ($self, $invoice, %params) = @_;
21 return _is_ir_record($self, $invoice, 'ar', %params);
24 sub purchase_invoice {
25 my ($self, $invoice, %params) = @_;
27 return _is_ir_record($self, $invoice, 'ir', %params);
31 my ($self, $invoice, %params) = @_;
33 return _is_ir_record($self, $invoice, 'ap', %params);
37 my ($self, $invoice, $controller, %params) = @_;
39 $params{display} ||= 'inline';
41 croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
44 $params{no_link} ? '' : '<a href="' . $controller . '.pl?action=edit&type=invoice&id=' . $self->escape($invoice->id) . '">',
45 $self->escape($invoice->invnumber),
46 $params{no_link} ? '' : '</a>',
48 return $self->escaped_text($text);
61 SL::Presenter::Invoice - Presenter module for sales invoice, AR
62 transaction, purchase invoice and AP transaction Rose::DB objects
67 my $object = SL::DB::Manager::Invoice->get_first(where => [ invoice => 1 ]);
68 my $html = SL::Presenter->get->sales_invoice($object, display => 'inline');
71 my $object = SL::DB::Manager::Invoice->get_first(where => [ or => [ invoice => undef, invoice => 0 ]]);
72 my $html = SL::Presenter->get->ar_transaction($object, display => 'inline');
75 my $object = SL::DB::Manager::PurchaseInvoice->get_first(where => [ invoice => 1 ]);
76 my $html = SL::Presenter->get->purchase_invoice($object, display => 'inline');
79 my $object = SL::DB::Manager::PurchaseInvoice->get_first(where => [ or => [ invoice => undef, invoice => 0 ]]);
80 my $html = SL::Presenter->get->ar_transaction($object, display => 'inline');
86 =item C<sales_invoice $object, %params>
88 Returns a rendered version (actually an instance of
89 L<SL::Presenter::EscapedText>) of the sales invoice object C<$object>
92 C<%params> can include:
98 Either C<inline> (the default) or C<table-cell>. At the moment both
99 representations are identical and produce the invoice number linked
100 to the corresponding 'edit' action.
104 If falsish (the default) then the invoice number will be linked to the
105 "edit invoice" dialog from the sales menu.
109 =item C<ar_transaction $object, %params>
111 Returns a rendered version (actually an instance of
112 L<SL::Presenter::EscapedText>) of the AR transaction object C<$object>
115 C<%params> can include:
121 Either C<inline> (the default) or C<table-cell>. At the moment both
122 representations are identical and produce the invoice number linked
123 to the corresponding 'edit' action.
127 If falsish (the default) then the invoice number will be linked to the
128 "edit invoice" dialog from the general ledger menu.
132 =item C<purchase_invoice $object, %params>
134 Returns a rendered version (actually an instance of
135 L<SL::Presenter::EscapedText>) of the purchase invoice object
138 C<%params> can include:
144 Either C<inline> (the default) or C<table-cell>. At the moment both
145 representations are identical and produce the invoice number name
146 linked to the corresponding 'edit' action.
150 If falsish (the default) then the invoice number will be linked to
151 the "edit invoice" dialog from the purchase menu.
155 =item C<ap_transaction $object, %params>
157 Returns a rendered version (actually an instance of
158 L<SL::Presenter::EscapedText>) of the AP transaction object C<$object>
161 C<%params> can include:
167 Either C<inline> (the default) or C<table-cell>. At the moment both
168 representations are identical and produce the invoice number linked
169 to the corresponding 'edit' action.
173 If falsish (the default) then the invoice number will be linked to the
174 "edit invoice" dialog from the general ledger menu.
186 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>