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

SF.net SVN: ledger-smb:[3072] addons/1.3/import_trans



Revision: 3072
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3072&view=rev
Author:   einhverfr
Date:     2010-09-28 19:49:17 +0000 (Tue, 28 Sep 2010)

Log Message:
-----------
Correcting a few issues with importing transactions

Modified Paths:
--------------
    addons/1.3/import_trans/trunk/UI/import_trans/import_trans.html
    addons/1.3/import_trans/trunk/scripts/import_trans.pl

Removed Paths:
-------------
    addons/1.3/import_trans/import_trans.pl

Deleted: addons/1.3/import_trans/import_trans.pl
===================================================================
--- addons/1.3/import_trans/import_trans.pl	2010-09-27 15:49:21 UTC (rev 3071)
+++ addons/1.3/import_trans/import_trans.pl	2010-09-28 19:49:17 UTC (rev 3072)
@@ -1,3 +0,0 @@
-#!/usr/bin/perl
-
-require 'lsmb-request.pl';

Modified: addons/1.3/import_trans/trunk/UI/import_trans/import_trans.html
===================================================================
--- addons/1.3/import_trans/trunk/UI/import_trans/import_trans.html	2010-09-27 15:49:21 UTC (rev 3071)
+++ addons/1.3/import_trans/trunk/UI/import_trans/import_trans.html	2010-09-28 19:49:17 UTC (rev 3072)
@@ -7,7 +7,7 @@
 <div class="listtop"><?lsmb title ?></div>
 <div class="info"><?lsmb info ?></div>
 <form action="<?lsmb script ?>" method="post" enctype="multipart/form-data">
-<?lsmb IF !multiple ?>
+<?lsmb IF !multi ?>
 <div class="inputrow" id = "referencerow">
 <?lsmb PROCESS input element_data = {
     type  = "text"
@@ -17,6 +17,12 @@
     value = reference
     size  = 15
 } ?>
+<?lsmb PROCESS input element_data = {
+    type = "hidden"
+    class = "hidden"
+    name = "type"
+    value = type
+} ?>
 </div>
 <div class="inputrow" id = "descriptionrow">
 <?lsmb PROCESS input element_data = {
@@ -36,7 +42,7 @@
      value = transdate
      size = 12
 } ?>
-<?lsmb END IF # !multiple ?>
+<?lsmb END # IF !multi ?>
 <div class="inputrow" id="filerow">
 <?lsmb PROCESS input element_data = {
        name = "import_file"

Modified: addons/1.3/import_trans/trunk/scripts/import_trans.pl
===================================================================
--- addons/1.3/import_trans/trunk/scripts/import_trans.pl	2010-09-27 15:49:21 UTC (rev 3071)
+++ addons/1.3/import_trans/trunk/scripts/import_trans.pl	2010-09-28 19:49:17 UTC (rev 3072)
@@ -31,39 +31,44 @@
                    $form->{description} = $request->{description};
                    $form->{transdate} = $request->{transdate};
                    $form->{rowcount} = 0;
-                   $form->{dbh} = $request->{_dbh};
+                   $form->{dbh} = $request->{dbh};
                    for my $ref (@$entries){
-                       if ($ref->{debits} !~ /\d/){
-                          delete $ref->{debits};
+                       if ($ref->[1] !~ /\d/){
+                          delete $ref->[1];
                        } else {
-                          $ref->{debits} = $form->parse_amount(
-                                         $request->{_user}, $ref->{debits}
+                          print STDERR "debits $ref->[1]\n";
+                          $ref->[1] = $form->parse_amount(
+                                         $request->{_user}, $ref->[1]
                           );
                        }
-                       if ($ref->{credits} !~ /\d/){
-                          delete $ref->{credits};
+                       if ($ref->[2] !~ /\d/){
+                          delete $ref->[2];
                        } else {
-                          $ref->{credits} = $form->parse_amount(
-                                         $request->{_user}, $ref->{credits}
+                          print STDERR "credits $ref->[2]\n";
+                          $ref->[2] = $form->parse_amount(
+                                         $request->{_user}, $ref->[2]
                           );
                        }
-                       next if !$ref->{debits} and !$ref->{credits};
-                       ++$form->{rowcount} = 0;
-                       for my $col (@{$col->{$request->{type}}}){
+                       next if !$ref->[1] and !$ref->[2];
+                       ++$form->{rowcount};
+                       for my $col (@{$cols->{$request->{type}}}){
                            $form->{"${col}_$form->{rowcount}"} = shift @$ref;
                        }
                    }
-                   LedgerSMB::GL->post($request->{_user}, $form);
+                   GL->post_transaction($request->{_user}, $form);
                 },
    ap_multi => sub {
                    use LedgerSMB::AA;
                    my ($request, $entries) = @_;
                    for my $ref (@$entries){
                        my $form = Form->new();
-                       $form->{dbh} = $request->{_dbh};
-                       $form->{rowcount} = 1;
+                       $form->{dbh} = $request->{dbh};
+                       $form->{rowcount} = 2;
                        $form->{vendor_id} = shift @$ref;
                        $form->{amount_1} = shift @$ref;
+                       next if $form->{amount_1} !~ /\d/;
+                       $form->{amount_1} = $form->parse_amount(
+                              $request->{_user}, $form->{amount_1}); 
                        $form->{accno_1} = shift @$ref;
                        $form->{ARAP} = 'AP';
                        $form->{vc} = "vendor";
@@ -72,7 +77,7 @@
                        $form->{description} = shift @$ref;
                        $form->{invnumber} = shift @$ref;
                        $form->{transdate} = shift @$ref;
-                       LedgerSMB::AA->post_invoice($request->{_user}, $form);
+                       AA->post_transaction($request->{_user}, $form);
                    }
                },
 };
@@ -112,15 +117,15 @@
     my $template = LedgerSMB::Template->new(
         user =>$request->{_user}, 
         locale => $request->{_locale},
-        path => 'UI/asset',
-        template => 'import_asset',
+        path => 'UI/import_trans',
+        template => 'import_trans',
         format => 'HTML'
     );
     $template->render($request);
 }
 
 sub run_import {
-    my $request = @_;
-    my @entries = process_file($request);
-    &$process->{$request->{type}}($request, ..hidden..) || begin_import($request);
+    my ($request) = @_;
+    my @entries = parse_file($request);
+    $process->{$request->{type}}($request, ..hidden..) || begin_import($request);
 }


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