summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LedgerSMB/DBObject/Draft.pm11
-rw-r--r--LedgerSMB/Form.pm7
-rw-r--r--LedgerSMB/Sysconfig.pm2
-rw-r--r--bin/aa.pl20
-rw-r--r--scripts/drafts.pl48
-rw-r--r--sql/modules/Drafts.sql16
6 files changed, 67 insertions, 37 deletions
diff --git a/LedgerSMB/DBObject/Draft.pm b/LedgerSMB/DBObject/Draft.pm
index 2aec59a9..b57bd238 100644
--- a/LedgerSMB/DBObject/Draft.pm
+++ b/LedgerSMB/DBObject/Draft.pm
@@ -4,24 +4,27 @@ use base qw/LedgerSMB::DBObject/;
sub search {
my ($self) = @_;
- @{$self->{draft_results} = $self->exec_method(funcname => 'draft__search');
- return @{$self->{draft_results};
+ @{$self->{draft_results}} = $self->exec_method(funcname => 'draft__search');
+ return @{$self->{draft_results}};
}
sub approve {
my ($self) = @_;
if (!$self->{id}){
- $self->error($self->{_locale}->text('No ID Set');
+ $self->error($self->{_locale}->text('No ID Set'));
}
($self->{approved}) = $self->exec_method(funcname => 'draft_approve');
+ $self->{dbh}->commit;
return $self->{approved};
}
sub delete {
my ($self) = @_;
if (!$self->{id}){
- $self->error($self->{_locale}->text('No ID Set');
+ $self->error($self->{_locale}->text('No ID Set'));
}
($self->{deleted}) = $self->exec_method(funcname => 'draft_delete');
return $self->{deleted};
}
+
+1;
diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm
index 1d61ac09..ab85c326 100644
--- a/LedgerSMB/Form.pm
+++ b/LedgerSMB/Form.pm
@@ -2241,7 +2241,8 @@ sub create_links {
d.description AS department,
a.amount AS oldinvtotal, a.paid AS oldtotalpaid,
a.person_id, e.name AS employee,
- c.language_code, a.ponumber, a.reverse
+ c.language_code, a.ponumber, a.reverse,
+ a.approved
FROM $arap a
JOIN entity_credit_account c USING (entity_id)
JOIN entity ce ON (ce.id = c.entity_id)
@@ -2258,6 +2259,10 @@ sub create_links {
$ref = $sth->fetchrow_hashref('NAME_lc');
$self->db_parse_numeric(sth=>$sth, hashref=>$ref);
+ if (!defined $ref->{approved}){
+ $ref->{approved} = 0;
+ }
+
foreach $key ( keys %$ref ) {
$self->{$key} = $ref->{$key};
}
diff --git a/LedgerSMB/Sysconfig.pm b/LedgerSMB/Sysconfig.pm
index 1d93ce8f..4b50ab75 100644
--- a/LedgerSMB/Sysconfig.pm
+++ b/LedgerSMB/Sysconfig.pm
@@ -83,7 +83,7 @@ read_config( 'ledgersmb.conf' => %config ) or die;
# Root variables
for $var (
qw(pathsep logging check_max_invoices language auth latex
- db_autoupdate force_username_case)
+ db_autoupdate force_username_case max_post_size)
)
{
${$var} = $config{''}{$var} if $config{''}{$var};
diff --git a/bin/aa.pl b/bin/aa.pl
index 9d4d5ed1..e9f827df 100644
--- a/bin/aa.pl
+++ b/bin/aa.pl
@@ -843,7 +843,6 @@ qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></t
}
sub form_footer {
-
$form->hide_form(qw(callback path login sessionid));
$transdate = $form->datetonum( \%myconfig, $form->{transdate} );
@@ -888,6 +887,13 @@ sub form_footer {
'delete' =>
{ ndx => 8, key => 'D', value => $locale->text('Delete') },
);
+ if (!$form->{approved}){
+ $button{approve} = { ndx => 3, key => 'O', value => $locale->text('Post') };
+ delete $button{post_as_new};
+ delete $button{print_and_post_as_new};
+ delete $button{post};
+ delete $button{print_and_post};
+ }
if ($form->{separate_duties}){
$button{post}->{value} = $locale->text('Save');
@@ -943,6 +949,18 @@ sub form_footer {
}
+sub approve {
+ use LedgerSMB::DBObject::Draft;
+ use LedgerSMB;
+ my $lsmb = LedgerSMB->new();
+ $lsmb->merge($form);
+
+ my $draft = LedgerSMB::DBObject::Draft->new({base => $lsmb});
+
+ $draft->approve();
+ $form->info($locale->text('Draft Posted'));
+}
+
sub update {
my $display = shift;
$is_update = 1;
diff --git a/scripts/drafts.pl b/scripts/drafts.pl
index 741b5fed..e38b434c 100644
--- a/scripts/drafts.pl
+++ b/scripts/drafts.pl
@@ -1,5 +1,5 @@
-package LedgerSMB::Scripts::vouchers;
+package LedgerSMB::Scripts::drafts;
our $VERSION = '0.1';
use LedgerSMB::DBObject::Draft;
@@ -8,6 +8,11 @@ use strict;
sub search {
my ($request) = @_;
+ $request->{class_types} = [
+ {text => $request->{_locale}->text('AR'), value => 'ar'},
+ {text => $request->{_locale}->text('AP'), value => 'ap'},
+ {text => $request->{_locale}->text('GL'), value => 'GL'},
+ ];
my $template = LedgerSMB::Template->new(
user =>$request->{_user},
locale => $request->{_locale},
@@ -20,12 +25,12 @@ sub search {
sub list_drafts {
my ($request) = @_;
- my $draft= LedgerSMB::Draft->new(base => $request);
+ my $draft= LedgerSMB::DBObject::Draft->new(base => $request);
my @search_results = $draft->search;
$draft->{script} = "drafts.pl";
my @columns =
- qw(select id transdate reference description, amount);
+ qw(select id transdate reference description amount);
my $base_href = "drafts.pl";
my $search_href = "$base_href?action=list_transactions";
@@ -39,25 +44,25 @@ sub list_drafts {
my %column_heading = (
'select' => $draft->{_locale}->text('Select'),
- transaction_total => {
+ amount => {
text => $draft->{_locale}->text('AR/AP/GL Total'),
href => "$search_href&order_by=transaction_total"
},
- payment_total => {
- text => $draft->{_locale}->text('Paid/Received Total'),
- href => "$search_href&order_by=payment_total"
- },
description => {
text => $draft->{_locale}->text('Description'),
href => "$search_href&order_by=description"
},
- control_code => {
- text => $draft->{_locale}->text('Batch Number'),
- href => "$search_href&order_by=control_code"
- },
id => {
text => $draft->{_locale}->text('ID'),
- href => "$search_href&order_by=control_code"
+ href => "$search_href&order_by=id"
+ },
+ reference => {
+ text => $draft->{_locale}->text('Reference'),
+ href => "$search_href&order_by=reference"
+ },
+ transdate => {
+ text => $draft->{_locale}->text('Date'),
+ href => "$search_href&order_by=transdate"
},
);
my $count = 0;
@@ -73,18 +78,15 @@ sub list_drafts {
name => "draft_$result->{id}"
}
},
- transaction_total => $draft->format_amount(
- amount => $result->{transaction_total}
+ amount => $draft->format_amount(
+ amount => $result->{amount}
),
- payment_total => $draft->format_amount (
- amount => $result->{payment_total}
- ),
- description => $result->{description},
- control_code => {
- text => $result->{control_code},
- href => "$draft_href&draft_id=$result->{id}",
-
+ reference => {
+ text => $result->{reference},
+ href => "$request->{type}.pl?action=edit&id=$result->{id}",
},
+ description => $result->{description},
+ transdate => $result->{transdate},
id => $result->{id},
};
}
diff --git a/sql/modules/Drafts.sql b/sql/modules/Drafts.sql
index c2fc5abb..9e8a95c2 100644
--- a/sql/modules/Drafts.sql
+++ b/sql/modules/Drafts.sql
@@ -24,17 +24,19 @@ BEGIN
ELSE 0
END) as amount
FROM (
+ SELECT id, transdate, reference, description,
+ approved from gl
+ WHERE in_type = 'gl'
+ UNION
SELECT id, transdate, invnumber as reference,
- description, approved from ap
+ description::text,
+ approved from ap
WHERE in_type = 'ap'
UNION
SELECT id, transdate, invnumber as reference,
- description, approved from ar
+ description,
+ approved from ar
WHERE in_type = 'ar'
- UNION
- SELECT id, transdate, reference, description,
- approved from gl
- WHERE in_type = 'gl'
) trans
JOIN acc_trans line ON (trans.id = line.trans_id)
JOIN chart ON (line.chart_id = chart.id)
@@ -43,7 +45,7 @@ BEGIN
or trans.transdate <= in_to_date)
AND trans.approved IS FALSE
AND trans.id NOT IN (select trans_id from voucher)
- GROUP BY trans.id, trans.transdate, trans.description
+ GROUP BY trans.id, trans.transdate, trans.description, trans.reference
HAVING (in_with_accno IS NULL or in_with_accno =
ANY(as_array(chart.accno)))
LOOP