Revision 59d0eec3
Von Sven Schöling vor fast 8 Jahren hinzugefügt
SL/DB/GLTransaction.pm | ||
---|---|---|
5 | 5 |
use SL::DB::MetaSetup::GLTransaction; |
6 | 6 |
use SL::Locale::String qw(t8); |
7 | 7 |
use List::Util qw(sum); |
8 |
use SL::Presenter::GLTransaction; |
|
8 | 9 |
|
9 | 10 |
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. |
10 | 11 |
__PACKAGE__->meta->make_manager_class; |
... | ... | |
23 | 24 |
|
24 | 25 |
__PACKAGE__->meta->initialize; |
25 | 26 |
|
26 |
sub abbreviation { |
|
27 |
my $self = shift; |
|
28 |
|
|
29 |
my $abbreviation = $::locale->text('GL Transaction (abbreviation)'); |
|
30 |
$abbreviation .= "(" . $::locale->text('Storno (one letter abbreviation)') . ")" if $self->storno; |
|
31 |
return $abbreviation; |
|
32 |
} |
|
33 |
|
|
34 |
sub displayable_type { |
|
35 |
return t8('GL Transaction'); |
|
36 |
} |
|
37 |
|
|
38 |
sub oneline_summary { |
|
39 |
my ($self) = @_; |
|
40 |
my $amount = sum map { $_->amount if $_->amount > 0 } @{$self->transactions}; |
|
41 |
$amount = $::form->format_amount(\%::myconfig, $amount, 2); |
|
42 |
return sprintf("%s: %s %s %s (%s)", $self->abbreviation, $self->description, $self->reference, $amount, $self->transdate->to_kivitendo); |
|
43 |
} |
|
44 |
|
|
45 |
sub url_link { |
|
46 |
return 'gl.pl?action=edit&id=' . $_[0]->id; |
|
47 |
} |
|
48 |
|
|
49 |
sub link { |
|
50 |
my ($self) = @_; |
|
51 |
|
|
52 |
return SL::Presenter->get->gl_transaction($self, display => 'inline'); |
|
53 |
} |
|
54 |
|
|
55 | 27 |
sub invnumber { |
56 |
return $_[0]->reference;
|
|
28 |
goto &reference;
|
|
57 | 29 |
} |
58 | 30 |
|
31 |
sub abbreviation { $_[0]->presenter->abbreviation } |
|
32 |
sub displayable_type { $_[0]->presenter->type } |
|
33 |
sub link { $_[0]->presenter->link_tag } |
|
34 |
sub oneline_summary { $_[0]->presenter->gist } |
|
35 |
|
|
59 | 36 |
1; |
SL/DB/Invoice.pm | ||
---|---|---|
18 | 18 |
use SL::DB::Helper::TransNumberGenerator; |
19 | 19 |
use SL::Locale::String qw(t8); |
20 | 20 |
use SL::DB::CustomVariable; |
21 |
use SL::Presenter::Invoice; |
|
21 | 22 |
|
22 | 23 |
__PACKAGE__->meta->add_relationship( |
23 | 24 |
invoiceitems => { |
... | ... | |
525 | 526 |
return 'invoice'; |
526 | 527 |
} |
527 | 528 |
|
528 |
sub displayable_state { |
|
529 |
my $self = shift; |
|
530 |
|
|
531 |
return $self->closed ? $::locale->text('closed') : $::locale->text('open'); |
|
532 |
} |
|
533 |
|
|
534 |
sub displayable_type { |
|
535 |
my ($self) = @_; |
|
536 |
|
|
537 |
return t8('AR Transaction') if $self->invoice_type eq 'ar_transaction'; |
|
538 |
return t8('Credit Note') if $self->invoice_type eq 'credit_note'; |
|
539 |
return t8('Invoice') . "(" . t8('Storno') . ")" if $self->invoice_type eq 'invoice_storno'; |
|
540 |
return t8('Credit Note') . "(" . t8('Storno') . ")" if $self->invoice_type eq 'credit_note_storno'; |
|
541 |
return t8('Invoice'); |
|
542 |
} |
|
543 |
|
|
544 |
sub displayable_name { |
|
545 |
join ' ', grep $_, map $_[0]->$_, qw(displayable_type record_number); |
|
546 |
}; |
|
547 |
|
|
548 |
sub abbreviation { |
|
549 |
my ($self) = @_; |
|
550 |
|
|
551 |
return t8('AR Transaction (abbreviation)') if $self->invoice_type eq 'ar_transaction'; |
|
552 |
return t8('Credit note (one letter abbreviation)') if $self->invoice_type eq 'credit_note'; |
|
553 |
return t8('Invoice (one letter abbreviation)') . "(" . t8('Storno (one letter abbreviation)') . ")" if $self->invoice_type eq 'invoice_storno'; |
|
554 |
return t8('Credit note (one letter abbreviation)') . "(" . t8('Storno (one letter abbreviation)') . ")" if $self->invoice_type eq 'credit_note_storno'; |
|
555 |
return t8('Invoice (one letter abbreviation)'); |
|
556 |
} |
|
557 |
|
|
558 |
sub oneline_summary { |
|
559 |
my $self = shift; |
|
560 |
|
|
561 |
return sprintf("%s: %s %s %s (%s)", $self->abbreviation, $self->invnumber, $self->customer->name, |
|
562 |
$::form->format_amount(\%::myconfig, $self->amount,2), $self->transdate->to_kivitendo); |
|
563 |
} |
|
564 |
|
|
565 | 529 |
sub date { |
566 | 530 |
goto &transdate; |
567 | 531 |
} |
... | ... | |
574 | 538 |
goto &customer; |
575 | 539 |
} |
576 | 540 |
|
577 |
sub url_link { |
|
578 |
return ($_[0]->invoice ? "is" : "ar") . '.pl?action=edit&type=invoice&id=' . $_[0]->id; |
|
579 |
} |
|
580 |
|
|
581 |
sub link { |
|
582 |
my ($self) = @_; |
|
583 |
|
|
584 |
return SL::Presenter->get->invoice($self, display => 'inline'); |
|
585 |
} |
|
541 |
sub abbreviation { $_[0]->presenter->abbreviation } |
|
542 |
sub displayable_name { $_[0]->presenter->id } |
|
543 |
sub displayable_state { $_[0]->presenter->state } |
|
544 |
sub displayable_type { $_[0]->presenter->type } |
|
545 |
sub link { $_[0]->presenter->link_tag; } |
|
546 |
sub oneline_summary { $_[0]->presenter->gist } |
|
547 |
sub url_link { $_[0]->presenter->url } |
|
586 | 548 |
|
587 | 549 |
sub mark_as_paid { |
588 | 550 |
my ($self) = @_; |
SL/DB/PurchaseInvoice.pm | ||
---|---|---|
13 | 13 |
use SL::DB::Helper::Payment qw(:ALL); |
14 | 14 |
use SL::Locale::String qw(t8); |
15 | 15 |
use Rose::DB::Object::Helpers qw(has_loaded_related forget_related); |
16 |
use SL::Presenter::PurchaseInvoice; |
|
16 | 17 |
|
17 | 18 |
# The calculator hasn't been adjusted for purchase invoices yet. |
18 | 19 |
# use SL::DB::Helper::PriceTaxCalculator; |
... | ... | |
78 | 79 |
goto &vendor; |
79 | 80 |
} |
80 | 81 |
|
81 |
sub abbreviation { |
|
82 |
my $self = shift; |
|
83 |
|
|
84 |
return t8('AP Transaction (abbreviation)') if !$self->invoice && !$self->storno; |
|
85 |
return t8('AP Transaction (abbreviation)') . '(' . t8('Storno (one letter abbreviation)') . ')' if !$self->invoice && $self->storno; |
|
86 |
return t8('Invoice (one letter abbreviation)'). '(' . t8('Storno (one letter abbreviation)') . ')' if $self->storno; |
|
87 |
return t8('Invoice (one letter abbreviation)'); |
|
88 |
|
|
89 |
}; |
|
90 |
|
|
91 |
sub oneline_summary { |
|
92 |
my $self = shift; |
|
93 |
|
|
94 |
return sprintf("%s: %s %s %s (%s)", $self->abbreviation, $self->invnumber, $self->vendor->name, |
|
95 |
$::form->format_amount(\%::myconfig, $self->amount,2), $self->transdate->to_kivitendo); |
|
96 |
} |
|
97 |
|
|
98 |
sub url_link { |
|
99 |
return ($_[0]->invoice ? "ir" : "ap") . '.pl?action=edit&type=invoice&id=' . $_[0]->id; |
|
100 |
} |
|
101 |
|
|
102 |
sub link { |
|
103 |
my ($self) = @_; |
|
104 |
|
|
105 |
return SL::Presenter->get->invoice($self, display => 'inline'); |
|
106 |
} |
|
107 |
|
|
108 | 82 |
sub invoice_type { |
109 | 83 |
my ($self) = @_; |
110 | 84 |
|
... | ... | |
112 | 86 |
return 'purchase_invoice'; |
113 | 87 |
} |
114 | 88 |
|
115 |
sub displayable_type { |
|
116 |
my ($self) = @_; |
|
117 |
|
|
118 |
return t8('AP Transaction') if $self->invoice_type eq 'ap_transaction'; |
|
119 |
return t8('Purchase Invoice'); |
|
120 |
} |
|
121 |
|
|
122 |
sub displayable_name { |
|
123 |
join ' ', grep $_, map $_[0]->$_, qw(displayable_type record_number); |
|
124 |
}; |
|
125 |
|
|
126 | 89 |
sub create_ap_row { |
127 | 90 |
my ($self, %params) = @_; |
128 | 91 |
# needs chart as param |
... | ... | |
206 | 169 |
return $acc_trans; |
207 | 170 |
}; |
208 | 171 |
|
172 |
sub abbreviation { $_[0]->presenter->abbreviation } |
|
173 |
sub displayable_type { $_[0]->presenter->type } |
|
174 |
sub displayable_name { $_[0]->presenter->id } |
|
175 |
sub link { $_[0]->presenter->link_tag } |
|
176 |
sub oneline_summary { $_[0]->presenter->gist } |
|
177 |
sub url_link { $_[0]->presenter->url } |
|
178 |
|
|
209 | 179 |
sub mark_as_paid { |
210 | 180 |
my ($self) = @_; |
211 | 181 |
|
SL/Presenter.pm | ||
---|---|---|
11 | 11 |
use SL::Presenter::CustomerVendor; |
12 | 12 |
use SL::Presenter::DeliveryOrder; |
13 | 13 |
use SL::Presenter::EscapedText; |
14 |
use SL::Presenter::Invoice; |
|
15 |
use SL::Presenter::GL; |
|
16 | 14 |
use SL::Presenter::Letter; |
17 | 15 |
use SL::Presenter::Order; |
18 | 16 |
use SL::Presenter::Part; |
SL/Presenter/GL.pm | ||
---|---|---|
1 |
package SL::Presenter::GL; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use parent qw(Exporter); |
|
6 |
|
|
7 |
use Exporter qw(import); |
|
8 |
our @EXPORT = qw(gl_transaction); |
|
9 |
|
|
10 |
use Carp; |
|
11 |
|
|
12 |
sub gl_transaction { |
|
13 |
my ($self, $gl_transaction, %params) = @_; |
|
14 |
|
|
15 |
$params{display} ||= 'inline'; |
|
16 |
|
|
17 |
croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/; |
|
18 |
|
|
19 |
my $text = join '', ( |
|
20 |
$params{no_link} ? '' : '<a href="gl.pl?action=edit&id=' . $self->escape($gl_transaction->id) . '">', |
|
21 |
$self->escape($gl_transaction->reference), |
|
22 |
$params{no_link} ? '' : '</a>', |
|
23 |
); |
|
24 |
return $self->escaped_text($text); |
|
25 |
} |
|
26 |
|
|
27 |
1; |
|
28 |
|
|
29 |
__END__ |
|
30 |
|
|
31 |
=pod |
|
32 |
|
|
33 |
=encoding utf8 |
|
34 |
|
|
35 |
=head1 NAME |
|
36 |
|
|
37 |
SL::Presenter::GL - Presenter module for GL transaction |
|
38 |
|
|
39 |
=head1 SYNOPSIS |
|
40 |
|
|
41 |
my $object = SL::DB::Manager::GLTransaction->get_first(); |
|
42 |
my $html = SL::Presenter->get->gl_transaction($object, display => 'inline'); |
|
43 |
|
|
44 |
=head1 FUNCTIONS |
|
45 |
|
|
46 |
=over 4 |
|
47 |
|
|
48 |
=item C<gl_transaction $object, %params> |
|
49 |
|
|
50 |
Returns a rendered version (actually an instance of |
|
51 |
L<SL::Presenter::EscapedText>) of a gl object C<$object>. |
|
52 |
|
|
53 |
C<%params> can include: |
|
54 |
|
|
55 |
=over 2 |
|
56 |
|
|
57 |
=item * display |
|
58 |
|
|
59 |
Either C<inline> (the default) or C<table-cell>. At the moment both |
|
60 |
representations are identical and produce the trans_id number linked |
|
61 |
to the corresponding 'edit' action. |
|
62 |
|
|
63 |
=item * no_link |
|
64 |
|
|
65 |
If falsish (the default) then the trans_id number will be linked to the |
|
66 |
"edit gl" dialog. |
|
67 |
|
|
68 |
|
|
69 |
=back |
|
70 |
|
|
71 |
=back |
|
72 |
|
|
73 |
=head1 BUGS |
|
74 |
|
|
75 |
Nothing here yet. |
|
76 |
|
|
77 |
=head1 AUTHOR |
|
78 |
|
|
79 |
G. Richardson E<lt>information@kivitendo-premium.deE<gt> |
|
80 |
|
|
81 |
=cut |
SL/Presenter/GLTransaction.pm | ||
---|---|---|
1 |
package SL::Presenter::GLTransaction; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use parent qw(SL::Presenter::Object); |
|
5 |
|
|
6 |
use SL::Locale::String qw(t8); |
|
7 |
use List::Util qw(sum); |
|
8 |
|
|
9 |
sub url { |
|
10 |
my ($class, $object, %params) = @_; |
|
11 |
|
|
12 |
return 'gl.pl?action=edit&id=' . $object->id; |
|
13 |
} |
|
14 |
|
|
15 |
sub id { |
|
16 |
$_[1]->reference; |
|
17 |
} |
|
18 |
|
|
19 |
sub type { |
|
20 |
t8('GL Transaction') |
|
21 |
} |
|
22 |
|
|
23 |
sub gist { |
|
24 |
my ($class, $self, %params) = @_; |
|
25 |
my $amount = sum map { $_->amount > 0 ? $_->amount : 0 } @{$self->transactions}; |
|
26 |
$amount = $::form->format_amount(\%::myconfig, $amount, 2); |
|
27 |
return sprintf("%s: %s %s %s (%s)", $self->abbreviation, $self->description, $self->reference, $amount, $self->transdate->to_kivitendo); |
|
28 |
} |
|
29 |
|
|
30 |
sub abbreviation { |
|
31 |
my ($class, $self, %params) = @_; |
|
32 |
|
|
33 |
my $abbreviation = $::locale->text('GL Transaction (abbreviation)'); |
|
34 |
$abbreviation .= "(" . $::locale->text('Storno (one letter abbreviation)') . ")" if $self->storno; |
|
35 |
$abbreviation; |
|
36 |
} |
|
37 |
|
|
38 |
1; |
SL/Presenter/Invoice.pm | ||
---|---|---|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
|
5 |
use parent qw(Exporter); |
|
6 |
|
|
7 |
use Exporter qw(import); |
|
8 |
our @EXPORT = qw(invoice sales_invoice ar_transaction purchase_invoice ap_transaction); |
|
5 |
use parent qw(SL::Presenter::Object); |
|
6 |
use SL::Locale::String qw(t8); |
|
9 | 7 |
|
10 | 8 |
use Carp; |
11 | 9 |
|
12 |
sub invoice { |
|
13 |
my ($self, $invoice, %params) = @_; |
|
14 |
|
|
15 |
if ( $invoice->is_sales ) { |
|
16 |
if ( $invoice->invoice ) { |
|
17 |
return _is_ir_record($self, $invoice, 'is', %params); |
|
18 |
} else { |
|
19 |
return _is_ir_record($self, $invoice, 'ar', %params); |
|
20 |
} |
|
21 |
} else { |
|
22 |
if ( $invoice->invoice ) { |
|
23 |
return _is_ir_record($self, $invoice, 'ir', %params); |
|
24 |
} else { |
|
25 |
return _is_ir_record($self, $invoice, 'ap', %params); |
|
26 |
} |
|
27 |
}; |
|
28 |
}; |
|
29 |
|
|
30 |
sub sales_invoice { |
|
31 |
my ($self, $invoice, %params) = @_; |
|
32 |
|
|
33 |
return _is_ir_record($self, $invoice, 'is', %params); |
|
34 |
} |
|
10 |
sub url { |
|
11 |
my ($class, $object, %params) = @_; |
|
35 | 12 |
|
36 |
sub ar_transaction {
|
|
37 |
my ($self, $invoice, %params) = @_;
|
|
13 |
return ($object->invoice ? "is" : "ar") . '.pl?action=edit&type=invoice&id=' . $object->id;
|
|
14 |
}
|
|
38 | 15 |
|
39 |
return _is_ir_record($self, $invoice, 'ar', %params); |
|
16 |
sub id { |
|
17 |
join ' ', grep $_, map $_[1]->$_, qw(displayable_type record_number); |
|
40 | 18 |
} |
41 | 19 |
|
42 |
sub purchase_invoice {
|
|
43 |
my ($self, $invoice, %params) = @_;
|
|
20 |
sub gist {
|
|
21 |
my ($class, $self, %params) = @_;
|
|
44 | 22 |
|
45 |
return _is_ir_record($self, $invoice, 'ir', %params); |
|
23 |
return sprintf("%s: %s %s %s (%s)", $self->abbreviation, $self->invnumber, $self->customer->name, |
|
24 |
$::form->format_amount(\%::myconfig, $self->amount,2), $self->transdate->to_kivitendo); |
|
46 | 25 |
} |
47 | 26 |
|
48 |
sub ap_transaction {
|
|
49 |
my ($self, $invoice, %params) = @_;
|
|
27 |
sub state {
|
|
28 |
my ($class, $self, %params) = @_;
|
|
50 | 29 |
|
51 |
return _is_ir_record($self, $invoice, 'ap', %params);
|
|
30 |
$self->closed ? t8('closed') : t8('open');
|
|
52 | 31 |
} |
53 | 32 |
|
54 |
sub _is_ir_record {
|
|
55 |
my ($self, $invoice, $controller, %params) = @_;
|
|
33 |
sub type {
|
|
34 |
my ($class, $self, %params) = @_;
|
|
56 | 35 |
|
57 |
$params{display} ||= 'inline'; |
|
36 |
return t8('AR Transaction') if $self->invoice_type eq 'ar_transaction'; |
|
37 |
return t8('Credit Note') if $self->invoice_type eq 'credit_note'; |
|
38 |
return t8('Invoice') . "(" . t8('Storno') . ")" if $self->invoice_type eq 'invoice_storno'; |
|
39 |
return t8('Credit Note') . "(" . t8('Storno') . ")" if $self->invoice_type eq 'credit_note_storno'; |
|
40 |
return t8('Invoice'); |
|
41 |
} |
|
58 | 42 |
|
59 |
croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/; |
|
43 |
sub abbreviation { |
|
44 |
my ($class, $self, %params) = @_; |
|
60 | 45 |
|
61 |
my $text = join '', ( |
|
62 |
$params{no_link} ? '' : '<a href="' . $self->escape($invoice->url_link) . '">', |
|
63 |
$self->escape($invoice->invnumber), |
|
64 |
$params{no_link} ? '' : '</a>', |
|
65 |
); |
|
66 |
return $self->escaped_text($text); |
|
46 |
return t8('AR Transaction (abbreviation)') if $self->invoice_type eq 'ar_transaction'; |
|
47 |
return t8('Credit note (one letter abbreviation)') if $self->invoice_type eq 'credit_note'; |
|
48 |
return t8('Invoice (one letter abbreviation)') . "(" . t8('Storno (one letter abbreviation)') . ")" if $self->invoice_type eq 'invoice_storno'; |
|
49 |
return t8('Credit note (one letter abbreviation)') . "(" . t8('Storno (one letter abbreviation)') . ")" if $self->invoice_type eq 'credit_note_storno'; |
|
50 |
return t8('Invoice (one letter abbreviation)'); |
|
67 | 51 |
} |
68 | 52 |
|
69 | 53 |
1; |
SL/Presenter/Object.pm | ||
---|---|---|
1 |
package SL::Presenter::Object; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use SL::Presenter; |
|
5 |
use SL::Presenter::EscapedText; |
|
6 |
|
|
7 |
sub link_tag { |
|
8 |
my ($class, $object, %params) = @_; |
|
9 |
|
|
10 |
SL::Presenter->escaped_text( |
|
11 |
SL::Presenter::Tag::link( |
|
12 |
SL::Presenter->get, |
|
13 |
$class->url($object, %params), |
|
14 |
$class->id($object, %params), |
|
15 |
%params |
|
16 |
), |
|
17 |
); |
|
18 |
} |
|
19 |
|
|
20 |
sub url { |
|
21 |
my ($class, $object, %params) = @_; |
|
22 |
|
|
23 |
die 'must be overridden'; |
|
24 |
} |
|
25 |
|
|
26 |
sub id { |
|
27 |
my ($class, $object, %params) = @_; |
|
28 |
|
|
29 |
die 'must be overridden'; |
|
30 |
} |
|
31 |
|
|
32 |
sub gist { |
|
33 |
my ($class, $object, %params) = @_; |
|
34 |
|
|
35 |
die 'must be overridden'; |
|
36 |
} |
|
37 |
|
|
38 |
sub table_cell { |
|
39 |
goto &link_tag; |
|
40 |
} |
|
41 |
|
|
42 |
sub inline { |
|
43 |
goto &link_tag; |
|
44 |
} |
|
45 |
|
|
46 |
sub render { |
|
47 |
my ($class, $object, %params) = @_; |
|
48 |
|
|
49 |
my $display = delete $params{display} || 'inline'; |
|
50 |
|
|
51 |
die "Unknown display type '$display'" unless $display && $class->can($display); |
|
52 |
|
|
53 |
$class->$display($object, %params); |
|
54 |
} |
|
55 |
|
|
56 |
sub picker { |
|
57 |
my ($class, $object, %params) = @_; |
|
58 |
|
|
59 |
die 'must be overridden'; |
|
60 |
} |
|
61 |
|
|
62 |
1; |
|
63 |
|
|
64 |
__END__ |
|
65 |
|
|
66 |
=encoding utf-8 |
|
67 |
|
|
68 |
=head1 NAME |
|
69 |
|
|
70 |
SL::Presenter::Object - base class for typed presenters |
|
71 |
|
|
72 |
=head1 SYNOPSIS |
|
73 |
|
|
74 |
# use as base class for presenter: |
|
75 |
use parent qw(SL::Presenter::Object); |
|
76 |
|
|
77 |
# implement some often used things |
|
78 |
# all of these have signature ($class, $object, %params) |
|
79 |
sub gist { $_[1]->number . ' ' . $_[1]->name } |
|
80 |
sub url { 'controller.pl?action=This/edit&id=' . $_[1]->id } |
|
81 |
|
|
82 |
=head1 CALLING CONVENTION |
|
83 |
|
|
84 |
All methods in classes derived from this should have the signature C<$class, |
|
85 |
$object, %params>. This way a proxy in C<SL::DB::Object> can be used to call |
|
86 |
these methods on single objects. |
|
87 |
|
|
88 |
=head1 METHODS |
|
89 |
|
|
90 |
=over 4 |
|
91 |
|
|
92 |
=item C<url $class, $object, %params> |
|
93 |
|
|
94 |
Returns an url to this object. Should handle callbacks. |
|
95 |
|
|
96 |
Must be overridden. |
|
97 |
|
|
98 |
=item C<id $class, $object, %params> |
|
99 |
|
|
100 |
Returns an identification of the object intended for human readers. Should be |
|
101 |
as concise and unique as possible. |
|
102 |
|
|
103 |
Must be overridden |
|
104 |
|
|
105 |
=item C<gist $class, $object, %params> |
|
106 |
|
|
107 |
Returns a summary of the object. Should be one serialized line with as much |
|
108 |
information as possible. |
|
109 |
|
|
110 |
Must be overridden |
|
111 |
|
|
112 |
=item C<link_tag $class, $object, %params> |
|
113 |
|
|
114 |
Returns a link build from L<url> and L<id>. |
|
115 |
|
|
116 |
=item C<table_cell $class, $object, %params> |
|
117 |
|
|
118 |
Returns a presentation of this object intended for table cells. |
|
119 |
|
|
120 |
Defaults to L<link_tag>. |
|
121 |
|
|
122 |
=item C<inline $class, $object, %params> |
|
123 |
|
|
124 |
Returns a presentation of this object intended for inlining in text. |
|
125 |
|
|
126 |
Defaults to L<link_tag>. |
|
127 |
|
|
128 |
=item C<render $class, $object, %params> |
|
129 |
|
|
130 |
A dispatch method that extracts C<display> from params and calls the |
|
131 |
appropriate method. If no C<display> is given, defaults to C<inline> for |
|
132 |
historical reasons. |
|
133 |
|
|
134 |
=item C<picker $class, $object, %params> |
|
135 |
|
|
136 |
Renders a picker. If C<$object> is given it will be used as preselection. |
|
137 |
|
|
138 |
Must be overridden. |
|
139 |
|
|
140 |
=back |
|
141 |
|
|
142 |
=head1 BUGS |
|
143 |
|
|
144 |
I'm won't tell! |
|
145 |
|
|
146 |
=head1 AUTHOR |
|
147 |
|
|
148 |
Sven Schöling E<lt>s.schoeling@linet-services.deE<gt> |
|
149 |
|
|
150 |
=cut |
SL/Presenter/PurchaseInvoice.pm | ||
---|---|---|
1 |
package SL::Presenter::PurchaseInvoice; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use parent qw(SL::Presenter::Object); |
|
6 |
|
|
7 |
use SL::Locale::String qw(t8); |
|
8 |
use Carp; |
|
9 |
|
|
10 |
sub url { |
|
11 |
my ($class, $object, %params) = @_; |
|
12 |
|
|
13 |
return ($object->invoice ? "ir" : "ap") . '.pl?action=edit&type=invoice&id=' . $object->id; |
|
14 |
} |
|
15 |
|
|
16 |
sub id { |
|
17 |
join ' ', grep $_, map $_[1]->$_, qw(displayable_type record_number); |
|
18 |
} |
|
19 |
|
|
20 |
sub gist { |
|
21 |
my ($class, $self, %params) = @_; |
|
22 |
|
|
23 |
return sprintf("%s: %s %s %s (%s)", $self->abbreviation, $self->invnumber, $self->vendor->name, |
|
24 |
$::form->format_amount(\%::myconfig, $self->amount,2), $self->transdate->to_kivitendo); |
|
25 |
} |
|
26 |
|
|
27 |
sub state { |
|
28 |
my ($class, $self, %params) = @_; |
|
29 |
|
|
30 |
$self->closed ? t8('closed') : t8('open'); |
|
31 |
} |
|
32 |
|
|
33 |
sub type { |
|
34 |
my ($class, $self, %params) = @_; |
|
35 |
|
|
36 |
return t8('AP Transaction') if $self->invoice_type eq 'ap_transaction'; |
|
37 |
return t8('Purchase Invoice'); |
|
38 |
|
|
39 |
} |
|
40 |
|
|
41 |
sub abbreviation { |
|
42 |
my ($class, $self, %params) = @_; |
|
43 |
|
|
44 |
return t8('AP Transaction (abbreviation)') if !$self->invoice && !$self->storno; |
|
45 |
return t8('AP Transaction (abbreviation)') . '(' . t8('Storno (one letter abbreviation)') . ')' if !$self->invoice && $self->storno; |
|
46 |
return t8('Invoice (one letter abbreviation)'). '(' . t8('Storno (one letter abbreviation)') . ')' if $self->storno; |
|
47 |
return t8('Invoice (one letter abbreviation)'); |
|
48 |
} |
|
49 |
|
|
50 |
1; |
Auch abrufbar als: Unified diff
neue Presenter Infrastruktur
Testweise implementiert für Invoice/PurchaseInvoice/GLTransaction