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

SF.net SVN: ledger-smb:[3490] trunk/LedgerSMB



Revision: 3490
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3490&view=rev
Author:   einhverfr
Date:     2011-07-11 09:25:40 +0000 (Mon, 11 Jul 2011)

Log Message:
-----------
File attachment subclasses complete

Modified Paths:
--------------
    trunk/LedgerSMB/File.pm

Added Paths:
-----------
    trunk/LedgerSMB/File/
    trunk/LedgerSMB/File/Order.pm
    trunk/LedgerSMB/File/Transaction.pm

Added: trunk/LedgerSMB/File/Order.pm
===================================================================
--- trunk/LedgerSMB/File/Order.pm	                        (rev 0)
+++ trunk/LedgerSMB/File/Order.pm	2011-07-11 09:25:40 UTC (rev 3490)
@@ -0,0 +1,108 @@
+=pod
+
+=head1 NAME
+
+LedgerSMB::File::Order
+
+=head1 SYNPSIS
+
+Manages attachments to orders (sales orders, purchase orders, quotations and
+RFQ's).
+
+=head1 INHERITS
+
+=over
+
+=item  LedgerSMB::File
+
+Provides all properties and accessors.  This subclass provides additional 
+methods only
+
+=back
+
+=cut
+
+package LedgerSMB::File::Order;
+use strict;
+use base(LedgerSMB::File);
+
+=head1 METHODS
+
+=over
+
+=item attach
+
+Attaches or links a specific file to the given transaction.
+
+=cut
+
+sub attach {
+    my ($self, $args) = @_;
+    $self->exec_method({funcname => 'file__attach_to_tx'});
+    $self->commit unless $args->{no_commit};
+}
+
+=item attach_all_from_order({id = int})
+
+Links all files to a specific transaction from a specific order.  Note this 
+only handles files that were attached to orders and transactions to start with.
+
+=cut
+
+sub attach_all_from_order {
+    my ($self, $args) = @_;
+    for $attach ($self->list({ref_key => $args->{int}, file_class => 2}){
+        my $new_link = LedgerSMB::File::Transaction->new();
+        $new_link->merge($attach);
+        $new_link->dbobject($self->dbobject);
+        $new_link->attach({no_commit => 1});
+    }
+    for $link ($self->list_links({ref_key => $args->{int}, file_class => 2}){
+        next if !($link->{src_class} == 2 || $link->{src_class} == 1);
+        my $new_link = LedgerSMB::File::Transaction->new();
+        $new_link->merge($link);
+        $new_link->dbobject($self->dbobject);
+        $new_link->attach({no_commit => 1});
+    }
+    $self->commit;
+}
+
+=item attach_all_from_transaction({id = int})
+
+Links all files to a specific transaction from a specific transaction.  Note 
+this only handles files that were attached to orders and transactions to start 
+with.
+
+=cut
+
+sub attach_all_from_transaction {
+    my ($self, $args) = @_;
+    for $attach ($self->list({ref_key => $args->{int}, file_class => 1}){
+        my $new_link = LedgerSMB::File::Transaction->new();
+        $new_link->merge($attach);
+        $new_link->dbobject($self->dbobject);
+        $new_link->attach({no_commit => 1});
+    }
+    for $link ($self->list_links({ref_key => $args->{int}, file_class => 1}){
+        next if !($link->{src_class} == 2 || $link->{src_class} == 1);
+        my $new_link = LedgerSMB::File::Transaction->new();
+        $new_link->merge($link);
+        $new_link->dbobject($self->dbobject);
+        $new_link->attach({no_commit => 1});
+    }
+    $self->commit;
+}
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright (C) 2011 The LedgerSMB Core Team
+
+This file is licensed under the Gnu General Public License version 2, or at your
+option any later version.  A copy of the license should have been included with
+your software.
+
+=cut
+
+1;

Added: trunk/LedgerSMB/File/Transaction.pm
===================================================================
--- trunk/LedgerSMB/File/Transaction.pm	                        (rev 0)
+++ trunk/LedgerSMB/File/Transaction.pm	2011-07-11 09:25:40 UTC (rev 3490)
@@ -0,0 +1,81 @@
+=pod
+
+=head1 NAME
+
+LedgerSMB::File::Transaction
+
+=head1 SYNPSIS
+
+Manages attachments to financial trnasactions (in 1.3, AR, AP, and GL entries)
+
+=head1 INHERITS
+
+=over
+
+=item  LedgerSMB::File
+
+Provides all properties and accessors.  This subclass provides additional 
+methods only
+
+=cut
+
+package LedgerSMB::File::Transaction;
+use strict;
+use base(LedgerSMB::File);
+
+=back
+
+=head1 METHODS
+
+=over
+
+=item attach([{no_commit => bool}])
+
+Attaches or links a specific file to the given transaction.
+
+=cut
+
+sub attach {
+    my ($self, $args) = @_;
+    $self->exec_method({funcname => 'file__attach_to_tx'});
+    $self->commit unless $args->{no_commit};
+}
+
+=item attach_all_from_order({id = int})
+
+Links all files to a specific transaction from a specific order.  Note this 
+only handles files that were attached to orders to start with.
+
+=cut
+
+sub attach_all_from_order {
+    my ($self, $args) = @_;
+    for $attach ($self->list({ref_key => $args->{int}, file_class => 2}){
+        my $new_link = LedgerSMB::File::Transaction->new();
+        $new_link->merge($attach);
+        $new_link->dbobject($self->dbobject);
+        $new_link->attach({no_commit => 1});
+    }
+    for $link ($self->list_links({ref_key => $args->{int}, file_class => 2}){
+        next if $link->{src_class} <> 2;
+        my $new_link = LedgerSMB::File::Transaction->new();
+        $new_link->merge($link);
+        $new_link->dbobject($self->dbobject);
+        $new_link->attach({no_commit => 1});
+    }
+    $self->commit;
+}
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright (C) 2011 The LedgerSMB Core Team
+
+This file is licensed under the Gnu General Public License version 2, or at your
+option any later version.  A copy of the license should have been included with
+your software.
+
+=cut
+
+1;

Modified: trunk/LedgerSMB/File.pm
===================================================================
--- trunk/LedgerSMB/File.pm	2011-07-11 08:58:36 UTC (rev 3489)
+++ trunk/LedgerSMB/File.pm	2011-07-11 09:25:40 UTC (rev 3490)
@@ -2,7 +2,7 @@
 
 =head1 NAME
 
-LedgerSMB::DBOBject::File
+LedgerSMB::File
 
 =head1 SYNPSIS
 


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