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

SF.net SVN: ledger-smb:[6249] addons/1.3/wxPOS/scripts/WXPOS



Revision: 6249
          http://sourceforge.net/p/ledger-smb/code/6249
Author:   einhverfr
Date:     2013-11-07 16:11:55 +0000 (Thu, 07 Nov 2013)
Log Message:
-----------
Adding part class, still need to add stored procs to support it.  Also moving WXPOS::User to WXPOS::PGObject for less boilerplate.

Modified Paths:
--------------
    addons/1.3/wxPOS/scripts/WXPOS/User.pm

Added Paths:
-----------
    addons/1.3/wxPOS/scripts/WXPOS/PGObject.pm
    addons/1.3/wxPOS/scripts/WXPOS/Part.pm

Added: addons/1.3/wxPOS/scripts/WXPOS/PGObject.pm
===================================================================
--- addons/1.3/wxPOS/scripts/WXPOS/PGObject.pm	                        (rev 0)
+++ addons/1.3/wxPOS/scripts/WXPOS/PGObject.pm	2013-11-07 16:11:55 UTC (rev 6249)
@@ -0,0 +1,26 @@
+=head1 NAME
+
+WXPOS::PGObject - WXPOS's wrappers for PGObject::Simple::Role
+
+=head1 SYNOPSIS
+
+ package WXPOS::MyClass;
+ use Moo;
+ with 'WXPOS::PGObject';
+
+=head1 DESCRIPTION
+
+This sets the _get_dbh to an appropriate value ensuring you don't need to worry 
+about it as a developer.
+
+=cut
+
+package WXPOS::PGObject;
+use Moo::Role;
+with 'PGObject::Simple::Role';
+
+sub _get_dbh {
+    return $WXPOS::State::DBH;
+}
+
+1;

Added: addons/1.3/wxPOS/scripts/WXPOS/Part.pm
===================================================================
--- addons/1.3/wxPOS/scripts/WXPOS/Part.pm	                        (rev 0)
+++ addons/1.3/wxPOS/scripts/WXPOS/Part.pm	2013-11-07 16:11:55 UTC (rev 6249)
@@ -0,0 +1,113 @@
+=head1 NAME
+
+WXPOS::Part - Parts lookups for LedgerSMB's wxPOS.
+
+=head1 SYNOPSIS
+
+To look up for a customer:
+
+  my $part = WXPOS::Part->get_by_partnumber($partnumber, $customer_id, 2);
+
+To look up for a vendor:
+
+  my $part = WXPOS::Part->get_by_partnumber($partnumber, $vendor_id, 1);
+
+=cut
+
+package WXPOS::Part;
+use Moo;
+with 'WXPOS::PGObject';
+
+=head1 DESCRIPTION
+
+WXPOS::Part handles parts and price lookups including price matrix lookups. 
+
+=head1 PROPERTIES
+
+=over
+
+=item id int
+
+=item partnumber text
+
+=item description text
+
+=item sell numeric
+
+=item cost numeric
+
+=item unit text
+
+=back
+
+=cut
+
+has id => (is => 'ro', required => 1); # Change required to 0 if support saving
+
+has partnumber => (is => 'ro', required => 1);
+
+has description => (is => 'ro', required => 1);
+
+has sell => (is => 'ro', required => 1);
+
+has cost => (is => 'ro', required => 0);
+
+has unit => (is => 'ro', required => 0);
+
+# Private method, set's prefix for stored proc lookup:
+#
+sub _get_prefix {
+    return 'wxpos_part__';
+}
+
+
+=head1 METHODS
+
+=head2 get_part_by_partnumber($partnumber, $contact_id, $entity_class)
+
+This retrieves the part and pricematrix given the partnumber, contact id, and 
+entity_class.  If the contact id's entity class does not match the db, an error
+is thrown.
+
+=cut
+
+sub get_part_by_partnumber {
+    my ($self, $partnumber, $contact_id, $entity_class) = @_;
+    my ($ref) = __PACKAGE__->call_procedure(funcname => 'get',
+                                                args => [$partnumber, 
+                                                         $contact_id, 
+                                                         $contact_class]
+    );
+    return __PACKAGE__->new(%$ref);
+}
+
+=head2 search($string, $contact_id, $contact_class)
+
+Returns a list of matching parts by description, given partnumber contact id, and
+entity class. If the contact id's entity class does not match the db, an error
+is thrown.
+
+=cut
+
+sub search {
+    my ($self, $string, $contact_id, $entity_class) = @_;
+    my @results = __PACKAGE__->call_procedure(funcname => 'search',
+                                                  args => [$search,
+                                                         $contact_id, 
+                                                         $contact_class]
+    );
+    for my $part (@results) {
+        my $part = __PACKAGE__->new(%$part);
+    }
+    return @results;
+}
+
+=head1 COPYRIGHT
+
+Copyright (C) 2013 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
+
+1;

Modified: addons/1.3/wxPOS/scripts/WXPOS/User.pm
===================================================================
--- addons/1.3/wxPOS/scripts/WXPOS/User.pm	2013-11-07 15:27:19 UTC (rev 6248)
+++ addons/1.3/wxPOS/scripts/WXPOS/User.pm	2013-11-07 16:11:55 UTC (rev 6249)
@@ -16,7 +16,7 @@
 use JSON;
 use Moo;
 use WXPOS::State;
-with 'PGObject::Simple::Role';
+with 'WXPOS::PGObject';
 
 =head1 PROPERTIES
 
@@ -72,10 +72,6 @@
 
 # Private method to get the database handle
 
-sub _get_dbh {
-    return $WXPOS::State::DBH;
-}
-
 =head2 get_current
 
 This returns the user associated with the current user.

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


------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits