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 gl_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, %params) = @_;
39 return _is_ir_record($self, $invoice, 'gl', %params);
43 my ($self, $invoice, $controller, %params) = @_;
45 $params{display} ||= 'inline';
47 croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
50 $params{no_link} ? '' : '<a href="' . $controller . '.pl?action=edit&type=invoice&id=' . $self->escape($invoice->id) . '">',
51 $self->escape($invoice->invnumber),
52 $params{no_link} ? '' : '</a>',
54 return $self->escaped_text($text);
67 SL::Presenter::Invoice - Presenter module for sales invoice, AR
68 transaction, purchase invoice and AP transaction Rose::DB objects
73 my $object = SL::DB::Manager::Invoice->get_first(where => [ invoice => 1 ]);
74 my $html = SL::Presenter->get->sales_invoice($object, display => 'inline');
77 my $object = SL::DB::Manager::Invoice->get_first(where => [ or => [ invoice => undef, invoice => 0 ]]);
78 my $html = SL::Presenter->get->ar_transaction($object, display => 'inline');
81 my $object = SL::DB::Manager::PurchaseInvoice->get_first(where => [ invoice => 1 ]);
82 my $html = SL::Presenter->get->purchase_invoice($object, display => 'inline');
85 my $object = SL::DB::Manager::PurchaseInvoice->get_first(where => [ or => [ invoice => undef, invoice => 0 ]]);
86 my $html = SL::Presenter->get->ar_transaction($object, display => 'inline');
92 =item C<sales_invoice $object, %params>
94 Returns a rendered version (actually an instance of
95 L<SL::Presenter::EscapedText>) of the sales invoice object C<$object>
98 C<%params> can include:
104 Either C<inline> (the default) or C<table-cell>. At the moment both
105 representations are identical and produce the invoice number linked
106 to the corresponding 'edit' action.
110 If falsish (the default) then the invoice number will be linked to the
111 "edit invoice" dialog from the sales menu.
115 =item C<ar_transaction $object, %params>
117 Returns a rendered version (actually an instance of
118 L<SL::Presenter::EscapedText>) of the AR transaction object C<$object>
121 C<%params> can include:
127 Either C<inline> (the default) or C<table-cell>. At the moment both
128 representations are identical and produce the invoice number linked
129 to the corresponding 'edit' action.
133 If falsish (the default) then the invoice number will be linked to the
134 "edit invoice" dialog from the general ledger menu.
138 =item C<purchase_invoice $object, %params>
140 Returns a rendered version (actually an instance of
141 L<SL::Presenter::EscapedText>) of the purchase invoice object
144 C<%params> can include:
150 Either C<inline> (the default) or C<table-cell>. At the moment both
151 representations are identical and produce the invoice number name
152 linked to the corresponding 'edit' action.
156 If falsish (the default) then the invoice number will be linked to
157 the "edit invoice" dialog from the purchase menu.
161 =item C<ap_transaction $object, %params>
163 Returns a rendered version (actually an instance of
164 L<SL::Presenter::EscapedText>) of the AP transaction object C<$object>
167 C<%params> can include:
173 Either C<inline> (the default) or C<table-cell>. At the moment both
174 representations are identical and produce the invoice number linked
175 to the corresponding 'edit' action.
179 If falsish (the default) then the invoice number will be linked to the
180 "edit invoice" dialog from the general ledger menu.
192 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>