Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 844f4629

Von Kivitendo Admin vor etwa 8 Jahren hinzugefügt

  • ID 844f4629a6c8a489f8fe8cbe2731511cdd75b5e5
  • Vorgänger d27b7dd6
  • Nachfolger 923c8609

Chart get_balance nimmt jetzt fromdate und todate als Parameter

Unterschiede anzeigen:

SL/DB/Chart.pm
50 50

  
51 51
  my $query = qq|SELECT SUM(amount) AS sum FROM acc_trans WHERE chart_id = ? AND transdate >= ? and transdate <= ?|;
52 52

  
53
  my $startdate = $self->get_balance_starting_date;
54
  my $today     = DateTime->today_local;
53
  my $fromdate = $params{fromdate} || $::locale->parse_date_to_object($self->get_balance_starting_date);
54
  my $todate   = $params{todate}   || DateTime->today_local;
55 55

  
56
  my ($balance)  = selectfirst_array_query($::form, $self->db->dbh, $query, $self->id, $startdate, $today);
56
  die "get_balance: fromdate and todate arguments must be DateTime Objects" unless ref($fromdate) eq 'DateTime' and ref($todate) eq 'DateTime';
57

  
58
  my ($balance)  = selectfirst_array_query($::form, $self->db->dbh, $query, $self->id, $fromdate, $todate);
57 59

  
58 60
  return $balance;
59 61
};
......
68 70
  return "" unless $self->has_transaction;
69 71

  
70 72
  # return abs of current balance with the abbreviation for debit or credit behind it
71
  my $balance = $self->get_balance || 0;
73
  my $balance = $self->get_balance(%params) || 0;
72 74
  my $dc_abbreviation = $balance > 0 ? t8("Credit (one letter abbreviation)") : t8("Debit (one letter abbreviation)");
73 75
  my $amount = $::form->format_amount(\%::myconfig, abs($balance), 2);
74 76

  
......
152 154
Returns the tax rate of the active tax key as determined by
153 155
C<get_active_taxkey>.
154 156

  
155
=item C<get_balance>
157
=item C<get_balance %PARAMS>
156 158

  
157 159
Returns the current balance of the chart (sum of amount in acc_trans, positive
158 160
or negative). The transactions are filtered by transdate, the maximum date is
......
161 163
The balance should be same as that in the balance report for that chart, with
162 164
the asofdate as the current day, and the accounting_method "accrual".
163 165

  
164
=item C<formatted_balance_dc>
166
If DateTime objects are passed via the params fromdate and todate, the balance
167
is calculated only for that period.
168

  
169
=item C<formatted_balance_dc %PARAMS>
165 170

  
166 171
Returns a formatted version of C<get_balance>, taking the absolute value and
167 172
adding the translated abbreviation for debit or credit after the number.
168 173

  
174
Any params are passed on to C<get_balance>.
175

  
169 176
=item C<number_of_transactions>
170 177

  
171 178
Returns number of transactions that exist for this chart in acc_trans.

Auch abrufbar als: Unified diff