Revision b09bc3de
Von Kivitendo Admin vor fast 10 Jahren hinzugefügt
SL/DB/AccTransaction.pm | ||
---|---|---|
6 | 6 |
use strict; |
7 | 7 |
|
8 | 8 |
use SL::DB::MetaSetup::AccTransaction; |
9 |
use SL::DB::Manager::AccTransaction; |
|
10 |
use SL::Locale::String qw(t8); |
|
9 | 11 |
|
10 |
use SL::DB::GLTransaction;
|
|
12 |
require SL::DB::GLTransaction;
|
|
11 | 13 |
require SL::DB::Invoice; |
12 | 14 |
require SL::DB::PurchaseInvoice; |
13 | 15 |
|
... | ... | |
31 | 33 |
|
32 | 34 |
__PACKAGE__->meta->initialize; |
33 | 35 |
|
34 |
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. |
|
35 |
__PACKAGE__->meta->make_manager_class; |
|
36 |
|
|
37 | 36 |
sub record { |
38 | 37 |
my ($self) = @_; |
39 | 38 |
|
... | ... | |
47 | 46 |
|
48 | 47 |
}; |
49 | 48 |
|
50 |
sub get_transaction { |
|
51 |
my ($self) = @_; |
|
49 |
sub get_type { |
|
50 |
my $self = shift; |
|
51 |
|
|
52 |
my $ref = ref $self->record; |
|
53 |
|
|
54 |
return "ar" if $ref->isa('SL::DB::Invoice'); |
|
55 |
return "ap" if $ref->isa('SL::DB::PurchaseInvoice'); |
|
56 |
return "gl" if $ref->isa('SL::DB::GLTransaction'); |
|
57 |
|
|
58 |
die "Can't find trans_id " . $self->trans_id . " in ar, ap or gl" unless $ref; |
|
59 |
|
|
60 |
}; |
|
61 |
|
|
62 |
sub transaction_name { |
|
63 |
my $self = shift; |
|
64 |
|
|
65 |
my $ref = ref $self->record; |
|
66 |
my $name = "trans_id: " . $self->trans_id; |
|
67 |
if ( $self->get_type eq 'ar' ) { |
|
68 |
$name .= " (" . $self->record->abbreviation . " " . t8("AR") . ") " . t8("Invoice Number") . ": " . $self->record->invnumber; |
|
69 |
} elsif ( $self->get_type eq 'ap' ) { |
|
70 |
$name .= " (" . $self->record->abbreviation . " " . t8("AP") . ") " . t8("Invoice Number") . ": " . $self->record->invnumber; |
|
71 |
} elsif ( $self->get_type eq 'gl' ) { |
|
72 |
$name = "trans_id: " . $self->trans_id . " (" . $self->record->abbreviation . ") " . $self->record->reference . " - " . $self->record->description; |
|
73 |
} else { |
|
74 |
die "can't determine type of acc_trans line with trans_id " . $self->trans_id; |
|
75 |
}; |
|
52 | 76 |
|
53 |
my $transaction = SL::DB::Manager::GLTransaction->find_by(id => $self->trans_id); |
|
54 |
$transaction = SL::DB::Manager::Invoice->find_by(id => $self->trans_id) if not defined $transaction; |
|
55 |
$transaction = SL::DB::Manager::PurchaseInvoice->find_by(id => $self->trans_id) if not defined $transaction; |
|
77 |
$name .= " " . t8("Date") . ": " . $self->transdate->to_kivitendo; |
|
56 | 78 |
|
57 |
return $transaction; |
|
58 |
} |
|
79 |
return $name; |
|
80 |
|
|
81 |
}; |
|
59 | 82 |
|
60 | 83 |
1; |
84 |
|
|
61 | 85 |
__END__ |
62 | 86 |
|
63 | 87 |
=pod |
... | ... | |
90 | 114 |
each record type, which returns true if the load was successful, so we don't |
91 | 115 |
bother to check the ref of the object. |
92 | 116 |
|
117 |
=item C<get_type> |
|
118 |
|
|
119 |
Returns the type of transaction the acc_trans entry belongs to: ar, ap or gl. |
|
120 |
|
|
121 |
Example: |
|
122 |
my $acc = SL::DB::Manager::AccTransaction->get_first(); |
|
123 |
my $type = $acc->get_type; |
|
124 |
|
|
125 |
=item C<transaction_name> |
|
126 |
|
|
127 |
Generate a meaningful transaction name for an acc_trans line from the |
|
128 |
corresponding ar/ap/gl object, a combination of trans_id, |
|
129 |
invnumber/description, abbreviation. Can be used for better error output of the |
|
130 |
DATEV export and contains some database information, e.g. the trans_id, and is |
|
131 |
a kind of displayable_name for debugging or in the console. |
|
132 |
|
|
93 | 133 |
=back |
94 | 134 |
|
95 | 135 |
=head1 BUGS |
Auch abrufbar als: Unified diff
AccTransaction: get_type und transaction_name umgeschrieben
Nutzen jetzt record um Typ zu bestimmen.