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

SF.net SVN: ledger-smb:[4530] branches/1.3



Revision: 4530
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4530&view=rev
Author:   einhverfr
Date:     2012-03-22 11:56:53 +0000 (Thu, 22 Mar 2012)
Log Message:
-----------
All parts more or less completed for pricelist fix.  Now for testing

Modified Paths:
--------------
    branches/1.3/Changelog
    branches/1.3/LedgerSMB/DBObject/Part.pm
    branches/1.3/LedgerSMB/ScriptLib/Common_Search/Part.pm
    branches/1.3/LedgerSMB/ScriptLib/Common_Search.pm
    branches/1.3/LedgerSMB/ScriptLib/Company.pm

Added Paths:
-----------
    branches/1.3/LedgerSMB/DBObject/Pricelist.pm

Modified: branches/1.3/Changelog
===================================================================
--- branches/1.3/Changelog	2012-03-22 11:21:34 UTC (rev 4529)
+++ branches/1.3/Changelog	2012-03-22 11:56:53 UTC (rev 4530)
@@ -15,6 +15,7 @@
 * Corrected warnings for missin glog initalization (Andres B)
 * XAL and ODS buttons are now disabled if prereqs are missing (Erik H)
 * Experimental support for migrating from SQL-Ledger via Setup.pl (Chris T)
+* Fixed POD issues with lsmb-request.pl (h/t Robert C) (Chris T item 3472648)
 
 Andres B is Andres Basile
 

Modified: branches/1.3/LedgerSMB/DBObject/Part.pm
===================================================================
--- branches/1.3/LedgerSMB/DBObject/Part.pm	2012-03-22 11:21:34 UTC (rev 4529)
+++ branches/1.3/LedgerSMB/DBObject/Part.pm	2012-03-22 11:56:53 UTC (rev 4530)
@@ -61,6 +61,8 @@
     );
 }
 
+=back
+
 =head1 COPYRIGHT
 
 Copyright (C) 2012 The LedgerSMB Core Team.  This file may be re-used under the

Copied: branches/1.3/LedgerSMB/DBObject/Pricelist.pm (from rev 4518, branches/1.3/LedgerSMB/DBObject/Part.pm)
===================================================================
--- branches/1.3/LedgerSMB/DBObject/Pricelist.pm	                        (rev 0)
+++ branches/1.3/LedgerSMB/DBObject/Pricelist.pm	2012-03-22 11:56:53 UTC (rev 4530)
@@ -0,0 +1,70 @@
+=head1 NAME
+
+LedgerSMB::DBObject::Pricelist - Pricelists for customers and vendors
+
+=head1 SYNOPSIS
+
+ my $pl = LedgerSMB::DBObject::Pricelist->new({base => $request});
+ $pl->save(..hidden..);
+
+=cut
+
+package LedgerSMB::DBObject::Pricelist;
+use base qw(LedgerSMB::DBObject);
+use strict;
+use warnings;
+
+=head1 DESCRIPTION
+
+This module contains the pricelist saving routines for 1.3.  In 1.4 more
+pricelist routines will be added.
+
+=head1 PROPERTIES
+
+=over
+
+=item entity_class
+
+This tells us whether this is a customer or vendor's pricelist.
+
+=item credit_id 
+
+tells us who this is for.
+
+=back
+
+=head1 METHODS
+
+=over
+
+=item save(..hidden..);
+
+Saves the pricelist.
+
+=cut
+
+sub save {
+    my ($self, $lines) = @_;
+    $self->exec_method({funcname => 'pricelist__clear'});
+    for my $ref (@$lines){
+        my $line = $self->new({base => $self, 
+                               copy => 'list',  
+                          mergelist => ['entity_class', 'credit_id'], }
+        );
+        $line->merge($ref);
+        $line->exec_method({funcname => 'pricelist__add'});
+    }
+    $dbh->commit;
+}
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright (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 included LICENSE.txt for more information.
+
+=cut
+
+return 1;

Modified: branches/1.3/LedgerSMB/ScriptLib/Common_Search/Part.pm
===================================================================
--- branches/1.3/LedgerSMB/ScriptLib/Common_Search/Part.pm	2012-03-22 11:21:34 UTC (rev 4529)
+++ branches/1.3/LedgerSMB/ScriptLib/Common_Search/Part.pm	2012-03-22 11:56:53 UTC (rev 4530)
@@ -26,7 +26,7 @@
 my $COLUMNS = [
       {col_id => 'id',
          name => 'ID',
-         type => 'mirrored', }
+         type => 'mirrored', },
 
       {col_id => 'partnumber',
          name => 'Partnumber',
@@ -88,7 +88,7 @@
 
 sub search {
     my ($self, $args) = @_;
-    @results = $self->{_part}->search_lite($args);
+    my @results = $self->{_part}->search_lite($args);
     $self->{_results} = ..hidden..;
     return $self->{_results};
 }

Modified: branches/1.3/LedgerSMB/ScriptLib/Common_Search.pm
===================================================================
--- branches/1.3/LedgerSMB/ScriptLib/Common_Search.pm	2012-03-22 11:21:34 UTC (rev 4529)
+++ branches/1.3/LedgerSMB/ScriptLib/Common_Search.pm	2012-03-22 11:56:53 UTC (rev 4530)
@@ -99,6 +99,8 @@
 
 =head2 Child Classes Must Implement the Following
 
+=over
+
 =item columns
 
 Returns a list of columns as expected for Dynatable.

Modified: branches/1.3/LedgerSMB/ScriptLib/Company.pm
===================================================================
--- branches/1.3/LedgerSMB/ScriptLib/Company.pm	2012-03-22 11:21:34 UTC (rev 4529)
+++ branches/1.3/LedgerSMB/ScriptLib/Company.pm	2012-03-22 11:56:53 UTC (rev 4530)
@@ -1026,6 +1026,67 @@
 
 =item delete_price
 
+=item save_pricelist
+
+This routine saves the price matrix.  For existing rows, valid_to, valid_from,
+price fields are saved.
+
+For the new row, the partnumber field matches the beginning of the part number,
+and the description is a full text search.
+
+=cut
+
+sub save_pricelist {
+    my ($request) = @_;
+    use LedgerSMB::ScriptLib::Common_Search::Part;
+
+    my $count = $request->{rowcount};
+    my $pricelist = LedgerSMB::DBObject::Pricelist;
+    my @lines;
+    my $redirect_to_selection = 0;
+
+    # Search and populate
+    my $psearch = LedgerSMB::ScriptLib::Common_Search::Part->new($request);
+    my @parts = $psearch->search(
+                   { partnumber => $request->{"int_partnumber_tfoot_$count"},
+                    description => $request->{"description_tfoot_$count"}, }
+    );
+    if (scalar @parts == 0) {
+        $request->error($request->{_locale}->text('Part not found'));
+    } elsif (scalar @parts > 1){
+        $redirect_to_selection = 1;
+    } else {
+        push @lines, { id => $parts[1]->{id},
+                  validfrom => $request->{"validfrom_tfoot_$count"},
+                    validto => $request->{"validto_tfoot_$count"},
+                   lastcost => $request->{"lastcost_tfoot_$count"},
+                  sellprice => $request->{"sellprice_tfoot_$count"},
+                   leadtime => $request->{"leadtime_tfoot_$count"},
+             }; 
+    }
+
+    # Save rows
+    for (1 .. ($count - 1)){
+        $id = $request->{"row_id_$_"};
+        push @lines, { id => $id,
+               validfrom => $request->{"validfrom_$id"},
+                 validto => $request->{"validto_$id"},
+                lastcost => $request->{"lastcost_$id"},
+               sellprice => $request->{"sellprice_$id"},
+                leadtime => $request->{"leadtime_$id"},
+        };
+    }
+
+    $pricelist->save(..hidden..);
+
+    # Return to UI
+
+    pricelist($request) unless $redirect_to_selection;
+
+    $psearch->render;
+}
+
+
 =back
 
 =head1 COPYRIGHT

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