Revision fea07b8e
Von Kivitendo Admin vor fast 9 Jahren hinzugefügt
SL/DB/Chart.pm | ||
---|---|---|
77 | 77 |
|
78 | 78 |
sub number_of_transactions { |
79 | 79 |
my ($self) = @_; |
80 |
|
|
81 |
my ($acc_trans) = $self->db->dbh->selectrow_array('select count(acc_trans_id) from acc_trans where chart_id = ?', {}, $self->id); |
|
82 |
|
|
83 |
return $acc_trans; |
|
80 |
require SL::DB::AccTransaction; |
|
81 |
return SL::DB::Manager::AccTransaction->get_all_count( where => [ chart_id => $self->id ] ); |
|
84 | 82 |
}; |
85 | 83 |
|
86 | 84 |
sub has_transaction { |
87 | 85 |
my ($self) = @_; |
88 | 86 |
|
89 |
my ($id) = $self->db->dbh->selectrow_array('select acc_trans_id from acc_trans where chart_id = ? limit 1', {}, $self->id) || 0; |
|
90 |
|
|
91 |
$id ? return 1 : return 0; |
|
92 |
|
|
93 |
}; |
|
87 |
$self->db->dbh->selectrow_array('select exists(select 1 from acc_trans where chart_id = ?)', {}, $self->id); |
|
88 |
} |
|
94 | 89 |
|
95 | 90 |
sub displayable_name { |
96 | 91 |
my ($self) = @_; |
... | ... | |
161 | 156 |
Returns a formatted version of C<get_balance>, taking the absolute value and |
162 | 157 |
adding the translated abbreviation for debit or credit after the number. |
163 | 158 |
|
159 |
=item C<number_of_transactions> |
|
160 |
|
|
161 |
Returns number of transactions that exist for this chart in acc_trans. |
|
162 |
|
|
164 | 163 |
=item C<has_transaction> |
165 | 164 |
|
166 | 165 |
Returns 1 or 0, depending whether the chart has a transaction in the database |
Auch abrufbar als: Unified diff
SL::DB::Chart - Refactoring der Transaktionsmethoden
... der Methoden number_of_transactions und has_transaction.
Machen fast das Gleiche, aber has_transaction liefert nur 0 oder 1
zurück, und ist schneller.