Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Batch search to new framework

git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@4876 4979c152-3d1c-0410-bac9-87ea11338e46
  • Loading branch information...
commit aefe25a91e730c40ccae7b107c16539c85480af6 2 parents 1449829 + bf972db
einhverfr authored
2  Changelog
View
@@ -62,6 +62,8 @@ Changelog for 1.3.19
* Clarified recon approval workflow (Chris T)
* Fixed error editing non-existent localized template (Chris T, 3531738)
* Fixed show/hide logic on nav bar on Contacts screen (Chris T)
+* Fixed "Post as Shown" button not showing properly on AR/AP drafts (Chris T)
+* Added fs_cssdir config option for easier packaging (Chris T, h/t Robert C)
Changelog for 1.3.18
* Fixed missing template for CSV pricelists (Chris T)
4 LedgerSMB/AM.pm
View
@@ -1223,7 +1223,7 @@ sub check_template_name {
if ( $form->{file} !~ /^$myconfig->{templates}\// ) {
$form->error("Not in a whitelisted directory: $form->{file}")
- unless $form->{file} =~ /^css\//;
+ unless $form->{file} =~ /^$LedgerSMB::Sysconfig::fs_cssdir\//;
}
}
@@ -1243,7 +1243,7 @@ sub load_template {
open( TEMPLATE, '<', "$form->{file}" ) || ($testval = 1);
if ($testval == 1 && ($! eq 'No such file or directory')){
my $file = $form->{file};
- $file =~ s|$form->{code}/||;
+ $file =~ s|$form->{code}/|| if $form->{code};
open( TEMPLATE, '<', "$file" ) || $form->error(
"Template not found: $file"
);
8 LedgerSMB/DBObject/Report.pm
View
@@ -148,6 +148,14 @@ bool, determines whether to show subtotals.
has show_subtotals => (is => 'rw', isa => 'Bool');
+=item buttons
+
+Buttons to show at the bottom of the screen
+
+=cut
+
+has buttons => (is => 'rw', isa => 'ArrayRef[Any]');
+
=back
=head1 METHODS
254 LedgerSMB/DBObject/Report/Unapproved/Batch_Overview.pm
View
@@ -0,0 +1,254 @@
+=head1 NAME
+
+LedgerSMB::DBObject::Report::Unapproved::Batch_Overview - Search Batches in
+LedgerSMB
+
+=head1 SYNPOSIS
+
+ my $report = LedgerSMB::DBObject::Report::Unapproved::Batch_Overview->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 batches
+themselves. You cannot delete individual vouchers in this report. For that,
+use LedgerSMB::DBObject::Report::Unapproved::Batch_Detail instead.
+
+=head1 INHERITS
+
+=over
+
+=item LedgerSMB::DBObject::Report;
+
+=back
+
+=cut
+
+package LedgerSMB::DBObject::Report::Unapproved::Batch_Overview;
+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 post_date
+
+Post date of transaction
+
+=item reference text
+
+Invoice number or GL reference
+
+=item description
+
+Description of transaction
+
+=item transaction_total
+
+Total of AR/AP/GL vouchers (GL vouchers credit side only is counted)
+
+=item payment_total
+
+Total of payment lines (credit side)
+
+Amount
+
+=back
+
+=cut
+
+our @COLUMNS = (
+ {col_id => 'select',
+ name => '',
+ type => 'checkbox' },
+
+ {col_id => 'id',
+ name => $locale->text('ID'),
+ type => 'text',
+ pwidth => 1, },
+
+ {col_id => 'default_date',
+ name => $locale->text('Date'),
+ type => 'text',
+ pwidth => '4', },
+
+ {col_id => 'control_code',
+ name => $locale->text('Control Code'),
+ type => 'href',
+ href_base => 'vouchers.pl?action=get_batch&id=',
+ pwidth => '3', },
+
+ {col_id => 'description',
+ name => $locale->text('Description'),
+ type => 'text',
+ pwidth => '6', },
+
+ {col_id => 'transaction_total',
+ name => $locale->text('AR/AP/GL Amount'),
+ type => 'text',
+ pwidth => '2', },
+
+ {col_id => 'payment_total',
+ name => $locale->text('Payment Amount'),
+ type => 'text',
+ pwidth => '2', },
+
+);
+
+sub columns {
+ return \@COLUMNS;
+}
+
+ # TODO: business_units int[]
+
+=item name
+
+Returns the localized template name
+
+=cut
+
+sub name {
+ return $locale->text('Batch Search');
+}
+
+=item header_lines
+
+Returns the inputs to display on header.
+
+=cut
+
+sub header_lines {
+ return [{name => 'type',
+ text => $locale->text('Batch Type')},
+ {name => 'reference',
+ text => $locale->text('Reference')},
+ {name => 'amount_gt',
+ text => $locale->text('Amount Greater Than')},
+ {name => 'amount_lt',
+ text => $locale->text('Amount Less Than')}, ]
+}
+
+=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 reference (text)
+
+Exact match on reference or invoice number.
+
+=cut
+
+has 'reference' => (is => 'rw', isa => 'Maybe[Str]');
+
+=item type
+
+ar for AR drafts, ap for AP drafts, gl for GL ones.
+
+=cut
+
+has 'type' => (is => 'rw', isa => 'Maybe[Str]');
+
+=item amount_gt
+
+The amount of the draft must be greater than this for it to show up.
+
+=cut
+
+has 'amount_gt' => (is => 'rw', isa => 'Maybe[Str]');
+
+=item amount_lt
+
+The amount of the draft must be less than this for it to show up.
+
+=cut
+
+has 'amount_lt' => (is => 'rw', isa => 'Maybe[Str]');
+
+=back
+
+=head1 METHODS
+
+=over
+
+=item prepare_criteria($request)
+
+Instantiates the PGDate and PGNumber inputs.
+
+=cut
+
+sub prepare_criteria{
+ my ($self, $request) = @_;
+}
+
+=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'),
+ value => 'batch_approve',
+ class => 'submit',
+ },{
+ name => 'action',
+ type => 'submit',
+ text => $locale->text('Delete'),
+ value => 'batch_delete',
+ class => 'submit',
+ }]);
+ my @rows = $self->exec_method({funcname => 'batch__search'});
+ for my $r (@rows){
+ $r->{row_id} = $r->{id};
+ }
+ $self->rows(\@rows);
+}
+
+
+=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;
130 LedgerSMB/Scripts/vouchers.pm
View
@@ -19,6 +19,7 @@ our $VERSION = '0.1';
use LedgerSMB::Batch;
use LedgerSMB::Template;
+use LedgerSMB::DBObject::Report::Unapproved::Batch_Overview;
use strict;
@@ -115,7 +116,7 @@ sub add_vouchers {
ar => {script => 'bin/ar.pl', function => sub {add()}},
gl => {script => 'bin/gl.pl', function => sub {add()}},
sales_invoice => {script => 'bin/is.pl', function => sub {add()}},
- vendor_invoice => {script => 'bin/ir.pl', function => sub {add()}}
+ vendor_invoice => {script => 'bin/ir.pl', function => sub {add()}},
receipt => {script => 'scripts/payment.pl',
function => sub {
my ($request) = @_;
@@ -223,129 +224,10 @@ class_id and created_by are exact matches
sub list_batches {
my ($request) = @_;
- $request->{action} = 'list_batches';
- my $batch = LedgerSMB::Batch->new(base => $request);
- $batch->close_form;
- $batch->open_form;
- $batch->{dbh}->commit;
- if ($batch->{order_by}){
- $batch->set_ordering(
- {method => $batch->get_search_method({custom_types => $custom_batch_types}),
- column => $batch->{order_by}
- });
- }
- my @search_results = $batch->get_search_results({custom_types => $custom_batch_types});
- $batch->{script} = "vouchers.pl";
-
- my @columns =
- qw(select id control_code description transaction_total payment_total default_date);
-
- my $base_href = "vouchers.pl";
- my $search_href = "$base_href?action=list_batches";
- my $batch_href = "$base_href?action=get_batch";
-
- for my $key (
- qw(class_id approved created_by description empty amount_gt amount_lt)
- ){
- $search_href .= "&$key=$batch->{$key}";
- }
-
- my $sort_href = "$search_href&order_by";
-
- my $column_names = {
- 'select' => 'Select',
- transaction_total => 'AR/AP/GL Total',
- payment_total => 'Paid/Received Total',
- description => 'Description',
- control_code => 'Batch Number',
- id => 'ID',
- default_date => 'Post Date'
- };
- my @sort_columns = qw(id control_code description transaction_total payment_total default_date);
-
- my $count = 0;
- my @rows;
- for my $result (@search_results){
- ++$count;
- $batch->{"row_$count"} = $result->{id};
- push @rows, {
- 'select' => {
- input => {
- type => 'checkbox',
- value => 1,
- name => "batch_$result->{id}"
- }
- },
- transaction_total => $batch->format_amount(
- amount => $result->{transaction_total}
- ),
- payment_total => $batch->format_amount (
- amount => $result->{payment_total}
- ),
- description => $result->{description},
- control_code => {
- text => $result->{control_code},
- href => "$batch_href&batch_id=$result->{id}",
-
- },
- id => $result->{id},
- default_date => $result->{default_date}
- };
- }
- $batch->{rowcount} = $count;
- my $template = LedgerSMB::Template->new(
- user => $request->{_user},
- locale => $request->{_locale},
- path => 'UI',
- template => 'form-dynatable',
- format => ($batch->{format}) ? $batch->{format} : 'HTML',
- );
-
- my $column_heading = $template->column_heading($column_names,
- {href => $sort_href, columns => \@sort_columns}
- );
-
- my $hiddens = $batch->take_top_level();
- $batch->{rowcount} = "$count";
- delete $batch->{search_results};
-
- my @buttons;
- if ($batch->{empty})
- {
- @buttons = [{
- name => 'action',
- type => 'submit',
- text => $request->{_locale}->text('Delete'),
- value => 'batch_delete',
- class => 'submit',
- }];
- } else {
- @buttons = [{
- name => 'action',
- type => 'submit',
- text => $request->{_locale}->text('Post'),
- value => 'batch_approve',
- class => 'submit',
- },{
- name => 'action',
- type => 'submit',
- text => $request->{_locale}->text('Delete'),
- value => 'batch_delete',
- class => 'submit',
- }];
- }
- # save form_id into the DB before sending the form.
- # TODO: need to find a better place for this.
- $batch->{dbh}->commit();
-
- $template->render({
- form => $batch,
- columns => \@columns,
- heading => $column_heading,
- rows => \@rows,
- hiddens => $hiddens,
- buttons => @buttons
- });
+ my $report = LedgerSMB::DBObject::Report::Unapproved::Batch_Overview->new(
+ %$request);
+ $report->run_report;
+ $report->render($request);
}
3  LedgerSMB/Sysconfig.pm
View
@@ -20,6 +20,7 @@ our $pathsep = ':';
our $auth = 'DB';
our $images = getcwd() . '/images';
our $cssdir = 'css/';
+our $fs_cssdir = 'css/';
our $force_username_case = undef; # don't force case
@@ -106,7 +107,7 @@ tie %config, 'Config::IniFiles', (-file=> 'ledgersmb.conf' );
for my $var (
qw(pathsep log_level DBI_TRACE check_max_invoices language auth latex
db_autoupdate force_username_case max_post_size decimal_places cookie_name
- return_accno no_db_str tempdir cache_templates cssdir)
+ return_accno no_db_str tempdir cache_templates cssdir fs_cssdir)
)
{
${$var} = $config{'main'}{$var} if $config{$var};
352 UI/Reports/filters/contact_search.html
View
@@ -3,7 +3,7 @@
PROCESS report_base.html ?>
<body>
<?lsmb
-IF account_class == 0;
+IF !account_class;
title = text('Contact Search'); #'
ELSIF account_class == 1;
title = text('Vendor Search'); #'
@@ -112,356 +112,6 @@
</td>
</tr>
<tr>
- <td>
- <table>
-<?lsmb IF target == 'list_history' -?>
- <tr>
- <td />
- <td>
- <table>
- <tr>
- <td>
- <table>
- <tr>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- type = 'radio',
- name = 'type',
- value = 'invoice',
- label = text('Invoice'),
- checked = 'checked',
- } -?>
- </td>
- </tr>
- <tr>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- type = 'radio',
- name = 'type',
- value = 'order',
- label = text('Order'),
- } -?>
- </td>
- </tr>
- <tr>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- type = 'radio',
- name = 'type',
- value = 'quotation',
- label = text('Quotation'),
- } -?>
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table>
- <tr>
- <th><?lsmb text('From') ?></th>
- <td><?lsmb INCLUDE input element_data={
- size = '11', name = 'transdatefrom', class = 'date', title = user.dateformat} -?></td>
- <th><?lsmb text('To') ?></th>
- <td><?lsmb INCLUDE input element_data={
- size = '11', name = 'transdateto', class = 'date', title = user.dateformat} -?></td>
- </tr>
- <tr>
- <td />
- <td colspan="3">
- <?lsmb INCLUDE input element_data={
- name = 'open',
- type = 'checkbox',
- value = 'Y',
- label = text('Open'),
- checked = 'checked'
- } -?>
- <?lsmb INCLUDE input element_data={
- name = 'closed',
- type = 'checkbox',
- value = 'Y',
- label = text('Closed'),
- } -?>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <th align="right"><?lsmb text('Include in Report') ?></th>
- <td>
- <table>
- <tr>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- name = 'history',
- type = 'radio',
- value = 'summary',
- label = text('Summary'),
- checked = 'checked',
- } -?>
- </td>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- name = 'history',
- type = 'radio',
- value = 'detail',
- label = text('Detail'),
- } -?>
- </td>
- </tr>
- <tr>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- name = 'col_partnumber',
- type = 'checkbox',
- value = 'Y',
- label = text('Part Number'), # '
- checked = 'checked',
- } -?>
- </td>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- name = 'col_description',
- type = 'checkbox',
- value = 'Y',
- label = text('Description'),
- checked = 'checked',
- } -?>
- </td>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- name = 'col_sellprice',
- type = 'checkbox',
- value = 'Y',
- label = text('Sell Price'), # '
- checked = 'checked',
- } -?>
- </td>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- name = 'col_curr',
- type = 'checkbox',
- value = 'Y',
- label = text('Currency'),
- } -?>
- </td>
- </tr>
- <tr>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- name = 'col_qty',
- type = 'checkbox',
- value = 'Y',
- label = text('Qty'),
- } -?>
- </td>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- name = 'col_unit',
- type = 'checkbox',
- value = 'Y',
- label = text('Unit'),
- } -?>
- </td>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- name = 'col_discount',
- type = 'checkbox',
- value = 'Y',
- label = text('Discount'),
- } -?>
- </td>
- </tr>
- <tr>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- name = 'col_deliverydate',
- type = 'checkbox',
- value = 'Y',
- label = text('Delivery Date'), # '
- } -?>
- </td>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- name = 'col_projectnumber',
- type = 'checkbox',
- value = 'Y',
- label = text('Project Number'), # '
- } -?>
- </td>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- name = 'col_serialnumber',
- type = 'checkbox',
- value = 'Y',
- label = text('Serial Number'), # '
- } -?>
- </td>
- </tr>
- </table>
- </td>
- </tr>
-<?lsmb ELSIF target == 'list_names' ?>
- <tr>
- <td />
- <td>
- <?lsmb INCLUDE input element_data={name = 'status', type = 'radio', value = 'all', label = text('All'), checked = 'checked'} -?>
- <?lsmb INCLUDE input element_data={name = 'status', type = 'radio', value = 'active', label = text('Active')} -?>
- <?lsmb INCLUDE input element_data={name = 'status', type = 'radio', value = 'inactive', label = text('Inactive')} -?>
- <?lsmb INCLUDE input element_data={name = 'status', type = 'radio', value = 'orphaned', label = text('Orphaned')} -?>
- </td>
- </tr>
- <tr>
- <td />
- <td>
- <table>
- <tr>
- <td>
- <table>
- <tr>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- name = 'col_transnumber',
- type = 'checkbox',
- value = 'Y',
- label = form.translabel,
- } -?>
- </td>
- </tr>
- <tr>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- name = 'col_invnumber',
- type = 'checkbox',
- value = 'Y',
- label = form.invlabel,
- } -?>
- </td>
- </tr>
- <tr>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- name = 'col_ordnumber',
- type = 'checkbox',
- value = 'Y',
- label = form.ordlabel,
- } -?>
- </td>
- </tr>
- <tr>
- <td align="right">
- <?lsmb INCLUDE input element_data={
- name = 'col_quonumber',
- type = 'checkbox',
- value = 'Y',
- label = form.quolabel,
- } -?>
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table>
- <tr>
- <th><?lsmb text('From') ?></th>
- <td>
- <?lsmb INCLUDE input element_data={
- name = 'transdatefrom',
- class = 'date'
- size = '11',
- title = user.dateformat,
- } -?>
- </td>
- <th><?lsmb text('To') ?></th>
- <td>
- <?lsmb INCLUDE input element_data={
- name = 'transdateto',
- class = 'date'
- size = '11',
- title = user.dateformat,
- } -?>
- </td>
- </tr>
- <tr>
- <td />
- <td colspan="3">
- <?lsmb INCLUDE input element_data={
- name = 'open',
- type = 'checkbox',
- value = 'Y',
- label = text('Open'),
- checked = 'checked'
- } -?>
- <?lsmb INCLUDE input element_data={
- name = 'closed',
- type = 'checkbox',
- value = 'Y',
- label = text('Closed'),
- } -?>
- </td>
- </tr>
- <tr>
- <td />
- <td colspan="3">
- <?lsmb INCLUDE input element_data={
- name = 'col_amount',
- type = 'checkbox',
- value = 'Y',
- label = text('Amount'),
- checked = 'checked'
- } -?>
- <?lsmb INCLUDE input element_data={
- name = 'col_tax',
- type = 'checkbox',
- value = 'Y',
- label = text('Tax'),
- checked = 'checked'
- } -?>
- <?lsmb INCLUDE input element_data={
- name = 'col_total',
- type = 'checkbox',
- value = 'Y',
- label = text('Total'),
- checked = 'checked'
- } -?>
- <?lsmb INCLUDE input element_data={
- name = 'col_subtotal',
- type = 'checkbox',
- value = 'Y',
- label = text('Subtotal'),
- } -?>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <th align="right"><?lsmb text('Include in Report') ?></th>
- <td>
- <table>
- <?lsmb FOREACH line IN form.includes -?>
- <tr>
- <?lsmb FOREACH item IN line -?>
- <td align="right">
- <?lsmb INCLUDE input element_data=item -?>
- </td>
- <?lsmb END -?>
- </tr>
- <?lsmb END -?>
- </table>
- </td>
- </tr>
-<?lsmb END ?>
- </table>
- </td>
- </tr>
- <tr>
<td><hr size="3" noshade="noshade" /></td>
</tr>
</table>
2  bin/aa.pl
View
@@ -1013,7 +1013,7 @@ sub form_footer {
ndx => 3,
key => 'O',
value => $locale->text('Post as Saved') };
- if (grep /^lsmb_$form->{company}__draft_modify$/, @{$form->{_roles}}){
+ if (grep /^lsmb_$form->{company}__draft_edit$/, @{$form->{_roles}}){
$button{edit_and_approve} = {
ndx => 4,
key => 'E',
5 bin/am.pl
View
@@ -38,6 +38,7 @@
use LedgerSMB::RP;
use LedgerSMB::GL;
use LedgerSMB::Template;
+use LedgerSMB::Sysconfig;
1;
@@ -962,7 +963,7 @@ sub yes_delete_language {
sub display_stylesheet {
- $form->{file} = "css/$myconfig{stylesheet}";
+ $form->{file} = "$LedgerSMB::Sysconfig::fs_cssdir/$myconfig{stylesheet}";
&display_form;
}
@@ -1405,7 +1406,7 @@ sub config {
};
}
- opendir CSS, "css/.";
+ opendir CSS, $LedgerSMB::Sysconfig::fs_cssdir;
@all = grep /.*\.css$/, readdir CSS;
closedir CSS;
7 ledgersmb.conf.default
View
@@ -4,8 +4,15 @@ logging = 0
#Be aware of tempdir setting.If client_browser and server_apache on same machine, sharing tmp-dir , problems 'Permission denied' if server tries to write temp-file wich already exists as client-owned
tempdir = /tmp/ledgersmb
+# This is the logical CSS directory. I.e. it is what comes before the
+# ledgersmb.css in the url. Example might be /my_css_dir/ or
+# http://localhost/other_css_dir/
cssdir = css/
+# THis is the location on the file system where the css files are, for editing
+# and selection. An example might be /var/www/ledgersmb_css/
+fs_cssdir = css/
+
# Set language for login and admin pages
language =
4 sql/modules/Voucher.sql
View
@@ -122,7 +122,7 @@ BEGIN
END;
$$ language plpgsql;
-COMMENT ON FUNCTION voucher_list (in_batch_id integer) IS
+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 (
@@ -138,7 +138,7 @@ CREATE TYPE batch_list_item AS (
);
CREATE OR REPLACE FUNCTION
-batch_search(in_class_id int, in_description text, in_created_by_eid int,
+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)
Please sign in to comment.
Something went wrong with that request. Please try again.