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

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



Revision: 5277
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5277&view=rev
Author:   einhverfr
Date:     2012-11-27 10:11:00 +0000 (Tue, 27 Nov 2012)
Log Message:
-----------
Adding accrual tax form reports
Adding test cases for accrual tax form reports

Modified Paths:
--------------
    trunk/LedgerSMB/Scripts/taxform.pm
    trunk/UI/taxform/add_taxform.html
    trunk/sql/modules/1099_reports.sql
    trunk/sql/modules/test/Taxform.sql
    trunk/t/43-dbtest.t

Modified: trunk/LedgerSMB/Scripts/taxform.pm
===================================================================
--- trunk/LedgerSMB/Scripts/taxform.pm	2012-11-27 08:45:52 UTC (rev 5276)
+++ trunk/LedgerSMB/Scripts/taxform.pm	2012-11-27 10:11:00 UTC (rev 5277)
@@ -126,6 +126,11 @@
        $request->{format} = 'HTML';
     }
 
+
+    my ($tf) = $request->call_procedure(
+              procname => 'taxform__get', args => $request->{'tax_form_id'});
+    my $sfx = '';
+    $stf = '_accrual' if $th->{is_accrual};
     # Business settings for 1099
     #
     my $cc = $LedgerSMB::Company_Config::settings;
@@ -139,7 +144,7 @@
                        $request->{begin_year}.'-'.$request->{begin_month}.'-'.$request->{begin_day}, $request->{end_year}.'-'.$request->{end_month}.'-'.$request->{end_day}, 
                        $request->{meta_number});
                        
-      my @results = $request->call_procedure(procname => 'tax_form_details_report', args => ..hidden..);
+      my @results = $request->call_procedure(procname => "tax_form_details_report$sfx", args => ..hidden..);
       my $credit_id;
       for my $r (@results){
           $r->{acc_sum} = $request->format_amount({amount => $r->{acc_sum}});
@@ -179,7 +184,7 @@
     else {
         
         my @call_args = ($request->{'tax_form_id'}, $request->{begin_year}.'-'.$request->{begin_month}.'-'.$request->{begin_day}, $request->{end_year}.'-'.$request->{end_month}.'-'.$request->{end_day});
-        my @results = $request->call_procedure(procname => 'tax_form_summary_report', args => ..hidden..);
+        my @results = $request->call_procedure(procname => "tax_form_summary_report$sfx", args => ..hidden..);
         for my $r (@results){
             my $company = LedgerSMB::DBObject::Vendor->new(base => $request);
             $company->{id} = $r->{credit_id};

Modified: trunk/UI/taxform/add_taxform.html
===================================================================
--- trunk/UI/taxform/add_taxform.html	2012-11-27 08:45:52 UTC (rev 5276)
+++ trunk/UI/taxform/add_taxform.html	2012-11-27 10:11:00 UTC (rev 5277)
@@ -65,6 +65,21 @@
      ?>
 </div>
 
+<div class="labelledinput">
+  
+     <?lsmb IF is_accrual; CHECKED = 'CHECKED';
+            ELSE; CHECKED = ''; 
+            END;
+        PROCESS input element_data = {
+	name = "is_accrual"
+	type = "checkbox"
+	value = "1"
+	label = text("Accrual Basis:") #"
+	checked = CHECKED
+                                         } 
+     ?>
+</div>
+
 <div id="buttons">
 
 <?lsmb INCLUDE button element_data = {

Modified: trunk/sql/modules/1099_reports.sql
===================================================================
--- trunk/sql/modules/1099_reports.sql	2012-11-27 08:45:52 UTC (rev 5276)
+++ trunk/sql/modules/1099_reports.sql	2012-11-27 10:11:00 UTC (rev 5277)
@@ -208,4 +208,156 @@
 $$ This provides a list of invoices and transactions that a report hits.  This 
 is intended to allow an organization to adjust what is reported on the 1099 
 before printing them.$$;
+
+CREATE OR REPLACE FUNCTION tax_form_summary_report_accrual
+(in_tax_form_id int, in_begin date, in_end date) 
+RETURNS SETOF tax_form_report_item AS $BODY$
+DECLARE
+	out_row tax_form_report_item;
+BEGIN
+	FOR out_row IN 
+              SELECT entity_credit_account.id,
+                     company.legal_name, company.entity_id, 
+                     entity_credit_account.entity_class, entity.control_code, 
+                     entity_credit_account.meta_number, 
+                     sum(CASE WHEN gl.amount = 0 THEN 0
+                              WHEN relation = 'acc_trans' 
+                          THEN ac.reportable_amount
+                          ELSE 0
+                      END * CASE WHEN gl.class = 'ap' THEN -1 else 1 end),
+                     sum(CASE WHEN gl.amount = 0 THEN 0
+                              WHEN relation = 'invoice'
+                          THEN ac.reportable_amount
+                          ELSE 0
+                      END * CASE WHEN gl.class = 'ar' THEN -1 else 1 end),
+                     sum(CASE WHEN gl.amount = 0 THEN 0
+                          ELSE ac.reportable_amount
+                      END * CASE WHEN gl.class = 'ap' THEN -1 else 1 end
+                      * CASE WHEN ac.relation = 'invoice' then -1 else 1 end)
+                         
+		FROM (select id, transdate, entity_credit_account, invoice, 
+                             amount, 'ar' as class FROM ar 
+                       WHERE transdate BETWEEN in_begin AND in_end
+                       UNION 
+                      select id, transdate, entity_credit_account, invoice, 
+                              amount, 'ap' as class from ap
+                       WHERE transdate BETWEEN in_begin AND in_end
+                     ) gl
+               JOIN (select trans_id, 'acc_trans' as relation, 
+                             sum(amount) as amount,
+                             sum(case when atf.reportable then amount else 0
+                                 end) as reportable_amount
+                        FROM  acc_trans
+                    LEFT JOIN ac_tax_form atf
+                          ON (acc_trans.entry_id = atf.entry_id)
+                       GROUP BY trans_id
+                       UNION
+                      select trans_id, 'invoice' as relation, 
+                             sum(sellprice * qty) as amount,
+                             sum(case when itf.reportable 
+                                      then sellprice * qty
+                                      else 0
+                                 end) as reportable_amount
+                        FROM invoice
+                    LEFT JOIN invoice_tax_form itf
+                          ON (invoice.id = itf.invoice_id)
+                       GROUP BY trans_id
+                     ) ac ON (ac.trans_id = gl.id 
+                             AND ((gl.invoice is true and ac.relation='invoice')
+                                  OR (gl.invoice is false 
+                                     and ac.relation='acc_trans')))
+		JOIN entity_credit_account 
+                  ON (gl.entity_credit_account = entity_credit_account.id) 
+		JOIN entity ON (entity.id = entity_credit_account.entity_id) 
+		JOIN company ON (entity.id = company.entity_id)
+		JOIN country_tax_form ON (entity_credit_account.taxform_id = country_tax_form.id)
+               WHERE country_tax_form.id = in_tax_form_id
+             GROUP BY legal_name, meta_number, company.entity_id, entity_credit_account.entity_class, entity.control_code, entity_credit_account.id
+    LOOP
+		RETURN NEXT out_row;
+	END LOOP;
+END;
+$BODY$ LANGUAGE PLPGSQL;
+
+COMMENT ON FUNCTION tax_form_summary_report_accrual
+(in_tax_form_id int, in_begin date, in_end date) IS
+$$This provides the total reportable value per vendor.  As per 1099 forms, these
+are cash-basis documents and show amounts paid.$$;
+
+CREATE OR REPLACE FUNCTION tax_form_details_report_accrual
+(in_tax_form_id int, in_begin date, in_end date, in_meta_number text) 
+RETURNS SETOF tax_form_report_detail_item AS $BODY$
+DECLARE
+	out_row tax_form_report_detail_item;
+BEGIN
+	FOR out_row IN 
+              SELECT entity_credit_account.id,
+                     company.legal_name, company.entity_id, 
+                     entity_credit_account.entity_class, entity.control_code, 
+                     entity_credit_account.meta_number, 
+                     sum(CASE WHEN gl.amount = 0 then 0 
+                              when relation = 'acc_trans'
+                          THEN ac.reportable_amount
+                          ELSE 0
+                      END * CASE WHEN gl.class = 'ap' THEN -1 else 1 end),
+                     sum(CASE WHEN gl.amount = 0 then 0
+                              WHEN relation = 'invoice'
+                          THEN ac.reportable_amount
+                          ELSE 0
+                      END * CASE WHEN gl.class = 'ar' THEN -1 else 1 end),
+                     SUM(CASE WHEN gl.amount = 0 
+                                   THEN 0 
+                              ELSE ac.reportable_amount
+                              END
+                         * CASE WHEN gl.class = 'ap' THEN -1 else 1 end 
+                         * CASE WHEN relation = 'invoice' THEN -1 ELSE 1 END),
+                     gl.invnumber, gl.duedate::text, gl.id
+                FROM (select id, entity_credit_account, invnumber, duedate, 
+                             amount, transdate, 'ar' as class
+                        FROM ar 
+                       WHERE transdate BETWEEN in_begin AND in_end
+                       UNION 
+                      select id, entity_credit_account, invnumber, duedate, 
+                             amount, transdate, 'ap' as class
+                        FROM ap
+                       WHERE transdate BETWEEN in_begin AND in_end
+                     ) gl 
+                JOIN (select trans_id, 'acc_trans' as relation, 
+                             sum(amount) as amount,
+                             sum(case when atf.reportable then amount else 0
+                                 end) as reportable_amount
+                        FROM  acc_trans
+                   LEFT JOIN ac_tax_form atf
+                          ON (acc_trans.entry_id = atf.entry_id)
+                       GROUP BY trans_id
+                       UNION
+                      select trans_id, 'invoice' as relation, 
+                             sum(sellprice * qty) as amount,
+                             sum(case when itf.reportable 
+                                      then sellprice * qty
+                                      else 0
+                                 end) as reportable_amount
+                        FROM invoice
+                   LEFT JOIN invoice_tax_form itf
+                          ON (invoice.id = itf.invoice_id)
+                       GROUP BY trans_id
+                     ) ac ON (ac.trans_id = gl.id)
+		JOIN entity_credit_account ON (gl.entity_credit_account = entity_credit_account.id) 
+		JOIN entity ON (entity.id = entity_credit_account.entity_id) 
+		JOIN company ON (entity.id = company.entity_id)
+		JOIN country_tax_form ON (entity_credit_account.taxform_id = country_tax_form.id)
+		WHERE country_tax_form.id = in_tax_form_id AND meta_number = in_meta_number
+		GROUP BY legal_name, meta_number, company.entity_id, entity_credit_account.entity_class, entity.control_code, gl.invnumber, gl.duedate, gl.id, entity_credit_account.id
+	LOOP
+		RETURN NEXT out_row;
+	END LOOP;
+END;
+$BODY$ LANGUAGE PLPGSQL;
+
+COMMENT ON FUNCTION tax_form_details_report_accrual
+(in_tax_form_id int, in_begin date, in_end date, in_meta_number text) IS
+$$ This provides a list of invoices and transactions that a report hits.  This 
+is intended to allow an organization to adjust what is reported on the 1099 
+before printing them.$$;
+
 COMMIT;

Modified: trunk/sql/modules/test/Taxform.sql
===================================================================
--- trunk/sql/modules/test/Taxform.sql	2012-11-27 08:45:52 UTC (rev 5276)
+++ trunk/sql/modules/test/Taxform.sql	2012-11-27 10:11:00 UTC (rev 5277)
@@ -296,17 +296,35 @@
                                   (date1() + '1 day'::interval)::date);
 
 INSERT INTO test_result(test_name, success)
+SELECT '2 rows on current accrual summary report', count(*) = 2
+  FROM tax_form_summary_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date);
+
+INSERT INTO test_result(test_name, success)
 SELECT '1 row on future summary report', count(*) = 1
   FROM tax_form_summary_report(-511, (date2() - '1 day'::interval)::date, 
                                   (date2() + '1 day'::interval)::date);
 
 INSERT INTO test_result(test_name, success)
-SELECT 'inv_sum for test vendor 1, current report is $2000', invoice_sum = 1000
+SELECT '0 rows on future summary accrual report', count(*) = 0
+  FROM tax_form_summary_report_accrual(-511, (date2() - '1 day'::interval)::date, 
+                                  (date2() + '1 day'::interval)::date);
+
+
+
+INSERT INTO test_result(test_name, success)
+SELECT 'inv_sum for test vendor 1, current report is $1000', invoice_sum = 1000
   FROM tax_form_summary_report(-511, (date1() - '1 day'::interval)::date, 
                                   (date1() + '1 day'::interval)::date)
  where meta_number = 'Test account 1';
 
 INSERT INTO test_result(test_name, success)
+SELECT 'inv_sum for test vendor 1, current accrual report is $2000', invoice_sum = 2000
+  FROM tax_form_summary_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date)
+ where meta_number = 'Test account 1';
+
+INSERT INTO test_result(test_name, success)
 SELECT 'inv_sum for test vendor 1, future report is $500', invoice_sum = 500
   FROM tax_form_summary_report(-511, (date2() - '1 day'::interval)::date, 
                                   (date2() + '1 day'::interval)::date)
@@ -318,14 +336,26 @@
                                   (date1() + '1 day'::interval)::date)
  where meta_number = 'Test account 2';
 
+INSERT INTO test_result(test_name, success)
+SELECT 'inv_sum for test vendor 2, current accrual report is $1000', invoice_sum = 1000
+  FROM tax_form_summary_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date)
+ where meta_number = 'Test account 2';
 
+
 INSERT INTO test_result(test_name, success)
-SELECT 'total_sum for test vendor 1, current report is $4000', total_sum = 3000
+SELECT 'total_sum for test vendor 1, current report is $3000', total_sum = 3000
   FROM tax_form_summary_report(-511, (date1() - '1 day'::interval)::date, 
                                   (date1() + '1 day'::interval)::date)
  where meta_number = 'Test account 1';
 
 INSERT INTO test_result(test_name, success)
+SELECT 'total_sum for test vendor 1, current accrual report is $5000', total_sum = 5000
+  FROM tax_form_summary_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date)
+ where meta_number = 'Test account 1';
+
+INSERT INTO test_result(test_name, success)
 SELECT 'total_sum for test vendor 1, future report is $1000', total_sum = 1000
   FROM tax_form_summary_report(-511, (date2() - '1 day'::interval)::date, 
                                   (date2() + '1 day'::interval)::date)
@@ -337,6 +367,11 @@
                                   (date1() + '1 day'::interval)::date)
  where meta_number = 'Test account 2';
 
+INSERT INTO test_result(test_name, success)
+SELECT 'total_sum for test vendor 2, current accrual report is $2000', total_sum = 2000
+  FROM tax_form_summary_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date)
+ where meta_number = 'Test account 2';
 
 INSERT INTO test_result(test_name, success)
 SELECT 'ac_sum for test vendor 1, current report is $2000', acc_sum = 2000
@@ -345,6 +380,12 @@
  where meta_number = 'Test account 1';
 
 INSERT INTO test_result(test_name, success)
+SELECT 'ac_sum for test vendor 1, current accrual report is $3000', acc_sum = 3000
+  FROM tax_form_summary_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date)
+ where meta_number = 'Test account 1';
+
+INSERT INTO test_result(test_name, success)
 SELECT 'ac_sum for test vendor 1, future report is $500', acc_sum = 500
   FROM tax_form_summary_report(-511, (date2() - '1 day'::interval)::date, 
                                   (date2() + '1 day'::interval)::date)
@@ -357,17 +398,35 @@
  where meta_number = 'Test account 2';
 
 INSERT INTO test_result(test_name, success)
+SELECT 'ac_sum for test vendor 2, current accrual report is $1000', acc_sum = 1000
+  FROM tax_form_summary_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date)
+ where meta_number = 'Test account 2';
+
+INSERT INTO test_result(test_name, success)
     SELECT '6 in detail report for current report, vendor 1', count(*) = 5
     FROM tax_form_details_report(-511, (date1() - '1 day'::interval)::date, 
                                   (date1() + '1 day'::interval)::date, 
                                 'Test account 1');
 
 INSERT INTO test_result(test_name, success)
+    SELECT '6 in detail report for current accrual report, vendor 1', count(*) = 5
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 1');
+
+INSERT INTO test_result(test_name, success)
     SELECT '2 in detail report for current report, vendor 2', count(*) = 2
     FROM tax_form_details_report(-511, (date1() - '1 day'::interval)::date, 
                                   (date1() + '1 day'::interval)::date, 
                                 'Test account 2');
+INSERT INTO test_result(test_name, success)
+    SELECT '2 in detail report for current accrual report, vendor 2', count(*) = 2
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 2');
 
+
 INSERT INTO test_result(test_name, success)
     SELECT '2 in detail report for future report, vendor 1', count(*) = 2
     FROM tax_form_details_report(-511, (date2() - '1 day'::interval)::date, 
@@ -388,6 +447,13 @@
     WHERE invoice_id = -1024;
 
 INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1024, acc $1000', acc_sum= 1000
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 1')
+    WHERE invoice_id = -1024;
+
+INSERT INTO test_result(test_name, success)
    SELECT 'current report, invoice -1025, acc $500', acc_sum= 500
     FROM tax_form_details_report(-511, (date1() - '1 day'::interval)::date, 
                                   (date1() + '1 day'::interval)::date, 
@@ -395,6 +461,13 @@
     WHERE invoice_id = -1025;
 
 INSERT INTO test_result(test_name, success)
+   SELECT 'current report, invoice -1025, acc $1000', acc_sum= 1000
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 1')
+    WHERE invoice_id = -1025;
+
+INSERT INTO test_result(test_name, success)
    SELECT 'current report, invoice -1026, acc $500', acc_sum= 500
     FROM tax_form_details_report(-511, (date1() - '1 day'::interval)::date, 
                                   (date1() + '1 day'::interval)::date, 
@@ -402,13 +475,27 @@
     WHERE invoice_id = -1026;
 
 INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1026, acc $1000', acc_sum= 1000
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 1')
+    WHERE invoice_id = -1026;
+
+INSERT INTO test_result(test_name, success)
    SELECT 'current report, invoice -1027, acc $1000', acc_sum= 1000
     FROM tax_form_details_report(-511, (date1() - '1 day'::interval)::date, 
                                   (date1() + '1 day'::interval)::date, 
                                 'Test account 2')
     WHERE invoice_id = -1027;
 
+INSERT INTO test_result(test_name, success)
+   SELECT 'current report, invoice -1027, acc $1000', acc_sum= 1000
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 2')
+    WHERE invoice_id = -1027;
 
+
 INSERT INTO test_result(test_name, success)
    SELECT 'current report, invoice -1024, total $1000', total_sum= 1000
     FROM tax_form_details_report(-511, (date1() - '1 day'::interval)::date, 
@@ -417,6 +504,13 @@
     WHERE invoice_id = -1024;
 
 INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1024, total $1000', total_sum= 1000
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 1')
+    WHERE invoice_id = -1024;
+
+INSERT INTO test_result(test_name, success)
    SELECT 'current report, invoice -1025, total $500', total_sum= 500
     FROM tax_form_details_report(-511, (date1() - '1 day'::interval)::date, 
                                   (date1() + '1 day'::interval)::date, 
@@ -424,6 +518,13 @@
     WHERE invoice_id = -1025;
 
 INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1025, total $1000', total_sum= 1000
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 1')
+    WHERE invoice_id = -1025;
+
+INSERT INTO test_result(test_name, success)
    SELECT 'current report, invoice -1026, total $500', total_sum= 500
     FROM tax_form_details_report(-511, (date1() - '1 day'::interval)::date, 
                                   (date1() + '1 day'::interval)::date, 
@@ -431,12 +532,26 @@
     WHERE invoice_id = -1026;
 
 INSERT INTO test_result(test_name, success)
+   SELECT 'current report, invoice -1026, total $1000', total_sum= 1000
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 1')
+    WHERE invoice_id = -1026;
+
+INSERT INTO test_result(test_name, success)
    SELECT 'current report, invoice -1027, total $1000', total_sum= 1000
     FROM tax_form_details_report(-511, (date1() - '1 day'::interval)::date, 
                                   (date1() + '1 day'::interval)::date, 
                                 'Test account 2')
     WHERE invoice_id = -1027;
 
+INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1027, total $1000', total_sum= 1000
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 2')
+    WHERE invoice_id = -1027;
+
    
 
 INSERT INTO test_result(test_name, success)
@@ -447,6 +562,13 @@
     WHERE invoice_id = -1024;
 
 INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1024, inv_total 0', invoice_sum= 0
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 1')
+    WHERE invoice_id = -1024;
+
+INSERT INTO test_result(test_name, success)
    SELECT 'current report, invoice -1025, inv 0', invoice_sum= 0
     FROM tax_form_details_report(-511, (date1() - '1 day'::interval)::date, 
                                   (date1() + '1 day'::interval)::date, 
@@ -454,6 +576,13 @@
     WHERE invoice_id = -1025;
 
 INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1025, inv 0', invoice_sum= 0
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 1')
+    WHERE invoice_id = -1025;
+
+INSERT INTO test_result(test_name, success)
    SELECT 'current report, invoice -1026, inv 0', invoice_sum = 0
     FROM tax_form_details_report(-511, (date1() - '1 day'::interval)::date, 
                                   (date1() + '1 day'::interval)::date, 
@@ -461,14 +590,28 @@
     WHERE invoice_id = -1026;
 
 INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1026, inv 0', invoice_sum = 0
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 1')
+    WHERE invoice_id = -1026;
+
+INSERT INTO test_result(test_name, success)
    SELECT 'current report, invoice -1027, inv 0', invoice_sum= 0
     FROM tax_form_details_report(-511, (date1() - '1 day'::interval)::date, 
                                   (date1() + '1 day'::interval)::date, 
                                 'Test account 2')
     WHERE invoice_id = -1027;
 
+INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1027, inv 0', invoice_sum= 0
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 2')
+    WHERE invoice_id = -1027;
 
 
+
 INSERT INTO test_result(test_name, success)
    SELECT 'current report, invoice -1035, inv $500', invoice_sum= 500
     FROM tax_form_details_report(-511, (date1() - '1 day'::interval)::date, 
@@ -477,6 +620,13 @@
     WHERE invoice_id = -1035;
 
 INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1035, inv $1000', invoice_sum= 1000
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 1')
+    WHERE invoice_id = -1035;
+
+INSERT INTO test_result(test_name, success)
    SELECT 'current report, invoice -1036, inv $500', invoice_sum= 500
     FROM tax_form_details_report(-511, (date1() - '1 day'::interval)::date, 
                                   (date1() + '1 day'::interval)::date, 
@@ -484,14 +634,28 @@
     WHERE invoice_id = -1036;
 
 INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1036, inv $1000', invoice_sum= 1000
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 1')
+    WHERE invoice_id = -1036;
+
+INSERT INTO test_result(test_name, success)
    SELECT 'current report, invoice -1037, inv $1000', invoice_sum= 1000
     FROM tax_form_details_report(-511, (date1() - '1 day'::interval)::date, 
                                   (date1() + '1 day'::interval)::date, 
                                 'Test account 2')
     WHERE invoice_id = -1037;
 
+INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1037, inv $1000', invoice_sum= 1000
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 2')
+    WHERE invoice_id = -1037;
 
 
+
 INSERT INTO test_result(test_name, success)
    SELECT 'current report, invoice -1035, total $500', total_sum= 500
     FROM tax_form_details_report(-511, (date1() - '1 day'::interval)::date, 
@@ -513,6 +677,27 @@
                                 'Test account 2')
     WHERE invoice_id = -1037;
 
+INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1035, total $1000', total_sum= 1000
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 1')
+    WHERE invoice_id = -1035;
+
+INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1036, total $1000', total_sum= 1000
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 1')
+    WHERE invoice_id = -1036;
+
+INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1037, total $1000', total_sum= 1000
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 2')
+    WHERE invoice_id = -1037;
+
    
 
 
@@ -537,7 +722,28 @@
                                 'Test account 2')
     WHERE invoice_id = -1037;
 
+INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1035, acc 0', acc_sum = 0
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 1')
+    WHERE invoice_id = -1035;
 
+INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1036, acc 0',  acc_sum = 0
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 1')
+    WHERE invoice_id = -1036;
+
+INSERT INTO test_result(test_name, success)
+   SELECT 'current accrual report, invoice -1037, acc 0', acc_sum = 0
+    FROM tax_form_details_report_accrual(-511, (date1() - '1 day'::interval)::date, 
+                                  (date1() + '1 day'::interval)::date, 
+                                'Test account 2')
+    WHERE invoice_id = -1037;
+
+
    
 INSERT INTO test_result(test_name, success)
    SELECT 'future report, invoice -1026, acc 500',  acc_sum = 500

Modified: trunk/t/43-dbtest.t
===================================================================
--- trunk/t/43-dbtest.t	2012-11-27 08:45:52 UTC (rev 5276)
+++ trunk/t/43-dbtest.t	2012-11-27 10:11:00 UTC (rev 5277)
@@ -5,7 +5,7 @@
 	plan skip_all => 'Skipping all.  Told not to test db.';
 }
 else {
-	plan tests => 261;
+	plan tests => 292;
 	if (defined $ENV{LSMB_NEW_DB}){
 		$ENV{PGDATABASE} = $ENV{LSMB_NEW_DB};
 	}

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