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

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



Revision: 5292
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5292&view=rev
Author:   einhverfr
Date:     2012-11-30 06:59:19 +0000 (Fri, 30 Nov 2012)
Log Message:
-----------
merging from branches/1.3

Modified Paths:
--------------
    trunk/Changelog
    trunk/LedgerSMB/AA.pm
    trunk/LedgerSMB.pm
    trunk/bin/io.pl
    trunk/tools/prepare-company-database.sh

Added Paths:
-----------
    trunk/tools/prepare-company-database.pl

Property Changed:
----------------
    trunk/


Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3:3711-5279
   + /branches/1.3:3711-5291

Modified: trunk/Changelog
===================================================================
--- trunk/Changelog	2012-11-29 21:18:08 UTC (rev 5291)
+++ trunk/Changelog	2012-11-30 06:59:19 UTC (rev 5292)
@@ -93,9 +93,13 @@
 * Fixed internal server errors retrieving taxes with invalid dates (Chris T)
 * Fixed taxform "default reportable" checkbox not persisted (Chris T, 3581310)
 * Fixed labelling of vendor column on taxform reports (Chris T, 3581317)
+* Fixed terms of sales/purchase order not respected (Chris T, 3581337)
+* Added Perl equivalent to prepare-company-database.sh (Chris T, 3551127)
+* Fixed prepare-company-database.sh, test getopt version. (Havard S, 3551127)
 
 Chris T is Chris Travers
 Kevin B is Kevin Bailey
+Havard S is Havard Sorli
 
 Changelog for 1.3.24
 * Fixed error in msgid for "Add Language" (Havard S, h/t Robert C)

Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm	2012-11-29 21:18:08 UTC (rev 5291)
+++ trunk/LedgerSMB/AA.pm	2012-11-30 06:59:19 UTC (rev 5292)
@@ -825,6 +825,7 @@
       : "current_date + c.terms";
 
     $form->{"$form->{vc}_id"} *= 1;
+    
 
     # get customer/vendor
     my $query = qq|
@@ -854,6 +855,7 @@
             delete $ref->{$_};
         }
     }
+    delete $ref->{duedate} if $form->{duedate};
 
     for ( keys %$ref ) { $form->{$_} = $ref->{$_} }
     $sth->finish;

Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm	2012-11-29 21:18:08 UTC (rev 5291)
+++ trunk/LedgerSMB.pm	2012-11-30 06:59:19 UTC (rev 5292)
@@ -234,7 +234,6 @@
 
     $type = "" unless defined $type;
     $argstr = "" unless defined $argstr;
-warn 'breakpoint:' . __LINE__;
 
     $logger->debug("Begin called from \$filename=$filename \$line=$line \$type=$type \$argstr=$argstr ref argstr=".ref $argstr);
 

Modified: trunk/bin/io.pl
===================================================================
--- trunk/bin/io.pl	2012-11-29 21:18:08 UTC (rev 5291)
+++ trunk/bin/io.pl	2012-11-30 06:59:19 UTC (rev 5292)
@@ -860,7 +860,6 @@
 }
 
 sub display_form {
-
     $form->close_form();
     $form->open_form();
     $form->{dbh}->commit;

Copied: trunk/tools/prepare-company-database.pl (from rev 5291, branches/1.3/tools/prepare-company-database.pl)
===================================================================
--- trunk/tools/prepare-company-database.pl	                        (rev 0)
+++ trunk/tools/prepare-company-database.pl	2012-11-30 06:59:19 UTC (rev 5292)
@@ -0,0 +1,204 @@
+#!/usr/bin/perl
+# Copyright (c) 2012, The LedgerSMB Core Team
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met: 
+#
+# Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer. 
+#
+# Redistributions in binary form must reproduce the above copyright notice, this
+# list of conditions and the following disclaimer in the documentation and/or
+# other materials provided with the distribution. 
+#
+# THIS SOFTWARE IS PROVIDED BY THE LEDGERSMB CORE TEAM AND CONTRIBUTORS "AS
+# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL LEDGERSMB CORE TEAM OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# This is the prepare-company-database.pl which serves as a command line tool
+# for creating LedgerSMB databases and also as a reference implementation to 
+# demonstrate the usage of the LedgerSMB::Database framework.
+#
+# 
+use Getopt::Long;
+use LedgerSMB::Database;
+use Cwd;
+
+# Needed for creating a user
+
+use LedgerSMB;
+use LedgerSMB::DBObject::Admin;
+use DBI;
+
+# always use strict!
+use strict;
+
+# DEFAULTS TO BE EDITED
+
+my $ADMIN_FIRSTNAME='Default';
+my $ADMIN_MIDDLENAME=undef;
+my $ADMIN_LASTNAME='Admin';
+my $ADMIN_USERNAME='admin';
+my $ADMIN_PASSWORD='admin';
+
+# Defaults for command line
+
+my $company=undef;
+my $owner='ledgersmb';
+my $pass='LEDGERSMBINITIAL';
+my $host='localhost';
+my $port=5432;
+my $srcdir=getcwd;
+my $dstdir=getcwd;
+my $cc = 'us';
+my $coa="$srcdir/sql/coa/us/chart/General.sql";
+my $gifi=undef;
+my $pgsql_contrib_dir='ignore';
+my $progress=0;
+my $help=0;
+
+my $script_name = 'tools/prepare-company-database.pl';
+
+my $usage = qq|
+usage: $script_name --company COMPANY --pgsql-contrib DIR [option1 .. optionN]
+
+This script wants to be run as the root user. If you don't, you'll be
+asked to enter the password of the 'postgres' user
+
+This script creates a 'ledgersmb' user on the specified PostgreSQL host,
+if it does not exist.  Then it proceeds to load the LedgerSMB database
+structure and content, loading Chart of Accounts data and GIFI data
+as specified in the argument list.
+
+After the database has been created, the script inserts a default user
+'$ADMIN_USERNAME' (password: '$ADMIN_PASSWORD'), with these initial values:
+
+First name:  $ADMIN_FIRSTNAME  (NULL == none)
+Middle name: $ADMIN_MIDDLENAME (NULL == none)
+Last name:   $ADMIN_LASTNAME   (NULL == none)
+Country:     'US'
+
+This default user will be assigned all privileges within the application.
+
+Available options:
+ --srcdir	The path where the sources for LedgerSMB are located
+                [$srcdir]
+ --dstdir	The path where the sources will be located when invoked
+		from the webserver [$dstdir]
+ --host		The PostgreSQL host to connect to (see 'man psql') [$host]
+ --port		The PostgreSQL port to connect to (see 'man psql') [$port]
+ --pgsql-contrib The directory where the tsearch2.sql, pg_trgm.sql and
+                tablefunc.sql PostgeSQL are located [$pgsql_contrib_dir] [*]
+ --company	The name of the database to be created for the company [*]
+ --owner	The name of the superuser which is to become owner of the
+		company's database [$owner]
+ --password	The password to be used to create the 'ledgersmb' user
+		on the specified PostgreSQL server [$pass]
+ --cc           The two letter country code to use [$cc]
+ --coa		The chart of accounts file to load [$coa]
+ --gifi		The GIFI file to load if any [$gifi]
+ --help		Shows this help screen
+
+ * These arguments don't have a default, but are required
+|;
+
+
+GetOptions(
+   'srcdir=s'        => \$srcdir,
+   'dstdir=s'        => \$dstdir,
+   'port=s'          => \$port,
+   'host=s'          => \$host,
+   'pgsql-contrib=s' => \$pgsql_contrib_dir,
+   'company=s'       => \$company,
+   'owner=s'         => \$owner,
+   'password=s'      => \$pass,
+   'cc=s'            => \$cc,
+   'coa=s'           => \$coa,
+   'gifi=s'          => \$gifi,
+   'help'            => \$help
+);
+
+&usage if $help;
+
+# Setting up the environment here in case at some point we want to expand to
+# call libpq programs directly.  It also makes the script more future proof in
+# other ways.  Note that PG_CONTRIB_DIR is not really needed in Pg 9.1 and later
+# and is a LedgerSMB-ism.
+#
+$ENV{PG_CONTRIB_DIR} = $pgsql_contrib_dir if $pgsql_contrib_dir;
+$ENV{PGUSER} = $owner if $owner;
+$ENV{PGPASS} = $pass if $pass;
+$ENV{PGDATABASE} = $company if $company;
+$ENV{PGHOST} = $host if $host;
+$ENV{PGPORT} = $port if $port;
+
+my $database = LedgerSMB::Database->new(
+        {dbname => $company, 
+    countrycode => $cc, 
+     chart_name => $coa, 
+   company_name => $company, 
+       username => $owner, 
+       password => $pass}
+);
+
+# Creating the actual database and loading it.  Note that process_roles is 
+# currently a separate call.  If you don't do that then permissions are never 
+# set up and therefore creating a user and assigning roles become futile 
+# endeavors
+
+$database->create_and_load();
+$database->process_roles();
+
+
+# CREATING THE USER
+#
+# This is a little tricky because we have to actually manually create a database
+# connection.  In the future we may want to have such a database connection 
+# returned by LedgerSMB::Database, but that is not done yet.
+
+my $lsmb = LedgerSMB->new() || die 'could not create new LedgerSMB object';
+$lsmb->{dbh} = DBI->connect("dbi:Pg:dbname=$ENV{PGDATABASE}",
+                                       undef, undef, { AutoCommit => 0 });
+
+# We also have to retrieve the country ID which requires a database query
+
+my $sth = $lsmb->{dbh}->prepare(
+            'SELECT id FROM country WHERE short_name ILIKE ?'
+);
+
+$sth->execute($cc);
+my ($country_id) = $sth->fetchrow_array;
+
+# In 1.3 it is not possible really to directly invoke a new object like a new
+# user.  This is changing for some things in 1.4 so keep in mind this may change
+# to be easier to use.    However for now, this is the way it will need to be 
+# done.
+
+$lsmb->merge({
+     username    => $ADMIN_USERNAME,
+     password    => $ADMIN_PASSWORD,
+     first_name  => $ADMIN_FIRSTNAME,
+     last_name   => $ADMIN_LASTNAME,
+     middle_name => $ADMIN_MIDDLENAME,
+     country_id  => $country_id,
+     import      => 't',
+});
+
+my $user = LedgerSMB::DBObject::Admin->new({base => $lsmb});
+
+$user->save_user;
+
+# SUBS
+#
+# usage:  Print the usage message and exit.
+#
+sub usage { print $usage; exit; }

Modified: trunk/tools/prepare-company-database.sh
===================================================================
--- trunk/tools/prepare-company-database.sh	2012-11-29 21:18:08 UTC (rev 5291)
+++ trunk/tools/prepare-company-database.sh	2012-11-30 06:59:19 UTC (rev 5292)
@@ -1,6 +1,34 @@
 #!/bin/sh
 
-# Script to explain the steps to take when installing LedgerSMB
+# Copyright (c) 2012, The LedgerSMB Core Team
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met: 
+#
+# Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer. 
+#
+# Redistributions in binary form must reproduce the above copyright notice, this
+# list of conditions and the following disclaimer in the documentation and/or
+# other materials provided with the distribution. 
+#
+# THIS SOFTWARE IS PROVIDED BY THE LEDGERSMB CORE TEAM AND CONTRIBUTORS "AS
+# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL LEDGERSMB CORE TEAM OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# This is the prepare-company-database.sh which serves as a command line tool
+# for creating LedgerSMB databases and also as a reference implementation to 
+# demonstrate how databases are created.
+#
 
 # Default variable values section
 
@@ -92,6 +120,15 @@
 )/d" -
 }
 
+# Test getopt version. This script use the GNU 'getopt' version.
+getopt -T > /dev/null
+if [ $? -eq 0 ]; then
+    # Original getopt is available
+    echo "This script need the GNU enhanced getopt to work"
+    echo "Use prepare-company-database.pl on your platform"
+    exit 0
+fi
+
 # Am I root?
 if ! test `whoami` = "root"
 then

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