X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FHelper%2FAccountingPeriod.pm;h=9be3774e502a2de2f74547908d8638cbe37a8714;hb=a44b04878198d94a18adf3867c4ba227a0d9d3ff;hp=1bd0806f7d0a10ac584ce9966dac179e403a4223;hpb=4249ea44f0c6772c019a6d3fbfcd5fe879556ef6;p=kivitendo-erp.git diff --git a/SL/DB/Helper/AccountingPeriod.pm b/SL/DB/Helper/AccountingPeriod.pm index 1bd0806f7..9be3774e5 100644 --- a/SL/DB/Helper/AccountingPeriod.pm +++ b/SL/DB/Helper/AccountingPeriod.pm @@ -1,17 +1,29 @@ package SL::DB::Helper::AccountingPeriod; use strict; +use SL::Locale::String qw(t8); use parent qw(Exporter); use SL::DBUtils; -our @EXPORT = qw(get_balance_starting_date); +our @EXPORT = qw(get_balance_starting_date get_balance_startdate_method_options); use Carp; +sub get_balance_startdate_method_options { + [ + { title => t8("After closed period"), value => "closed_to" }, + { title => t8("Start of year"), value => "start_of_year" }, + { title => t8("All transactions"), value => "all_transactions" }, + { title => t8("Last opening balance or all transactions"), value => "last_ob_or_all_transactions" }, + { title => t8("Last opening balance or start of year"), value => "last_ob_or_start_of_year" }, + ] +} + sub get_balance_starting_date { - my ($self,$asofdate) = @_; + my ($self, $asofdate, $startdate_method) = @_; - $asofdate ||= DateTime->today_local; + $asofdate ||= DateTime->today_local; + $startdate_method ||= $::instance_conf->get_balance_startdate_method; unless ( ref $asofdate eq 'DateTime' ) { $asofdate = $::locale->parse_date_to_object($asofdate); @@ -19,7 +31,6 @@ sub get_balance_starting_date { my $dbh = $::form->get_standard_dbh; - my $startdate_method = $::instance_conf->get_balance_startdate_method; # We could use the following objects to determine the starting date for # calculating the balance from asofdate (the reference date for the balance): @@ -106,7 +117,12 @@ SL::DB::Helper::AccountingPeriod - Helper functions for calculating dates relati =over 4 -=item C +=item C + +Returns an arrayref of translated options for determining the startdate of a +balance period or the yearend period. To be used as the options for a dropdown. + +=item C Given a date this method calculates and returns the starting date of the financial period relative to that date, according to the configured @@ -118,6 +134,8 @@ date-parsed. If no argument is passed the current day is assumed as default. +If no startdate method is passed, the default method from defaults is used. + =back =head1 BUGS