[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[2392] trunk
- Subject: SF.net SVN: ledger-smb:[2392] trunk
- From: ..hidden..
- Date: Thu, 13 Nov 2008 01:15:47 +0000
Revision: 2392
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2392&view=rev
Author: einhverfr
Date: 2008-11-13 01:15:47 +0000 (Thu, 13 Nov 2008)
Log Message:
-----------
Correcting issues with draft editing.
Moving AA::post_transaction to use strict.
Modified Paths:
--------------
trunk/LedgerSMB/AA.pm
trunk/LedgerSMB/DBObject.pm
trunk/LedgerSMB/Form.pm
trunk/LedgerSMB/GL.pm
trunk/bin/aa.pl
trunk/bin/gl.pl
trunk/scripts/drafts.pl
trunk/scripts/vendor.pl
trunk/sql/modules/Roles.sql
Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm 2008-11-12 17:49:51 UTC (rev 2391)
+++ trunk/LedgerSMB/AA.pm 2008-11-13 01:15:47 UTC (rev 2392)
@@ -59,8 +59,15 @@
=cut
sub post_transaction {
+ use strict;
my ( $self, $myconfig, $form ) = @_;
+
+ my $exchangerate;
+ my $batch_class;
+ my %paid;
+ my $paidamount;
+ my @queries;
if ($form->{separate_duties}){
$form->{approved} = '0';
}
@@ -404,7 +411,6 @@
# add individual transactions
foreach $ref ( @{ $form->{acc_trans}{lineitems} } ) {
-
# insert detail records in acc_trans
if ( $ref->{amount} ) {
$query = qq|
Modified: trunk/LedgerSMB/DBObject.pm
===================================================================
--- trunk/LedgerSMB/DBObject.pm 2008-11-12 17:49:51 UTC (rev 2391)
+++ trunk/LedgerSMB/DBObject.pm 2008-11-13 01:15:47 UTC (rev 2392)
@@ -121,7 +121,7 @@
$ref = $sth->fetchrow_hashref('NAME_lc');
- my $args = $ref->{proargnames};
+ my $pargs = $ref->{proargnames};
my @proc_args;
if ( !$ref->{proname} ) { # no such function
@@ -132,7 +132,7 @@
$ref->{pronargs} = 0 unless defined $ref->{pronargs};
# If the user provided args..
if (!defined $args{args}) {
- @proc_args = $self->_parse_array($args);
+ @proc_args = $self->_parse_array($pargs);
if (@proc_args) {
for my $arg (@proc_args) {
if ( $arg =~ s/^in_// ) {
Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm 2008-11-12 17:49:51 UTC (rev 2391)
+++ trunk/LedgerSMB/Form.pm 2008-11-13 01:15:47 UTC (rev 2392)
@@ -536,7 +536,7 @@
my ( $self, $msg ) = @_;
if ( $self->{callback} || !$msg ) {
-
+ print STDERR "Full redirect\n";
main::redirect();
exit;
}
@@ -1189,6 +1189,16 @@
push @{ $self->{custom_db_fields}{ $ref->{extends} } },
$ref->{field_def};
}
+ # Roles tracking
+ $self->{_roles} = [];
+ $query = "select rolname from pg_roles
+ where pg_has_role(SESSION_USER, 'USAGE')";
+ $sth = $dbh->prepare($query);
+ $sth->execute();
+ while (my @roles = $sth->fetchrow_array){
+ push @{$self->{_roles}}, $roles[0];
+ }
+ $sth->finish();
}
=item $form->run_custom_queries($tablename, $query_type[, $linenum]);
Modified: trunk/LedgerSMB/GL.pm
===================================================================
--- trunk/LedgerSMB/GL.pm 2008-11-12 17:49:51 UTC (rev 2391)
+++ trunk/LedgerSMB/GL.pm 2008-11-13 01:15:47 UTC (rev 2392)
@@ -166,7 +166,6 @@
# extract accno
($accno) = split( /--/, $form->{"accno_$i"} );
-
if ($credit) {
$amount = $credit;
$posted = 0;
@@ -564,6 +563,7 @@
my $results = $sth->fetchall_hashref('setting_key');
$form->{closedto} = $results->{'closedto'}->{'value'};
$form->{revtrans} = $results->{'revtrans'}->{'value'};
+ #$form->{separate_duties} = $results->{'separate_duties'}->{'value'};
$sth->finish;
$query = qq|SELECT g.*, d.description AS department
Modified: trunk/bin/aa.pl
===================================================================
--- trunk/bin/aa.pl 2008-11-12 17:49:51 UTC (rev 2391)
+++ trunk/bin/aa.pl 2008-11-13 01:15:47 UTC (rev 2392)
@@ -883,7 +883,16 @@
{ ndx => 8, key => 'D', value => $locale->text('Delete') },
);
if (!$form->{approved} && !$form->{batch_id}){
- $button{approve} = { ndx => 3, key => 'O', value => $locale->text('Post') };
+ $button{approve} = {
+ ndx => 3,
+ key => 'O',
+ value => $locale->text('Post as Saved') };
+ if (grep /^lsmb_$form->{company}__draft_modify$/, @{$form->{_roles}}){
+ $button{edit_and_approve} = {
+ ndx => 4,
+ key => 'O',
+ value => $locale->text('Post as Shown') };
+ }
delete $button{post_as_new};
delete $button{print_and_post_as_new};
delete $button{post};
@@ -942,6 +951,18 @@
}
+sub edit_and_approve {
+ use LedgerSMB::DBObject::Draft;
+ use LedgerSMB;
+ my $lsmb = LedgerSMB->new();
+ $lsmb->merge($form);
+ my $draft = LedgerSMB::DBObject::Draft->new({base => $lsmb});
+ $draft->delete();
+ delete $form->{id};
+ AA->post_transaction( \%myconfig, \%$form );
+ approve();
+}
+
sub approve {
use LedgerSMB::DBObject::Draft;
use LedgerSMB;
@@ -1150,6 +1171,7 @@
if ( $form->{printandpost} ) {
&{"print_$form->{formname}"}( $old_form, 1 );
}
+ print STDERR "Redirecting\n";
$form->redirect( $locale->text('Transaction posted!') );
}
else {
Modified: trunk/bin/gl.pl
===================================================================
--- trunk/bin/gl.pl 2008-11-12 17:49:51 UTC (rev 2391)
+++ trunk/bin/gl.pl 2008-11-13 01:15:47 UTC (rev 2392)
@@ -92,6 +92,39 @@
$form->{accno_3} = $pos_config{'coa_prefix'};
}
+sub edit_and_approve {
+ use LedgerSMB::DBObject::Draft;
+ use LedgerSMB;
+ my $lsmb = LedgerSMB->new();
+ $lsmb->merge($form);
+ my $draft = LedgerSMB::DBObject::Draft->new({base => $lsmb});
+ $draft->delete();
+ GL->post_transaction( \%myconfig, \%$form );
+ approve();
+}
+
+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();
+ if ($form->{callback}){
+ print "Location: $form->{callback}\n";
+ print "Status: 302 Found\n\n";
+ print "<html><body>";
+ my $url = $form->{callback};
+ print qq|If you are not redirected automatically, click <a href="$url">|
+ . qq|here</a>.</body></html>|;
+
+ } else {
+ $form->info($locale->text('Draft Posted'));
+ }
+}
+
sub add_pos_adjust {
$form->{pos_adjust} = 1;
$form->{reference} =
@@ -1283,6 +1316,22 @@
for ( "update", "post", "schedule" ) { $a{$_} = 1 }
}
}
+ if (!$form->{approved} && !$form->{batch_id}){
+ $button{approve} = {
+ ndx => 3,
+ key => 'S',
+ value => $locale->text('Post as Saved') };
+ $a{approve} = 1;
+ $a{edit_and_approve} = 1;
+ if (grep /^lsmb_$form->{company}__draft_modify$/, @{$form->{_roles}}){
+ $button{edit_and_approve} = {
+ ndx => 4,
+ key => 'O',
+ value => $locale->text('Post as Shown') };
+ }
+ delete $button{post_as_new};
+ delete $button{post};
+ }
for ( keys %button ) { delete $button{$_} if !$a{$_} }
for ( sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button )
Modified: trunk/scripts/drafts.pl
===================================================================
--- trunk/scripts/drafts.pl 2008-11-12 17:49:51 UTC (rev 2391)
+++ trunk/scripts/drafts.pl 2008-11-13 01:15:47 UTC (rev 2392)
@@ -11,7 +11,7 @@
$request->{class_types} = [
{text => $request->{_locale}->text('AR'), value => 'ar'},
{text => $request->{_locale}->text('AP'), value => 'ap'},
- {text => $request->{_locale}->text('GL'), value => 'GL'},
+ {text => $request->{_locale}->text('GL'), value => 'gl'},
];
my $template = LedgerSMB::Template->new(
user =>$request->{_user},
Modified: trunk/scripts/vendor.pl
===================================================================
--- trunk/scripts/vendor.pl 2008-11-12 17:49:51 UTC (rev 2391)
+++ trunk/scripts/vendor.pl 2008-11-13 01:15:47 UTC (rev 2392)
@@ -23,7 +23,7 @@
use LedgerSMB::DBObject::Vendor;
use base qw(LedgerSMB::ScriptLib::Company);
-require 'lsmb-request.pl';
+# require 'lsmb-request.pl';
sub set_entity_class {
my ($null, $request) = @_;
Modified: trunk/sql/modules/Roles.sql
===================================================================
--- trunk/sql/modules/Roles.sql 2008-11-12 17:49:51 UTC (rev 2391)
+++ trunk/sql/modules/Roles.sql 2008-11-13 01:15:47 UTC (rev 2392)
@@ -1185,7 +1185,7 @@
CREATE ROLE "lsmb_<?lsmb dbname ?>__edit_business_type"
WITH INHERIT NOLOGIN;
-GRANT UPDATE ON business TO "lsmb_<?lsmb dbname ?>__edit_business_type";
+GRANT UPDATE, DELETE ON business TO "lsmb_<?lsmb dbname ?>__edit_business_type";
INSERT INTO menu_acl (node_id, acl_type, role_name)
values (128, 'allow', 'lsmb_<?lsmb dbname ?>__edit_business_type');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.