Revision 59d0eec3
Von Sven Schöling vor fast 8 Jahren hinzugefügt
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; |
Auch abrufbar als: Unified diff
neue Presenter Infrastruktur
Testweise implementiert für Invoice/PurchaseInvoice/GLTransaction