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

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



Revision: 4882
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4882&view=rev
Author:   einhverfr
Date:     2012-06-10 10:09:41 +0000 (Sun, 10 Jun 2012)
Log Message:
-----------
Moving batch details to new framework

Modified Paths:
--------------
    trunk/LedgerSMB/Scripts/vouchers.pm
    trunk/sql/modules/Voucher.sql

Added Paths:
-----------
    trunk/LedgerSMB/DBObject/Report/Unapproved/Batch_Detail.pm

Removed Paths:
-------------
    trunk/UI/batch/filter.html
    trunk/UI/batch/search_transactions.html

Added: trunk/LedgerSMB/DBObject/Report/Unapproved/Batch_Detail.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Report/Unapproved/Batch_Detail.pm	                        (rev 0)
+++ trunk/LedgerSMB/DBObject/Report/Unapproved/Batch_Detail.pm	2012-06-10 10:09:41 UTC (rev 4882)
@@ -0,0 +1,221 @@
+=head1 NAME
+
+LedgerSMB::DBObject::Report::Unapproved::Batch_Detail - List Vouchers by Batch 
+in LedgerSMB
+
+=head1 SYNPOSIS
+
+  my $report = LedgerSMB::DBObject::Report::Unapproved::Batch_Detail->new(
+      %$request
+  );
+  $report->run;
+  $report->render($request, $format);
+
+=head1 DESCRIPTION
+
+This provides an ability to search for (and approve or delete) pending
+transactions grouped in batches.  This report only handles the vouchers in the 
+bach themselves. For searching for batches, use
+LedgerSMB::DBObject::Report::Unapproved::Batch_Overview instead.
+
+=head1 INHERITS
+
+=over
+
+=item LedgerSMB::DBObject::Report;
+
+=back
+
+=cut
+
+package LedgerSMB::DBObject::Report::Unapproved::Batch_Detail;
+use Moose;
+extends 'LedgerSMB::DBObject::Report';
+
+use LedgerSMB::DBObject::Business_Unit_Class;
+use LedgerSMB::DBObject::Business_Unit;
+use LedgerSMB::App_State;
+
+my $locale = $LedgerSMB::App_State::Locale;
+
+=head1 PROPERTIES
+
+=over
+
+=item columns
+
+Read-only accessor, returns a list of columns.
+
+=over
+
+=item select
+
+Select boxes for selecting the returned items.
+
+=item id
+
+ID of transaction
+
+=item batch_class
+
+Text description of batch class
+
+=item transdate
+
+Post date of transaction
+use LedgerSMB::DBObject::Report::Unapproved::Batch_Overview;
+
+=item reference text
+
+Invoice number or GL reference
+
+=item description
+
+Description of transaction
+
+=item amount
+
+Total on voucher.  For AR/AP amount, this is the total of the AR/AP account 
+before payments.  For payments, receipts, and GL, it is the sum of the credits.
+
+=back
+
+=cut
+
+our @COLUMNS = (
+    {col_id => 'select',
+       name => '',
+       type => 'checkbox' },
+
+    {col_id => 'id',
+       name => $locale->text('ID'),
+       type => 'text',
+     pwidth => 1, },
+
+    {col_id => 'batch_class',
+       name => $locale->text('Batch Class'),
+       type => 'text', 
+     pwidth => 2, },
+
+    {col_id => 'default_date',
+       name => $locale->text('Date'),
+       type => 'text',
+     pwidth => '4', },
+
+    {col_id => 'Reference',
+       name => $locale->text('Reference'),
+       type => 'href',
+  href_base => '',
+     pwidth => '3', },
+
+    {col_id => 'description',
+       name => $locale->text('Description'),
+       type => 'text',
+     pwidth => '6', },
+
+    {col_id => 'amount',
+       name => $locale->text('Amount'),
+       type => 'text',
+     pwidth => '2', },
+
+);
+
+sub columns {
+    return ..hidden..;
+}
+
+    # TODO:  business_units int[]
+
+=item name
+
+Returns the localized template name
+
+=cut
+
+sub name {
+    return $locale->text('Voucher List');
+}
+
+=item header_lines
+
+Returns the inputs to display on header.
+
+=cut
+
+sub header_lines {
+    return [{name => 'batch_id',
+             text => $locale->text('Batch ID')}, ]
+}
+
+=item subtotal_cols
+
+Returns list of columns for subtotals
+
+=cut
+
+sub subtotal_cols {
+    return [];
+}
+
+=head2 Criteria Properties
+
+Note that in all cases, undef matches everything.
+
+=item batch_id (Int)
+
+ID of batch to list vouchers of.
+
+=cut
+
+has 'batch_id' => (is => 'rw', isa => 'Int');
+
+=head1 METHODS
+
+=over
+
+=item run_report()
+
+Runs the report, and assigns rows to $self->rows.
+
+=cut
+
+sub run_report{
+    my ($self) = @_;
+    $self->buttons([{
+                    name  => 'action',
+                    type  => 'submit',
+                    text  => $locale->text('Post Batch'),
+                    value => 'batch_approve',
+                    class => 'submit',
+                 },{
+                    name  => 'action',
+                    type  => 'submit',
+                    text  => $locale->text('Delete Batch'),
+                    value => 'batch_delete',
+                    class => 'submit',
+                 },{
+                    name  => 'action',
+                    type  => 'submit',
+                    text  => $locale->text('Delete Vouchers'),
+                    value => 'vouchers_delete',
+                    class => 'submit',
+                }]);
+    my @rows = $self->exec_method({funcname => 'batch__search'});
+    for my $r (@rows){
+       # TODO hrefs
+       $r->{row_id} = $r->{id};
+    }
+    $self->rows(..hidden..);
+}
+
+
+=head1 COPYRIGHT
+
+COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used following
+the terms of the GNU General Public License version 2 or at your option any
+later version.  Please see included LICENSE.TXT for details.
+
+=cut
+
+__PACKAGE__->meta->make_immutable;
+return 1;

Modified: trunk/LedgerSMB/Scripts/vouchers.pm
===================================================================
--- trunk/LedgerSMB/Scripts/vouchers.pm	2012-06-10 09:34:55 UTC (rev 4881)
+++ trunk/LedgerSMB/Scripts/vouchers.pm	2012-06-10 10:09:41 UTC (rev 4882)
@@ -241,120 +241,11 @@
 
 sub get_batch {
     my ($request)  = @_;
-    $request->{action} = 'get_batch';
-    my $callback = "vouchers.pl?action=get_batch&batch_id=$request->{batch_id}";
-    $callback = $request->escape(string => $callback);
-    my $batch = LedgerSMB::Batch->new(base => $request);
-    $batch->close_form;
-    $batch->open_form;
-    $batch->{dbh}->commit;
-    $batch->{script} = 'vouchers.pl';
-    my $rows = [];
-
-    $batch->{id} ||= $batch->{batch_id};
-    # $batch->get;
-    my @vouchers = $batch->list_vouchers;
-    my $edit_base= "batch_id=$batch->{batch_id}&action=edit&callback=$callback";
-
-    my $base_href = "vouchers.pl?action=get_batch&batch_id=$batch->{batch_id}";
-
-    my @columns = qw(selected id description batch_class reference amount date);
-    my $column_names = {
-        selected => 'Selected',
-        id => 'ID',
-        description => 'Description',
-        batch_class => 'Class',
-        amount => 'Amount',
-        reference => 'Source/Reference',
-        date => 'Date'
-    };
-    my $sort_href = "$base_href&order_by";
-    my @sort_columns = qw(id description batch_class reference amount date);
-
-    my $classcount;
-    my $count = 1;
-    for my $row (@vouchers) {
-       $classcount = ($classcount + 1) % 2;
-       $classcount ||= 0;
-       my $escript = undef;
-       if ($row->{batch_class} eq 'Receivable'){
-           $escript = 'ar.pl';
-       } elsif ($row->{batch_class} eq 'Payable'){
-           $escript = 'ap.pl';
-       } elsif ($row->{batch_class} eq 'GL'){
-           $escript = 'gl.pl';
-       } 
-       if (defined $escript){
-           $row->{reference} = { 
-                     text => $row->{reference},
-                     href => "$escript?id=$row->{transaction_id}&"
-                             . $edit_base
-                     };
-       }
-       push @$rows, {
-           description => $row->{description},
-           id          => $row->{id},
-           batch_class => $row->{batch_class},
-           amount      => $batch->format_amount(amount => $row->{amount}),
-           date        => $row->{transaction_date},
-           reference   => $row->{reference},
-           i           => "$classcount",
-           selected    => {
-                           input => {
-                                  type  => 'checkbox',
-                                  name  => "voucher_$row->{id}",
-                                  value => "1"
-                                  }
-                          }  
-       };
-       $batch->{"row_$count"} = $row->{id};
-       ++$count;
-    }
-
-    $batch->{rowcount} = $count;
-
-    $batch->{title} = "Batch ID: $batch->{batch_id}";
-    my $template = LedgerSMB::Template->new(
-        user     => $request->{_user},
-        locale   => $request->{_locale},
-        path     => 'UI',
-        template => 'form-dynatable',
-        format   => ($batch->{format}) ? $batch->{format} : 'HTML', 
-    );
-    my $hiddens = $batch->take_top_level();
-    
-    my $column_heading = $template->column_heading($column_names,
-        {href => $sort_href, columns => ..hidden..
-    );
-    
-    $template->render({ 
-	form    => $batch,
-	columns => ..hidden..,
-	heading => $column_heading,
-        rows    => $rows,
-        hiddens => $hiddens,
-        buttons => [{
-                    name  => 'action',
-                    type  => 'submit',
-                    text  => $request->{_locale}->text('Post Batch'),
-                    value => 'batch_approve',
-                    class => 'submit',
-		},{
-                    name  => 'action',
-                    type  => 'submit',
-                    text  => $request->{_locale}->text('Delete Batch'),
-                    value => 'batch_delete',
-                    class => 'submit',
-		},{
-                    name  => 'action',
-                    type  => 'submit',
-                    text  => $request->{_locale}->text('Delete Vouchers'),
-                    value => 'voucher_delete',
-                    class => 'submit',
-               }]
-    });
-        
-    
+    use LedgerSMB::DBObject::Report::Unapproved::Batch_Detail;
+    my $report = LedgerSMB::DBObject::Report::Unapproved::Batch_Detail->new(
+                 %$request);
+    $report->run_report;
+    $report->render($request);
 }
 
 # alias for batch_delete, needed for form-dynatable

Deleted: trunk/UI/batch/filter.html
===================================================================
--- trunk/UI/batch/filter.html	2012-06-10 09:34:55 UTC (rev 4881)
+++ trunk/UI/batch/filter.html	2012-06-10 10:09:41 UTC (rev 4882)
@@ -1,94 +0,0 @@
-<?lsmb INCLUDE "ui-header.html"
-        stylesheet = stylesheet
-	titlebar = text('Batch Selection') # '
-?><?lsmb PROCESS "elements.html" ?>
-<body>
-<form action="vouchers.pl" method="post">
-<div class="listtop" id="title_div"><?lsmb text('Batch Selection') ?></div>
-<div class="input" id="batch_class_div">
-	<?lsmb INCLUDE select element_data = {
-		label = text('Batch Type') # '
-		options = batch_classes
-		value_attr = "id"
-		text_attr = "class"
-		name = "class_id"
-		default_values = [class_id]
-	} ?>
-	<?lsmb INCLUDE input element_data = {
-		label = text("Approved")
-		name = "approved"
-		value = '1'
-                type = "checkbox"
-	} ?>
-	<?lsmb INCLUDE input element_data = {
-		label = text("Empty")
-		name = "empty"
-		value = '1'
-                type = "checkbox"
-	} ?>
-</div>
-<div class="input" id="entered_by_div">
-	<?lsmb INCLUDE select element_data = {
-		label = text('Created By') # '
-		options = batch_users
-		value_attr = "entity_id"
-		text_attr = "username"
-		name = "created_by_eid"
-		default_values = [created_by]
-	} ?></div>
-<div class="input" id="description_div">
-	<?lsmb INCLUDE input element_data = {
-		label = text('Description')
-		size = 20
-		value = description
-		name = "description"
-	} ?>
-	</div>
-<div class="input" id="amounts_div">
-	<?lsmb INCLUDE input element_data = {
-		label = "Minimum Value"
-		name = "amount_gt"
-		class = "numeric"
-		size = 20
-		value = amount_gt
-		type = "text"
-	} ?>
-	<?lsmb INCLUDE input element_data = {
-		label = "Maximum Value"
-		name = "amount_lt"
-		value = amount_lt
-		size = 20
-		class = "numeric"
-		type = "text"
-	} ?>
-	</div>
-<div class="input" id="date_row">
-	<?lsmb INCLUDE input element_data  = {
-		label = "Minimum Date"
-		name = "date_from"
-		value = date_from
-		size = 20
-		class = "date"
-		type  = "text"
-	} ?>
-	<?lsmb INCLUDE input element_data  = {
-		label = "Maximum Date"
-		name = "date_to"
-		value = date_to
-		size = 20
-		class = "date"
-		type  = "text"
-	} ?>
-</div>
-<div class="input" id="buttons_div">
-	<?lsmb INCLUDE button element_data = {
-		text = text('Search')
-		name = "action"
-		value = "list_batches"
-		class = "submit"
-		type = "submit"
-	} ?> </div>
-</form>
-</body>
-
-</html>

Deleted: trunk/UI/batch/search_transactions.html
===================================================================
--- trunk/UI/batch/search_transactions.html	2012-06-10 09:34:55 UTC (rev 4881)
+++ trunk/UI/batch/search_transactions.html	2012-06-10 10:09:41 UTC (rev 4882)
@@ -1,70 +0,0 @@
-<?lsmb INCLUDE "ui-header.html"
-        stylesheet = stylesheet
-	include_stylesheet = [
-		"css/global.css"
-	]
-	titlebar = text('Batch Selection') # '
-?><?lsmb PROCESS "elements.html" ?>
-<body>
-<form action="drafts.pl" method="post">
-<div class="listtop" id="title_div"><?lsmb text('Search Unapproved Transactions') ?></div>
-<div class="input" id="batch_class_div">
-	<?lsmb INCLUDE select element_data = {
-		label = text('Transaction Type') # '
-		options = class_types
-		value_attr = "value"
-		text_attr = "text"
-		name = "type"
-		default_values = [class_id]
-	} ?>
-</div>
-<!-- 
-Commenting this section out.  Does not seem to be used by API. -CT
-
-<div class="input" id="entered_by_div">
-	<?lsmb INCLUDE select element_data = {
-		label = text('Created By') # '
-		options = users
-		value_attr = "entity_id"
-		text_attr = "username"
-		name = "created_by_eid"
-		default_values = [created_by]
-	} ?></div> -->
-<div class="input" id="reference_div">
-	<?lsmb INCLUDE input element_data = {
-		label = text('Reference/Invoice Number') #'
-		size = 20
-		value = reference
-		name = "reference"
-	} ?>
-	</div>
-<div class="input" id="amounts_div">
-	<?lsmb INCLUDE input element_data = {
-		label = "Minimum Value"
-		name = "amount_gt"
-		class = "numeric"
-		size = 20
-		value = amount_gt
-		type = "text"
-	} ?>
-	<?lsmb INCLUDE input element_data = {
-		label = "Maximum Value"
-		name = "amount_lt"
-		value = amount_lt
-		size = 20
-		class = "numeric"
-		type = "text"
-	} ?>
-	</div>
-<div class="input" id="buttons_div">
-	<?lsmb INCLUDE button element_data = {
-		text = text('Search')
-		name = "action"
-		value = "list_drafts"
-		class = "submit"
-		type = "submit"
-	} ?> </div>
-</form>
-</body>
-
-</html>

Modified: trunk/sql/modules/Voucher.sql
===================================================================
--- trunk/sql/modules/Voucher.sql	2012-06-10 09:34:55 UTC (rev 4881)
+++ trunk/sql/modules/Voucher.sql	2012-06-10 10:09:41 UTC (rev 4882)
@@ -26,7 +26,7 @@
 
 -- voucher_list could use refactoring
 
-CREATE OR REPLACE FUNCTION voucher_list (in_batch_id integer)
+CREATE OR REPLACE FUNCTION voucher__list (in_batch_id integer)
 RETURNS SETOF voucher_list AS
 $$
 declare voucher_item record;

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