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

SF.net SVN: ledger-smb:[3081] addons/1.3/import_trans/trunk/scripts/ import_trans.pl



Revision: 3081
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3081&view=rev
Author:   einhverfr
Date:     2010-10-01 23:37:03 +0000 (Fri, 01 Oct 2010)

Log Message:
-----------
Imports now check for AP errors before creating drafts

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

Modified: addons/1.3/import_trans/trunk/scripts/import_trans.pl
===================================================================
--- addons/1.3/import_trans/trunk/scripts/import_trans.pl	2010-10-01 23:07:00 UTC (rev 3080)
+++ addons/1.3/import_trans/trunk/scripts/import_trans.pl	2010-10-01 23:37:03 UTC (rev 3081)
@@ -62,7 +62,27 @@
    ap_multi => sub {
                    use LedgerSMB::AA;
                    my ($request, $entries) = @_;
+                   # Necessary to test things are found before starting to 
+                   # import! -- CT
+                   my $acst = $request->{dbh}->prepare(
+                        "select count(*) from account where accno = ?"
+                   );
+                   my $vcst = $request->{dbh}->prepare(
+                        "select count(*) from account where accno = ?"
+                   );
                    for my $ref (@$entries){
+                       my $pass;
+                       $acst->execute($ref->[2]);
+                       ($pass) = $acst->fetchrow_array;
+                       $request->error("Account $ref->[2] not found") if !$pass;
+                       $acst->execute($ref->[3]);
+                       ($pass) = $acst->fetchrow_array;
+                       $request->error("Account $ref->[3] not found") if !$pass;
+                       $vcst->execute(uc($ref->[0]));
+                       ($pass) = $vcst->fetchrow_array;
+                       $request->error("Vendor $ref->[0] not found") if !$pass;
+                   }
+                   for my $ref (@$entries){
                        my $form = Form->new();
                        $form->{dbh} = $request->{dbh};
                        $form->{rowcount} = 1;
@@ -86,7 +106,7 @@
                             "SELECT id FROM entity_credit_account
                               WHERE entity_class = 1 and meta_number = ?"
                        );
-                       $sth->execute($form->{vendornumber});
+                       $sth->execute(uc($form->{vendornumber}));
                        ($form->{vendor_id}) = $sth->fetchrow_array;
                       
                        AA->post_transaction($request->{_user}, $form);


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