diff options
-rwxr-xr-x | LedgerSMB.pm | 2 | ||||
-rw-r--r-- | LedgerSMB/Batch.pm | 3 | ||||
-rw-r--r-- | LedgerSMB/DBObject.pm | 14 | ||||
-rw-r--r-- | LedgerSMB/Form.pm | 2 | ||||
-rw-r--r-- | LedgerSMB/GL.pm | 18 | ||||
-rw-r--r-- | UI/create_batch.html | 2 | ||||
-rw-r--r-- | bin/aa.pl | 8 | ||||
-rw-r--r-- | bin/gl.pl | 6 | ||||
-rw-r--r-- | scripts/vouchers.pl | 18 | ||||
-rw-r--r-- | sql/modules/Voucher.sql | 2 |
10 files changed, 47 insertions, 28 deletions
diff --git a/LedgerSMB.pm b/LedgerSMB.pm index 9ca12b2f..99a3d994 100755 --- a/LedgerSMB.pm +++ b/LedgerSMB.pm @@ -535,7 +535,7 @@ sub call_procedure { my @results; $procname = $self->{dbh}->quote_identifier($procname); - + print STDERR join(':', @call_args) . "\n"; for ( 1 .. scalar @call_args ) { $argstr .= "?, "; } diff --git a/LedgerSMB/Batch.pm b/LedgerSMB/Batch.pm index 1e6b320e..19cb656e 100644 --- a/LedgerSMB/Batch.pm +++ b/LedgerSMB/Batch.pm @@ -6,7 +6,8 @@ use base qw(LedgerSMB::DBObject); sub create { $self = shift @_; my ($ref) = $self->exec_method(funcname => 'batch_create'); - $self->{id} = $ref->{id} + print STDERR "$ref, $ref->{batch_create}, " . join (':', keys %$ref); + $self->{id} = $ref->{batch_create}; return $ref->{id}; } diff --git a/LedgerSMB/DBObject.pm b/LedgerSMB/DBObject.pm index 93fc4f6e..4c96c82e 100644 --- a/LedgerSMB/DBObject.pm +++ b/LedgerSMB/DBObject.pm @@ -128,13 +128,13 @@ sub exec_method { my $m_name = $ref->{proname}; -# if ($args) { -# for my $arg (@proc_args) { -# if ( $arg =~ s/^in_// ) { - # push @call_args, $arg; -# } -# } -# } + if ($args) { + for my $arg (@proc_args) { + if ( $arg =~ s/^in_// ) { + push @call_args, $self->{$arg}; + } + } + } for (@in_args) { push @call_args, $_ } ; $self->{call_args} = \@call_args; diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index e5a8c9e4..5cc3b258 100644 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -2299,7 +2299,7 @@ sub create_links { } $sth->finish; } - if (!$self->{id}){ + if (!$self->{id} && !$self->{transdate}){ $self->{transdate} = $self->{current_date}; } diff --git a/LedgerSMB/GL.pm b/LedgerSMB/GL.pm index 834bf8f0..7e4f8cc8 100644 --- a/LedgerSMB/GL.pm +++ b/LedgerSMB/GL.pm @@ -130,22 +130,24 @@ sub post_transaction { WHERE id = ?|; if (defined $form->{approved}) { - - $query = qq| UPDATE gl SET approved = ? WHERE id = ?|; + my $query = qq| UPDATE gl SET approved = ? WHERE id = ?|; $dbh->prepare($query)->execute($form->{approved}, $form->{id}) || $form->dberror($query); if (!$form->{approved}){ if (not defined $form->{batch_id}){ $form->error($locale->text('Batch ID Missing')); } - $query = qq| - INSERT INTO voucher (batch_id, trans_id) VALUES (?, ?)|; - $sth = $dbh->prepare($query); - $sth->execute($form->{batch_id}, $form->{id}) || + my $query = qq| + INSERT INTO voucher (batch_id, trans_id, batch_class) + VALUES (?, ?, (select id FROM batch_class + WHERE class = ?))|; + my $sth2 = $dbh->prepare($query); + $sth2->execute($form->{batch_id}, $form->{id}, 'gl') || $form->dberror($query); } } $sth = $dbh->prepare($query); + print STDERR $query; $sth->execute( $form->{transdate}, $department_id, $form->{id} ) || $form->dberror($query); @@ -570,7 +572,9 @@ sub transaction { my $results = $sth->fetchall_hashref('setting_key'); $form->{closedto} = $results->{'closedto'}->{'value'}; $form->{revtrans} = $results->{'revtrans'}->{'value'}; - $form->{transdate} = $results->{'revtrans'}->{'transdate'}; + if (!$form->{transdate}){ + $form->{transdate} = $results->{'revtrans'}->{'transdate'}; + } } $sth->finish; diff --git a/UI/create_batch.html b/UI/create_batch.html index 4b507f17..cb01d62b 100644 --- a/UI/create_batch.html +++ b/UI/create_batch.html @@ -21,7 +21,7 @@ <?lsmb text("Batch Number") ?> </div> <div class="value"> - <input name="batchnumber" type="text" value="<?lsmb batchnumber ?>"/> + <input name="batch_number" type="text" value="<?lsmb batch_number ?>"/> </div> <div class="labelledinput"> <div class="label"> @@ -541,10 +541,12 @@ qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|; <input type=hidden name=title value="$title"> |; - + if (!defined $form->{approved}){ + $form->{approved} = 1; + } $form->hide_form( - qw(id printed emailed sort closedto locked oldtransdate audittrail - recurring checktax reverse batch_id subtype) + qw(batch_id approved id printed emailed sort closedto locked + oldtransdate audittrail recurring checktax reverse batch_id subtype) ); if ( $form->{vc} eq 'customer' ) { @@ -1103,6 +1103,9 @@ qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|; else { $notes = qq|<input name=notes size=50 value="$form->{notes}">|; } + if (!defined $form->{approved}){ + $form->{approved} = '1'; + } $department = qq| <tr> @@ -1131,10 +1134,11 @@ qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|; <body onload="document.forms[0].${focus}.focus()" /> <form method=post action=$form->{script}> + <input type="hidden" name="approved" value="$form->{approved}" /> |; $form->hide_form( - qw(id transfer selectaccno closedto locked oldtransdate recurring)); + qw(batch_id id transfer selectaccno closedto locked oldtransdate recurring)); print qq| <input type=hidden name=title value="$title"> diff --git a/scripts/vouchers.pl b/scripts/vouchers.pl index 7e131bc2..e264ed8a 100644 --- a/scripts/vouchers.pl +++ b/scripts/vouchers.pl @@ -37,6 +37,7 @@ sub create_vouchers { use LedgerSMB::Form; my $batch = LedgerSMB::Batch->new({base => $request}); + $batch->{batch_class} = $request->{batch_type}; $batch->create; my $vouchers_dispatch = @@ -49,29 +50,36 @@ sub create_vouchers { }; # Note that the line below is generally considered incredibly bad form. - # However, the code we are including is going to require it for now. - no strict; + # However, the code we are including is going to require it for now. -- CT our $form = new Form; our $locale = $request->{_locale}; + for (keys %$request){ $form->{$_} = $request->{$_}; } + $form->{batch_id} = $batch->{id}; $form->{approved} = 0; $form->{transdate} = $request->{batch_date}; - print STDERR "$request->{batch_type}\n"; - require $vouchers_dispatch->{$request->{batch_type}}{script}; + my $script = $vouchers_dispatch->{$request->{batch_type}}{script}; + { no strict; no warnings 'redefine'; do $script; } + $script =~ s|.*/||; $form->{script} = $script; + $vouchers_dispatch->{$request->{batch_type}}{function}(); +} -\ $vouchers_dispatch->{$request->{batch_type}}{function}(); +sub get_batch { } sub list_vouchers { } +sub add_vouchers { +} + sub approve_batch { } diff --git a/sql/modules/Voucher.sql b/sql/modules/Voucher.sql index d626595f..c21105c4 100644 --- a/sql/modules/Voucher.sql +++ b/sql/modules/Voucher.sql @@ -276,7 +276,7 @@ BEGIN batch (batch_class_id, description, control_code, created_by) VALUES ((SELECT id FROM batch_class WHERE class = in_batch_class), in_description, in_batch_number, - (select id FROM users WHERE username = session_user)); + (select entity_id FROM users WHERE username = session_user)); return currval('batch_id_seq'); END; |