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

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



Revision: 2827
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2827&view=rev
Author:   aurynn_cmd
Date:     2009-12-15 20:50:57 +0000 (Tue, 15 Dec 2009)

Log Message:
-----------
Adding the currency restriction code to AR and AP. Adds the check constraint of CHECK ( (amount IS NULL AND curr IS NULL) OR (amount IS NOT NULL AND curr IS NOT NULL)).

Adds LWP test cases to verify that currencies can be saved correctly.

Modified Paths:
--------------
    trunk/sql/Pg-database.sql
    trunk/t/data/62-request-data

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2009-12-15 01:41:17 UTC (rev 2826)
+++ trunk/sql/Pg-database.sql	2009-12-15 20:50:57 UTC (rev 2827)
@@ -1016,7 +1016,8 @@
   shippingpoint text,
   terms int2 DEFAULT 0,
   notes text,
-  curr char(3),
+  curr char(3) CHECK ( (amount IS NULL AND curr IS NULL) 
+      OR (amount IS NOT NULL AND curr IS NOT NULL)),
   ordnumber text,
   person_id integer references entity_employee(entity_id),
   till varchar(20),
@@ -1050,7 +1051,8 @@
   duedate date,
   invoice bool DEFAULT 'f',
   ordnumber text,
-  curr char(3),
+  curr char(3) CHECK ( (amount IS NULL AND curr IS NULL) 
+    OR (amount IS NOT NULL AND curr IS NOT NULL)) , -- This can be null, but shouldn't be.
   notes text,
   person_id integer references entity_employee(entity_id),
   till varchar(20),

Modified: trunk/t/data/62-request-data
===================================================================
--- trunk/t/data/62-request-data	2009-12-15 01:41:17 UTC (rev 2826)
+++ trunk/t/data/62-request-data	2009-12-15 20:50:57 UTC (rev 2827)
@@ -1,5 +1,10 @@
 use Test::More;
 our $lwp_tests = {};
+
+# Added to support the entity ID test.
+our %GLOBAL;
+#
+
 our $test_request_data = [
 	# AR/AP Transaction Screen Tests
 	{
@@ -14,6 +19,58 @@
 		'module'    => 'ap.pl',
 		'action'    => 'add'
 	},
+	
+	# Tests adding a new customer/vendor.
+	
+	{
+	    "_test_id"      => "AP Add Vendor",
+	    "_codebase"     => "new",
+	    "action"        => "add",
+	    "module"        => "customer.pl",
+	    "control_code"  => "TestableEntityObject",
+	    "name"          => "TestObj",
+	    "_lwp_tests"    => sub {
+	        # Catch the entity ID, and pass it forwards.
+	        # Res is the full LWP response object.
+	        # ~A
+	        my $res = shift @_;
+	        ($GLOBAL{"entity_id"}) = \
+	            ($res->content =~ m/\<input id="entity-id" type="hidden" name="entity_id" value="(\d+)" \/\>/);
+	        return 1;
+	    },
+	},
+	
+	{
+	    "_test_id"          => "AP Save Vendor",
+	    "_codebase"         => "new",
+	    "module"            => "customer.pl",
+	    "action"            => "save",
+	    "pay_to_name"       => "TestEntity",
+	    "entity_id"         => $GLOBAL{"entity_id"},
+	    "control_code"      => "TestableEntityObject",
+	    "ar_ap_account_id"  => 10,
+	    "cash_account_id"   => 1,
+	    "_lwp_tests"        => sub {
+	        
+	        my $res = shift @_;
+	        ($GLOBAL{"vendor_id"}) = \
+	            ($res->content =~ m/\<input id="meta-number" type="text" name="meta_number" size="20" value="(\d+)" maxlength="255" \/\>/);
+	    },
+	},
+	{
+	    "_test_id"          => "AP Add Transaction",
+	    "_codebase"         => "old",
+	    "module"            => "ap.pl",
+	    "action"            => "post",
+	    "vendor"            => "TestObj",
+	    "currency"          => "USD",
+	    "amount_1"          => "5",
+	    "AP_amount_1"       => "5010--Purchases",
+	    "AP"                => "2100--Accounts Payable",
+	    "transdate"         => "2009-12-08",
+	    "AP_paid_1"         => "1060--Checking Account"
+	},
+	
 	# Create Batch Screens
 	{
 		'_test_id'   => 'AR Transaction Voucher Screen',
@@ -188,7 +245,7 @@
 		'contact_1'	=> '25',				
 		'id_25'         => '25',				
 		'paid_25'       => 'all',		
-                'payment_209'   => '1000.00',	
+        'payment_209'   => '1000.00',	
 		'invoice_25_1'  => 209,
 		'net_209'	=> '1000.00',				
 		'payment_210'	=> '-100.00',


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