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

SF.net SVN: ledger-smb:[2380] trunk/sql



Revision: 2380
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2380&view=rev
Author:   einhverfr
Date:     2008-10-28 17:54:14 +0000 (Tue, 28 Oct 2008)

Log Message:
-----------
Allowing multiple payment vouchers per batch per invoice.  Test cases added

Modified Paths:
--------------
    trunk/sql/Pg-database.sql

Added Paths:
-----------
    trunk/sql/modules/test/Voucher.sql

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2008-10-24 22:21:47 UTC (rev 2379)
+++ trunk/sql/Pg-database.sql	2008-10-28 17:54:14 UTC (rev 2380)
@@ -491,12 +491,14 @@
 COMMENT ON COLUMN batch.batch_class_id IS
 $$ Note that this field is largely used for sorting the vouchers.  A given batch is NOT restricted to this type.$$;
 
+
+-- Although I am moving the primary key to voucher.id for now, as of 1.4, I 
+-- would expect trans_id to be primary key
 CREATE TABLE voucher (
   trans_id int REFERENCES transactions(id) NOT NULL,
   batch_id int references batch(id) not null,
-  id serial NOT NULL unique,
-  batch_class int references batch_class(id) not null,
-  PRIMARY KEY (batch_class, batch_id, trans_id)
+  id serial PRIMARY KEY,
+  batch_class int references batch_class(id) not null
 );
 
 COMMENT ON COLUMN voucher.batch_class IS $$ This is the authoritative class of the 

Added: trunk/sql/modules/test/Voucher.sql
===================================================================
--- trunk/sql/modules/test/Voucher.sql	                        (rev 0)
+++ trunk/sql/modules/test/Voucher.sql	2008-10-28 17:54:14 UTC (rev 2380)
@@ -0,0 +1,41 @@
+BEGIN;
+\i Base.sql
+
+INSERT INTO test_result (test_name, success)
+SELECT 'Batch Created', 
+	batch_create('_TEST', '_TEST', 'payment', '2008-01-01') IS NOT NULL;
+
+INSERT INTO entity (id, name, entity_class, control_code) 
+values (-2, 'Test', 1, 'test');
+INSERT INTO entity_credit_account (entity_id, id, meta_number, entity_class) 
+values (-2, -1, 'Test', 1);
+
+INSERT INTO chart (id, accno, description, link)
+VALUES ('-1', '-21111', 'Testing AP', 'AP');
+
+INSERT INTO ap (id, invnumber, amount, curr, approved, entity_credit_account)
+VALUES (-1, 'test1', '1000', 'USD', false, -1);
+
+INSERT INTO acc_trans(trans_id, chart_id, amount, approved)
+values (-1, -1, 1000, true);
+
+INSERT INTO voucher (trans_id, batch_id, batch_class)
+values (-1, currval('batch_id_seq'), 1);
+INSERT INTO voucher (trans_id, batch_id, batch_class)
+values (-1, currval('batch_id_seq'), 3);
+INSERT INTO voucher (trans_id, batch_id, batch_class)
+values (-1, currval('batch_id_seq'), 3);
+
+
+INSERT INTO test_result (test_name, success)
+SELECT 'partial payment support', count(*) > 1 
+FROM voucher where trans_id = -1 and batch_class = 3;
+
+SELECT * FROM test_result;
+
+SELECT (select count(*) from test_result where success is true) 
+|| ' tests passed and ' 
+|| (select count(*) from test_result where success is not true) 
+|| ' failed' as message;
+
+ROLLBACK;


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