[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[5037] trunk



Revision: 5037
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5037&view=rev
Author:   einhverfr
Date:     2012-07-25 06:35:33 +0000 (Wed, 25 Jul 2012)
Log Message:
-----------
Adding missing inventory_adj.html
Trial balance now largely works on 1.4 framework. Still need to add account headings though

Modified Paths:
--------------
    trunk/LedgerSMB/GL.pm
    trunk/LedgerSMB/Report/Trial_Balance.pm
    trunk/LedgerSMB/Report.pm
    trunk/LedgerSMB/Scripts/trial_balance.pm
    trunk/sql/modules/Report.sql
    trunk/sql/modules/trial_balance.sql

Added Paths:
-----------
    trunk/LedgerSMB/Report/Dates.pm
    trunk/LedgerSMB/Report/Trial_Balance/
    trunk/LedgerSMB/Report/Trial_Balance/List.pm
    trunk/UI/Reports/filters/inventory_adj.html

Modified: trunk/LedgerSMB/GL.pm
===================================================================
--- trunk/LedgerSMB/GL.pm	2012-07-24 09:01:09 UTC (rev 5036)
+++ trunk/LedgerSMB/GL.pm	2012-07-25 06:35:33 UTC (rev 5037)
@@ -57,7 +57,6 @@
 sub get_files {
      my ($self, $form, $locale) = @_;
      my $file = LedgerSMB::File->new();
-     $file->new_dbobject({base => $form, locale => $locale});
      @{$form->{files}} = $file->list({ref_key => $form->{id}, file_class => 1});
      @{$form->{file_links}} = $file->list_links(
                   {ref_key => $form->{id}, file_class => 1}

Added: trunk/LedgerSMB/Report/Dates.pm
===================================================================
--- trunk/LedgerSMB/Report/Dates.pm	                        (rev 0)
+++ trunk/LedgerSMB/Report/Dates.pm	2012-07-25 06:35:33 UTC (rev 5037)
@@ -0,0 +1,42 @@
+=head1 NAME
+
+LedgerSMB::Report::Dates - Date properties for reports in LedgerSMB
+
+=head1 SYNOPSIS
+
+ with 'LedgerSMB::Report::Dates'
+
+=cut
+
+package LedgerSMB::Report::Dates;
+use Moose::Role;
+use LedgerSMB::MooseTypes;
+
+=head1 DESCRIPTION
+
+This handles standard date controls in reports.  It just adds properties to 
+relevant Moose objects.
+
+=head1 PROPERTIES ADDED
+
+=over
+
+=item from_date
+
+=cut 
+
+has from_date => (is => 'ro', isa => 'LedgerSMB::Moose::Date', coerce => 1);
+
+=item to_date
+
+=cut 
+
+has to_date => (is => 'ro', isa => 'LedgerSMB::Moose::Date', coerce => 1);
+
+=item ...
+
+=head1 COPYRIGHT
+
+=cut
+
+1;

Added: trunk/LedgerSMB/Report/Trial_Balance/List.pm
===================================================================
--- trunk/LedgerSMB/Report/Trial_Balance/List.pm	                        (rev 0)
+++ trunk/LedgerSMB/Report/Trial_Balance/List.pm	2012-07-25 06:35:33 UTC (rev 5037)
@@ -0,0 +1,103 @@
+=head1 NAME
+
+LedgerSMB::Report::Trial_Balance::List - List saved trial balances in LedgerSMB
+
+=head1 SYNPOPSIS
+
+ my $tblist = LedgerSMB::Report::Trial_Balance::List->new(%$request);
+ $tblist->render($request);
+
+=cut
+
+package LedgerSMB::Report::Trial_Balance::List;
+use Moose;
+extends 'LedgerSMB::Report';
+
+use LedgerSMB::App_State;
+my $locale = $LedgerSMB::App_State::Locale;
+
+=head1 DESCRIPTION
+
+This module lists trial balances for LedgerSMB.
+
+=head1 CRITERIA PROPERTIES
+
+None used
+
+=head1 REPORT-RELATED CONSTANT FUNCTIONS
+
+=over
+
+=item name
+
+=cut
+
+sub name { return $locale->text('Trial Balance List') }
+
+=item header_lines
+
+=cut
+
+sub header_lines { return [] };
+
+=item columns
+
+=cut
+
+sub columns {
+    return [{ col_id => 'description',
+                type => 'href',
+           href_base => 'trial_balance.pl?action=get&id=',
+                name => $locale->text('Description') },
+            { col_id => 'date_from',
+                type => 'text',
+                name => $locale->text('Start Date') },
+            { col_id => 'date_to',
+                type => 'text',
+                name => $locale->text('End Date') },
+            { col_id => 'yearend',
+                type => 'text',
+                name => $locale->text('Ignore Yearends') },
+           ];
+}
+
+=back
+
+=head1 METHODS
+
+=over
+
+=item run_report
+
+=cut
+
+sub run_report {
+    my ($self) = (@_);
+    my @rows = $self->exec_method({funcname => 'trial_balance__list'});
+    $_->{row_id} = $_->{id} for @rows;
+    $self->rows(..hidden..);
+}
+
+=over
+
+=head1 SEE ALSO
+
+=over
+
+=item LedgerSMB::DBObject
+
+=item LedgerSMB::DBObject_Moose
+
+=item LedgerSMB::MooseTypes
+
+=item LedgerSMB::Report
+
+=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: trunk/LedgerSMB/Report/Trial_Balance.pm
===================================================================
--- trunk/LedgerSMB/Report/Trial_Balance.pm	2012-07-24 09:01:09 UTC (rev 5036)
+++ trunk/LedgerSMB/Report/Trial_Balance.pm	2012-07-25 06:35:33 UTC (rev 5037)
@@ -25,6 +25,7 @@
 package LedgerSMB::Report::Trial_Balance;
 use Moose;
 use LedgerSMB::App_State;
+with 'LedgerSMB::Report::Dates';
 extends 'LedgerSMB::Report';
 
 my $locale = $LedgerSMB::App_State::Locale;
@@ -67,13 +68,13 @@
 has date_from => (is => 'rw', coerce => 1, isa => 'LedgerSMB::Moose::Date');
 has date_to => (is => 'rw', coerce => 1, isa => 'LedgerSMB::Moose::Date');
 
-=item desc
+=item description
 
 Only used for saved criteria sets, is a human-readable description.
 
 =cut
 
-has desc => (is => 'rw', isa => 'Maybe[Str]');
+has description => (is => 'rw', isa => 'Str', required => 0);
 
 =item yearend
 
@@ -82,7 +83,7 @@
 
 =cut
 
-has yearend => (is => 'rw', isa => 'Str');
+has ignore_yearend => (is => 'rw', isa => 'Str');
 
 
 =item heading
@@ -91,7 +92,7 @@
 
 =cut
 
-has heading => (is => 'rw', isa => 'Maybe[Int]')l
+has heading => (is => 'rw', isa => 'Maybe[Int]');
 
 =item accounts
 
@@ -161,7 +162,7 @@
 =cut
 
 sub header_lines {
-    return [{name => 'date_from'
+    return [{name => 'date_from',
              text => $locale->text('From date') },
             {name => 'date_to',
              text => $locale->text('To Date') },
@@ -183,8 +184,8 @@
 =cut
 
 sub get {
-    my ($self) = @_;
-    my $ref = __PACKAGE__->call_procedure(procname => 'trial_balance__get', 
+    my ($self, $id) = @_;
+    my ($ref) = __PACKAGE__->call_procedure(procname => 'trial_balance__get', 
                                               args => [$id]);
     return __PACKAGE__->new(%$ref);
 }
@@ -198,7 +199,7 @@
 sub save {
     my ($self) = @_;
     my ($ref) = $self->exec_method({funcname => 'trial_balance__save'});
-    $self->id(shift (values @$ref));
+    $self->id(values %$ref);
 }
 
 =item run_report
@@ -209,7 +210,7 @@
 
 sub run_report {
     my ($self) = @_;
-    my @rows = $self->exec_method({funcname => 'report__gl'});
+    my @rows = $self->exec_method({funcname => 'trial_balance__generate'});
     my $total_debits;
     my $total_credits;
     for my $ref(@rows){
@@ -223,7 +224,7 @@
         $ref->{gifi_accno_href_suffix} = $href_suffix;
         
     }
-    push @rows {class => 'total', 
+    push @rows, {class => 'total', 
                debits => $total_debits,
               credits => $total_credits, };
 

Modified: trunk/LedgerSMB/Report.pm
===================================================================
--- trunk/LedgerSMB/Report.pm	2012-07-24 09:01:09 UTC (rev 5036)
+++ trunk/LedgerSMB/Report.pm	2012-07-25 06:35:33 UTC (rev 5037)
@@ -164,6 +164,8 @@
     my ($self, $request) = @_;
     my $template;
 
+    my $testref = $self->rows;
+    $self->run_report if !defined $testref;
     # This is a hook for other modules to use to override the default
     # template --CT
     eval {$template = $self->template};

Modified: trunk/LedgerSMB/Scripts/trial_balance.pm
===================================================================
--- trunk/LedgerSMB/Scripts/trial_balance.pm	2012-07-24 09:01:09 UTC (rev 5036)
+++ trunk/LedgerSMB/Scripts/trial_balance.pm	2012-07-25 06:35:33 UTC (rev 5037)
@@ -46,7 +46,7 @@
 
 sub get {
     my ($request) = @_;
-    $request->merge(LedgerSMB::Report::Trial_Balance->get($request->{id});
+    $request->merge(LedgerSMB::Report::Trial_Balance->get($request->{id}));
     run($request);
 }
 
@@ -71,7 +71,9 @@
 
 sub list {
     my ($request) = @_;
-    ...
+    use LedgerSMB::Report::Trial_Balance::List;
+    my $rpt = LedgerSMB::Report::Trial_Balance::List->new(%$request);
+    $rpt->render($request);
 }
 
 =item run
@@ -82,7 +84,7 @@
 
 sub run {
     my ($request) = @_;
-    my LedgerSMB::Report::Trial_Balance->new(%$request);
+    my $tb = LedgerSMB::Report::Trial_Balance->new(%$request);
     $tb->run_report;
     $tb->render($request);
 }

Added: trunk/UI/Reports/filters/inventory_adj.html
===================================================================
--- trunk/UI/Reports/filters/inventory_adj.html	                        (rev 0)
+++ trunk/UI/Reports/filters/inventory_adj.html	2012-07-25 06:35:33 UTC (rev 5037)
@@ -0,0 +1,38 @@
+<?lsmb 
+INCLUDE 'ui-header.html';
+PROCESS 'elements.html';
+PROCESS 'report_base.html'; ?>
+<form action="inv_reports.pl" method="get">
+<div class="input_row">
+<div class="input_group">
+<?lsmb PROCESS input element_data = {
+        label = text('Source')
+         name = 'source'
+         type = 'text'
+         size = '20'
+        value = source
+        class = 'control_code'
+} ?>
+</div>
+<?lsmb PROCESS input element_data = {
+        label = text('Includes Part') #'
+         name = 'partnumber'
+         type = 'text'
+         size = '20'
+        value = partnumber
+        class = 'control_code'
+} ?>
+</div>
+</div>
+<?lsmb PROCESS date_row_div ?>
+<div class="input_row">
+<?lsmb PROCESS button element_data = {
+       name = "action"
+      value = "search_adj"
+       type = "submit"
+       text = text('Run Report') #'
+}; ?>
+</div>
+</form>
+</body>
+</html>

Modified: trunk/sql/modules/Report.sql
===================================================================
--- trunk/sql/modules/Report.sql	2012-07-24 09:01:09 UTC (rev 5036)
+++ trunk/sql/modules/Report.sql	2012-07-25 06:35:33 UTC (rev 5037)
@@ -242,9 +242,9 @@
                    OR in_source is null)
               AND (ac.memo ilike '%' || in_memo || '%' OR in_memo is null)
              AND (in_description IS NULL OR
-                  to_tsvector(get_default_lang()::name, g.description)
+                  g.description
                   @@
-                  plainto_tsquery(get_default_lang()::name, in_description))
+                  plainto_tsquery(get_default_lang()::regconfig, in_description))
               AND (transdate BETWEEN in_from_date AND in_to_date
                    OR (transdate >= in_from_date AND  in_to_date IS NULL)
                    OR (transdate <= in_to_date AND in_from_date IS NULL)

Modified: trunk/sql/modules/trial_balance.sql
===================================================================
--- trunk/sql/modules/trial_balance.sql	2012-07-24 09:01:09 UTC (rev 5036)
+++ trunk/sql/modules/trial_balance.sql	2012-07-25 06:35:33 UTC (rev 5037)
@@ -1,3 +1,5 @@
+BEGIN;
+
 CREATE OR REPLACE FUNCTION unnest(anyarray)
   RETURNS SETOF anyelement AS
 $BODY$
@@ -7,7 +9,7 @@
 $BODY$
   LANGUAGE 'sql' IMMUTABLE;
 
-
+DROP TYPE IF EXISTS tb_row CASCADE;
 create type tb_row AS (
    account_id int,
    account_number text,
@@ -22,7 +24,7 @@
 
 CREATE OR REPLACE FUNCTION trial_balance__generate 
 (in_date_from DATE, in_date_to DATE, in_heading INT, in_accounts INT[],
- in_ignore_yearend TEXT, in_department INT, in_business_units int[]) 
+ in_ignore_yearend TEXT, in_business_units int[]) 
 returns setof tb_row AS
 $$
 DECLARE
@@ -59,7 +61,9 @@
     END IF;
 
     IF t_roll_forward IS NULL THEN
-       SELECT min(transdate) INTO t_roll_forward FROM acc_trans;
+       SELECT min(transdate) - '1 day'::interval 
+         INTO t_roll_forward 
+         FROM acc_trans;
     END IF;
 
     IF in_ignore_yearend = 'last' THEN
@@ -84,9 +88,6 @@
             SELECT id, id::text AS path
               FROM business_unit
              WHERE parent_id = any(in_business_units)
-                   OR (parent_id = IS NULL 
-                       AND (in_business_units = '{}' 
-                             OR in_business_units IS NULL))
             UNION
             SELECT bu.id, bu_tree.path || ',' || bu.id
               FROM business_unit bu
@@ -94,19 +95,17 @@
             )
        SELECT ac.transdate, ac.amount, ac.chart_id
          FROM acc_trans ac
-         JOIN (SELECT id, approved, department_id FROM ar UNION ALL
-               SELECT id, approved, department_id FROM ap UNION ALL
-               SELECT id, approved, department_id FROM gl) gl
+         JOIN (SELECT id, approved FROM ar UNION ALL
+               SELECT id, approved FROM ap UNION ALL
+               SELECT id, approved FROM gl) gl
                    ON ac.approved and gl.approved and ac.trans_id = gl.id
     LEFT JOIN business_unit_ac buac ON ac.entry_id = buac.entry_id
     LEFT JOIN bu_tree ON buac.bu_id = bu_tree.id
         WHERE ac.transdate BETWEEN t_roll_forward + '1 day'::interval 
                                     AND t_end_date
-              AND ac.trans_id <> ALL(ignore_trans)
-              AND (in_department is null 
-                 or gl.department_id = in_department)
-              ((in_business_units = '{}' OR in_business_units IS NULL)
-                OR bu_tree.id IS NOT NULL)
+              AND (ignore_trans is null or ac.trans_id <> ALL(ignore_trans))
+              AND ((in_business_units = '{}' OR in_business_units IS NULL)
+               OR bu_tree.id IS NOT NULL)
        )
        SELECT a.id, a.accno, a.description, a.gifi_accno,
          case when in_date_from is null then 0 else
@@ -164,8 +163,8 @@
     in_id int,
     in_date_from date,
     in_date_to date,
-    in_desc text,
-    in_yearend text,
+    in_description text,
+    in_ignore_yearend text,
     in_heading int,
     in_accounts int[]
 ) RETURNS int AS $body$
@@ -185,8 +184,8 @@
             UPDATE trial_balance
                SET date_from   = in_date_from,
                    date_to     = in_date_to,
-                   description = in_desc,
-                   yearend     = in_yearend
+                   description = in_description,
+                   ignore_yearend     = in_ignore_yearend
              WHERE id = in_id;
             
             SELECT heading_id 
@@ -234,7 +233,8 @@
             -- We can just create a new one whole cloth. Woo!
             new_report_id := nextval('trial_balance_id_seq');
             INSERT INTO trial_balance (id, date_from, date_to, description, yearend)
-                 VALUES (new_report_id, in_date_from, in_date_to, in_desc, in_yearend);
+                 VALUES (new_report_id, in_date_from, in_date_to, 
+                        in_description, in_ignore_yearend);
             
             IF in_heading IS NOT NULL THEN
                 INSERT INTO trial_balance__heading_to_report (report_id, heading_id)
@@ -285,6 +285,7 @@
     SELECT * FROM trial_balance ORDER BY id ASC;
 $body$ LANGUAGE SQL STABLE;
 
+DROP TYPE IF EXISTS trial_balance__heading CASCADE;
 CREATE TYPE trial_balance__heading AS (
     id int,
     accno text,
@@ -321,3 +322,5 @@
         RETURN FALSE;
     END;
 $body$ LANGUAGE PLPGSQL;
+
+COMMIT;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.