]> wagnertech.de Git - kivitendo-erp.git/blob - SL/Presenter/Invoice.pm
Bankerweiterung - Zwischenstand, erster Entwurf
[kivitendo-erp.git] / SL / Presenter / Invoice.pm
1 package SL::Presenter::Invoice;
2
3 use strict;
4
5 use parent qw(Exporter);
6
7 use Exporter qw(import);
8 our @EXPORT = qw(sales_invoice ar_transaction purchase_invoice ap_transaction gl_transaction);
9
10 use Carp;
11
12 sub sales_invoice {
13   my ($self, $invoice, %params) = @_;
14
15   return _is_ir_record($self, $invoice, 'is', %params);
16 }
17
18 sub ar_transaction {
19   my ($self, $invoice, %params) = @_;
20
21   return _is_ir_record($self, $invoice, 'ar', %params);
22 }
23
24 sub purchase_invoice {
25   my ($self, $invoice, %params) = @_;
26
27   return _is_ir_record($self, $invoice, 'ir', %params);
28 }
29
30 sub ap_transaction {
31   my ($self, $invoice, %params) = @_;
32
33   return _is_ir_record($self, $invoice, 'ap', %params);
34 }
35
36 sub gl_transaction {
37   my ($self, $invoice, %params) = @_;
38
39   return _is_ir_record($self, $invoice, 'gl', %params);
40 }
41
42 sub _is_ir_record {
43   my ($self, $invoice, $controller, %params) = @_;
44
45   $params{display} ||= 'inline';
46
47   croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
48
49   my $text = join '', (
50     $params{no_link} ? '' : '<a href="' . $controller . '.pl?action=edit&amp;type=invoice&amp;id=' . $self->escape($invoice->id) . '">',
51     $self->escape($invoice->invnumber),
52     $params{no_link} ? '' : '</a>',
53   );
54   return $self->escaped_text($text);
55 }
56
57 1;
58
59 __END__
60
61 =pod
62
63 =encoding utf8
64
65 =head1 NAME
66
67 SL::Presenter::Invoice - Presenter module for sales invoice, AR
68 transaction, purchase invoice and AP transaction Rose::DB objects
69
70 =head1 SYNOPSIS
71
72   # Sales invoices:
73   my $object = SL::DB::Manager::Invoice->get_first(where => [ invoice => 1 ]);
74   my $html   = SL::Presenter->get->sales_invoice($object, display => 'inline');
75
76   # AR transactions:
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');
79
80   # Purchase invoices:
81   my $object = SL::DB::Manager::PurchaseInvoice->get_first(where => [ invoice => 1 ]);
82   my $html   = SL::Presenter->get->purchase_invoice($object, display => 'inline');
83
84   # AP transactions:
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');
87
88 =head1 FUNCTIONS
89
90 =over 4
91
92 =item C<sales_invoice $object, %params>
93
94 Returns a rendered version (actually an instance of
95 L<SL::Presenter::EscapedText>) of the sales invoice object C<$object>
96 .
97
98 C<%params> can include:
99
100 =over 2
101
102 =item * display
103
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.
107
108 =item * no_link
109
110 If falsish (the default) then the invoice number will be linked to the
111 "edit invoice" dialog from the sales menu.
112
113 =back
114
115 =item C<ar_transaction $object, %params>
116
117 Returns a rendered version (actually an instance of
118 L<SL::Presenter::EscapedText>) of the AR transaction object C<$object>
119 .
120
121 C<%params> can include:
122
123 =over 2
124
125 =item * display
126
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.
130
131 =item * no_link
132
133 If falsish (the default) then the invoice number will be linked to the
134 "edit invoice" dialog from the general ledger menu.
135
136 =back
137
138 =item C<purchase_invoice $object, %params>
139
140 Returns a rendered version (actually an instance of
141 L<SL::Presenter::EscapedText>) of the purchase invoice object
142 C<$object>.
143
144 C<%params> can include:
145
146 =over 2
147
148 =item * display
149
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.
153
154 =item * no_link
155
156 If falsish (the default) then the invoice number will be linked to
157 the "edit invoice" dialog from the purchase menu.
158
159 =back
160
161 =item C<ap_transaction $object, %params>
162
163 Returns a rendered version (actually an instance of
164 L<SL::Presenter::EscapedText>) of the AP transaction object C<$object>
165 .
166
167 C<%params> can include:
168
169 =over 2
170
171 =item * display
172
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.
176
177 =item * no_link
178
179 If falsish (the default) then the invoice number will be linked to the
180 "edit invoice" dialog from the general ledger menu.
181
182 =back
183
184 =back
185
186 =head1 BUGS
187
188 Nothing here yet.
189
190 =head1 AUTHOR
191
192 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
193
194 =cut