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

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



Revision: 2890
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2890&view=rev
Author:   einhverfr
Date:     2010-02-12 05:20:26 +0000 (Fri, 12 Feb 2010)

Log Message:
-----------
corrected dispatching to new invoice/order/quotation routines

Modified Paths:
--------------
    trunk/CONTRIBUTORS
    trunk/LedgerSMB/Initiate.pm
    trunk/LedgerSMB/ScriptLib/Company.pm

Modified: trunk/CONTRIBUTORS
===================================================================
--- trunk/CONTRIBUTORS	2010-02-12 04:32:16 UTC (rev 2889)
+++ trunk/CONTRIBUTORS	2010-02-12 05:20:26 UTC (rev 2890)
@@ -79,6 +79,8 @@
 Josh Berkus <josh @ agliodbs.com> has helped provide assistance in promotion,
 advocacy, and other assistance.
 
+Ian Goodacre [email omitted] has provided numerous bugfixes.
+
 Original Authors of SQL-Ledger:
 ===================================
 Dieter Simader <dsimader @ sql-ledger.com>

Modified: trunk/LedgerSMB/Initiate.pm
===================================================================
--- trunk/LedgerSMB/Initiate.pm	2010-02-12 04:32:16 UTC (rev 2889)
+++ trunk/LedgerSMB/Initiate.pm	2010-02-12 05:20:26 UTC (rev 2890)
@@ -54,10 +54,7 @@
 
       if(scalar($self->{initiateon})==1)
       {
-          if (!$form->{company}){
-               $form->{company} = 'template1';
-          }
-          $form->{company}=${LedgerSMB::Sysconfig::default_db};
+          $form->{company}= 'template1';
 	  $form->{port}=${LedgerSMB::Sysconfig::port};
           $form->{host}=${LedgerSMB::Sysconfig::host};
 

Modified: trunk/LedgerSMB/ScriptLib/Company.pm
===================================================================
--- trunk/LedgerSMB/ScriptLib/Company.pm	2010-02-12 04:32:16 UTC (rev 2889)
+++ trunk/LedgerSMB/ScriptLib/Company.pm	2010-02-12 05:20:26 UTC (rev 2890)
@@ -44,6 +44,92 @@
        "directly!");
 }
 
+sub dispatch_legacy {
+    our ($request) = shift @_;
+    use LedgerSMB::Form;
+    my $aa;
+    my $inv;
+    my $otype;
+    my $qtype;
+    my $cv;
+    if ($request->{account_class} == 1){
+       $aa = 'ap';
+       $inv = 'ir';
+       $otypr = 'purchase_order';
+       $qtype = 'request_quotation';
+       $cv = 'vendor';
+    } elsif ($request->{account_class} == 2){
+       $aa = 'ar';
+       $inv = 'is';
+       $otypr = 'sales_order';
+       $qtype = 'sales_quotation';
+       $cv = 'customer';
+    } else {
+       $request->error($request->{_locale}->text('Unsupport account type'));
+    }
+    our $dispatch = 
+    {
+        add_transaction  => {script => "bin/$aa.pl", 
+                               data => {"${cv}_id" => $request->{credit_id}},
+                            },
+        add_invoice      => {script => "bin/$inv.pl",
+                               data => {"${cv}_id" => $request->{credit_id}},
+                            },
+        add_order        => {script => 'bin/oe.pl', 
+                               data => {"${cv}_id" => $request->{credit_id},
+                                            type   => $otype,
+                                               vc  => $cv,
+                                       },
+                            },
+        rfq              => {script => 'bin/oe.pl', 
+                               data => {"${cv}_id" => $request->{credit_id},
+                                            type   => $qtype,
+                                               vc  => $cv,
+                                       },
+                            },
+ 
+    };
+
+    our $form = new Form;
+    our %myconfig = ();
+    %myconfig = %{$request->{_user}};
+    $form->{stylesheet} = $myconfig{stylesheet};
+    our $locale = $request->{_locale};
+
+    for (keys %{$dispatch->{$request->{action}}->{data}}){
+        $form->{$_} = $dispatch->{$request->{action}}->{data}->{$_};
+    }
+
+    my $script = $dispatch->{$request->{action}}{script};
+    $form->{script} = $script;
+    $form->{action} = 'add';
+    $form->{dbh} = $request->{dbh};
+    $form->{script} =~ s|.*/||;
+    { no strict; no warnings 'redefine'; do $script; }
+
+    $form->{action}();
+}
+
+sub add_transaction {
+    my $request = shift @_;
+    dispatch_legacy($request);
+}
+
+sub add_invoice {
+    my $request = shift @_;
+    dispatch_legacy($request);
+}
+
+sub add_order {
+    my $request = shift @_;
+    dispatch_legacy($request);
+}
+
+sub rfq {
+    my $request = shift @_;
+    dispatch_legacy($request);
+}
+
 =pod
 
 =over


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