Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Balance Sheet & Income Tax comparisons report by dates or by periods #8169

Merged
merged 5 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/LedgerSMB/Report/Balance_Sheet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ Boolean, true if it is a gifi report.

has gifi => (is => 'rw', isa => 'Bool');

=item from_date
=item to_date

Dates come from LedgerSMB::Report::Dates

=cut

=item legacy_hierarchy

Boolean, true if the regular hierarchies need to be ignored,
Expand Down Expand Up @@ -168,8 +175,8 @@ sub run_report {

my $col_id = $self->cheads->map_path($self->column_path_prefix);
$self->cheads->id_props($col_id,
{ description => $self->date_to->to_output,
to_date => $self->date_to->to_output,
{ description => $self->date_to->to_output($self->{formatter_options}),
to_date => $self->date_to->to_output($self->{formatter_options}),
});

for my $line (@lines) {
Expand Down
10 changes: 3 additions & 7 deletions lib/LedgerSMB/Report/Dates.pm
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ These are the first and last date in acc_trans.

=cut


sub get_bracket_dates {
my ($self) = @_;
my $return_hashref = {};
Expand All @@ -150,9 +149,9 @@ sub _collect_dates_comparisons {

foreach my $i (1 .. $args{comparison_periods}) {
push @dates, {
from_date => LedgerSMB::PGDate->from_input($args{"from_date_$i"}),
to_date => LedgerSMB::PGDate->from_input($args{"to_date_$i"}),
column_path_prefix => [ $i ]
from_date => LedgerSMB::PGDate->from_input($args{"from_date_$i"},$args{formatter_options}),
to_date => LedgerSMB::PGDate->from_input($args{"to_date_$i"},$args{formatter_options}),
column_path_prefix => [ sprintf('%02u', $i) ]
ehuelsmann marked this conversation as resolved.
Show resolved Hide resolved
};
}

Expand Down Expand Up @@ -242,9 +241,6 @@ sub _set_lazy_dates {
return;
}




before 'render' => sub {
my ($self) = @_;
# Set lazy attributes
Expand Down
17 changes: 13 additions & 4 deletions lib/LedgerSMB/Report/PNL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ Boolean, true if it is a gifi report.

has gifi => (is => 'rw', isa => 'Bool');

=item from_date
=item to_date

Dates come from LedgerSMB::Report::Dates

=cut

=item legacy_hierarchy

Boolean, true if the regular hierarchies need to be ignored,
Expand Down Expand Up @@ -153,14 +160,16 @@ sub run_report {


my $col_id = $self->cheads->map_path($self->column_path_prefix);
my $_from_date = $self->from_date->to_output($self->{formatter_options});
my $_to_date = $self->to_date->to_output($self->{formatter_options});
$self->cheads->id_props($col_id,
{ description =>
$self->Text(
"[_1]\n[_2]",
$self->from_date->to_output,
$self->to_date->to_output),
from_date => $self->from_date->to_output,
to_date => $self->to_date->to_output,
$_from_date,
$_to_date),
from_date => $_from_date,
to_date => $_to_date
});

for my $line (@lines) {
Expand Down
8 changes: 5 additions & 3 deletions lib/LedgerSMB/Scripts/pnl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ sub generate_income_statement {
$rpt = LedgerSMB::Report::PNL::Income_Statement->new(
%$request,
formatter_options => $request->formatter_options,
from_date => $request->parse_date( $request->{from_date} ),
to_date => $request->parse_date( $request->{to_date} ),
from_date => $request->{from_date} ? $request->parse_date( $request->{from_date} ) : undef,
to_date => $request->{to_date} ? $request->parse_date( $request->{to_date} ) : undef,
column_path_prefix => [ 0 ]);
$rpt->run_report($request);

Expand All @@ -85,7 +85,9 @@ sub generate_income_statement {

for my $cmp_dates (@{$rpt->comparisons}) {
my $cmp = LedgerSMB::Report::PNL::Income_Statement->new(
%$request, %$cmp_dates);
%$request,
formatter_options => $request->formatter_options,
%$cmp_dates);
$cmp->run_report($request);
$rpt->add_comparison($cmp);
}
Expand Down
16 changes: 5 additions & 11 deletions lib/LedgerSMB/Scripts/reports.pm
Original file line number Diff line number Diff line change
Expand Up @@ -193,27 +193,21 @@ Generates a balance sheet

=cut

use Log::Any;
my $logger = Log::Any->get_logger(category => 'LedgerSMB::Scripts::reports');

sub generate_balance_sheet {
my ($request) = @_;
$logger->debug("Stub LedgerSMB::Scripts::reports->generate_balance_sheet\n");
my $rpt = LedgerSMB::Report::Balance_Sheet->new(
%$request,
formatter_options => $request->formatter_options,
from_date => $request->parse_date( $request->{from_date} ),
to_date => $request->parse_date( $request->{to_date} ),
from_date => $request->{from_date} ? $request->parse_date( $request->{from_date} ) : undef,
to_date => $request->{to_date} ? $request->parse_date( $request->{to_date} ) : undef,
column_path_prefix => [ 0 ]);
$rpt->run_report($request);

for my $key (qw(from_month from_year from_date to_date internal)) {
delete $request->{$_} for (grep { /^$key/ } keys %$request);
}

for my $cmp_dates (@{$rpt->comparisons}) {
my $cmp = LedgerSMB::Report::Balance_Sheet->new(
%$request, %$cmp_dates);
%$request,
formatter_options => $request->formatter_options,
%$cmp_dates);
$cmp->run_report($request);
$rpt->add_comparison($cmp);
}
Expand Down