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

SF.net SVN: ledger-smb:[2770] addons/1.3/templatetrans/trunk



Revision: 2770
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2770&view=rev
Author:   einhverfr
Date:     2009-10-14 16:01:08 +0000 (Wed, 14 Oct 2009)

Log Message:
-----------
Template transactions set for testing

Modified Paths:
--------------
    addons/1.3/templatetrans/trunk/sql/modules/trans-tables.sql

Added Paths:
-----------
    addons/1.3/templatetrans/trunk/LedgerSMB/
    addons/1.3/templatetrans/trunk/LedgerSMB/DBObject/
    addons/1.3/templatetrans/trunk/LedgerSMB/DBObject/TransTemplate.pm
    addons/1.3/templatetrans/trunk/patches/
    addons/1.3/templatetrans/trunk/patches/aa_gl.patch
    addons/1.3/templatetrans/trunk/scripts/
    addons/1.3/templatetrans/trunk/scripts/transtemplate.pl

Added: addons/1.3/templatetrans/trunk/LedgerSMB/DBObject/TransTemplate.pm
===================================================================
--- addons/1.3/templatetrans/trunk/LedgerSMB/DBObject/TransTemplate.pm	                        (rev 0)
+++ addons/1.3/templatetrans/trunk/LedgerSMB/DBObject/TransTemplate.pm	2009-10-14 16:01:08 UTC (rev 2770)
@@ -0,0 +1,32 @@
+package LedgerSMB::DBObject::TempTrans;
+use base qw(LedgerSMB::DBObject);
+
+sub save {
+   my $self = shift @_;
+   $self->execute_method(funcname => 'journal__add');
+   for my $line (@{$self->{journal_lines}}){
+       bless $line, LedgerSMB::DBObject;
+       $line->execute_method(funcname=> 'journal__add_line');
+   } 
+   if ($self->{is_invoice}){
+       $self->execute_method(funcname => 'journal__make_invoice');
+   }
+   $self->commit;
+}
+
+sub search {
+   my $self = shift @_;
+   @{$self->{search_results}} = $self->execute_method(
+            funcname => 'journal__search'
+   );
+}
+
+sub retrieve {
+   my $self = shift @_;
+   my @vals = $self->execute_method(funcname => 'journal__retrieve');
+   $self->merge(shift @vals);
+   @{$self->{line_items}} = $self->execute_method(funcname => 'journal__retrieve_lines');
+   ($self->{inv_data}) = $self->execute_method(funcname => 'journal__retrieve_invoice');
+}
+
+1;

Added: addons/1.3/templatetrans/trunk/patches/aa_gl.patch
===================================================================
--- addons/1.3/templatetrans/trunk/patches/aa_gl.patch	                        (rev 0)
+++ addons/1.3/templatetrans/trunk/patches/aa_gl.patch	2009-10-14 16:01:08 UTC (rev 2770)
@@ -0,0 +1,68 @@
+Index: bin/aa.pl
+===================================================================
+--- bin/aa.pl	(revision 2719)
++++ bin/aa.pl	(working copy)
+@@ -959,6 +959,8 @@
+ 
+             'save_info' => 
+               { ndx => 9, key => 'I', value => $locale->text('Save Info') },
++            'save_temp' =>
++              { ndx => 10, key => 'T', value => $locale->text('Save Template')},
+         );
+         if (!$form->{approved} && !$form->{batch_id}){
+            $button{approve} = { 
+@@ -1028,6 +1030,21 @@
+ |;
+ }
+ 
++sub save_temp {
++    use LedgerSMB;
++    use LedgerSMB::DBObject::TransTemplate;
++    my $lsmb = LedgerSMB->new();
++    $lsmb->{is_invoice} = 1;
++    if ($form->{arap} eq 'ar'){
++        $lsmb->{entity_class} = 2;
++    } else {
++        $lsmb->{entity_class} = 1;
++    }
++    $template = LedgerSMB::DBObject::TransTemplate->new(base => $lsmb);
++    $template->save;
++    $form->redirect( $locale->text('Template Saved!') );
++}
++
+ sub edit_and_approve {
+     use LedgerSMB::DBObject::Draft;
+     use LedgerSMB;
+Index: bin/gl.pl
+===================================================================
+--- bin/gl.pl	(revision 2764)
++++ bin/gl.pl	(working copy)
+@@ -247,6 +247,10 @@
+ 		    { ndx => 7, key => 'H', value => $locale->text('Schedule') },
+ 		  'delete' =>
+ 		    { ndx => 8, key => 'D', value => $locale->text('Delete') },
++                  'save_temp' =>
++                    { ndx   => 9, 
++                      key   => 'T', 
++                      value => $locale->text('Save Template') },
+ 	      );
+ 
+ 	      if ($form->{separate_duties}){            
+@@ -334,7 +338,17 @@
+ }
+  
+ 
++sub save_temp {
++    use LedgerSMB;
++    use LedgerSMB::DBObject::TransTemplate;
++    my $lsmb = LedgerSMB->new();
++    $lsmb->{type} = 'gl';
++    $template = LedgerSMB::DBObject::TransTemplate->new(base => $lsmb);
++    $template->save;
++    $form->redirect( $locale->text('Template Saved!') );
++}
+ 
++
+ sub display_row
+ {
+  

Added: addons/1.3/templatetrans/trunk/scripts/transtemplate.pl
===================================================================
--- addons/1.3/templatetrans/trunk/scripts/transtemplate.pl	                        (rev 0)
+++ addons/1.3/templatetrans/trunk/scripts/transtemplate.pl	2009-10-14 16:01:08 UTC (rev 2770)
@@ -0,0 +1,42 @@
+
+package LedgerSMB::Scripts::transtemplate;
+our $VERSION = '0.1';
+
+sub view {
+    our $template_dispatch = 
+    {
+        ap         => {script => 'bin/ap.pl', function => sub {edit()}},
+        ar         => {script => 'bin/ar.pl', function => sub {edit()}},
+        gl         => {script => 'bin/gl.pl', function => sub {edit()}},
+    };
+
+    our $form = new Form;
+    our %myconfig = ();
+    %myconfig = %{$request->{_user}};
+    our $locale = $request->{_locale};
+    if ($script =~ /^bin/){
+	# I hate this old code!
+        { no strict; no warnings 'redefine'; do $script; }
+
+    } elsif ($script =~ /scripts/) {
+         { do $script } 
+
+    }
+
+    $vouchers_dispatch->{$request->{batch_type}}{function}($request);
+
+}
+
+sub search {
+    my ($request) = @_;
+    my $template = LedgerSMB::Template->new(
+        user     => $request->{_user},
+        locale   => $request->{_locale},
+        path     => 'UI/transtemplate',
+        template => 'filter',
+        format   => 'HTML', 
+   );
+   $template->render($request);
+}
+
+1;

Modified: addons/1.3/templatetrans/trunk/sql/modules/trans-tables.sql
===================================================================
--- addons/1.3/templatetrans/trunk/sql/modules/trans-tables.sql	2009-10-14 15:28:29 UTC (rev 2769)
+++ addons/1.3/templatetrans/trunk/sql/modules/trans-tables.sql	2009-10-14 16:01:08 UTC (rev 2770)
@@ -2,22 +2,22 @@
 -- and easier QA on 1.3.
 
 
-CREATE journal_entry_type (
-id serial,
-type text primary key
+CREATE table journal_entry_type (
+id serial not null unique,
+"type" text primary key
 );
 
 create table journal (
 source text not null,  -- invoice number or source document number
 id serial not null,
 description text not null,
-locked_by int references session(id) on delete set null, -- used for
+locked_by int references session(session_id) on delete set null, -- used for
 entry_type int references journal_entry_type(id),
 transaction_date date not null default now(),
 approved bool default false, -- this way we do vouchers by default,
 department_id int references department(id) not null, 
 is_template bool default false,
-primary_key(id), -- no other set of fields guaranteed to be unique
+primary key (id), -- no other set of fields guaranteed to be unique
 check (is_template is false or approved is false)
 );
 
@@ -29,9 +29,9 @@
 amount numeric not null check (amount <> 'NaN'),
 cleared bool not null default false,
 memo text,
-entered_by int references user(entity_id),
-line_id serial not null,
-primary key (entry_id) -- required to be a surrogate key because it is possible to have a single payment which pays two identical bills.
+entered_by int references users(id),
+line_id serial,
+primary key (line_id) -- required to be a surrogate key because it is possible to have a single payment which pays two identical bills.
 );
 
 create table payment_map (
@@ -47,7 +47,7 @@
 create table forex_line (
 line_id int references journal_line(line_id),
 currency char(3), -- should we look at making a separate currency
-table?  Maybe attaching to country?
+                 -- table?  Maybe attaching to country?
 primary key (line_id)
 );
 
@@ -58,10 +58,10 @@
 
 create table orders ( -- an invoice is treated as an order with a corresponding journal entry.
 credit_account int references entity_credit_account(id) not null,
-id serial not null,
+id serial not null unique,
 include_tax bool default false not null,
 terms int not null default 0,
-language_id int references language(id)
+language_code char(6) references language(code),
 order_number text not null
 );
 
@@ -72,28 +72,29 @@
 on_hold bool default false,
 reverse bool default false,
 credit_id int references entity_credit_account(id) not null,
-language_id int references language(id),
+language_code char(6) references language(code),
 PRIMARY KEY  (journal_id)
 );
 
-CREATE TABLE order_line ( -- replaces invoice and order_item
-entry_id serial not null unique,
-parts_id int references parts(id),
-quantity numeric not null check (quantity <> 'NaN'),
-lot_price numeric not null check (quantity <> 'NaN'),
-allocated numeric not null check (allocated <> 'NaN' AND
-abs(allocated) < abs(quantity))
-allocated_price numeric not null check(allocated_price <> 'NaN' AND
-abs(allocated_price) < abs(lot_price), -- tracking allocated prices
-separately so that we can handle purchase quantities in intelligeable
-ways.
-lot_size numeric not null check (lot_size <> 'NaN'),
-lot_qty numeric not null check (lot_qtty <> 'NaN'),
-displayed_sku text not null,
-displayed_description text not null
-);
+-- CREATE TABLE order_line ( -- replaces invoice and order_item
+--entry_id serial not null unique,
+--parts_id int references parts(id),
+--quantity numeric not null check (quantity <> 'NaN'),
+--lot_price numeric not null check (quantity <> 'NaN'),
+--allocated numeric not null check (allocated <> 'NaN' AND
+--abs(allocated) < abs(quantity)),
+--allocated_price numeric not null check(allocated_price <> 'NaN' AND
+--abs(allocated_price) < abs(lot_price), -- tracking allocated prices
+                                       --separately so that we can handle 
+                                       -- purchase quantities in intelligeable
+                                       -- ways.
+--lot_size numeric not null check (lot_size <> 'NaN'),
+--lot_qty numeric not null check (lot_qtty <> 'NaN'),
+--displayed_sku text not null,
+--displayed_description text not null
+--);
 
-CREATE TABLE forex_order_line (
-entry_id int not null primary key references order_line(entry_id),
-fx_lot_price numeric not null ot null check (fx_lot_price <> 'NaN')
-);
+--CREATE TABLE forex_order_line (
+--entry_id int not null primary key references order_line(entry_id),
+--fx_lot_price numeric not null ot null check (fx_lot_price <> 'NaN')
+--);


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