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

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



Revision: 4791
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4791&view=rev
Author:   einhverfr
Date:     2012-05-27 15:00:13 +0000 (Sun, 27 May 2012)
Log Message:
-----------
Notes now on new framework and working  Next up is to make the screen work with a more general controller script and integrate natural persons.

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Entity/Bank.pm
    trunk/LedgerSMB/ScriptLib/Company.pm
    trunk/UI/Contact/divs/notes.html

Added Paths:
-----------
    trunk/LedgerSMB/DBObject/Entity/Note.pm

Modified: trunk/LedgerSMB/DBObject/Entity/Bank.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity/Bank.pm	2012-05-27 13:37:04 UTC (rev 4790)
+++ trunk/LedgerSMB/DBObject/Entity/Bank.pm	2012-05-27 15:00:13 UTC (rev 4791)
@@ -10,11 +10,9 @@
 
 =head1 DESCRIPTION
 
-This module provides contact info handling for LedgerSMB.  Each contact info
-record consists of optionally an entity_id or a credit_id, a class, a class
-name, a description, and the actual contact information.  This is used to track
-everything from phone numbers to email addresses both of natural persons and
-companies in LedgerSMB.
+This module manages bank accounts, for wire transfers, etc. for customers,
+vendors, employees etc.   Bank accounts are attached to the entity with the
+credit account being able to attach itself to a single bank account.
 
 =cut
 

Copied: trunk/LedgerSMB/DBObject/Entity/Note.pm (from rev 4790, trunk/LedgerSMB/DBObject/Entity/Bank.pm)
===================================================================
--- trunk/LedgerSMB/DBObject/Entity/Note.pm	                        (rev 0)
+++ trunk/LedgerSMB/DBObject/Entity/Note.pm	2012-05-27 15:00:13 UTC (rev 4791)
@@ -0,0 +1,136 @@
+=head1 NAME
+
+LedgerSMB::DBObject::Entity::Note - Notes handling for customers, vendors, 
+employees, etc.
+
+=head1 SYNPOSIS
+
+  @notes = LedgerSMB::DBObject::Entity::Bank->list($entity_id, [$credit_id]);
+  $note->add;
+
+=head1 DESCRIPTION
+
+This module handles tracking of notes for customers, vendors, employees, sales
+leads, and more.  Notes are expected to be read-only, and essentially
+append-only.
+
+This module handles attaching notes either at the entity level or the credit id
+level.  
+
+=cut
+
+package LedgerSMB::DBObject::Entity::Note;
+use Moose;
+extends 'LedgerSMB::DBObject_Moose';
+
+=head1 INHERITS
+
+=over
+
+=item LedgerSMB::DBObject_Moose;
+
+=back
+
+head1 PROPERTIES
+
+=over
+
+=item entity_id Int
+
+If set this is attached to an entity.  This can optionally be set to a contact
+record attached to a credit account but is ignored in that case.
+
+=cut
+
+has 'entity_id' => (is => 'rw', isa => 'Maybe[Int]');
+
+=item credit_id Int
+
+If this is set, this is attached to an entity credit account.  If this and
+entity_id are set, entity_id is ignored.
+
+=cut
+
+has 'credit_id' => (is => 'rw', isa => 'Maybe[Int]');
+
+=item id
+
+If set this indicates this has been saved to the db. 
+
+=cut
+
+has 'id' => (is =>'ro', isa => 'Maybe[Int]');
+
+=item subject
+
+This is the subject of the note. 
+
+=cut
+
+has 'subject' => (is =>'rw', isa => 'Maybe[Str]');
+
+=item note
+
+The contents of the note.  Required
+
+=cut
+
+has 'note' => (is => 'rw', isa => 'Str');
+
+=back
+
+=head1 METHODS
+
+=over
+
+=item list($entity_id, [$credit_id])
+
+Lists all bank accounts for entity_id.  This does not need to be performed on a
+blessed reference.  All return results are objects.
+
+=cut
+
+sub list{
+    my ($self, $entity_id, $credit_id) = @_;
+    my @results;
+    if ($credit_id){
+        @results = $self->call_procedure(procname =>
+             'eca__list_notes', args => [$credit_id]);
+    } else {
+        @results = $self->call_procedure(procname =>
+             'entity__list_notes', args => [$credit_id]);
+    }
+    for my $row(@results){
+        $self->prepare_dbhash($row); 
+        $row = $self->new(%$row);
+    }
+    return @results;
+}
+
+=item save()
+
+Saves the bank account object to the database and reinstantiates it, thus
+setting things like the id field.
+
+=cut
+
+sub save {
+    my ($self) = @_;
+    my ($ref) = $self->exec_method({funcname => 'entity__save_notes'});
+    $self->prepare_dbhash($ref);
+    $self = $self->new(%$ref);
+}
+
+=back
+
+=head1 COPYRIGHT
+
+OPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used under the
+terms of the GNU General Public License version 2 or at your option any later
+version.  Please see the enclosed LICENSE file for details.
+
+=cut
+
+__PACKAGE__->meta->make_immutable;
+
+return 1;

Modified: trunk/LedgerSMB/ScriptLib/Company.pm
===================================================================
--- trunk/LedgerSMB/ScriptLib/Company.pm	2012-05-27 13:37:04 UTC (rev 4790)
+++ trunk/LedgerSMB/ScriptLib/Company.pm	2012-05-27 15:00:13 UTC (rev 4791)
@@ -6,6 +6,7 @@
 use LedgerSMB::DBObject::Entity::Location;
 use LedgerSMB::DBObject::Entity::Contact;
 use LedgerSMB::DBObject::Entity::Bank;
+use LedgerSMB::DBObject::Entity::Note;
 use LedgerSMB::DBObject::Vendor;
 use Log::Log4perl;
 
@@ -780,6 +781,9 @@
                          
     @{$company->{bank_account}} = 
          LedgerSMB::DBObject::Entity::Bank->list($company->{entity_id});
+    @{$company->{notes}} = 
+         LedgerSMB::DBObject::Entity::Note->list($company->{entity_id}, 
+                                                 $company->{credit_act}->{id});
     $company->{creditlimit} = $request->format_amount({amount => $company->{creditlimit}}) unless !defined $company->{creditlimit}; 
     $company->{discount} = "$company->{discount}" unless !defined $company->{discount}; 
     $company->{note_class_options} = [
@@ -1012,12 +1016,9 @@
 
 sub save_notes {
     my ($request) = @_;
-    my $company = new_company($request);
-    if (_close_form($company)){
-        $company->save_notes();
-    }
-    $company->get();
-    _render_main_screen($company );
+    my $note = LedgerSMB::DBObject::Entity::Note->new(%$request);
+    $note->save;
+    get($request);
 }
 
 =item pricelist

Modified: trunk/UI/Contact/divs/notes.html
===================================================================
--- trunk/UI/Contact/divs/notes.html	2012-05-27 13:37:04 UTC (rev 4790)
+++ trunk/UI/Contact/divs/notes.html	2012-05-27 15:00:13 UTC (rev 4791)
@@ -21,7 +21,6 @@
 		name="credit_id" 
 		value=credit_id
 	} ?>
-<?lsmb IF credit_id -?>
 <div class="input">
    <?lsmb PROCESS input element_data = {
       label = text('Subject'),
@@ -31,6 +30,7 @@
       size = "20"
 	} ?>
 </div>
+<?lsmb IF credit_id -?>
 <div class="input"><?lsmb PROCESS select element_data = {
 			name = "note_class"
 			default_values = [note_class]

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