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

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



Revision: 3594
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3594&view=rev
Author:   einhverfr
Date:     2011-07-29 22:12:16 +0000 (Fri, 29 Jul 2011)

Log Message:
-----------
docstrings for batch/vouchers
also removed one unused function from Voucher.sql
Adding accidently omitted fixed asset user interface temlates.

Modified Paths:
--------------
    trunk/LedgerSMB/Batch.pm
    trunk/scripts/vouchers.pl
    trunk/sql/modules/Voucher.sql
    trunk/t/98-pod-coverage.t

Added Paths:
-----------
    trunk/UI/asset/
    trunk/UI/asset/asset.css
    trunk/UI/asset/asset.js
    trunk/UI/asset/begin_approval.html
    trunk/UI/asset/begin_depreciation_all.html
    trunk/UI/asset/begin_report.html
    trunk/UI/asset/edit_asset.html
    trunk/UI/asset/edit_class.html
    trunk/UI/asset/import_asset.html
    trunk/UI/asset/search_asset.html
    trunk/UI/asset/search_class.html
    trunk/UI/asset/search_reports.html
    trunk/sql/upgrade/3594-drop-batch-update.sql

Removed Paths:
-------------
    trunk/LedgerSMB/Voucher.pm

Modified: trunk/LedgerSMB/Batch.pm
===================================================================
--- trunk/LedgerSMB/Batch.pm	2011-07-29 20:24:29 UTC (rev 3593)
+++ trunk/LedgerSMB/Batch.pm	2011-07-29 22:12:16 UTC (rev 3594)
@@ -1,9 +1,26 @@
+=head1 NAME
+LedgerSMB::Batch
 
+=head1 SYNOPSIS
+Batch/voucher management model for LedgerSMB 1.3
 
+=head1 METHODS
+
+=over
+
+=cut
+
 package LedgerSMB::Batch;
 use LedgerSMB::Setting;
 use base qw(LedgerSMB::DBObject);
 
+=item get_new_info
+
+This gets the information required for the new batch screen.  Currently this
+just populates the batch_number hashref value.
+
+=cut
+
 sub get_new_info {
     $self = shift @_;
     my $cc_object = LedgerSMB::Setting->new({base => $self});
@@ -12,6 +29,12 @@
     $self->{dbh}->commit;
 }
 
+=item create
+
+Saves the batch info and populates the id hashref value with the id inserted.
+
+=cut
+
 sub create {
     $self = shift @_;
     my ($ref) = $self->exec_method(funcname => 'batch_create');
@@ -20,13 +43,33 @@
     return $ref->{id};
 }
 
+=item delete_voucher($id)
+
+Deletes the voucher specified by $id. 
+
+=cut
+
 sub delete_voucher {
     my ($self, $voucher_id) = @_;
     $self->call_procedure(procname => 'voucher__delete', args => [$voucher_id]);
     $self->{dbh}->commit;
 }
 
+=item get_search_criteria
+Sets all hash values needed for the search interface:
 
+=over
+
+=item batch_classes
+List of all batch classes
+
+=item batch_users
+List of all users
+
+=back
+
+=cut
+
 sub get_search_criteria {
     $self = shift @_;
     my ($custom_types) = @_;
@@ -45,6 +88,17 @@
     unshift @{$self->{batch_users}}, {username => $self->{_locale}->text('Any'), id => '0', entity_id => '0'};
 }
 
+=item get_search_method (private)
+
+Determines the appropriate search method, either for empty, mini, or full 
+searches
+
+Returns the appropriate stored proc name.
+
+=cut
+
+# This needs to be refactored.  Input sanitation should be moved to 
+# get_search_results
 sub get_search_method {
 	my ($self, @args) = @_;
 	my $search_proc;
@@ -76,6 +130,12 @@
 	return $search_proc;
 }
 
+=item get_search_results
+
+Returns the appropriate search as detected by get_search_method.
+
+=cut
+
 sub get_search_results {
     my ($self, $args) = @_;
 	my $search_proc = $self->get_search_method($args);
@@ -83,6 +143,12 @@
     return @{$self->{search_results}};
 }
 
+=item get_class_id($type)
+
+Returns the class_id of batch class specified by its label.
+
+=cut
+
 sub get_class_id {
     my ($self, $type) = @_;
     @results = $self->call_procedure(
@@ -93,6 +159,13 @@
     return $result->{batch_get_class_id};
 }
 
+=item post
+
+Posts a batch to the books and makes the vouchers show up in transaction 
+reports, financial statements, and more.
+
+=cut
+
 sub post {
     my ($self) = @_;
     ($self->{post_return_ref}) = $self->exec_method(funcname => 'batch_post');
@@ -100,6 +173,12 @@
     return $self->{post_return_ref};
 }
 
+=item delete
+
+Deletes the unapproved batch and all vouchers under it.
+
+=cut
+
 sub delete {
     my ($self) = @_;
     ($self->{delete_ref}) = $self->exec_method(funcname => 'batch_delete');
@@ -107,12 +186,24 @@
     return $self->{delete_ref};
 }
 
+=item list_vouchers
+Returns a list of all vouchers in the batch and attaches that list to 
+$self->{vouchers}
+
+=cut
+
 sub list_vouchers {
     my ($self) = @_;
     @{$self->{vouchers}} = $self->exec_method(funcname => 'voucher_list');
     return @{$self->{vouchers}};
 }
 
+=item get
+
+Gets the batch and merges information with the current batch object.
+
+=cut
+
 sub get {
     my ($self) = @_;
     my ($ref) = $self->exec_method(funcname => 'voucher_get_batch');
@@ -120,3 +211,13 @@
 }
 
 1;
+
+=back
+
+=head1 Copyright (C) 2009, The LedgerSMB core team.
+
+This file is licensed under the Gnu General Public License version 2, or at your
+option any later version.  A copy of the license should have been included with
+your software.
+
+=cut

Deleted: trunk/LedgerSMB/Voucher.pm
===================================================================
--- trunk/LedgerSMB/Voucher.pm	2011-07-29 20:24:29 UTC (rev 3593)
+++ trunk/LedgerSMB/Voucher.pm	2011-07-29 22:12:16 UTC (rev 3594)
@@ -1,5 +0,0 @@
-
-
-package LedgerSMB::Voucher;
-use base qw(LedgerSMB::DBObject);
-1;

Added: trunk/UI/asset/asset.css
===================================================================
--- trunk/UI/asset/asset.css	                        (rev 0)
+++ trunk/UI/asset/asset.css	2011-07-29 22:12:16 UTC (rev 3594)
@@ -0,0 +1,19 @@
+label { display: block;
+	float: left;
+	width: 170px;	
+	text-align: right;
+}
+
+span.inputgroup { display: block;
+	float: left;
+	width: 40%;
+}
+
+div.inputrow {
+	overflow: auto;
+	width: 100%;
+}
+
+.invisible {
+       display: none;
+}

Added: trunk/UI/asset/asset.js
===================================================================
--- trunk/UI/asset/asset.js	                        (rev 0)
+++ trunk/UI/asset/asset.js	2011-07-29 22:12:16 UTC (rev 3594)
@@ -0,0 +1,48 @@
+function setDefaultAccount(){
+    var asset_dropdown = document.getElementById('asset-account-id');
+    var dep_dropdown = document.getElementById('dep-account-id');
+    var old_class = document.getElementById('last-class-id').value;
+    var class_dropdown = document.getElementById('asset-class');
+    var new_class = class_dropdown.options[class_dropdown.selectedIndex].value;
+    var unit_caption_e = document.getElementById('caption-usablelifegroup');
+    var unit_caption = document.getElementById('unit-label-' + new_class).value;
+
+    if (new_class == ""){
+        new_class = class_dropdown.options[0].value;
+    }
+    if (old_class != ""){
+        unit_caption_e.innerHTML = '(' + unit_caption + ')';
+        document.getElementById('asset-account-default-' + old_class).value 
+        = asset_dropdown.options[asset_dropdown.selectedIndex].value;
+        document.getElementById('dep-account-default-' + old_class).value 
+        = dep_dropdown.options[dep_dropdown.selectedIndex].value;
+    }
+    document.getElementById('last-class-id').value = new_class;
+
+    set_dropdown(asset_dropdown, 
+                 document.getElementById('asset-account-default-' + new_class).value);
+    set_dropdown(dep_dropdown,
+                 document.getElementById('dep-account-default-' + new_class).value);
+
+}
+
+function set_dropdown (selectElement, newValue){
+    for (var i = 0; i < selectElement.options.length; i++) {
+        if (selectElement.options[i].value == newValue) {
+           selectElement.options[i].selected = true;
+        } else {
+           selectElement.options[i].selected = false;
+        }
+    }
+   
+}
+
+function init(){
+    if (document.GetElementById('id').value > 0){
+        return;
+    }
+    document.getElementById('asset-class').addEventListener('blur', Function('setDefaultAccount()'), false);
+    setDefaultAccount();
+    document.getElementById('update-accounts').setAttribute('class', 'generic');
+    document.getElementById('update-accounts').addEventListener('click', 'return false', false);
+}

Added: trunk/UI/asset/begin_approval.html
===================================================================
--- trunk/UI/asset/begin_approval.html	                        (rev 0)
+++ trunk/UI/asset/begin_approval.html	2011-07-29 22:12:16 UTC (rev 3594)
@@ -0,0 +1,84 @@
+<?lsmb INCLUDE "ui-header.html"
+       include_stylesheet = ["UI/asset/asset.css"] -?>
+<?lsmb PROCESS "elements.html" -?>
+<body>
+<form action="asset.pl" method="post">
+<div class="listtop"><?lsmb text('New Asset Report Search') ?></div>
+<div class="inputrow" id="classrow"><div class="inputgroup" id="classgrp">
+<?lsmb asset_classes.unshift({}) ?>
+<?lsmb PROCESS select element_data = {
+     name = "asset_class"
+     default_values = [asset_class]
+     options = asset_classes
+     text_attr = "label"
+     value_attr = "id"
+     label = text('Asset Class') #'
+} ?>
+</div></div>
+<div class="inputrow" id="daterow"><div class="inputgroup" id="startdategrp">
+<?lsmb PROCESS input element_data = {
+     name = "start_date"
+     class = "date"
+     value = start_date
+     label = text("From")
+} ?>
+</div>
+<div class="inputgroup" id="todategroup">
+<?lsmb PROCESS input element_data = {
+     name = "end_date"
+     class = "date"
+     value = end_date
+     label = text("To")
+} ?>
+</div>
+</div>
+<div class="inputrow" id="accountrow">
+<?lsmb IF depreciation ?>
+<!-- moved expense acct drop down to asset screen -->
+<?lsmb ELSE ?>
+<div class="inputgroup" id="gaingroup">
+<?lsmb PROCESS select element_data = {
+     name = "gain_acct"
+     class = "account"
+     value_attr = "id"
+     options = gain_accounts
+     default_values = [gain_acct]
+     label = text('Gain Account') #'
+} ?>
+</div>
+<div class="inputgroup" id="lossgroup">
+<?lsmb PROCESS select element_data = {
+     name = "loss_acct"
+     class = "account"
+     options = loss_accounts
+     value_attr = "id"
+     default_values = [loss_acct]
+     label = text('Loss Account') #'
+} ?>
+</div>
+<?lsmb END ?>
+</div>
+<div class="inputrow" id="buttonrow">
+<div class="inputgroup" id="buttongroupnext">
+<label>&nbsp;</label>
+<?lsmb PROCESS button element_data = {
+     name = "action"
+     text = text("Continue")
+     value = "report_results"
+     type = "submit"
+     class = "submit"
+} ?>
+</div></div>
+<?lsmb PROCESS input element_data = {
+     name = "approved"
+     type = "hidden"
+     value = "0"
+} ?>
+<?lsmb PROCESS input element_data = {
+     name = "depreciation"
+     type = "hidden"
+     value = depreciation
+} ?>
+</form>
+</body>
+</html>

Added: trunk/UI/asset/begin_depreciation_all.html
===================================================================
--- trunk/UI/asset/begin_depreciation_all.html	                        (rev 0)
+++ trunk/UI/asset/begin_depreciation_all.html	2011-07-29 22:12:16 UTC (rev 3594)
@@ -0,0 +1,33 @@
+<?lsmb INCLUDE "ui-header.html"
+       include_stylesheet = ["UI/asset/asset.css"] -?>
+<?lsmb PROCESS "elements.html" -?>
+<body>
+<div class="listtop"><?lsmb text('Depreciate All') ?></div>
+<form action="asset.pl" method="post">
+<div class="inputrow" id="daterow"><div class="inputgroup" id="dategroup">
+<?lsmb PROCESS input element_data = {
+     name = "report_date"
+     class = "date"
+     value = report_date
+     label = text("Date")
+} ?>
+</div></div>
+<?lsmb PROCESS input element_data = {
+     name = "depreciation"
+     type = "hidden"
+     value = 1
+} ?>
+<div class="inputrow" id="buttonrow">
+<div class="inputgroup" id="buttongroupnext">
+<label>&nbsp;</label>
+<?lsmb PROCESS button element_data = {
+     name = "action"
+     text = text("Continue")
+     value = "depreciate_all"
+     type = "submit"
+     class = "submit"
+} ?>
+</div></div>
+</form>
+</body>
+</html>

Added: trunk/UI/asset/begin_report.html
===================================================================
--- trunk/UI/asset/begin_report.html	                        (rev 0)
+++ trunk/UI/asset/begin_report.html	2011-07-29 22:12:16 UTC (rev 3594)
@@ -0,0 +1,66 @@
+<?lsmb INCLUDE "ui-header.html"
+       include_stylesheet = ["UI/asset/asset.css"] -?>
+<?lsmb PROCESS "elements.html" -?>
+<body>
+<form action="asset.pl" method="post">
+<div class="listtop"><?lsmb text('New Asset Report') ?></div>
+<div class="inputrow" id="classrow"><div class="inputgroup" id="classgrp">
+<?lsmb PROCESS select element_data = {
+     name = "asset_class"
+     default_values = [asset_class]
+     options = asset_classes
+     text_attr = "label"
+     value_attr = "id"
+     label = text('Asset Class') #'
+} ?>
+</div></div>
+<div class="inputrow" id="daterow"><div class="inputgroup" id="dategroup">
+<?lsmb PROCESS input element_data = {
+     name = "report_date"
+     class = "date"
+     value = report_date
+     label = text("Date")
+} ?>
+</div></div>
+<div class="inputrow" id="disposaltyperow">
+<div class="inputgroup">
+<?lsmb IF !depreciation ?>
+<?lsmb PROCESS input element_data ={
+    name = 'report_class'
+    class = 'type'
+    label = text('Full')
+    value = 2
+    checked = 'CHECKED'
+    type  = 'radio'
+} ?>
+
+</div>
+<div class="inputgroup">
+<?lsmb PROCESS input element_data ={
+    name = 'report_class'
+    class = 'type'
+    label = text('Partial')
+    value = 4
+    type  = 'radio'
+} ?>
+<?lsmb END ?>
+</div></div>
+<?lsmb PROCESS input element_data = {
+     name = "depreciation"
+     type = "hidden"
+     value = depreciation
+} ?>
+<div class="inputrow" id="buttonrow">
+<div class="inputgroup" id="buttongroupnext">
+<label>&nbsp;</label>
+<?lsmb PROCESS button element_data = {
+     name = "action"
+     text = text("Continue")
+     value = "report_init"
+     type = "submit"
+     class = "submit"
+} ?>
+</div></div>
+</form>
+</body>
+</html>

Added: trunk/UI/asset/edit_asset.html
===================================================================
--- trunk/UI/asset/edit_asset.html	                        (rev 0)
+++ trunk/UI/asset/edit_asset.html	2011-07-29 22:12:16 UTC (rev 3594)
@@ -0,0 +1,215 @@
+<?lsmb INCLUDE 'ui-header.html' 
+      include_stylesheet = ["UI/asset/asset.css"] 
+      include_script = ["UI/asset/asset.js"] 
+?>
+<?lsmb PROCESS 'elements.html' ?>
+<body onLoad="init()">
+<div class="listtop"><?lsmb title ?></div>
+<form action="<?lsmb script ?>" method="post">
+<!-- These are for Javascript automation of defaults -CT -->
+<?lsmb PROCESS input element_data = {
+	type = "hidden"
+	name = "id"
+	value = id
+} ?>
+<?lsmb FOREACH a_class IN asset_classes -?>
+<?lsmb PROCESS input element_data = {
+       type = "hidden",
+       name = "asset_account_default_$a_class.id",
+       value = a_class.asset_account_id,
+} ?>
+<?lsmb PROCESS input element_data = {
+       type = "hidden",
+       name = "dep_account_default_$a_class.id",
+       value = a_class.dep_account_id,
+} ?>
+<?lsmb PROCESS input element_data = {
+       type = "hidden",
+       name = "unit_label_$a_class.id",
+       value = dep_method.${a_class.id}.unit_label,
+} ?>
+<?lsmb- END # For a_class ?>
+<?lsmb PROCESS input element_data = {
+       type = "hidden"
+       name = "last_class_id"
+       value = asset_class
+} ?>
+<!-- end set for javascript automation -CT -->
+<div class="inputrow" id="tagrow">
+<?lsmb PROCESS input element_data = {
+	type = "text"
+	class = "control_code"
+	name = "tag"
+	value = tag
+	label = text('Tag:')
+	size = 32
+} ?>
+</div>
+<div class="inputrow" id="classrow">
+<?lsmb PROCESS select element_data = {
+	name = "asset_class"
+	class = "class"
+	options = asset_classes
+	default_options = [asset_class]
+	text_attr = "label"
+	value_attr = "id"
+	label = text("Asset Class:") #"
+} ?>
+</div>
+<div class="inputrow" id="descrow">
+<?lsmb PROCESS input element_data = {
+	label = text("Description:")
+	name = "description"
+	class = "description"
+	value = description
+	type = "text"
+} ?>
+</div>
+<div class="inputrow" id="purchaserow">
+<span class="inputgroup" id="purchasedategroup">
+<?lsmb PROCESS input element_data = {
+	label = text("Purchase Date:") #"
+	name = "purchase_date"
+	class = "date"
+	value = purchase_date
+	type = "text"
+	size = 12
+} ?>
+</span>
+<span class="inputgroup" id="purchasevaluegroup">
+<?lsmb PROCESS input element_data = {
+	label = text("Purchase Value:") #"
+	name = "purchase_value"
+	class = "money"
+	value = purchase_value
+	type = "text"
+	size = 16
+} ?>
+</span>
+</div>
+<div class="inputrow" id="salvagerow">
+<span class="inputgroup" id="usablelifegroup">
+<?lsmb PROCESS input element_data = {
+	label = text("Usable Life") #"
+	name = "usable_life"
+	value = usable_life
+	type = "text"
+	size = 10
+} ?>
+<span class="caption" id="caption-usablelifegroup">
+(<?lsmb text('Method Default') ?>)
+</span>
+</span>
+<span class="inputgroup" id="salvagevaluegroup">
+<?lsmb PROCESS input element_data = {
+	label = text("Salvage Value:") #"
+	name = "salvage_value"
+	class = "money"
+	value = salvage_value
+	type = "text"
+	size = 16
+} ?>
+</span>
+</div>
+<div class="inputrow" id="startdeprow">
+<span class="inputgroup" id="startdepgroup">
+<?lsmb PROCESS input element_data = {
+	label = text("Depreciation Starts") #"
+	name = "start_depreciation"
+	value = start_depreciation
+	type = "text"
+	size = 12
+        class = "date"
+} ?>
+</span>
+</div>
+<div class="inputrow" id="business_row">
+<span class="inputgroup" id="locationgroup">
+<?lsmb PROCESS select element_data = {
+	name = "warehouse_id"
+	options = locations
+	value_attr = "id"
+	text_attr = "description"
+	default_values = [warehouse_id]
+	label = text('Location')
+} ?>
+</span>
+<span class="inputgroup" id="departmentgroup">
+<?lsmb PROCESS select element_data = {
+	name = "department_id"
+	options = departments
+	value_attr = "id"
+	text_attr = "description"
+	default_values = [department_id]
+	label = text('Department')
+} ?>
+</span>
+</div>
+<div class="inputrow" id="accountsrow">
+<span class="inputgroup" id="assetaccgroup">
+<?lsmb PROCESS select element_data = {
+	label = text('Asset Account') #'
+	options = asset_accounts
+	name = "asset_account_id"
+	default_values = [asset_account_id]
+	value_attr = 'id'
+	text_attr = 'text'
+} ?>
+</span>
+<span class="inputgroup" id="depaccgroup">
+<?lsmb PROCESS select element_data = {
+	label = text('Depreciation Account') #'
+	options = dep_accounts
+	name = "dep_account_id"
+	default_values = [dep_account_id]
+	value_attr = 'id'
+	text_attr = 'text'
+} ?>
+</span>
+</div>
+<div class="inputrow" id="exprow"
+<span class="inputgroup" id="expensegroup">
+<?lsmb PROCESS select element_data = {
+     name = "exp_account_id"
+     class = "account"
+     options = exp_accounts
+     text_attr = 'text'
+     value_attr = 'id'
+     default_values = [exp_account_id]
+     label = text('Expense Account') #'
+} ?>
+</span></div>
+<div class="inputrow" id="invoicerow">
+<span class="inputgroup" id="vendorgroup">
+<?lsmb PROCESS input element_data = {
+	label = text('Vendor Number') #'
+	type = "text"
+	class = "identifier"
+	size = 20
+	value = meta_number
+	name = "meta_number"
+} ?>
+</span>
+<span class="inputgroup" id="invgroup">
+<?lsmb PROCESS input element_data = {
+	label = text('Invoice Number') #'
+	type = "text"
+	class = "identifier"
+	size = 20
+	value = invnumber
+	name = "invnumber"
+} ?>
+</span>
+</div>
+<div class="inputrow" id="buttonrow">
+<?lsmb PROCESS button element_data = {
+	text = text("Save")
+	type = "submit"
+	class = "submit"
+	name = "action"
+	value = "asset_save"
+} ?>
+</div>
+</form>
+</body>
+</html>

Added: trunk/UI/asset/edit_class.html
===================================================================
--- trunk/UI/asset/edit_class.html	                        (rev 0)
+++ trunk/UI/asset/edit_class.html	2011-07-29 22:12:16 UTC (rev 3594)
@@ -0,0 +1,65 @@
+<?lsmb INCLUDE 'ui-header.html' ?>
+<?lsmb PROCESS 'elements.html' ?>
+<div class="listtop"><?lsmb title ?></div>
+<form action="<?lsmb script ?>" method="post">
+<?lsmb PROCESS input element_data = {
+	type = "hidden"
+	name = "id"
+	value = id
+} ?>
+<div class="inputrow" id="labelrow">
+<?lsmb PROCESS input element_data = {
+	type = "text"
+	name = "label"
+	value = label
+	class = "control_code"
+	size = 32
+	label = text('Label:')
+} ?>
+</div>
+<div class="inputrow" id="methodrow">
+<span class="inputgroup" id="methodgroup">
+<?lsmb PROCESS select element_data = {
+	label = text('Depreciation Method') #'
+	options = dep_methods
+	value_attr = 'id'
+	text_attr = 'method'
+	default_values = [method_id]
+	name = 'method_id'
+} ?>
+</span>
+</div>
+<div class="inputrow" id="accountsrow">
+<span class="inputgroup" id="assetaccgroup">
+<?lsmb PROCESS select element_data = {
+	label = text('Asset Account') #'
+	options = asset_accounts
+	name = "asset_account_id"
+	default_values = [asset_account_id]
+	value_attr = 'id'
+	text_attr = 'text'
+} ?>
+</span>
+<span class="inputgroup" id="depaccgroup">
+<?lsmb PROCESS select element_data = {
+	label = text('Depreciation Account') #'
+	options = dep_accounts
+	name = "dep_account_id"
+	default_values = [dep_account_id]
+	value_attr = 'id'
+	text_attr = 'text'
+} ?>
+</span>
+</div>
+<div class="inputrow" id="buttonrow">
+<?lsmb PROCESS button element_data = {
+	text = text("Save")
+	type = "submit"
+	class = "submit"
+	name = "action"
+	value = "asset_category_save"
+} ?>
+</div>
+</form>
+</body>
+</html>

Added: trunk/UI/asset/import_asset.html
===================================================================
--- trunk/UI/asset/import_asset.html	                        (rev 0)
+++ trunk/UI/asset/import_asset.html	2011-07-29 22:12:16 UTC (rev 3594)
@@ -0,0 +1,66 @@
+<?lsmb INCLUDE 'ui-header.html' 
+      include_stylesheet = ["UI/asset/asset.css"] 
+      include_script = ["UI/asset/asset.js"] 
+?>
+<?lsmb PROCESS 'elements.html' ?>
+<body onLoad="init()">
+<div class="listtop"><?lsmb title ?></div>
+<div class="info"><?lsmb info ?></div>
+<form action="<?lsmb script ?>" method="post" enctype="multipart/form-data">
+<!-- These are for Javascript automation of defaults -CT -->
+<?lsmb PROCESS input element_data = {
+	type = "hidden"
+	name = "id"
+	value = id
+} ?>
+<?lsmb FOREACH a_class IN asset_classes -?>
+<?lsmb PROCESS input element_data = {
+       type = "hidden",
+       name = "asset_account_default_$a_class.id",
+       value = a_class.asset_account_id,
+} ?>
+<?lsmb PROCESS input element_data = {
+       type = "hidden",
+       name = "dep_account_default_$a_class.id",
+       value = a_class.dep_account_id,
+} ?>
+<?lsmb PROCESS input element_data = {
+       type = "hidden",
+       name = "unit_label_$a_class.id",
+       value = dep_method.${a_class.id}.unit_label,
+} ?>
+<?lsmb- END # For a_class ?>
+<?lsmb PROCESS input element_data = {
+       type = "hidden"
+       name = "last_class_id"
+       value = asset_class
+} ?>
+<!-- end set for javascript automation -CT -->
+<div class="inputrow" id="daterow">
+<?lsmb PROCESS input element_data = {
+     type = "text"
+     class = "date"
+     label = text("Depreciate Through") #"
+     name = "report_date"
+     value = report_date
+} ?>
+<div class="inputrow" id="filerow">
+<?lsmb PROCESS input element_data = {
+       name = "import_file"
+       type = "file"
+       label = text('From File') #'
+       class = "file"
+} ?>
+</div>
+<div class="inputrow" id="buttonrow">
+<?lsmb PROCESS button element_data = {
+	text = text("Save")
+	type = "submit"
+	class = "submit"
+	name = "action"
+	value = "run_import"
+} ?>
+</div>
+</form>
+</body>
+</html>

Added: trunk/UI/asset/search_asset.html
===================================================================
--- trunk/UI/asset/search_asset.html	                        (rev 0)
+++ trunk/UI/asset/search_asset.html	2011-07-29 22:12:16 UTC (rev 3594)
@@ -0,0 +1,194 @@
+<?lsmb INCLUDE 'ui-header.html' 
+      include_stylesheet = ["UI/asset/asset.css"] 
+?>
+<?lsmb PROCESS 'elements.html' ?>
+<body>
+<div class="listtop"><?lsmb title ?></div>
+<form action="<?lsmb script ?>" method="post">
+<!-- These are for Javascript automation of defaults -CT -->
+<?lsmb PROCESS input element_data = {
+	type = "hidden"
+	name = "id"
+	value = id
+} ?>
+<?lsmb FOREACH a_class IN asset_classes -?>
+<?lsmb PROCESS input element_data = {
+       type = "hidden",
+       name = "asset_account_default_$a_class.id",
+       value = a_class.asset_account_id,
+} ?>
+<?lsmb PROCESS input element_data = {
+       type = "hidden",
+       name = "dep_account_default_$a_class.id",
+       value = a_class.dep_account_id,
+} ?>
+<?lsmb- END # For a_class ?>
+<?lsmb PROCESS input element_data = {
+       type = "hidden"
+       name = "last_class_id"
+       value = asset_class
+} ?>
+<!-- end set for javascript automation -CT -->
+<div class="inputrow" id="tagrow">
+<?lsmb PROCESS input element_data = {
+	type = "text"
+	class = "control_code"
+	name = "tag"
+	value = tag
+	label = text('Tag:')
+	size = 32
+} ?>
+</div>
+<div class="inputrow" id="classrow">
+<?lsmb PROCESS select element_data = {
+	name = "asset_class"
+	class = "class"
+	options = asset_classes
+	default_options = [asset_class]
+	text_attr = "label"
+	value_attr = "id"
+	label = text("Asset Class:") #"
+} ?>
+</div>
+<div class="inputrow" id="descrow">
+<?lsmb PROCESS input element_data = {
+	label = text("Description:")
+	name = "description"
+	class = "description"
+	value = description
+	type = "text"
+} ?>
+</div>
+<div class="inputrow" id="purchaserow">
+<span class="inputgroup" id="purchasedategroup">
+<?lsmb PROCESS input element_data = {
+	label = text("Purchase Date:") #"
+	name = "purchase_date"
+	class = "date"
+	value = purchase_date
+	type = "text"
+	size = 12
+} ?>
+</span>
+<span class="inputgroup" id="purchasevaluegroup">
+<?lsmb PROCESS input element_data = {
+	label = text("Purchase Value:") #"
+	name = "purchase_value"
+	class = "money"
+	value = purchase_value
+	type = "text"
+	size = 16
+} ?>
+</span>
+</div>
+<div class="inputrow" id="salvagerow">
+<span class="inputgroup" id="usablelifegroup">
+<?lsmb PROCESS input element_data = {
+	label = text("Usable Life") #"
+	name = "usable_life"
+	value = usable_life
+	type = "text"
+	size = 10
+} ?>
+</span>
+<span class="inputgroup" id="salvagevaluegroup">
+<?lsmb PROCESS input element_data = {
+	label = text("Salvage Value:") #"
+	name = "salvage_value"
+	class = "money"
+	value = salvage_value
+	type = "text"
+	size = 16
+} ?>
+</span>
+</div>
+<div class="inputrow" id="startdeprow">
+<span class="inputgroup" id="startdepgroup">
+<?lsmb PROCESS input element_data = {
+	label = text("Depreciation Starts") #"
+	name = "start_depreciation"
+	value = start_depreciation
+	type = "text"
+	size = 12
+        class = "date"
+} ?>
+</span>
+</div>
+<div class="inputrow" id="business_row">
+<span class="inputgroup" id="locationgroup">
+<?lsmb PROCESS select element_data = {
+	name = "warehouse_id"
+	options = locations
+	value_attr = "id"
+	text_attr = "description"
+	default_values = [warehouse_id]
+	label = text('Location')
+} ?>
+</span>
+<span class="inputgroup" id="departmentgroup">
+<?lsmb PROCESS select element_data = {
+	name = "department_id"
+	options = departments
+	value_attr = "id"
+	text_attr = "description"
+	default_values = [department_id]
+	label = text('Department')
+} ?>
+</span>
+</div>
+<div class="inputrow" id="accountsrow">
+<span class="inputgroup" id="assetaccgroup">
+<?lsmb PROCESS select element_data = {
+	label = text('Asset Account') #'
+	options = asset_accounts
+	name = "asset_account_id"
+	default_values = [asset_account_id]
+	value_attr = 'id'
+	text_attr = 'text'
+} ?>
+</span>
+<span class="inputgroup" id="depaccgroup">
+<?lsmb PROCESS select element_data = {
+	label = text('Depreciation Account') #'
+	options = dep_accounts
+	name = "dep_account_id"
+	default_values = [dep_account_id]
+	value_attr = 'id'
+	text_attr = 'text'
+} ?>
+</span>
+</div>
+<div class="inputrow" id="invoicerow">
+<span class="inputgroup" id="vendorgroup">
+<?lsmb PROCESS input element_data = {
+	label = text('Vendor Number') #'
+	type = "text"
+	class = "identifier"
+	size = 20
+	value = meta_number
+	name = "meta_number"
+} ?>
+</span>
+<span class="inputgroup" id="invgroup">
+<?lsmb PROCESS input element_data = {
+	label = text('Invoice Number') #'
+	type = "text"
+	class = "identifier"
+	size = 20
+	value = invnumber
+	name = "invnumber"
+} ?>
+</span>
+</div>
+<div class="inputrow" id="buttonrow">
+<?lsmb PROCESS button element_data = {
+	text = text("Search")
+	type = "submit"
+	class = "submit"
+	name = "action"
+	value = "asset_results"
+} ?>
+</div>
+</form>
+</body>
+</html>

Added: trunk/UI/asset/search_class.html
===================================================================
--- trunk/UI/asset/search_class.html	                        (rev 0)
+++ trunk/UI/asset/search_class.html	2011-07-29 22:12:16 UTC (rev 3594)
@@ -0,0 +1,74 @@
+<?lsmb INCLUDE 'ui-header.html' ?>
+<?lsmb PROCESS 'elements.html' ?>
+<div class="listtop"><?lsmb text('Search Asset Class') ?></div>
+<form action="<?lsmb script ?>" method="post">
+<div class="inputrow" id="labelrow">
+<?lsmb PROCESS input element_data = {
+	type = "text"
+	name = "label"
+	value = label
+	class = "control_code"
+	size = 32
+	label = text('Label:')
+} ?>
+</div>
+<div class="inputrow" id="methodrow">
+<span class="inputgroup" id="methodgroup">
+<?lsmb dep_methods.push({}); 
+	PROCESS select element_data = {
+	label = text('Depreciation Method') #'
+	options = dep_methods
+	value_attr = 'id'
+	text_attr = 'method'
+	default_values = [method_id]
+	name = 'method_id'	
+} ?>
+</span>
+<span class="inputgroup" id="Units">
+<?lsmb life_units.push({});
+	PROCESS select element_data = {
+	label = text('Lifetime Measured In') #'
+	options = life_units
+	name = "life_unit"
+	default_values = [life_unit]
+	text_attr = "unit"
+	value_atr = "id"
+} ?>
+</span>
+</div>
+<div class="inputrow" id="accountsrow">
+<span class="inputgroup" id="assetaccgroup">
+<?lsmb asset_accounts.push({});
+	PROCESS select element_data = {
+	label = text('Asset Account') #'
+	options = asset_accounts
+	name = "asset_account_id"
+	default_values = [asset_account_id]
+	value_attr = 'id'
+	text_attr = 'text'
+} ?>
+</span>
+<span class="inputgroup" id="depaccgroup">
+<?lsmb dep_accounts.push({});
+	PROCESS select element_data = {
+	label = text('Depreciation Account') #'
+	options = dep_accounts
+	name = "dep_account_id"
+	default_values = [dep_account_id]
+	value_attr = 'id'
+	text_attr = 'text'
+} ?>
+</span>
+</div>
+<div class="inputrow" id="buttonrow">
+<?lsmb PROCESS button element_data = {
+	text = text("Search")
+	type = "submit"
+	class = "submit"
+	name = "action"
+	value = "asset_category_results"
+} ?>
+</div>
+</form>
+</body>
+</html>

Added: trunk/UI/asset/search_reports.html
===================================================================
--- trunk/UI/asset/search_reports.html	                        (rev 0)
+++ trunk/UI/asset/search_reports.html	2011-07-29 22:12:16 UTC (rev 3594)
@@ -0,0 +1,75 @@
+<?lsmb INCLUDE 'ui-header.html' 
+      include_stylesheet = ["UI/asset/asset.css"] 
+?>
+<?lsmb PROCESS 'elements.html' ?>
+<body>
+<div class="listtop"><?lsmb title ?></div>
+<form action="<?lsmb script ?>" method="post">
+<div class="inputrow" id="classrow">
+<div class="inputgroup" id="classgroup">
+<?lsmb asset_classes.unshift({});
+PROCESS select element_data = {
+	 label = text('Asset Class') #'
+          name = asset_class
+default_values = [asset_class]
+         class = "class"
+       options = asset_classes
+    value_attr = 'id' 
+     text_attr = "label"
+} ?>
+</div>
+</div>
+<div class="inputrow" id="daterow">
+<div class="inputgroup" id="start-dategroup">
+<?lsmb PROCESS input element_data = {
+           label = text('From')
+           class = "date"
+            name = "start_date"
+           value = start_date
+            size = 12
+} ?>
+</div>
+<div class="inputgroup" id="end-dategroup">
+<?lsmb PROCESS input element_data = {
+           label = text('To')
+           class = "date"
+            name = "end_date"
+           value = end_date
+            size = 12
+} ?>
+</div>
+</div>
+<div class="inputrow" id="userrow">
+<!--
+<div class="inputgroup" id="createdbygrp">
+<?lsmb report_users.unshift({});
+PROCESS select element_data = {
+	 label = text('Created By') #'
+          name = "created_by"
+default_values = [created_by]
+         class = "users"
+       options = report_users
+    value_attr = 'entity_id' 
+     text_attr = "login"
+} ?>
+</div>
+-->
+<div class="inputgroup" id="approvedgroup">
+<?lsmb IF approved; approved = 'CHECKED'; END;
+PROCESS input element_data = {
+       label = text('Approved')
+        type = "checkbox"
+       value = approved
+} ?>
+</div>
+<div class="inputrow" id="buttonrow">
+<?lsmb PROCESS button element_data = {
+       name = "action"
+      value = "report_results"
+      text  = text('Search')
+      class = "submit"
+      type  = "submit"
+} ?>
+</form>
+</body>
+</html>

Modified: trunk/scripts/vouchers.pl
===================================================================
--- trunk/scripts/vouchers.pl	2011-07-29 20:24:29 UTC (rev 3593)
+++ trunk/scripts/vouchers.pl	2011-07-29 22:12:16 UTC (rev 3594)
@@ -1,37 +1,46 @@
+=head1 NAME
+LedgerSMB::Scripts::vouchers
+
+=head1 SYNPOSIS
+Voucher workflow scripts.
+
+#      --CT
+=head1 METHODS
+
+=over
+
+=cut
+
 #!/usr/bin/perl
 
-# This file is copyright (C) 2007the LedgerSMB core team and licensed under 
-# the GNU General Public License.  For more information please see the included
-# LICENSE and COPYRIGHT files
 
-# THIS FILE NEEDS POD
-
 package LedgerSMB::Scripts::vouchers;
 our $VERSION = '0.1';
 
 use LedgerSMB::Batch;
-use LedgerSMB::Voucher;
 use LedgerSMB::Template;
 use strict;
 
-# custom_batch_types hash provides hooks for handling additional batch types
-# beyond the default types.  Entries can be added in a custom file.
-# Each entry is a hash, keyed by name, with the following keys:
-#  * map_to int (maps to another type, not needed for new types in batch_class 
-#                table)
-#  * select_method (maps to the selection stored proc)
-#
-#  for example:
-#  $custom_batch_types->{ap_sample} = 
-#      {map_to       => 1, 
-#      select_method => 'custom_sample_ap_select'};
-#
-#      --CT
 
 our $custom_batch_types = {};
 
 eval { do "scripts/custom/vouchers.pl"};
 
+=item create_batch
+
+Displays the new batch screen.  Required inputs are
+
+=over 
+
+=item batch_type
+
+=back
+
+Additionally order_by can be specified for the list of current batches for the
+current user.
+
+=cut
+
 sub create_batch {
     my ($request) = @_;
 	$request->open_form;
@@ -63,6 +72,15 @@
     $template->render($batch);
 }
 
+=item create-vouchers
+
+Closes the form in the db, and if unsuccessful displays the batch info again.
+
+If successful at closing the form, it saves the batch to the db and redirects to
+add_vouchers().
+
+=cut
+
 sub create_vouchers {
     my ($request) = shift @_;
     my $batch = LedgerSMB::Batch->new({base => $request});
@@ -76,7 +94,12 @@
         create_batch($request);
     }
 }
+=item add_vouchers
 
+Redirects to a script to add vouchers for the type.  batch_type must be set.
+
+=cut
+
 sub add_vouchers {
     #  This function is not safe for caching as long as the scripts are in bin.
     #  This is because these scripts import all functions into the *current*
@@ -161,6 +184,12 @@
     $vouchers_dispatch->{$request->{batch_type}}{function}($request);
 }
 
+=item search_batch
+
+Displays the search criteria screen.  No inputs required.
+
+=cut
+
 sub search_batch {
     my ($request) = @_;
     my $batch_request = LedgerSMB::Batch->new(base => $request);
@@ -175,6 +204,21 @@
     $template->render($batch_request);
 }
 
+=item list_batches
+
+This function displays the search results.
+
+No inputs are required, but amount_lt and amount_gt can specify range
+Also description can be a partial match.
+
+empty specifies only voucherless batches
+
+approved (true or false) specifies whether the batch has been approved
+
+class_id and created_by are exact matches
+
+=cut
+
 sub list_batches {
     my ($request) = @_;
     $request->{action} = 'list_batches';
@@ -303,6 +347,14 @@
         
 }
 
+=item get_batch
+
+Requires that batch_id is set.
+
+Displays all vouchers from the batch by type, and includes amount.
+
+=cut
+
 sub get_batch {
     my ($request)  = @_;
     $request->{action} = 'get_batch';
@@ -421,14 +473,22 @@
     
 }
 
+# alias for batch_delete, needed for form-dynatable
 sub list_batches_batch_delete {
     batch_delete(@_);
 }
 
+# alias for batch_post, needed for form-dynatable
 sub list_batches_batch_approve {
     batch_approve(@_);
 }
 
+=item get_batch_batch_approve
+
+Approves the single batch on the details screen.  Batch_id must be set.,
+
+=cut
+
 sub get_batch_batch_approve {
     my ($request) = @_;
     my $batch = LedgerSMB::Batch->new(base => $request);
@@ -441,6 +501,12 @@
     }
 }
 
+=item get_batch_voucher_delete
+
+Deletes selected vouchers. 
+
+=cut
+
 sub get_batch_voucher_delete {
     my ($request) = @_;
     my $batch = LedgerSMB::Batch->new(base => $request);
@@ -456,6 +522,12 @@
     search_batch($request);
 }
 
+=item batch_approve
+
+Approves all selected batches.
+
+=cut
+
 sub batch_approve {
     my ($request) = @_;
     my $batch = LedgerSMB::Batch->new(base => $request);
@@ -471,6 +543,12 @@
     search_batch($request);
 }
 
+=item batch_delete
+
+Deletes selected batches
+
+=cut
+
 sub batch_delete {
     my ($request)  = @_;
     my $batch = LedgerSMB::Batch->new(base => $request);
@@ -488,3 +566,35 @@
 
 eval { do "scripts/custom/vouchers.pl"};
 1;
+
+=back
+
+=head1 CUSTOM BATCH TYPES
+ custom_batch_types hash provides hooks for handling additional batch types
+ beyond the default types.  Entries can be added in a custom file.
+ Each entry is a hash, keyed by name, with the following keys:
+
+=over
+
+=item map_to int 
+
+maps to another type, not needed for new types in batch_class table
+
+=item select_method 
+
+maps to the selection stored proc
+
+=back
+
+  for example:
+  $custom_batch_types->{ap_sample} = 
+      {map_to       => 1, 
+      select_method => 'custom_sample_ap_select'};
+
+=head1 Copyright (C) 2009, The LedgerSMB core team.
+
+This file is licensed under the Gnu General Public License version 2, or at your
+option any later version.  A copy of the license should have been included with
+your software.
+
+=cut

Modified: trunk/sql/modules/Voucher.sql
===================================================================
--- trunk/sql/modules/Voucher.sql	2011-07-29 20:24:29 UTC (rev 3593)
+++ trunk/sql/modules/Voucher.sql	2011-07-29 22:12:16 UTC (rev 3594)
@@ -10,31 +10,9 @@
 END;
 $$ language plpgsql;
 
+COMMENT ON FUNCTION voucher_get_batch (in_batch_id integer) is
+$$ Retrieves basic batch information based on batch_id.$$;
 
-CREATE OR REPLACE FUNCTION batch_update (in_batch text, in_login varchar, in_entered date,
-	in_batch_number text, in_description text, in_id integer) 
-RETURNS integer AS
-$$
-BEGIN
-	UPDATE batch
-	SET batch_number = in_batch_number,
-		description = in_description,
-		entered = in_entered
-	WHERE id = in_id;
-
-	IF FOUND THEN 
-		RETURN in_id;
-	END IF;
-
-	INSERT INTO batch (batch, employee_id, batch_number, description, 
-		entered)
-	VALUES (in_batch, (SELECT id FROM employees WHERE login = in_login),
-		in_batch_number, description);
-
-	RETURN currval('id');
-END;
-$$ LANGUAGE PLPGSQL;
-
 CREATE TYPE voucher_list AS (
 	id int,
 	reference text,
@@ -46,6 +24,8 @@
         batch_class text
 );
 
+-- voucher_list could use refactoring
+
 CREATE OR REPLACE FUNCTION voucher_list (in_batch_id integer)
 RETURNS SETOF voucher_list AS
 $$
@@ -140,6 +120,9 @@
 END;
 $$ language plpgsql;
 
+COMMENT ON FUNCTION voucher_list (in_batch_id integer) IS
+$$ Retrieves a list of vouchers and amounts attached to the batch.$$;
+
 CREATE TYPE batch_list_item AS (
     id integer,
     batch_class text,
@@ -227,11 +210,27 @@
 END;
 $$ LANGUAGE PLPGSQL;
 
+COMMENT ON FUNCTION
+batch_search(in_class_id int, in_description text, in_created_by_eid int,
+        in_date_from date, in_date_to date,
+        in_amount_gt numeric,
+        in_amount_lt numeric, in_approved bool) IS
+$$Returns a list of batches and amounts processed on the batch.
+
+Nulls match all values.
+in_date_from and in_date_to specify date ranges.
+in_description is a partial match.
+All other criteria are exact matches.
+$$;
+
 CREATE OR REPLACE FUNCTION batch_get_class_id (in_type text) returns int AS
 $$
 SELECT id FROM batch_class WHERE class = $1;
 $$ language sql;
 
+COMMENT ON FUNCTION batch_get_class_id (in_type text) IS
+$$ returns the batch class id associated with the in_type label provided.$$;
+
 CREATE OR REPLACE FUNCTION 
 batch_search_mini
 (in_class_id int, in_description text, in_created_by_eid int, in_approved bool) 
@@ -263,7 +262,17 @@
 END;
 $$ LANGUAGE PLPGSQL;
 
+COMMENT ON FUNCTION batch_search_mini
+(in_class_id int, in_description text, in_created_by_eid int, in_approved bool)
+IS $$ This performs a simple search of open batches created by the entity_id
+in question.  This is used to pull up batches that were currently used so that
+they can be picked up and more vouchers added.
 
+NULLs match all values.
+in_description is a partial match
+All other inouts are exact matches.
+$$;
+
 CREATE OR REPLACE FUNCTION 
 batch_search_empty(in_class_id int, in_description text, in_created_by_eid int, 
 	in_amount_gt numeric, 
@@ -290,7 +299,19 @@
 END;
 $$ LANGUAGE PLPGSQL;
 
+COMMENT ON FUNCTION
+batch_search_empty(in_class_id int, in_description text, in_created_by_eid int,
+        in_amount_gt numeric,
+        in_amount_lt numeric, in_approved bool) IS
+$$ This is a full search for the batches, listing them by amount processed.
+in_amount_gt and in_amount_lt provide a range to search for.
+in_description is a partial match field.
+Other fields are exact matches.
 
+NULLs match all values.
+$$;
+
+
 CREATE OR REPLACE FUNCTION batch_post(in_batch_id INTEGER)
 returns date AS
 $$
@@ -325,17 +346,25 @@
 END;
 $$ LANGUAGE PLPGSQL;
 
+COMMENT ON FUNCTION batch_post(in_batch_id INTEGER) is
+$$ Posts the specified batch to the books.  Only posted batches should show up
+on standard financial reports.$$;
+
 CREATE OR REPLACE FUNCTION batch_list_classes() RETURNS SETOF batch_class AS
 $$
 DECLARE out_val record;
 BEGIN
-	FOR out_val IN select * from batch_class
+	FOR out_val IN select * from batch_class order by id
  	LOOP
 		return next out_val;
 	END LOOP;
 END;
 $$ language plpgsql;
 
+COMMENT ON FUNCTION batch_list_classes() 
+IS $$ Returns a list of all batch classes.$$;
+
+-- Move to the admin module and call it from there.
 CREATE OR REPLACE FUNCTION batch_get_users() RETURNS SETOF users AS
 $$
 DECLARE out_record users%ROWTYPE;
@@ -348,6 +377,10 @@
 END;
 $$ LANGUAGE PLPGSQL;
 
+COMMENT ON FUNCTION batch_get_users() IS
+$$ Returns a sim[ple set of user objects.  This should be renamed so that 
+it is more obvious it is a general purpose function.$$;
+
 CREATE OR REPLACE FUNCTION batch_create(
 in_batch_number text, in_description text, in_batch_class text, 
 in_batch_date date) 
@@ -365,6 +398,11 @@
 END;	
 $$ LANGUAGE PLPGSQL;
 
+COMMENT ON FUNCTION batch_create(
+in_batch_number text, in_description text, in_batch_class text,
+in_batch_date date) IS
+$$ Inserts the batch into the table.$$;
+
 CREATE OR REPLACE FUNCTION batch_delete(in_batch_id int) RETURNS int AS
 $$
 DECLARE 
@@ -373,6 +411,10 @@
 	-- Adjust AR/AP tables for payment and payment reversal vouchers
 	-- voucher_id is only set in acc_trans on payment/receipt vouchers and
 	-- their reversals. -CT
+        perform * from batch where id = in_batch_id and approved_on IS NULL;
+        IF NOT FOUND THEN
+            RAISE EXCEPTION 'Batch not found';
+        END IF; 
 	update ar set paid = amount + 
 		(select sum(amount) from acc_trans 
 		join chart ON (acc_trans.chart_id = chart.id)
@@ -423,6 +465,10 @@
 END;
 $$ language plpgsql SECURITY DEFINER;
 
+COMMENT ON  FUNCTION batch_delete(in_batch_id int) IS
+$$ If the batch is found and unapproved, deletes it and returns 1.
+Otherwise raises an exception.$$;
+
 REVOKE ALL ON FUNCTION batch_delete(int) FROM PUBLIC;
 
 CREATE OR REPLACE FUNCTION voucher__delete(in_voucher_id int)
@@ -472,3 +518,6 @@
 $$ LANGUAGE PLPGSQL SECURITY DEFINER;
 
 REVOKE ALL ON FUNCTION voucher__delete(int) FROM public;
+
+COMMENT ON FUNCTION voucher__delete(in_voucher_id int) IS
+$$ Deletes the specified voucher from the batch.$$;

Added: trunk/sql/upgrade/3594-drop-batch-update.sql
===================================================================
--- trunk/sql/upgrade/3594-drop-batch-update.sql	                        (rev 0)
+++ trunk/sql/upgrade/3594-drop-batch-update.sql	2011-07-29 22:12:16 UTC (rev 3594)
@@ -0,0 +1,2 @@
+DROP FUNCTION batch_update (in_batch text, in_login varchar, in_entered date,
+	in_batch_number text, in_description text, in_id integer);

Modified: trunk/t/98-pod-coverage.t
===================================================================
--- trunk/t/98-pod-coverage.t	2011-07-29 20:24:29 UTC (rev 3593)
+++ trunk/t/98-pod-coverage.t	2011-07-29 22:12:16 UTC (rev 3594)
@@ -13,7 +13,7 @@
 if ($@){
     plan skip_all => "Test::Pod::Coverage required for testing POD coverage";
 } else {
-    plan tests => 25;
+    plan tests => 26;
 }
 pod_coverage_ok("LedgerSMB");
 pod_coverage_ok("LedgerSMB::Form");
@@ -39,6 +39,7 @@
 pod_coverage_ok("LedgerSMB::DBObject::Employee");
 pod_coverage_ok("LedgerSMB::File");
 pod_coverage_ok("LedgerSMB::DBObject");
+pod_coverage_ok("LedgerSMB::Batch");
 pod_coverage_ok("LedgerSMB::DBObject::Payment", 
                {also_private => [qr/^(format_ten_|num2text_)/]}
 );


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