[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[6880] addons/1.3/report_framework/trunk
- Subject: SF.net SVN: ledger-smb:[6880] addons/1.3/report_framework/trunk
- From: ..hidden..
- Date: Thu, 20 Feb 2014 03:58:29 +0000
Revision: 6880
http://sourceforge.net/p/ledger-smb/code/6880
Author: einhverfr
Date: 2014-02-20 03:58:27 +0000 (Thu, 20 Feb 2014)
Log Message:
-----------
Report framework changes, merged in from trunk
Modified Paths:
--------------
addons/1.3/report_framework/trunk/LedgerSMB/DBObject_Moose.pm
addons/1.3/report_framework/trunk/LedgerSMB/I18N.pm
addons/1.3/report_framework/trunk/LedgerSMB/PGDate.pm
addons/1.3/report_framework/trunk/LedgerSMB/PGNumber.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/Aging.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/Budget/Variance.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/COA.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/Contact/History.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/Contact/Purchase.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/Contact/Search.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/Dates.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/GL.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/Inventory/Adj_Details.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/Inventory/Search_Adj.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL/ECA.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL/Income_Statement.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL/Invoice.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL/Product.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/Trial_Balance.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/Unapproved/Batch_Detail.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/Unapproved/Batch_Overview.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/Unapproved/Drafts.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/co/Balance_y_Mayor.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report/co/Caja_Diaria.pm
addons/1.3/report_framework/trunk/LedgerSMB/Report.pm
addons/1.3/report_framework/trunk/UI/Reports/PNL.html
addons/1.3/report_framework/trunk/UI/Reports/aging_report.html
addons/1.3/report_framework/trunk/UI/Reports/co/filter_bm.html
addons/1.3/report_framework/trunk/UI/Reports/co/filter_cd.html
addons/1.3/report_framework/trunk/UI/Reports/display_report.html
addons/1.3/report_framework/trunk/UI/Reports/display_report.tex
addons/1.3/report_framework/trunk/UI/Reports/filters/aging.html
addons/1.3/report_framework/trunk/UI/Reports/filters/budget_search.html
addons/1.3/report_framework/trunk/UI/Reports/filters/contact_search.html
addons/1.3/report_framework/trunk/UI/Reports/filters/gl.html
addons/1.3/report_framework/trunk/UI/Reports/filters/income_statement.html
addons/1.3/report_framework/trunk/UI/Reports/filters/inventory_adj.html
addons/1.3/report_framework/trunk/UI/Reports/filters/purchase_history.html
addons/1.3/report_framework/trunk/UI/Reports/filters/trial_balance.html
addons/1.3/report_framework/trunk/UI/Reports/filters/unapproved.html
addons/1.3/report_framework/trunk/UI/Reports/pnl.css
addons/1.3/report_framework/trunk/sql/modules/PNL.sql
Modified: addons/1.3/report_framework/trunk/LedgerSMB/DBObject_Moose.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/DBObject_Moose.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/DBObject_Moose.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -15,9 +15,8 @@
use LedgerSMB;
use Scalar::Util;
use Log::Log4perl;
-use LedgerSMB::DBObject;
use Moose::Util::TypeConstraints;
-use LedgerSMB::MooseTypes;
+use LedgerSMB::MooseTypes
=head1 METHODS
@@ -66,7 +65,7 @@
#
sub _to_dbobject {
my $self = shift @_;
- return LedgerSMB::DBObject->new({base => $self, ignore_base_type => 1});
+ return LedgerSMB::DBObject->new({base => $self});
}
=item set_ordering
@@ -127,7 +126,6 @@
end => LedgerSMB::PGDate->from_db($end, 'date') };
}
-
=back
=head1 Copyright (C) 2007, The LedgerSMB core team.
Modified: addons/1.3/report_framework/trunk/LedgerSMB/I18N.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/I18N.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/I18N.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -20,7 +20,7 @@
sub text {
my ($string) = @_;
- return $LedgerSMB::App_State::Locale->text($string);
+ return LedgerSMB::App_State->Locale->text($string);
}
=head1 COPYRIGHT
Modified: addons/1.3/report_framework/trunk/LedgerSMB/PGDate.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/PGDate.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/PGDate.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -6,18 +6,10 @@
package LedgerSMB::PGDate;
use Moose;
use DateTime::Format::Strptime;
+use LedgerSMB::App_State;
use Carp;
+use DateTime::Duration;
-BEGIN {
- use LedgerSMB::SODA;
- LedgerSMB::SODA->register_type({sql_type => 'date',
- perl_class => 'LedgerSMB::PGDate'});
- LedgerSMB::SODA->register_type({sql_type => 'datetime',
- perl_class => 'LedgerSMB::PGDate'});
- LedgerSMB::SODA->register_type({sql_type => 'timestamp',
- perl_class => 'LedgerSMB::PGDate'});
-}
-
=head1 SYNPOSIS
This class handles formatting and mapping between the DateTime module and
PostgreSQL. It provides a handler for date and timestamp datatypes.
@@ -27,12 +19,21 @@
=over
=item date
+
A DateTime object for internal storage and processing.
=cut
-has date => (isa => 'Maybe[DateTime]', is=> 'ro', required => '1');
+has date => (isa => 'DateTime', is=> 'ro', required => '0');
+=item dummy
+
+If set to 1, this is a dummy value for an unknown value
+
+=cut
+
+has dummy => (isa => 'Bool', is=> 'ro', required => '0');
+
=back
=head1 SUPPORTED FORMATS
@@ -155,10 +156,13 @@
my ($self, $input, $has_time) = @_;
return $input if eval {$input->isa(__PACKAGE__)};
$input = undef if $input eq '';
- return undef if !defined $input;
my $format = $LedgerSMB::App_State::User->{dateformat};
+ $format ||= 'yyyy-mm-dd';
+ $format = 'yyyy-mm-dd' if $input =~ /^\d{4}/;
my $dt = _parse_string($self, $input, uc($format), $has_time);
- return $self->new({date => $dt});
+ my %prop = (date => $dt, dummy => !defined $dt);
+ delete $prop{date} unless defined $prop{date} and $prop{date} ne '';
+ return $self->new(%prop);
}
@@ -174,10 +178,12 @@
return undef if !defined $self->date;
my $fmt;
if (defined $LedgerSMB::App_State::User->{dateformat}){
- $fmt = $formats->{uc($LedgerSMB::App_State::User->{dateformat})}->[0];
+ $fmt = $LedgerSMB::App_State::User->{dateformat};
} else {
$fmt = '%F';
}
+ $fmt = $formats->{uc($fmt)}->[0] if defined $formats->{uc($fmt)};
+ $fmt .= ' %T' if ($self->date->hour);
my $formatter = new DateTime::Format::Strptime(
pattern => $fmt,
@@ -208,7 +214,10 @@
confess 'LedgerSMB::PGDate Invalid DB Type';
}
my $dt = _parse_string($self, $input, $format, $has_time);
- return $self->new({date => $dt});
+ my %prop = (date => $dt, dummy => !defined $dt);
+ delete $prop{date} unless defined $prop{date} and $prop{date} ne '';
+
+ return $self->new(%prop);
}
=item to_db
@@ -229,7 +238,7 @@
return $formatter->format_datetime($self->date);
}
-__PACKAGE__->meta->make_immutable;
+#__PACKAGE__->meta->make_immutable;
1;
Modified: addons/1.3/report_framework/trunk/LedgerSMB/PGNumber.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/PGNumber.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/PGNumber.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -11,16 +11,6 @@
package LedgerSMB::PGNumber;
-BEGIN {
- use LedgerSMB::SODA;
- LedgerSMB::SODA->register_type({sql_type => 'float',
- perl_class => 'LedgerSMB::PGNumber'});
- LedgerSMB::SODA->register_type({sql_type => 'double',
- perl_class => 'LedgerSMB::PGNumber'});
- LedgerSMB::SODA->register_type({sql_type => 'numeric',
- perl_class => 'LedgerSMB::PGNumber'});
-}
-
=head1 SYNPOSIS
This is a wrapper class for handling a database interface for numeric (int,
@@ -121,12 +111,16 @@
sub from_input {
my $self = shift @_;
my $string = shift @_;
- $string = undef if $string eq '';
+ #tshvr4 avoid 'Use of uninitialized value $string in string eq'
+ if(!defined $string || $string eq ''){
+ return undef;
+ }
+ #$string = undef if $string eq '';
my %args = (ref($_[0]) eq 'HASH')? %{$_[0]}: @_;
my $format = ($args{format}) ? $args{format}
: $LedgerSMB::App_State::User->{numberformat};
die 'LedgerSMB::PGNumber No Format Set' if !$format;
- return undef if !defined $string;
+ #return undef if !defined $string;
my $negate;
my $pgnum;
my $newval;
@@ -183,10 +177,12 @@
sub to_output {
my $self = shift @_;
my %args = (ref($_[0]) eq 'HASH')? %{$_[0]}: @_;
+ $args{money} = 1 if $ENV{LSMB_ALWAYS_MONEY};
my $is_neg = $self->is_neg;
my $format = ($args{format}) ? $args{format}
: $LedgerSMB::App_State::User->{numberformat};
+ die 'LedgerSMB::PGNumber No Format Set, check numberformat in user_preference' if !$format;
my $places = undef;
$places = LedgerSMB::Setting->get('decimal_places') if $args{money};
@@ -196,12 +192,23 @@
$places = 0 unless defined $places and ($places > 0);
my $zfill = ($places > 0) ? 1 : 0;
$dplaces = 5 unless defined $dplaces;
- my $formatter = new Number::Format(
+ my $formatter;
+ if ($format eq '1000.00'){ # Default decimal sep, no thousands sep
+ $formatter = new Number::Format(
+ -decimal_fill => $zfill,
+ -neg_format => 'x'
+ );
+ $str = $formatter->format_number($str, $dplaces);
+ $str =~ s/,//g;
+ } else {
+ $formatter = new Number::Format(
-thousands_sep => $lsmb_formats->{$format}->{thousands_sep},
-decimal_point => $lsmb_formats->{$format}->{decimal_sep},
-decimal_fill => $zfill,
- -neg_format => 'x');
- $str = $formatter->format_number($str, $dplaces);
+ -neg_format => 'x'
+ );
+ $str = $formatter->format_number($str, $dplaces);
+ }
my $neg_format = ($args{neg_format}) ? $args{neg_format} : 'def';
my $fmt = ($is_neg) ? $lsmb_neg_formats->{$neg_format}->{neg}
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/Aging.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/Aging.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/Aging.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -22,8 +22,8 @@
use Moose;
extends 'LedgerSMB::Report';
-use LedgerSMB::DBObject::Business_Unit_Class;
-use LedgerSMB::DBObject::Business_Unit;
+use LedgerSMB::Business_Unit_Class;
+use LedgerSMB::Business_Unit;
use LedgerSMB::App_State;
@@ -121,26 +121,31 @@
{col_id => 'c0',
name => LedgerSMB::Report::text('Current'),
type => 'text',
+ money => 1,
pwidth => '2', },
{col_id => 'c30',
name => LedgerSMB::Report::text('30'),
type => 'text',
+ money => 1,
pwidth => '3', },
{col_id => 'c60',
name => LedgerSMB::Report::text('60'),
type => 'text',
+ money => 1,
pwidth => '3', },
{col_id => 'c90',
name => LedgerSMB::Report::text('90'),
type => 'text',
+ money => 1,
pwidth => '3', },
{col_id => 'total',
name => LedgerSMB::Report::text('Total'),
type => 'text',
+ money => 1,
pwidth => '1', };
return \@COLUMNS;
}
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/Budget/Variance.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/Budget/Variance.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/Budget/Variance.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -20,6 +20,7 @@
package LedgerSMB::Report::Budget::Variance;
use Moose;
extends 'LedgerSMB::Report';
+use LedgerSMB::Budget;
=head1 PROPERTIES
@@ -75,14 +76,17 @@
{col_id => 'budget_amount',
type => 'text',
+ money => 1,
name => LedgerSMB::Report::text('Amount Budgetted')},
{col_id => 'used_amount',
type => 'text',
+ money => 1,
name => '- ' . LedgerSMB::Report::text('Used')},
{col_id => 'variance',
type => 'text',
+ money => 1,
name => '= ' . LedgerSMB::Report::text('Variance')},
];
}
@@ -176,9 +180,8 @@
sub for_budget_id {
my ($self, $id) = @_;
- use LedgerSMB::DBObject::Budget;
- my $budget = LedgerSMB::DBObject::Budget->get($id);
+ my $budget = LedgerSMB::Budget->get($id);
my $report = $self->new(%$budget);
return $report;
}
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/COA.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/COA.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/COA.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -101,11 +101,13 @@
{col_id => 'debit_balance',
name => LedgerSMB::Report::text('Debits'),
type => 'text',
+ money => 1,
pwidth => '2', },
{col_id => 'credit_balance',
name => LedgerSMB::Report::text('Credits'),
type => 'text',
+ money => 1,
pwidth => '2', },
{col_id => 'link',
@@ -117,13 +119,13 @@
name => LedgerSMB::Report::text('Edit'),
type => 'href',
href_base => '',
- pwidth => '3', },
+ html_only => 1, },
{col_id => 'delete',
name => LedgerSMB::Report::text('Delete'),
type => 'href',
href_base => '',
- pwidth => '3', },
+ html_only => '1', },
);
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/Contact/History.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/Contact/History.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/Contact/History.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -27,7 +27,10 @@
package LedgerSMB::Report::Contact::History;
use Moose;
extends 'LedgerSMB::Report';
+with 'LedgerSMB::Report::Dates';
+
use LedgerSMB::PGDate;
+use LedgerSMB::MooseTypes;
=head1 PROPERTIES
@@ -46,24 +49,30 @@
sub columns {
my ($self) = @_;
my $script = 'contacts.pl';
- return [
+ my $cols = [
{col_id => 'name',
type => 'text',
name => LedgerSMB::Report::text('Name') },
{col_id => 'meta_number',
type => 'text',
- name => LedgerSMB::Report::text('Account Number') },
+ name => LedgerSMB::Report::text('Account Number') }];
+ if (!$self->is_summary){
+
+ push @$cols,
{col_id => 'invnumber',
type => 'href',
- href_base => 'is.pl?action=edit&id=',
+ #href_base => 'is.pl?action=edit&id=',
name => LedgerSMB::Report::text('Invoice Number') },
{col_id => 'curr',
type => 'text',
- name => LedgerSMB::Report::text('Currency') },
+ name => LedgerSMB::Report::text('Currency') };
+ }
+ push @$cols,
+
{col_id => 'partnumber',
type => 'text',
name => LedgerSMB::Report::text('Part Number') },
@@ -78,12 +87,15 @@
{col_id => 'unit',
type => 'text',
- name => LedgerSMB::Report::text('Unit') },
-
+ name => LedgerSMB::Report::text('Unit') };
+
+ push @$cols,
{col_id => 'sellprice',
type => 'text',
- name => LedgerSMB::Report::text('Sell Price') },
+ money => 1,
+ name => LedgerSMB::Report::text('Sell Price') };
+ push @$cols,
{col_id => 'discount',
type => 'text',
name => LedgerSMB::Report::text('Disc') },
@@ -94,17 +106,19 @@
{col_id => 'serialnumber',
type => 'text',
- name => LedgerSMB::Report::text('Serial Number') },
-
+ name => LedgerSMB::Report::text('Serial Number') }
+ unless $self->is_summary;
+
+ push @$cols,
{col_id => 'exchangerate',
type => 'text',
name => LedgerSMB::Report::text('Exchange Rate') },
{col_id => 'salesperson_name',
type => 'text',
- name => LedgerSMB::Report::text('Salesperson') },
+ name => LedgerSMB::Report::text('Salesperson') };
- ];
+ return $cols;
}
=item name
@@ -228,22 +242,6 @@
has country_id => (is => 'ro', isa => 'Maybe[Int]');
-=item from_date
-
-Include only invoices starting on this date
-
-=cut
-
-has from_date => (is => 'ro', coerce => 1, isa => 'LedgerSMB::DBObject::Date');
-
-=item to_date
-
-Include only invoices before this date
-
-=cut
-
-has to_date => (is => 'ro', coerce => 1, isa => 'LedgerSMB::DBObject::Date');
-
=item type
This is the type of document to be returned:
@@ -327,7 +325,15 @@
$proc .= '_summary' if $self->is_summary;
my @rows = $self->exec_method({funcname => $proc});
for my $r(@rows){
- $r->{invnumber_href_suffix} = $r->{invoice_id};
+ my $script;
+ if($self->entity_class == 1){
+ $script = 'ir.pl';
+ }
+ else{
+ $script = 'is.pl';
+ }
+ #$r->{invnumber_href_suffix} = $r->{invoice_id};
+ $r->{invnumber_href_suffix} = "$script?action=edit&id=$r->{inv_id}";
}
$self->rows(\@rows);
}
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/Contact/Purchase.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/Contact/Purchase.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/Contact/Purchase.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -29,6 +29,7 @@
package LedgerSMB::Report::Contact::Purchase;
use Moose;
extends 'LedgerSMB::Report';
+with 'LedgerSMB::Report::Dates';
=head1 PROPERTIES
@@ -76,18 +77,22 @@
{col_id => 'amount',
type => 'text',
+ money => 1,
name => LedgerSMB::Report::text('Amount') },
{col_id => 'tax',
type => 'text',
+ money => 1,
name => LedgerSMB::Report::text('Tax') },
{col_id => 'paid',
type => 'text',
+ money => 1,
name => LedgerSMB::Report::text('Paid') },
{col_id => 'due',
type => 'text',
+ money => 1,
name => LedgerSMB::Report::text('Due') },
{col_id => 'date_paid',
@@ -235,22 +240,6 @@
has ship_via => (is => 'ro', isa => 'Maybe[Str]');
-=item from_date
-
-Invoices posted starting on this date
-
-=cut
-
-has from_date => (is => 'ro', coerce => 1, isa => 'LedgerSMB::Moose::Date');
-
-=item to_date
-
-Invoices posted no later than this date
-
-=cut
-
-has to_date => (is => 'ro', coerce => 1, isa => 'LedgerSMB::Moose::Date');
-
=item as_of
Shows invoice balances as of this date.
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/Contact/Search.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/Contact/Search.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/Contact/Search.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -115,7 +115,9 @@
=item name_part
-Full text search on contact name.
+Full text search on contact name. This also matches the beginning of a
+company's name. So Acme Software Testing Inc would come up under searches of
+'Ac', 'Software', 'Software Tester', and so forth but not 'Sting' or 'are.'
=cut
@@ -153,6 +155,15 @@
has phone => (is => 'ro', isa => 'Str', required => 0);
+=item contact
+
+Full text search on contact string
+
+=cut
+
+has contact => (is => 'ro', isa => 'Str', required => 0);
+
+
=item meta_number
Matches beginning of customer/vendor/etc. number.
@@ -179,7 +190,7 @@
=item city
-Exact match on city
+City contains this string.
=cut
@@ -187,7 +198,7 @@
=item state
-Exact match on state/province
+State or province contains this string
=cut
@@ -228,6 +239,14 @@
coerce => 1,
required => 0);
+=item users
+
+If the entity_class is 3 then this restricts the report to only users.
+
+=cut
+
+has users => (is => 'ro', isa => 'Bool', required => 0);
+
=back
=head1 METHODS
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/Dates.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/Dates.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/Dates.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -25,18 +25,113 @@
=cut
-has from_date => (is => 'ro', isa => 'LedgerSMB::Moose::Date', coerce => 1);
+has from_date => (is => 'ro', isa => 'LedgerSMB::Moose::Date', coerce => 1,
+ lazy => 1, builder => '_get_from_date');
=item to_date
=cut
-has to_date => (is => 'ro', isa => 'LedgerSMB::Moose::Date', coerce => 1);
+has to_date => (is => 'ro', isa => 'LedgerSMB::Moose::Date', coerce => 1,
+ lazy => 1, builder => '_get_to_date');
-=item ...
+=item interval string
+Either 'none', 'month', 'quarter', or 'year'
+
+=cut
+
+has interval => (is => 'ro', isa => 'Str', required => 0);
+
+=item from_month int
+
+1 - 12
+
+=cut
+
+has from_month => (is => 'ro', isa => 'Int', required => 0);
+
+=item from_year int
+
+=cut
+
+has from_year => (is => 'ro', isa => 'Int', required => 0);
+
+=back
+
+=cut
+
+has date_from => (is => 'ro', lazy => '1', builder => 'from_date');
+
+has date_to => (is => 'ro', lazy => '1', builder => 'to_date');
+
+sub _get_from_date {
+ my ($self) = @_;
+ if ($self->from_month and $self->from_year){
+ my $date_string = $self->from_year . "-" . $self->from_month . '-01';
+ return LedgerSMB::PGDate->from_db($date_string, 'date');
+ } else {
+ my ($ref) = $self->exec_method({funcname => 'lsmb__min_date'});
+ if ($ref->{lsmb__min_date}){
+ return LedgerSMB::PGDate->from_db($ref->{lsmb__min_date}, 'date');
+ } else {
+ return LedgerSMB::PGDate->new();
+ }
+
+ }
+}
+
+sub _get_to_date {
+ my ($self) = @_;
+ if (!$self->from_month or !$self->from_year or $self->interval eq 'none'){
+ my ($ref) = $self->exec_method({funcname => 'lsmb__max_date'});
+ if ($ref->{lsmb__max_date}){
+ return LedgerSMB::PGDate->from_db($ref->{lsmb__max_date}, 'date');
+ } else {
+ return LedgerSMB::PGDate->new();
+ }
+
+ }
+ my $dateobj = $self->from_date;
+ my $date = $dateobj->from_db($dateobj->to_db, 'date'); # copy, round trip
+ if ($self->interval eq 'month'){
+ $date->date->add(months => 1);
+ } elsif ($self->interval eq 'quarter'){
+ $date->date->add(months => 3);
+ } elsif ($self->interval eq 'year'){
+ $date->date->add(years => 1);
+ }
+ $date->date->subtract(days => 1); # dates are inclusive
+ return $date;
+}
+
+sub _set_lazy_dates {
+ my ($self) = @_;
+ # Set lazy attributes
+ $self->from_date;
+ $self->to_date;
+ $self->date_from;
+ $self->date_to;
+}
+
+before 'render' => sub {
+ my ($self) = @_;
+ # Set lazy attributes
+ $self->_set_lazy_dates;
+};
+before 'run_report' => sub {
+ my ($self) = @_;
+ # Set lazy attributes
+ $self->_set_lazy_dates;
+};
+
+
=head1 COPYRIGHT
+COPYRIGHT (C) 2012 The LedgerSMB Core Team. This file may be re-used under the
+terms of the LedgerSMB General Public License version 2 or at your option any
+later version. Please see enclosed LICENSE file for details.
+
=cut
1;
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/GL.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/GL.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/GL.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -26,9 +26,10 @@
package LedgerSMB::Report::GL;
use Moose;
extends 'LedgerSMB::Report';
+with 'LedgerSMB::Report::Dates';
-use LedgerSMB::DBObject::Business_Unit_Class;
-use LedgerSMB::DBObject::Business_Unit;
+use LedgerSMB::Business_Unit_Class;
+use LedgerSMB::Business_Unit;
use LedgerSMB::App_State;
=head1 PROPERTIES
@@ -107,11 +108,13 @@
{col_id => 'debits',
name => LedgerSMB::Report::text('Debits'),
type => 'text',
+ money => 1,
pwidth => '2', },
{col_id => 'credits',
name => LedgerSMB::Report::text('Credits'),
type => 'text',
+ money => 1,
pwidth => '2', },
{col_id => 'source',
@@ -157,9 +160,10 @@
{col_id => 'running_balance',
name => LedgerSMB::Report::text('Balance'),
type => 'text',
+ money => 1,
pwidth => '3', },
);
- my @bclasses = LedgerSMB::DBObject::Business_Unit_Class->list('1', 'gl');
+ my @bclasses = LedgerSMB::Business_Unit_Class->list('1', 'gl');
for my $class (@bclasses){
push @COLS, {col_id => "bc_" . $class->id,
name => LedgerSMB::Report::text($class->label),
@@ -277,22 +281,6 @@
has 'description' => (is => 'rw', isa => 'Maybe[Str]');
-=item from_date
-
-Earliest date which matches the search
-
-=cut
-
-has 'from_date' => (is => 'rw', coerce => 1, isa => 'LedgerSMB::Moose::Date');
-
-=item to_date
-
-Last date that matches the search
-
-=cut
-
-has 'to_date' => (is => 'rw', coerce => 1, isa => 'LedgerSMB::Moose::Date');
-
=item approved
Unless false, only matches approved transactions. When false, matches all
@@ -338,8 +326,15 @@
=cut
+sub _exclude_from_totals {
+ return {running_balance => 1};
+}
+
sub run_report{
my ($self) = @_;
+ my $accno = $self->accno;
+ $accno =~ s/--.*//;
+ $self->accno($accno);
my @rows = $self->exec_method({funcname => 'report__gl'});
for my $ref(@rows){
if ($ref->{amount} < 0){
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/Inventory/Adj_Details.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/Inventory/Adj_Details.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/Inventory/Adj_Details.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -15,11 +15,19 @@
use Moose;
use LedgerSMB::Report::Inventory::Search_Adj;
extends 'LedgerSMB::Report';
+use LedgerSMB::Form;
+use LedgerSMB::IS;
+use LedgerSMB::IR;
+use LedgerSMB::AA;
+use LedgerSMB::App_State;
+use LedgerSMB::Setting;
=head1 DESCRIPTION
This report shows the details of an inventory adjustment report.
+THIS IS NOT SAFE TO CACHE UNTIL THE FINANCIAL LOGIC IS IN THE NEW FRAMEWORK.
+
=head1 CRITERIA PROPERTIES
=over
@@ -44,7 +52,7 @@
=cut
-has source => (is => 'ro', isa => 'Maybe[Str]');
+has source => (is => 'rw', isa => 'Maybe[Str]');
=back
@@ -91,6 +99,30 @@
];
}
+=head2 set_buttons
+
+This sets buttons relevant to approving the adjustments.
+
+=cut
+
+sub set_buttons {
+ return [{
+ name => 'action',
+ type => 'submit',
+ value => 'approve',
+ text => LedgerSMB::Report::text('Approve'),
+ class => 'submit',
+ },{
+ name => 'action',
+ type => 'submit',
+ value => 'delete',
+ text => LedgerSMB::Report::text('Delete'),
+ class => 'submit',
+ }];
+}
+
+=back
+
=head1 METHODS
=over
@@ -102,7 +134,7 @@
sub run_report {
my ($self) = @_;
my ($rpt) = $self->exec_method({funcname => 'inventory_adj__get'});
- $self->source($rpt->source);
+ $self->source($rpt->{source});
my @rows = $self->exec_method({funcname => 'inventory_adj__details'});
for my $row (@rows){
$row->{row_id} = $row->{parts_id};
@@ -110,6 +142,87 @@
$self->rows(\@rows);
}
+=head2 approve
+
+Approves the report. This currently goes through the legacy code and is the
+point where caching becomes unsafe.
+
+=cut
+
+sub approve {
+ my ($self) = @_;
+ my $form_ar = bless({rowcount => 1}, 'Form');
+ my $form_ap = bless({rowcount => 1}, 'Form');
+ my $curr = LedgerSMB::Setting->get('curr');
+ ($curr) = split(':', $curr);
+
+ ## Setting up forms
+ #
+ # ar
+ $form_ar->{dbh} = LedgerSMB::App_State::DBH;
+ $form_ar->{customer} = '00000';
+ $form_ar->{vc} = 'customer';
+ $form_ar->get_name( {}, 'customer', 'today', '2' );
+ $form_ar->{customer_id} = $form_ar->{'name_list'}->[0]->{id};
+ $form_ar->{currency} = $curr;
+ $form_ar->{defaultcurrency} = $curr;
+
+
+ # ap
+ $form_ap->{dbh} = LedgerSMB::App_State::DBH;
+ $form_ap->{vendor} = '00000';
+ $form_ap->{vc} = 'vendor';
+ $form_ap->get_name( {}, 'vendor', 'today', '1' );
+ $form_ap->{vendor_id} = $form_ap->{'name_list'}->[0]->{id};
+ $form_ap->{currency} = $curr;
+ $form_ap->{defaultcurrency} = $curr;
+
+
+ ## Processing reports
+ $self->run_report;
+ my @rows = @{$self->rows};
+ for my $row (@rows){
+ next if $row->{variance} == 0;
+ if ($row->{variance} < 0){
+ my $form = $form_ar;
+ my $rc = $form->{rowcount};
+ $form->{"qty_$rc"} = -1 * $row->{variance};
+ $form->{"id_$rc"} = $row->{parts_id};
+ $form->{"description_$rc"} = $row->{description};
+ $form->{"discount_$rc"} = '100';
+ $form->{"sellprice_$rc"} = $row->{sellprice};
+ ++$form->{rowcount};
+ } elsif ($row->{variance} > 0){
+ my $form = $form_ap;
+ my $rc = $form->{rowcount};
+ $form->{"qty_$rc"} = $row->{variance};
+ $form->{"id_$rc"} = $row->{parts_id};
+ $form->{"description_$rc"} = $row->{description};
+ $form->{"discount_$rc"} = '100';
+ $form->{"sellprice_$rc"} = $row->{lastcost};
+ ++$form->{rowcount};
+
+ }
+ }
+ ## Posting
+ IS->post_invoice({}, $form_ar);
+ IR->post_invoice({}, $form_ap);
+ $self->call_procedure(procname => 'inventory_report__approve',
+ args => [$self->id, $form_ar->{id}, $form_ap->{ap}]
+ );
+}
+
+=head2 delete
+
+Deletes the inventory report
+
+=cut
+
+sub delete {
+ my ($self) = @_;
+ $self->exec_method(funcname => 'inventory_report__delete');
+}
+
=back
=head1 SEE ALSO
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/Inventory/Search_Adj.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/Inventory/Search_Adj.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/Inventory/Search_Adj.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -106,6 +106,8 @@
];
}
+=back
+
=head1 METHODS
=over
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL/ECA.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL/ECA.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL/ECA.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -37,7 +37,7 @@
has id => (is => 'rw', isa =>'Int');
-=item name
+=item legal_name
Name of the customer
@@ -84,7 +84,7 @@
=cut
sub header_lines {
- return [{name => 'legal_name',
+ return [{name => 'name',
text => LedgerSMB::Report::text('Name') },
{name => 'meta_number',
text => LedgerSMB::Report::text('Account Number')},
@@ -93,12 +93,6 @@
];
}
-=item columns
-
-=cut
-
-sub columns { return [] }
-
=back
=head1 METHODS
@@ -132,6 +126,8 @@
=item LedgerSMB::Report::PNL
+=back
+
=head1 COPYRIGHT
COPYRIGHT (C) 2012 The LedgerSMB Core Team. This file may be re-used under the
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL/Income_Statement.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL/Income_Statement.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL/Income_Statement.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -31,7 +31,14 @@
has basis => (is => 'ro', isa =>'Str', required => 1);
+=item ignore_yearend
+This is 'none', 'all', or 'last'
+
+=cut
+
+has ignore_yearend => (is => 'ro', 'isa' =>'Str', required =>1);
+
=back
=head1 CONSTANT REPORT-RELATED FUNCTIONS
@@ -59,12 +66,6 @@
text => LedgerSMB::Report::text('Reporting Basis') }];
}
-=item columns
-
-=cut
-
-sub columns { return [] }
-
=back
=head1 METHODS
@@ -100,6 +101,8 @@
=item LedgerSMB::Report::PNL
+=back
+
=head1 COPYRIGHT
COPYRIGHT (C) 2012 The LedgerSMB Core Team. This file may be re-used under the
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL/Invoice.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL/Invoice.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL/Invoice.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -32,7 +32,7 @@
has id => (is => 'ro', isa =>'Int', required => 1);
-=over invnumber
+=item invnumber
Invoice number
@@ -40,17 +40,15 @@
has invnumber => (is => 'rw', isa =>'Str');
-=cut
+=item transdate
-=over transdate
-
Transaction Date
=cut
has transdate => (is => 'rw', isa =>'LedgerSMB::Moose::Date', coerce=> 1);
-=over name
+=item name
Customer/vendor name
@@ -90,12 +88,6 @@
];
}
-=item columns
-
-=cut
-
-sub columns { return [] }
-
=back
=head1 METHODS
@@ -128,6 +120,8 @@
=item LedgerSMB::Report::PNL
+=back
+
=head1 COPYRIGHT
COPYRIGHT (C) 2012 The LedgerSMB Core Team. This file may be re-used under the
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL/Product.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL/Product.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL/Product.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -80,12 +80,6 @@
];
}
-=item columns
-
-=cut
-
-sub columns { return [] }
-
=back
=head1 METHODS
@@ -118,6 +112,8 @@
=item LedgerSMB::Report::PNL
+=back
+
=head1 COPYRIGHT
COPYRIGHT (C) 2012 The LedgerSMB Core Team. This file may be re-used under the
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/PNL.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -66,6 +66,8 @@
has 'comparisons' => (is => 'rw', isa => 'ArrayRef[Any]');
+=back
+
=head1 CONSTANT REPORT-RELATED FUNCTIONS
=over
@@ -82,7 +84,9 @@
=cut
-sub columns { return [] }
+sub columns { [{col_id => 'amount',
+ money => 1 }]
+}
=back
@@ -112,8 +116,8 @@
$data->{$r->{account_category}}->{$r->{account_number}} = {$label => $r};
$data->{$r->{account_category}}->{$r->{account_number}}->{info} = $r;
}
- my $i_total = Math::BigFloat->new(0);
- my $e_total = Math::BigFloat->new(0);
+ my $i_total = LedgerSMB::PGNumber->from_input('0');
+ my $e_total = LedgerSMB::PGNumber->from_input('0');
my $total;
for my $k (keys %{$data->{I}}){
$i_total += $data->{I}->{$k}->{$label}->{amount};
@@ -121,12 +125,9 @@
for my $k (keys %{$data->{E}}){
$e_total += $data->{E}->{$k}->{$label}->{amount};
}
- $i_total->bfround($LedgerSMB::Sysconfig::decimal_places * -1);
- $data->{totals}->{$label}->{I} = $i_total->bstr();
-
- $e_total->bfround($LedgerSMB::Sysconfig::decimal_places * -1);
- $data->{totals}->{$label}->{E} = $e_total->bstr();
- $data->{totals}->{$label}->{total} = ($i_total - $e_total)->bstr();
+ $data->{totals}->{$label}->{I} = $i_total->to_output(money => 1);
+ $data->{totals}->{$label}->{E} = $e_total->to_output(money => 1);
+ $data->{totals}->{$label}->{total} = ($i_total - $e_total)->to_output(money => 1);
$self->account_data($data);
}
@@ -151,23 +152,26 @@
=cut
sub add_comparison {
- my ($self, $label, $from, $to) = @_;
- my %attributes = %{ $self->meta->get_attribute_map };
- my %new_data;
- while (my ($name, $attribute) = each %attributes) {
- my $reader = $attribute->get_read_method;
- $new_data{$name} = $self->$reader;
- }
- $new_data{from_date} = $from;
- $new_data{to_date} = $to;
- my $new_report = $self->new(%new_data);
- my @rows = $new_report->run_report;
+ my ($self, $new_pnl) = @_;
my $comparisons = $self->comparisons;
$comparisons ||= [];
- push @$comparisons, {label => $label, from_date => $from, to_date => $to};
- $self->_merge_rows($label, @rows);
+ my $old_ad = $self->account_data;
+ my $new_ad = $new_pnl->account_data;
+ for my $cat (qw(I E)){
+ for my $k (keys %{$new_ad->{$cat}}){
+ $old_ad->{$cat}->{$k}->{main}->{account_description}
+ ||= $new_ad->{$cat}->{$k}->{main}->{account_description};
+ }
+ }
+ push @$comparisons, {from_date => $new_pnl->from_date,
+ to_date => $new_pnl->to_date,
+ account_data => $new_pnl->account_data,
+ };
+ $self->comparisons($comparisons);
}
+=back
+
=head1 SEE ALSO
=over
@@ -182,6 +186,8 @@
=item LedgerSMB::Report::Dates
+=back
+
=head1 COPYRIGHT
COPYRIGHT (C) 2012 The LedgerSMB Core Team. This file may be re-used under the
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/Trial_Balance.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/Trial_Balance.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/Trial_Balance.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -25,8 +25,8 @@
package LedgerSMB::Report::Trial_Balance;
use Moose;
use LedgerSMB::App_State;
+extends 'LedgerSMB::Report';
with 'LedgerSMB::Report::Dates';
-extends 'LedgerSMB::Report';
=head1 DESCRIPTION
@@ -83,7 +83,16 @@
has ignore_yearend => (is => 'rw', isa => 'Str');
+=item balance_sign
+Either 1, 0, or -1. 1 for credit, -1 for debit, 0 for normal balances (i.e
+credit balances except for asset and expense accounts).
+
+=cut
+
+has balance_sign => (is => 'rw', isa => 'Int');
+
+
=item heading
If set, only select accounts under this heading
@@ -100,6 +109,8 @@
has accounts => (is => 'rw', isa => 'Maybe[ArrayRef[Int]]');
+=back
+
=head1 REPORT CONSTANT FUNCTIONS
See the documentation for LedgerSMB::Report for details on these
@@ -124,33 +135,44 @@
{col_id => 'account_number',
type => 'href',
href_base => 'journal.pl?action=search&col_transdate=Y&col_reference=Y&col_description=Y&col_debits=Y&col_credits=Y&col_source=Y&col_accno=Y',
- name => LedgerSMB::Report::text('Account Number') },
+ name => LedgerSMB::Report::text('Account Number'),
+ pwidth => 1,},
{col_id => 'account_desc',
type => 'href',
href_base => 'journal.pl?action=search&col_transdate=Y&col_reference=Y&col_description=Y&col_debits=Y&col_credits=Y&col_source=Y&col_accno=Y',
- name => LedgerSMB::Report::text('Account Description') },
+ name => LedgerSMB::Report::text('Account Description'),
+ pwidth => 3,},
{col_id => 'gifi_accno',
type => 'href',
href_base => 'journal.pl?action=search&col_transdate=Y&col_reference=Y&col_description=Y&col_debits=Y&col_credits=Y&col_source=Y&col_accno=Y',
- name => LedgerSMB::Report::text('GIFI') } ,
+ name => LedgerSMB::Report::text('GIFI'),
+ pwidth => 1, } ,
{col_id => 'starting_balance',
type => 'text',
- name => LedgerSMB::Report::text('Starting Balance') } ,
+ money => 1,
+ name => LedgerSMB::Report::text('Starting Balance'),
+ pwidth => 1,} ,
{col_id => 'debits',
type => 'text',
- name => LedgerSMB::Report::text('Debits') } ,
+ money => 1,
+ name => LedgerSMB::Report::text('Debits'),
+ pwidth => 1} ,
{col_id => 'credits',
type => 'text',
- name => LedgerSMB::Report::text('Credits') } ,
+ money => 1,
+ name => LedgerSMB::Report::text('Credits'),
+ pwidth => 1} ,
{col_id => 'ending_balance',
type => 'text',
- name => LedgerSMB::Report::text('Ending Balance') } ,
+ money => 1,
+ name => LedgerSMB::Report::text('Ending Balance'),
+ pwidth => 1} ,
];
}
@@ -208,24 +230,31 @@
sub run_report {
my ($self) = @_;
- my @rows = $self->exec_method({funcname => 'trial_balance__generate'});
+ $self->manual_totals('1');
+ my @rawrows = $self->exec_method({funcname => 'trial_balance__generate'});
my $total_debits;
my $total_credits;
- for my $ref(@rows){
- my $href_suffix = "from_date=" . $self->from_date .
- "&to_date=" . $self->to_date .
- "&accno=" . $ref->{account_number};
+ my @rows = ();
+ for my $ref(@rawrows){
+ next if (($ref->{starting_balance} == 0)
+ and ($ref->{credits} == 0) and ($ref->{debits} == 0));
+ my $href_suffix = "&accno=" . $ref->{account_number};
+ $href_suffix .= "&from_date=" . $self->date_from->to_db
+ if defined $self->date_from;
+ $href_suffix .= "&to_date=" . $self->date_to->to_db
+ if defined $self->date_to;
+
$total_debits += $ref->{debits};
$total_credits += $ref->{credits};
$ref->{account_number_href_suffix} = $href_suffix;
$ref->{account_desc_href_suffix} = $href_suffix;
$ref->{gifi_accno_href_suffix} = $href_suffix;
-
+ push @rows, $ref;
}
push @rows, {class => 'total',
debits => $total_debits,
- credits => $total_credits, };
-
+ credits => $total_credits,
+ html_class => 'listtotal'};
$self->rows(\@rows);
}
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/Unapproved/Batch_Detail.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/Unapproved/Batch_Detail.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/Unapproved/Batch_Detail.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -115,6 +115,7 @@
{col_id => 'amount',
name => LedgerSMB::Report::text('Amount'),
type => 'text',
+ money => 1,
pwidth => '2', },
];
@@ -200,9 +201,15 @@
text => LedgerSMB::Report::text('Delete Vouchers'),
value => 'vouchers_delete',
class => 'submit',
+ },
+ {
+ name => 'action',
+ type => 'submit',
+ text => LedgerSMB::Report::text('Unlock Batch'),
+ value => 'batch_unlock',
+ class => 'submit',
}]);
- my @rows = $self->exec_method({funcname => 'batch__search'});
- for my $r (@rows){
+ my @rows = $self->exec_method({funcname => 'voucher__list'});
for my $ref (@rows){
my $script;
my $class_to_script = {
@@ -227,6 +234,5 @@
later version. Please see included LICENSE.TXT for details.
=cut
-
__PACKAGE__->meta->make_immutable;
return 1;
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/Unapproved/Batch_Overview.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/Unapproved/Batch_Overview.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/Unapproved/Batch_Overview.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -30,8 +30,8 @@
use Moose;
extends 'LedgerSMB::Report';
-use LedgerSMB::DBObject::Business_Unit_Class;
-use LedgerSMB::DBObject::Business_Unit;
+use LedgerSMB::Business_Unit_Class;
+use LedgerSMB::Business_Unit;
=head1 PROPERTIES
@@ -82,6 +82,10 @@
name => '',
type => 'checkbox' },
+ {col_id => 'batch_class',
+ name => LedgerSMB::Report::text('Type'),
+ type => 'text'},
+
{col_id => 'id',
name => LedgerSMB::Report::text('ID'),
type => 'text',
@@ -95,7 +99,7 @@
{col_id => 'control_code',
name => LedgerSMB::Report::text('Control Code'),
type => 'href',
- href_base => 'vouchers.pl?action=get_batch&id=',
+ href_base => 'vouchers.pl?action=get_batch&batch_id=',
pwidth => '3', },
{col_id => 'description',
@@ -106,11 +110,13 @@
{col_id => 'transaction_total',
name => LedgerSMB::Report::text('AR/AP/GL Amount'),
type => 'text',
+ money => 1,
pwidth => '2', },
{col_id => 'payment_total',
name => LedgerSMB::Report::text('Payment Amount'),
type => 'text',
+ money => 1,
pwidth => '2', },
);
@@ -138,7 +144,7 @@
=cut
sub header_lines {
- return [{name => 'type',
+ return [{name => 'batch_class',
text => LedgerSMB::Report::text('Batch Type')},
{name => 'reference',
text => LedgerSMB::Report::text('Reference')},
@@ -184,8 +190,16 @@
=cut
-has 'type' => (is => 'rw', isa => 'Maybe[Str]');
+has 'type' => (is => 'rw', isa => 'Int');
+=item class_id
+
+class id associated with type
+
+=cut
+
+has class_id => (is => 'rw', isa => 'Int');
+
=item amount_gt
The amount of the draft must be greater than this for it to show up.
@@ -216,6 +230,7 @@
sub run_report{
my ($self) = @_;
+ $self->class_id($self->type) if $self->type;
$self->buttons([{
name => 'action',
type => 'submit',
@@ -228,6 +243,12 @@
text => LedgerSMB::Report::text('Delete'),
value => 'batch_delete',
class => 'submit',
+ },{
+ name => 'action',
+ type => 'submit',
+ text => LedgerSMB::Report::text('Unlock'),
+ value => 'batch_unlock',
+ class => 'submit',
}]);
my @rows = $self->exec_method({funcname => 'batch__search'});
for my $r (@rows){
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/Unapproved/Drafts.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/Unapproved/Drafts.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/Unapproved/Drafts.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -28,8 +28,8 @@
use Moose;
extends 'LedgerSMB::Report';
-use LedgerSMB::DBObject::Business_Unit_Class;
-use LedgerSMB::DBObject::Business_Unit;
+use LedgerSMB::Business_Unit_Class;
+use LedgerSMB::Business_Unit;
=head1 PROPERTIES
@@ -75,6 +75,10 @@
name => '',
type => 'checkbox' },
+ {col_id => 'type',
+ name => LedgerSMB::Report::text('Type'),
+ type => 'text' },
+
{col_id => 'id',
name => LedgerSMB::Report::text('ID'),
type => 'text',
@@ -99,6 +103,7 @@
{col_id => 'amount',
name => LedgerSMB::Report::text('AR/AP/GL Amount'),
type => 'text',
+ money => 1,
pwidth => '2', },
];
# TODO: business_units int[]
@@ -203,7 +208,7 @@
{name => 'action',
type => 'submit',
text => LedgerSMB::Report::text('Delete'),
- value => 'approve',
+ value => 'delete',
class => 'submit', },
];
}
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/co/Balance_y_Mayor.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/co/Balance_y_Mayor.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/co/Balance_y_Mayor.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -74,20 +74,24 @@
{col_id => 'starting_balance',
name => LedgerSMB::Report::text('Starting Balance'),
type => 'text',
+ money => 1,
pwidth => '3', },
{col_id => 'debits',
name => LedgerSMB::Report::text('Debit'),
type => 'text',
+ money => 1,
pwidth => '4', },
{col_id => 'credits',
name => LedgerSMB::Report::text('Credit'),
type => 'text',
+ money => 1,
pwidth => '4', },
{col_id => 'ending_balance',
name => LedgerSMB::Report::text('Balance'),
type => 'text',
+ money => 1,
pwidth => '3', },
);
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report/co/Caja_Diaria.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report/co/Caja_Diaria.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report/co/Caja_Diaria.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -80,11 +80,13 @@
{col_id => 'debits',
name => LedgerSMB::Report::text('Debit'),
type => 'text',
+ money => 1,
pwidth => '4', },
{col_id => 'credits',
name => LedgerSMB::Report::text('Credit'),
type => 'text',
+ money => 1,
pwidth => '4', },
];
}
Modified: addons/1.3/report_framework/trunk/LedgerSMB/Report.pm
===================================================================
--- addons/1.3/report_framework/trunk/LedgerSMB/Report.pm 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/LedgerSMB/Report.pm 2014-02-20 03:58:27 UTC (rev 6880)
@@ -42,7 +42,6 @@
with 'LedgerSMB::DBObject_Moose', 'LedgerSMB::I18N';
use LedgerSMB::Template;
use LedgerSMB::App_State;
-use LedgerSMB::Sysconfig;
=head1 PROPERTIES
@@ -141,6 +140,16 @@
has show_subtotals => (is => 'rw', isa => 'Bool');
+=item manual_totals
+
+Defaults to false. Shows totals for all numeric (but not int) columns.
+Typically this would be set to true in the run_report function if manual
+totals are used.
+
+=cut
+
+has manual_totals => (is => 'rw', isa => 'Bool');
+
=item buttons
Buttons to show at the bottom of the screen
@@ -167,6 +176,21 @@
return [];
}
+=item _exclude_from_totals
+
+Returns a hashref with the keys pointing to true values for column id's that
+should not appear on the total row.
+
+This is useful in avoiding a running total column from being added together and
+a meaningless sum displayed on the totals row.
+
+=cut
+
+sub _exclude_from_totals {
+ return {};
+}
+
+
=item render
This takes no arguments and simply renders the report as is.
@@ -177,8 +201,9 @@
my ($self, $request) = @_;
my $template;
+
my $testref = $self->rows;
- $self->run_report if !defined $testref;
+ $self->run_report($request) if !defined $testref;
# This is a hook for other modules to use to override the default
# template --CT
eval {$template = $self->template};
@@ -186,7 +211,6 @@
# Sorting and Subtotal logic
my $url = LedgerSMB::App_State::get_url();
- no warnings;
if ($self->order_by eq $self->old_order_by){
if (lc($self->order_dir) eq 'asc'){
$self->order_dir('desc');
@@ -199,62 +223,82 @@
$self->order_url(
"$url&old_order_by=".$self->order_by."&order_dir=".$self->order_dir
);
- use warnings;
my $rows = $self->rows;
- @$rows = sort {$a->{$self->order_by} cmp $b->{$self->order_by}} @$rows
+ @$rows = sort {$a->{$self->order_by} <=> $b->{$self->order_by}
+ or
+ $a->{$self->order_by} cmp $b->{$self->order_by}} @$rows
if $self->order_by;
if (lc($self->order_dir) eq 'desc' and $self->order_by) {
@$rows = reverse @$rows;
}
$self->rows($rows);
- if ($self->show_subtotals){
- my @newrows;
- my $subtotals = {html_class => 'subtotal'};
- for my $col ({eval $self->subtotal_on}){
- $subtotals->{$col} = 0;
- }
- my $col_val = undef;
- for my $r (@{$self->rows}){
- if (defined $col_val and ($col_val ne $r->{$self->order_by})){
- push @newrows, $subtotals;
- $subtotals = {html_class => 'subtotal'};
- for my $col ({eval $self->subtotal_on}){
- $subtotals->{$col} = 0;
- }
+ my $total_row = {html_class => 'listtotal', NOINPUT => 1};
+ my $col_val = undef;
+ my $old_subtotal = {};
+ my @newrows;
+ my $exclude = $self->_exclude_from_totals;
+ for my $r (@{$self->rows}){
+ for my $k (keys %$r){
+ next if $exclude->{$k};
+ if (eval { $r->{$k}->isa('LedgerSMB::PGNumber') }){
+ $total_row->{$k} ||= LedgerSMB::PGNumber->from_input('0');
+ $total_row->{$k}->badd($r->{$k});
}
- for my $col ({eval $self->subtotal_on}){
- $subtotals->{$col} += $r->{$col};
- }
- push @newrows, $r;
+
}
- }
-
- # Rendering
- for my $r(@{$self->rows}){
- for my $k (keys %$r){
- if (eval { $r->{$k}->isa('Math::BigFloat')}){
- $r->{$k}->bfround($LedgerSMB::Sysconfig::decimal_places * -1);
- $r->{$k} = $r->{$k}->bstr;
+ if ($self->show_subtotals and defined $col_val and
+ ($col_val ne $r->{$self->order_by})
+ ){
+ my $subtotals = {html_class => 'listsubtotal', NOINPUT => 1};
+ for my $k (keys %$total_row){
+ $subtotals->{$k} = $total_row->{$k}->copy
+ unless $subtotals->{k};
+ $subtotals->{$k}->bsub($old_subtotal->{$k})
+ if ref $old_subtotal->{$k};
}
- }
+ push @newrows, $subtotals;
+ }
+ push @newrows, $r;
}
+ push @newrows, $total_row unless $self->manual_totals;
+ $self->rows(\@newrows);
+ # Rendering
if (!defined $self->format){
$self->format('html');
}
+ my $name = $self->name;
+ $name =~ s/ /_/g;
+ $name = $name . '_' . $self->from_date->to_output if $self->{from_date};
+ $name = $name . '-' . $self->to_date->to_output if $self->{to_date};
+ $name = undef unless $request->{format};
+ my $columns = $self->show_cols($request);
+
+ for my $col (@$columns){
+ if ($col->{money}) {
+ $col->{class} = 'money';
+ for my $row(@{$self->rows}){
+ if ( eval {$row->{$col->{col_id}}->can('to_output')}){
+ $row->{$col->{col_id}} = $row->{$col->{col_id}}->to_output(money => 1);
+ }
+ }
+ }
+ }
+
$template = LedgerSMB::Template->new(
user => $LedgerSMB::App_State::User,
locale => $LedgerSMB::App_State::Locale,
path => 'UI',
template => $template,
+ output_file => $name,
format => uc($request->{format} || 'HTML'),
);
$template->render({report => $self,
request => $request,
name => $self->name,
hlines => $self->header_lines,
- columns => $self->show_cols($request),
+ columns => $columns,
order_url => $self->order_url,
buttons => $self->buttons,
rows => $self->rows});
@@ -307,22 +351,10 @@
sub prepare_input {
my ($self, $request) = @_;
- if ($request->{from_month} and $request->{year}){
- my $interval = $self->get_interval_dates(
- $request->{year},
- $request->{from_month},
- $request->{interval}
- );
- $request->{from_date} = $interval->{start};
- $request->{to_date} = $interval->{end};
- } else {
- $request->{from_date} = LedgerSMB::PGDate->from_input(
- $request->{from_date}
- );
- $request->{date_to} = LedgerSMB::PGDate->from_input(
- $request->{date_to}
- );
- }
+ # Removing date handling since this is done by
+ # LedgerSMB::Report::Dates
+ # Question: Should we move from_amount and to_amount to a role like this
+ # instead? --CT
$request->{from_amount} = LedgerSMB::PGNumber->from_input(
$request->{from_amount}
);
@@ -338,17 +370,34 @@
bc_$class_id holding the $bu_id fields.
=cut
-
sub process_bclasses {
my ($self, $ref) = @_;
for my $bu (@{$ref->{business_units}}){
+ if($bu->[1]){#avoid message:Use of uninitialized value in hash element
push @{$ref->{$bu->[0]}}, $bu->[1]
unless grep(/$bu->[1]/, @{$ref->{$bu->[0]}});
+ }
}
}
=back
+=head1 WRITING REPORTS
+
+LedgerSMB::Report subclasses are written typically in a few parts:
+
+=over
+
+=item SQL or PL/PGSQL function
+
+=item Criteria Properties
+
+=item Method overrides
+
+=item Main processing function(s)
+
+=back
+
=head1 COPYRIGHT
COPYRIGHT (C) 2012 The LedgerSMB Core Team. This file may be re-used under the
Modified: addons/1.3/report_framework/trunk/UI/Reports/PNL.html
===================================================================
--- addons/1.3/report_framework/trunk/UI/Reports/PNL.html 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/UI/Reports/PNL.html 2014-02-20 03:58:27 UTC (rev 6880)
@@ -1,10 +1,11 @@
<?lsmb INCLUDE 'ui-header.html' include_stylesheet = ['UI/Reports/pnl.css'];
account_data = report.account_data ?>
<?lsmb COLS = comparison.length + 2 ?>
-<body>
+<body class="<?lsmb dojo_theme ?>">
<h1><?lsmb name ?></h1>
<h2><?lsmb text('Accounting period: [_1] to [_2]', report.from_date, report.to_date); ?></h2>
<?lsmb
+comparisons = report.comparisons;
IF comparisons;
FOREACH COMP IN comparisons ?>
<h2><?lsmb text('Compared to: [_1] to [_2]', COMP.from_date, COMP.to_date) ?>
@@ -16,11 +17,11 @@
<tr class="sectionhead">
<th><?lsmb text('Income Account') ?></th>
<th><?lsmb report.from_date _ '<br /> - <br />' _ report.to_date ?></th>
- <?lsmb FOREACH COMP IN comparison ?>
+ <?lsmb FOREACH COMP IN comparisons ?>
<th><?lsmb COMP.from_date _ '<br /> - <br />' _ COMP.to_date ?></th>
<?lsmb END ?>
</tr>
- <?lsmb FOREACH k IN account_data.I.keys ?>
+ <?lsmb FOREACH k IN account_data.I.keys.sort ?>
<tr class="incomerow">
<td class="label"><a href="account.pl?action=edit&id=<?lsmb
account_data.I.${k}.main.account_id
@@ -33,21 +34,21 @@
?>&category=X&col_transdate=Y&col_reference=Y&col_description=Y&col_debits=Y&col_credits=Y&col_source=Y&col_accno=Y&action=search"
><?lsmb account_data.I.${k}.main.amount ?></a></td>
- <?lsmb FOREACH COMP IN comparison ?>
+ <?lsmb FOREACH COMP IN comparisons ?>
<td class="amount"><a href="journal.pl?sort=transdate&accno=<?lsmb k
?>&from_date=<?lsmb COMP.from_date
?>&to_date=<?lsmb COMP.to_date
?>&category=X&col_transdate=Y&col_reference=Y&col_description=Y&col_debits=Y&col_credits=Y&col_source=Y&col_accno=Y&action=search"
- ><?lsmb account_data.I.${k}.${COMP.label}.amount ?></a></td>
+ ><?lsmb COMP.account_data.I.${k}.info.amount ?></a></td>
<?lsmb END ?>
</tr>
<?lsmb END ?>
<tr class="sectionfoot">
<th><?lsmb text('Total Income') ?></th>
<td class="amount total"><?lsmb account_data.totals.main.I ?></td>
- <?lsmb FOREACH COMP IN comparison ?>
+ <?lsmb FOREACH COMP IN comparisons ?>
<td class="amount total">
- <?lsmb account_data.totals.${COMP.label}.I ?></td>
+ <?lsmb COMP.account_data.totals.main.I ?></td>
<?lsmb END ?>
</tr>
<tr class="separator"><td colspan="<?lsmb COLS ?>"></td></tr>
@@ -58,10 +59,10 @@
<th> </th>
<?lsmb END ?>
</tr>
- <?lsmb FOREACH k IN account_data.E.keys ?>
+ <?lsmb FOREACH k IN account_data.E.keys.sort ?>
<tr class="incomerow">
<td class="label"><a href="account.pl?action=edit&id=<?lsmb
- account_data.I.${k}.main.account_id
+ account_data.E.${k}.main.account_id
?>&charttype=A"
><?lsmb k _ '--' _
account_data.E.${k}.main.account_description ?></a></td>
@@ -70,46 +71,45 @@
?>&to_date=<?lsmb report.to_date
?>&category=X&col_transdate=Y&col_reference=Y&col_description=Y&col_debits=Y&col_credits=Y&col_source=Y&col_accno=Y&action=search"
><?lsmb account_data.E.${k}.main.amount ?></a></td>
- <?lsmb FOREACH COMP IN comparison ?>
- <td class="amount">
+ <?lsmb FOREACH COMP IN comparisons ?>
<td class="amount"><a href="journal.pl?sort=transdate&accno=<?lsmb k
?>&from_date=<?lsmb COMP.from_date
?>&to_date=<?lsmb COMP.to_date
?>&category=X&col_transdate=Y&col_reference=Y&col_description=Y&col_debits=Y&col_credits=Y&col_source=Y&col_accno=Y&action=search"
- ><?lsmb account_data.E.${k}.${COMP.label}.amount ?></a></td>
+ ><?lsmb COMP.account_data.E.${k}.info.amount ?></a></td>
<?lsmb END ?>
</tr>
<?lsmb END ?>
<tr class="sectionfoot">
<th><?lsmb text('Total Expense') ?></th>
<td class="amount total"><?lsmb account_data.totals.main.E ?></td>
- <?lsmb FOREACH COMP IN comparison ?>
+ <?lsmb FOREACH COMP IN comparisons ?>
<td class="amount total">
- <?lsmb account_data.totals.${COMP.label}.E ?></td>
+ <?lsmb COMP.account_data.totals.main.E ?></td>
<?lsmb END ?></tr>
- <tr class="separator"><td colspan="<?lsmb COLS ?>"></td></tr>
+ <tr class="separator"><td colspan="<?lsmb COLS ?>"> </td></tr>
<tr class="sectionfoot">
<th><?lsmb text('Total Income') ?></th>
<td class="amount"><?lsmb account_data.totals.main.I ?></td>
- <?lsmb FOREACH COMP IN comparison ?>
+ <?lsmb FOREACH COMP IN comparisons ?>
<td class="amount">
- <?lsmb account_data.totals.${COMP.label}.I ?></td>
+ <?lsmb COMP.account_data.totals.main.I ?></td>
<?lsmb END ?>
</tr>
<tr class="reportfoot">
<th><?lsmb text('Less Total Expense') ?></th>
<td class="amount"><?lsmb account_data.totals.main.E ?></td>
- <?lsmb FOREACH COMP IN comparison ?>
+ <?lsmb FOREACH COMP IN comparisons ?>
<td class="amount">
- <?lsmb account_data.totals.${COMP.label}.E ?></td>
+ <?lsmb COMP.account_data.totals.main.E ?></td>
<?lsmb END ?>
</tr>
<tr class="reportfoot">
<th> = <?lsmb text('Net Income (Loss)') ?></th>
<td class="amount total"><?lsmb account_data.totals.main.total ?></td>
- <?lsmb FOREACH COMP IN comparison ?>
+ <?lsmb FOREACH COMP IN comparisons ?>
<td class="amount total">
- <?lsmb account_data.totals.${COMP.label}.total ?></td>
+ <?lsmb COMP.account_data.totals.main.total ?></td>
<?lsmb END ?>
</tr>
</tbody>
Modified: addons/1.3/report_framework/trunk/UI/Reports/aging_report.html
===================================================================
--- addons/1.3/report_framework/trunk/UI/Reports/aging_report.html 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/UI/Reports/aging_report.html 2014-02-20 03:58:27 UTC (rev 6880)
@@ -11,11 +11,11 @@
_ '?' _ ENVARS.QUERY_STRING _ '&company=' _ DBNAME;
?>
-<body>
+<body class="<?lsmb dojo_theme ?>">
<div class="report_header"><label><?lsmb text('Report Name') ?>:</label>
<span class="report_header"><?lsmb name ?></span>
</div>
-<body>
+<body class="<?lsmb dojo_theme ?>">
<div class="report_header"><label><?lsmb text('Company') ?>:</label>
<span class="report_header"><?lsmb request.company ?></span>
</div>
@@ -92,7 +92,7 @@
PROCESS button element_data = {
text = text('Generate')
name = 'action'
- value = 'generate_statements'
+ value = 'generate_statement'
type = 'submit'
class = 'submit'
};
Modified: addons/1.3/report_framework/trunk/UI/Reports/co/filter_bm.html
===================================================================
--- addons/1.3/report_framework/trunk/UI/Reports/co/filter_bm.html 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/UI/Reports/co/filter_bm.html 2014-02-20 03:58:27 UTC (rev 6880)
@@ -2,7 +2,7 @@
include_script = ["UI/ajax/scriptaculous/lib/prototype.js","UI/ajax/scriptaculous/src/scriptaculous.js?load=builder,effects,dragdrop,controls","UI/ajax/helpers.js"]
?>
<?lsmb PROCESS 'elements.html' ?>
-<body>
+<body class="<?lsmb dojo_theme ?>">
<form method="get" action="<?lsmb script ?>">
<?lsmb PROCESS input element_data = {
Modified: addons/1.3/report_framework/trunk/UI/Reports/co/filter_cd.html
===================================================================
--- addons/1.3/report_framework/trunk/UI/Reports/co/filter_cd.html 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/UI/Reports/co/filter_cd.html 2014-02-20 03:58:27 UTC (rev 6880)
@@ -2,7 +2,7 @@
include_script = ["UI/ajax/scriptaculous/lib/prototype.js","UI/ajax/scriptaculous/src/scriptaculous.js?load=builder,effects,dragdrop,controls","UI/ajax/helpers.js"]
?>
<?lsmb PROCESS 'elements.html' ?>
-<body>
+<body class="<?lsmb dojo_theme ?>">
<form method="get" action="<?lsmb script ?>">
<?lsmb PROCESS input element_data = {
Modified: addons/1.3/report_framework/trunk/UI/Reports/display_report.html
===================================================================
--- addons/1.3/report_framework/trunk/UI/Reports/display_report.html 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/UI/Reports/display_report.html 2014-02-20 03:58:27 UTC (rev 6880)
@@ -13,11 +13,11 @@
_ '?' _ ENVARS.QUERY_STRING _ '&company=' _ DBNAME;
?>
-<body>
+<body class="<?lsmb dojo_theme ?>">
<div class="report_header"><label><?lsmb text('Report Name') ?>:</label>
<span class="report_header"><?lsmb name ?></span>
</div>
-<body>
+<body class="<?lsmb dojo_theme ?>">
<div class="report_header"><label><?lsmb text('Company') ?>:</label>
<span class="report_header"><?lsmb request.company ?></span>
</div>
@@ -39,16 +39,23 @@
value = request.form_id
type = 'hidden'
} ?>
+<?lsmb FOREACH K IN request.hiddens.keys;
+ PROCESS input element_data = {
+ name = K
+ type = 'hidden'
+ value = request.hiddens.$K
+ };
+ END; ?>
<?lsmb PROCESS dynatable tbody = {rows = rows }
attributes = {class = 'report', order_url = order_url } ?>
-<?lsmb IF FORMATS.grep('PDF').size()
-?>
-<?lsmb
+<?lsmb
FOREACH BUTTON IN buttons;
PROCESS button element_data = BUTTON;
-END; ?><br />
+END; ?><br />
<a href="<?lsmb LINK ?>">[<?lsmb text('permalink') ?>]</a>
+<?lsmb IF FORMATS.grep('PDF').size()
+?>
<a href="<?lsmb LINK _ '&format=PDF' ?>">[<?lsmb text('PDF') ?>]</a>
<?lsmb END;
IF FORMATS.grep('TXT').size();
Modified: addons/1.3/report_framework/trunk/UI/Reports/display_report.tex
===================================================================
--- addons/1.3/report_framework/trunk/UI/Reports/display_report.tex 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/UI/Reports/display_report.tex 2014-02-20 03:58:27 UTC (rev 6880)
@@ -3,16 +3,14 @@
papersize = 'a4paper';
END;
+SKIP_TYPES = ['hidden', 'radio', 'checkbox'];
COLNUMBER = 0;
-SKIP_TYPES = ['hidden', 'radio', 'checkbox'];
-
FOREACH COL IN columns;
- IF 0 == SKIP_TYPES.grep(COL.type).size();
- COLNUMBER = COLNUMBER + 1;
+ IF 0 == SKIP_TYPES.grep(COL.type).size() and ! COL.html_only.defined();
+ COLNUMBER = COLNUMBER + 1;
END;
END;
-
FILTER latex;
-?>
\documentclass[<?lsmb papersize ?>]{article}
Modified: addons/1.3/report_framework/trunk/UI/Reports/filters/aging.html
===================================================================
--- addons/1.3/report_framework/trunk/UI/Reports/filters/aging.html 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/UI/Reports/filters/aging.html 2014-02-20 03:58:27 UTC (rev 6880)
@@ -1,7 +1,7 @@
<?lsmb INCLUDE 'ui-header.html';
PROCESS elements.html;
PROCESS report_base.html ?>
-<body>
+<body class="<?lsmb dojo_theme ?>">
<form method="get" action="report_aging.pl">
<table width="100%">
<tr><th class="listtop"><?lsmb text('Aging Report') ?></th></tr>
Modified: addons/1.3/report_framework/trunk/UI/Reports/filters/budget_search.html
===================================================================
--- addons/1.3/report_framework/trunk/UI/Reports/filters/budget_search.html 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/UI/Reports/filters/budget_search.html 2014-02-20 03:58:27 UTC (rev 6880)
@@ -2,7 +2,7 @@
stylesheet=stylesheet
include_stylesheet = ["UI/budgetting/budgetting.css"] ?>
<?lsmb PROCESS elements.html ?>
-<body>
+<body class="<?lsmb dojo_theme ?>">
<form action="budget_reports.pl" method="get">
<div class="listtop"><?lsmb text('Search Budgets') ?></div>
<div class="input_row" id = "reference_row">
Modified: addons/1.3/report_framework/trunk/UI/Reports/filters/contact_search.html
===================================================================
--- addons/1.3/report_framework/trunk/UI/Reports/filters/contact_search.html 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/UI/Reports/filters/contact_search.html 2014-02-20 03:58:27 UTC (rev 6880)
@@ -1,7 +1,7 @@
<?lsmb INCLUDE 'ui-header.html' ?>
<?lsmb PROCESS elements.html;
PROCESS report_base.html ?>
-<body>
+<body class="<?lsmb dojo_theme ?>">
<?lsmb
IF !account_class;
title = text('Contact Search'); #'
@@ -50,6 +50,10 @@
<td><?lsmb INCLUDE input element_data={size = '20', name = 'phone'} ?></td>
</tr>
<tr>
+ <th align="right"><?lsmb text('Contact') ?></th>
+ <td><?lsmb INCLUDE input element_data={size = '20', name = 'contact'} ?></td>
+ </tr>
+ <tr>
<?lsmb IF entity_type == 'Customer' -?>
<th align="right"><?lsmb text('Salesperson') ?></th>
<td><?lsmb INCLUDE input element_data={size = '32', name = 'employee'} ?></td>
@@ -58,6 +62,13 @@
<td><?lsmb INCLUDE input element_data={size = '32', name = 'employee'} ?></td>
<?lsmb END -?>
</tr>
+ <tr>
+ <th align="right"><?lsmb text('Only Users') ?></th>
+ <td><?lsmb PROCESS input element_data = {
+ type = 'checkbox', name = 'users', value = '1'
+ } ?> (<?lsmb text('Only for Employees') ?>)</td>
+ </tr>
+ <tr>
<th align="right"><?lsmb text('Notes') ?></th>
<td><?lsmb INCLUDE textarea element_data={
rows = '3', cols = '32', name = 'notes'} ?></td>
Modified: addons/1.3/report_framework/trunk/UI/Reports/filters/gl.html
===================================================================
--- addons/1.3/report_framework/trunk/UI/Reports/filters/gl.html 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/UI/Reports/filters/gl.html 2014-02-20 03:58:27 UTC (rev 6880)
@@ -1,9 +1,8 @@
<?lsmb INCLUDE 'ui-header.html'
- include_script = ["UI/ajax/scriptaculous/lib/prototype.js","UI/ajax/scriptaculous/src/scriptaculous.js?load=builder,effects,dragdrop,controls","UI/ajax/helpers.js"]
?>
<?lsmb PROCESS 'elements.html';
PROCESS 'report_base.html' ?>
-<body>
+<body class="<?lsmb dojo_theme ?>">
<form method="get" action="journal.pl">
<?lsmb PROCESS input element_data = {
@@ -32,13 +31,33 @@
<tr>
<th align="right"><?lsmb text('Account') ?></th>
<td colspan="3">
- <?lsmb PROCESS ajaxselect element_data = {
+ <!-- tshvr fixed accno is better here, but commented for test
+ <?lsmb IF accno;
+ accno;
+ PROCESS input element_data = {
+ name = 'accno',
+ type = 'hidden',
+ value = accno
+ };
+ ELSE;
+ PROCESS input element_data = {
name = "accno"
- initial_value = accno
- text_attr = 'accno'
- value_attr = 'id'
- ajax_target = 'journal.pl'
+ size = '15'
+ value = accno
+ type = 'text'
+ class = 'AccountBox'
+ };
+ END ?> </td>
+ -->
+ <!-- tshvr test http://sourceforge.net/p/ledger-smb/bugs/1057/ -->
+ <?lsmb PROCESS input element_data = {
+ name = "accno"
+ size = '15'
+ value = accno
+ type = 'text'
+ class = 'AccountBox'
} ?> </td>
+ <!--tshvr end test-->
</tr>
<tr>
<th align="right"><?lsmb text('Source') ?></th>
@@ -227,7 +246,7 @@
value="Y"
} ?> <?lsmb text('Account Name') ?></td>
<td nowrap><?lsmb PROCESS input element_data = {
- name="col_balance"
+ name="col_running_balance"
class="checkbox"
type="checkbox"
value="Y"
Modified: addons/1.3/report_framework/trunk/UI/Reports/filters/income_statement.html
===================================================================
--- addons/1.3/report_framework/trunk/UI/Reports/filters/income_statement.html 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/UI/Reports/filters/income_statement.html 2014-02-20 03:58:27 UTC (rev 6880)
@@ -1,7 +1,7 @@
<?lsmb INCLUDE 'ui-header.html' ?>
<?lsmb PROCESS elements.html;
PROCESS 'report_base.html'; ?>
-<body>
+<body class="<?lsmb dojo_theme ?>">
<form method="get" action="pnl.pl">
<?lsmb PROCESS input element_data = {
name = 'pnl_type',
@@ -11,21 +11,12 @@
<table width="100%">
<tr><th class="listtop"><?lsmb text('Income Statement') ?></th></tr>
<tr><td> </td></tr>
- <tr>
- <td>
- <table>
- <?lsmb PROCESS business_classes;
- PROCESS date_row; # TODO add comparisons ?>
- </tr>
- </table>
- </td>
-</tr>
<tr>
<td>
<table>
<tr>
<th align="right"><?lsmb text('Method') ?></th>
- <td colspan="3">
+ <td>
<?lsmb PROCESS input element_data={
name = 'basis',
type = 'radio',
@@ -41,9 +32,47 @@
} -?>
</td>
</tr>
+ <tr>
+ <th align="right"><?lsmb text('Ignore Year-ends'); ?></th>
+ <td><?lsmb PROCESS select element_data = {
+ options = [
+ {
+ label="All",
+ id="all",
+ },
+ {
+ label="Last Only",
+ id="last"
+ },
+ {
+ label="None",
+ id="none",
+ }
+ ],
+ default_values = [report.ignore_yearend],
+ name = 'ignore_yearend',
+ text_attr = 'label',
+ value_attr = 'id',
+ } ?>
+ </td>
+ </tr>
</table>
</td>
</tr>
+ <tr>
+ <td>
+ <table>
+ <?lsmb PROCESS business_classes;
+ PROCESS date_row; # TODO add comparisons ?>
+ <tr>
+ <th colspan="7"><?lsmb text('Enter up to 3 date ranges for comparison') ?></th>
+ </tr>
+ <?lsmb FOREACH c IN [1, 2, 3];
+ PROCESS date_row SUFFIX='_' _ c;
+ END ?>
+ </table>
+ </td>
+</tr>
<tr><td><hr size="3" noshade="noshade" /></td></tr>
</table>
<?lsmb PROCESS button element_data = {
Modified: addons/1.3/report_framework/trunk/UI/Reports/filters/inventory_adj.html
===================================================================
--- addons/1.3/report_framework/trunk/UI/Reports/filters/inventory_adj.html 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/UI/Reports/filters/inventory_adj.html 2014-02-20 03:58:27 UTC (rev 6880)
@@ -1,7 +1,9 @@
<?lsmb
-INCLUDE 'ui-header.html';
+INCLUDE 'ui-header.html' include_stylesheet = ['UI/Reports/filter.css'];
PROCESS 'elements.html';
PROCESS 'report_base.html'; ?>
+<body class="<?lsmb dojo_theme ?>">
+<div class="listtop"><?lsmb text('Search Inventory Entry'); ?></div>
<form action="inv_reports.pl" method="get">
<div class="input_row">
<div class="input_group">
@@ -33,6 +35,7 @@
text = text('Run Report') #'
}; ?>
</div>
+</div>
</form>
</body>
</html>
Modified: addons/1.3/report_framework/trunk/UI/Reports/filters/purchase_history.html
===================================================================
--- addons/1.3/report_framework/trunk/UI/Reports/filters/purchase_history.html 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/UI/Reports/filters/purchase_history.html 2014-02-20 03:58:27 UTC (rev 6880)
@@ -4,7 +4,7 @@
<?lsmb PROCESS 'elements.html';
PROCESS 'report_base.html'; ?>
-<body>
+<body class="<?lsmb dojo_theme ?>">
<form method="get" action="contact_reports.pl">
<table width=100%>
@@ -216,18 +216,18 @@
<td><?lsmb
INCLUDE input element_data= {
label = text('Summary'),
- name = 'report_type'
+ name = 'is_summary'
type = 'radio',
- value = 'summary',
+ value = '1',
class = 'radio',
checked = 'CHECKED'
} ?></td>
<td><?lsmb
INCLUDE input element_data= {
label = text('Detail'),
- name = 'report_type',
+ name = 'is_summary',
type = 'radio',
- value = 'detail',
+ value = '0',
class = 'radio',
} ?></td>
</tr>
Modified: addons/1.3/report_framework/trunk/UI/Reports/filters/trial_balance.html
===================================================================
--- addons/1.3/report_framework/trunk/UI/Reports/filters/trial_balance.html 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/UI/Reports/filters/trial_balance.html 2014-02-20 03:58:27 UTC (rev 6880)
@@ -1,10 +1,15 @@
<?lsmb include_stylesheet = ['css/trial_balance/search.css']?>
<?lsmb INCLUDE 'ui-header.html' ?>
<?lsmb PROCESS elements.html;
- PROCESS report_base.html ?>
+ PROCESS report_base.html;
+BALANCE_TYPES = [
+ {text = text('Debit'), id = -1}
+ {text = text('Credit'), id = 1}
+ {text = text('Normal'), id = 0}
+] ?>
-<body>
- <form method="post" action="trial_balance.pl">
+<body class="<?lsmb dojo_theme ?>">
+ <form method="get" action="trial_balance.pl">
<?lsmb IF report.id;
INCLUDE input element_data = {
type="hidden",
@@ -19,37 +24,8 @@
<td>
<table>
<?lsmb PROCESS business_classes ?>
+ <?lsmb PROCESS date_row ?>
<tr>
- <th align="right"><?lsmb text('From') ?></th>
- <td>
- <?lsmb PROCESS input element_data={
- class => 'date',
- name => 'date_from',
- size => '11',
- title => user.dateformat,
- value => report.date_from,
- } ?>
- </td>
- <th align="right"><?lsmb text('To') ?></th>
- <td>
- <?lsmb PROCESS input element_data={
- class => 'date',
- name => 'date_to',
- size => '11',
- title => user.dateformat,
- value => report.date_to,
- } ?>
- </td>
- </tr>
- <tr>
- <th colspan=2><?lsmb text('Round Amounts First') ?>
- <td><?lsmb PROCESS input element_data={
- name => 'discrete_amounts',
- type => 'checkbox',
- value => 'Y',
- } -?>
- </td>
- </tr>
</table>
</td>
</tr>
@@ -80,17 +56,13 @@
} ?>
</td>
</tr>
- <tr>
- <th align="righ"><?lsmb text("Description")?></th>
- <td colspan="2">
- <?lsmb PROCESS input element_data={
- name="description",
- value=report.description,
- size=65,
- class= 'text'
- }?>
- </td>
- </tr>
+ <tr><th><?lsmb text('Balances as') ?></th>
+ <td><?lsmb PROCESS select element_data = {
+ name = 'balance_sign'
+ options = BALANCE_TYPES
+ default_values = ['0']
+ value_attr = 'id'
+ } ?></td>
</table>
</td>
</tr>
@@ -135,28 +107,13 @@
<br />
<?lsmb PROCESS button element_data={
- text => 'Save',
- attributes => {
- name=>'action',
- value=>'save'
+ text = text('Continue'),
+ attributes = {
+ name= 'action',
+ value= 'run'
}
}?>
- <?lsmb PROCESS button element_data={
- text => 'Run',
- attributes => {
- name=>'action',
- value=>'run'
- }
- }?>
- <?lsmb PROCESS button element_data={
- text => 'Save & Run',
- attributes => {
- name=>'action',
- value=>'save_and_run'
- }
- }?>
-
</form>
</body>
</html>
Modified: addons/1.3/report_framework/trunk/UI/Reports/filters/unapproved.html
===================================================================
--- addons/1.3/report_framework/trunk/UI/Reports/filters/unapproved.html 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/UI/Reports/filters/unapproved.html 2014-02-20 03:58:27 UTC (rev 6880)
@@ -9,22 +9,28 @@
IF search_type == 'drafts';
batch_classes = [
+ {},
{ text = text('AP'), value = 'ap'},
{ text = text('AR'), value = 'ar'},
{ text = text('GL'), value = 'gl'},
];
script = 'drafts.pl';
+ action = 'list_drafts';
ELSE;
+ script = 'vouchers.pl';
+ action = 'list_batches';
FOR CLS IN batch_classes;
CLS.text = CLS.class;
- CLS.value = CLS.class;
+ CLS.value = CLS.id;
END;
+ batch_classes.unshift({});
END;
?>
-<body>
+<body class="<?lsmb dojo_theme ?>">
<form action="<?lsmb script ?>" method="get">
<div class="listtop" id="title_div"><?lsmb text('Search Unapproved Transactions') ?></div>
+<div class="tabular col-1">
<div class="input" id="batch_class_div">
<?lsmb INCLUDE select element_data = {
label = text('Transaction Type') # '
@@ -49,7 +55,7 @@
} ?></div> -->
<div class="input" id="reference_div">
<?lsmb INCLUDE input element_data = {
- label = text('Reference/Invoice Number') #'
+ label = text('Reference') #'
size = 20
value = reference
name = "reference"
@@ -73,11 +79,12 @@
type = "text"
} ?>
</div>
+</div>
<div class="input" id="buttons_div">
<?lsmb INCLUDE button element_data = {
text = text('Search')
name = "action"
- value = "list_drafts"
+ value = action
class = "submit"
type = "submit"
} ?> </div>
Modified: addons/1.3/report_framework/trunk/UI/Reports/pnl.css
===================================================================
--- addons/1.3/report_framework/trunk/UI/Reports/pnl.css 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/UI/Reports/pnl.css 2014-02-20 03:58:27 UTC (rev 6880)
@@ -23,8 +23,17 @@
text-align: right;
}
tr.separator {
- background-color: gray;
+ min-height: 1em;
}
+tr.sectionhead {
+}
+tr.sectionhead th {
+ padding-top: 2em;
+ margin-top: 4em;
+ font-size: 120%;
+ font-weight: bold;
+}
+
td.total {
border: 0px;
border-top: 1px;
@@ -35,3 +44,11 @@
th {
vertical-align: bottom;
}
+
+table {
+ margin-right: auto;
+ margin-left: auto;
+}
+h1, h2 {
+ text-align: center;
+}
Modified: addons/1.3/report_framework/trunk/sql/modules/PNL.sql
===================================================================
--- addons/1.3/report_framework/trunk/sql/modules/PNL.sql 2014-02-19 20:08:12 UTC (rev 6879)
+++ addons/1.3/report_framework/trunk/sql/modules/PNL.sql 2014-02-20 03:58:27 UTC (rev 6880)
@@ -18,59 +18,177 @@
account_heading_id int,
account_heading_number text,
account_heading_description text,
- amount numeric
+ amount numeric,
+ heading_path text[]
);
CREATE OR REPLACE FUNCTION pnl__product
(in_from_date date, in_to_date date, in_parts_id int, in_business_units int[])
RETURNS SETOF pnl_line AS
$$
+WITH RECURSIVE bu_tree (id, parent, path) AS (
+ SELECT id, null, row(array[id])::tree_record FROM business_unit
+ WHERE id = any($4)
+ UNION ALL
+ SELECT bu.id, parent, row((path).t || bu.id)::tree_record
+ FROM business_unit bu
+ JOIN bu_tree ON bu.parent_id = bu_tree.id
+)
SELECT a.id, a.accno, a.description, a.category, ah.id, ah.accno,
ah.description,
- sum(ac.amount) * -1
+ sum(ac.amount) * -1, at.path
FROM account a
JOIN account_heading ah on a.heading = ah.id
JOIN acc_trans ac ON ac.chart_id = a.id
JOIN invoice i ON i.id = ac.invoice_id
JOIN account_link l ON l.account_id = a.id
- JOIN ar ON ar.id = ac.trans_id
+ JOIN account_heading_tree at ON a.heading = at.id
+ JOIN ar ON ar.id = ac.trans_id
+LEFT JOIN (select as_array(bu.path) as bu_ids, entry_id
+ from business_unit_inv bui
+ JOIN bu_tree bu ON bui.bu_id = bu.id
+ GROUP BY entry_id) bui ON bui.entry_id = i.id
WHERE i.parts_id = $3
AND (ac.transdate >= $1 OR $1 IS NULL)
AND (ac.transdate <= $2 OR $2 IS NULL)
AND ar.approved
AND l.description = 'IC_expense'
+ AND ($4 is null or $4 = '{}' OR in_tree($4, bu_ids))
GROUP BY a.id, a.accno, a.description, a.category, ah.id, ah.accno,
- ah.description
+ ah.description, at.path
UNION
SELECT a.id, a.accno, a.description, a.category, ah.id, ah.accno,
ah.description,
- sum(i.sellprice * i.qty * (1 - coalesce(i.discount, 0)))
+ sum(i.sellprice * i.qty * (1 - coalesce(i.discount, 0))), at.path
FROM parts p
JOIN invoice i ON i.id = p.id
JOIN acc_trans ac ON ac.invoice_id = i.id
JOIN account a ON p.income_accno_id = a.id
JOIN ar ON ar.id = ac.trans_id
+ JOIN account_heading_tree at ON a.heading = at.id
JOIN account_heading ah on a.heading = ah.id
+LEFT JOIN (select as_array(bu.path) as bu_ids, entry_id
+ from business_unit_inv bui
+ JOIN bu_tree bu ON bui.bu_id = bu.id
+ GROUP BY entry_id) bui ON bui.entry_id = i.id
WHERE i.parts_id = $3
AND (ac.transdate >= $1 OR $1 IS NULL)
AND (ac.transdate <= $2 OR $2 IS NULL)
AND ar.approved
+ AND ($4 is null or $4 = '{}' OR in_tree($4, bu_ids))
GROUP BY a.id, a.accno, a.description, a.category, ah.id, ah.accno,
- ah.description
+ ah.description, at.path
$$ language SQL;
+CREATE OR REPLACE FUNCTION pnl__income_statement_accrual
+(in_from_date date, in_to_date date, in_ignore_yearend text,
+in_business_units int[])
+RETURNS SETOF pnl_line AS
+$$
+WITH RECURSIVE bu_tree (id, parent, path) AS (
+ SELECT id, null, row(array[id])::tree_record FROM business_unit
+ WHERE id = any($4)
+ UNION ALL
+ SELECT bu.id, parent, row((path).t || bu.id)::tree_record
+ FROM business_unit bu
+ JOIN bu_tree ON bu.parent_id = bu_tree.id
+)
+ SELECT a.id, a.accno, a.description, a.category, ah.id, ah.accno,
+ ah.description,
+ CASE WHEN a.category = 'E' THEN -1 ELSE 1 END * sum(ac.amount),
+ at.path
+ FROM account a
+ JOIN account_heading ah on a.heading = ah.id
+ JOIN acc_trans ac ON a.id = ac.chart_id AND ac.approved
+ JOIN tx_report gl ON ac.trans_id = gl.id AND gl.approved
+ JOIN account_heading_tree at ON a.heading = at.id
+LEFT JOIN (select array_agg(path) as bu_ids, entry_id
+ FROM business_unit_ac buac
+ JOIN bu_tree ON bu_tree.id = buac.bu_id
+ GROUP BY buac.entry_id) bu
+ ON (ac.entry_id = bu.entry_id)
+ WHERE ac.approved is true
+ AND ($1 IS NULL OR ac.transdate >= $1)
+ AND ($2 IS NULL OR ac.transdate <= $2)
+ AND ($4 = '{}'
+ OR $4 is null or in_tree($4, bu_ids))
+ AND a.category IN ('I', 'E')
+ AND ($3 = 'none'
+ OR ($3 = 'all'
+ AND NOT EXISTS (SELECT * FROM yearend WHERE trans_id = gl.id
+ ))
+ OR ($3 = 'last'
+ AND NOT EXISTS (SELECT 1 FROM yearend
+ HAVING max(trans_id) = gl.id))
+ )
+ GROUP BY a.id, a.accno, a.description, a.category,
+ ah.id, ah.accno, ah.description, at.path
+ ORDER BY a.category DESC, a.accno ASC;
+$$ LANGUAGE SQL;
+
+CREATE OR REPLACE FUNCTION pnl__income_statement_cash
+(in_from_date date, in_to_date date, in_ignore_yearend text,
+in_business_units int[])
+RETURNS SETOF pnl_line AS
+$$
+WITH RECURSIVE bu_tree (id, parent, path) AS (
+ SELECT id, null, row(array[id])::tree_record FROM business_unit
+ WHERE id = any($4)
+ UNION ALL
+ SELECT bu.id, parent, row((path).t || bu.id)::tree_record
+ FROM business_unit bu
+ JOIN bu_tree ON bu.parent_id = bu_tree.id
+)
+ SELECT a.id, a.accno, a.description, a.category, ah.id, ah.accno,
+ ah.description,
+ CASE WHEN a.category = 'E' THEN -1 ELSE 1 END
+ * sum(ac.amount * ca.portion), at.path
+ FROM account a
+ JOIN account_heading ah on a.heading = ah.id
+ JOIN acc_trans ac ON a.id = ac.chart_id AND ac.approved
+ JOIN tx_report gl ON ac.trans_id = gl.id AND gl.approved
+ JOIN account_heading_tree at ON a.heading = at.id
+ JOIN (SELECT id, sum(portion) as portion
+ FROM cash_impact ca
+ WHERE ($1 IS NULL OR ca.transdate >= $1)
+ AND ($2 IS NULL OR ca.transdate <= $2)
+ GROUP BY id
+ ) ca ON gl.id = ca.id
+LEFT JOIN (select array_agg(path) as bu_ids, entry_id
+ FROM business_unit_ac buac
+ JOIN bu_tree ON bu_tree.id = buac.bu_id
+ GROUP BY entry_id) bu
+ ON (ac.entry_id = bu.entry_id)
+ WHERE ac.approved is true
+ AND ($4 = '{}'
+ OR $4 is null or in_tree($4, bu_ids))
+ AND a.category IN ('I', 'E')
+ AND ($3 = 'none'
+ OR ($3 = 'all'
+ AND NOT EXISTS (SELECT * FROM yearend WHERE trans_id = gl.id
+ ))
+ OR ($3 = 'last'
+ AND NOT EXISTS (SELECT 1 FROM yearend
+ HAVING max(trans_id) = gl.id))
+ )
+ GROUP BY a.id, a.accno, a.description, a.category,
+ ah.id, ah.accno, ah.description, at.path
+ ORDER BY a.category DESC, a.accno ASC;
+$$ LANGUAGE SQL;
+
CREATE OR REPLACE FUNCTION pnl__invoice(in_id int) RETURNS SETOF pnl_line AS
$$
SELECT a.id, a.accno, a.description, a.category,
ah.id, ah.accno, ah.description,
- CASE WHEN a.category = 'E' THEN -1 ELSE 1 END * sum(ac.amount)
+ CASE WHEN a.category = 'E' THEN -1 ELSE 1 END * sum(ac.amount), at.path
FROM account a
JOIN account_heading ah on a.heading = ah.id
JOIN acc_trans ac ON a.id = ac.chart_id
+ JOIN account_heading_tree at ON a.heading = at.id
WHERE ac.approved is true and ac.trans_id = $1
GROUP BY a.id, a.accno, a.description, a.category,
- ah.id, ah.accno, ah.description
+ ah.id, ah.accno, ah.description, at.path
ORDER BY a.category DESC, a.accno ASC;
$$ LANGUAGE sql;
@@ -85,17 +203,18 @@
)
SELECT a.id, a.accno, a.description, a.category,
ah.id, ah.accno, ah.description,
- CASE WHEN a.category = 'E' THEN -1 ELSE 1 END * sum(ac.amount)
+ CASE WHEN a.category = 'E' THEN -1 ELSE 1 END * sum(ac.amount), at.path
FROM account a
JOIN account_heading ah on a.heading = ah.id
JOIN acc_trans ac ON a.id = ac.chart_id
+ JOIN account_heading_tree at ON a.heading = at.id
JOIN gl ON ac.trans_id = gl.id
WHERE ac.approved is true
AND ($2 IS NULL OR ac.transdate >= $2)
AND ($3 IS NULL OR ac.transdate <= $3)
AND a.category IN ('I', 'E')
GROUP BY a.id, a.accno, a.description, a.category,
- ah.id, ah.accno, ah.description
+ ah.id, ah.accno, ah.description, at.path
ORDER BY a.category DESC, a.accno ASC;
$$ LANGUAGE SQL;
@@ -103,14 +222,17 @@
$$
SELECT a.id, a.accno, a.description, a.category,
ah.id, ah.accno, ah.description,
- CASE WHEN a.category = 'E' THEN -1 ELSE 1 END * sum(ac.amount)
+ CASE WHEN a.category = 'E' THEN -1 ELSE 1 END * sum(ac.amount), at.path
FROM account a
JOIN account_heading ah on a.heading = ah.id
JOIN acc_trans ac ON a.id = ac.chart_id
+ JOIN account_heading_tree at ON a.heading = at.id
WHERE ac.approved AND ac.trans_id = $1 AND a.category IN ('I', 'E')
GROUP BY a.id, a.accno, a.description, a.category,
- ah.id, ah.accno, ah.description
+ ah.id, ah.accno, ah.description, at.path
ORDER BY a.category DESC, a.accno ASC;
$$ LANGUAGE SQL;
+update defaults set value = 'yes' where setting_key = 'module_load_ok';
+
COMMIT;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits