1 package SL::Presenter::Invoice;
5 use parent qw(Exporter);
7 use Exporter qw(import);
8 our @EXPORT = qw(invoice sales_invoice ar_transaction purchase_invoice ap_transaction gl_transaction);
13 my ($self, $invoice, %params) = @_;
15 if ( $invoice->is_sales ) {
16 if ( $invoice->invoice ) {
17 return _is_ir_record($self, $invoice, 'is', %params);
19 return _is_ir_record($self, $invoice, 'ar', %params);
22 if ( $invoice->invoice ) {
23 return _is_ir_record($self, $invoice, 'ir', %params);
25 return _is_ir_record($self, $invoice, 'ap', %params);
31 my ($self, $invoice, %params) = @_;
33 return _is_ir_record($self, $invoice, 'is', %params);
37 my ($self, $invoice, %params) = @_;
39 return _is_ir_record($self, $invoice, 'ar', %params);
42 sub purchase_invoice {
43 my ($self, $invoice, %params) = @_;
45 return _is_ir_record($self, $invoice, 'ir', %params);
49 my ($self, $invoice, %params) = @_;
51 return _is_ir_record($self, $invoice, 'ap', %params);
55 my ($self, $invoice, %params) = @_;
57 return _is_ir_record($self, $invoice, 'gl', %params);
61 my ($self, $invoice, $controller, %params) = @_;
63 $params{display} ||= 'inline';
65 croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
68 $params{no_link} ? '' : '<a href="' . $controller . '.pl?action=edit&type=invoice&id=' . $self->escape($invoice->id) . '">',
69 $self->escape($invoice->invnumber),
70 $params{no_link} ? '' : '</a>',
72 return $self->escaped_text($text);
85 SL::Presenter::Invoice - Presenter module for sales invoice, AR
86 transaction, purchase invoice and AP transaction Rose::DB objects
91 my $object = SL::DB::Manager::Invoice->get_first(where => [ invoice => 1 ]);
92 my $html = SL::Presenter->get->sales_invoice($object, display => 'inline');
95 my $object = SL::DB::Manager::Invoice->get_first(where => [ or => [ invoice => undef, invoice => 0 ]]);
96 my $html = SL::Presenter->get->ar_transaction($object, display => 'inline');
99 my $object = SL::DB::Manager::PurchaseInvoice->get_first(where => [ invoice => 1 ]);
100 my $html = SL::Presenter->get->purchase_invoice($object, display => 'inline');
103 my $object = SL::DB::Manager::PurchaseInvoice->get_first(where => [ or => [ invoice => undef, invoice => 0 ]]);
104 my $html = SL::Presenter->get->ar_transaction($object, display => 'inline');
106 # use with any of the above ar/ap/is/ir types:
107 my $html = SL::Presenter->get->invoice($object, display => 'inline');
113 =item C<invoice $object, %params>
115 Returns a rendered version (actually an instance of
116 L<SL::Presenter::EscapedText>) of an ar/ap/is/ir object C<$object> . Determines
117 which type (sales or purchase, invoice or not) the object is.
119 C<%params> can include:
125 Either C<inline> (the default) or C<table-cell>. At the moment both
126 representations are identical and produce the invoice number linked
127 to the corresponding 'edit' action.
131 If falsish (the default) then the invoice number will be linked to the
132 "edit invoice" dialog from the sales menu.
136 =item C<sales_invoice $object, %params>
138 Returns a rendered version (actually an instance of
139 L<SL::Presenter::EscapedText>) of the sales invoice object C<$object>
142 C<%params> can include:
148 Either C<inline> (the default) or C<table-cell>. At the moment both
149 representations are identical and produce the invoice number linked
150 to the corresponding 'edit' action.
154 If falsish (the default) then the invoice number will be linked to the
155 "edit invoice" dialog from the sales menu.
159 =item C<ar_transaction $object, %params>
161 Returns a rendered version (actually an instance of
162 L<SL::Presenter::EscapedText>) of the AR transaction object C<$object>
165 C<%params> can include:
171 Either C<inline> (the default) or C<table-cell>. At the moment both
172 representations are identical and produce the invoice number linked
173 to the corresponding 'edit' action.
177 If falsish (the default) then the invoice number will be linked to the
178 "edit invoice" dialog from the general ledger menu.
182 =item C<purchase_invoice $object, %params>
184 Returns a rendered version (actually an instance of
185 L<SL::Presenter::EscapedText>) of the purchase invoice object
188 C<%params> can include:
194 Either C<inline> (the default) or C<table-cell>. At the moment both
195 representations are identical and produce the invoice number name
196 linked to the corresponding 'edit' action.
200 If falsish (the default) then the invoice number will be linked to
201 the "edit invoice" dialog from the purchase menu.
205 =item C<ap_transaction $object, %params>
207 Returns a rendered version (actually an instance of
208 L<SL::Presenter::EscapedText>) of the AP transaction object C<$object>
211 C<%params> can include:
217 Either C<inline> (the default) or C<table-cell>. At the moment both
218 representations are identical and produce the invoice number linked
219 to the corresponding 'edit' action.
223 If falsish (the default) then the invoice number will be linked to the
224 "edit invoice" dialog from the general ledger menu.
236 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>