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

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



Revision: 6822
          http://sourceforge.net/p/ledger-smb/code/6822
Author:   einhverfr
Date:     2014-02-10 08:52:19 +0000 (Mon, 10 Feb 2014)
Log Message:
-----------
workflow runs clean through for reversing overpayments but now dies on internal database error

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Payment.pm
    trunk/LedgerSMB/Scripts/reports.pm
    trunk/UI/Reports/filters/overpayments.html
    trunk/UI/create_batch.html
    trunk/sql/modules/Payment.sql

Modified: trunk/LedgerSMB/DBObject/Payment.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Payment.pm	2014-02-10 08:36:11 UTC (rev 6821)
+++ trunk/LedgerSMB/DBObject/Payment.pm	2014-02-10 08:52:19 UTC (rev 6822)
@@ -815,9 +815,14 @@
 =cut
 
 sub overpayment_reverse {
-    my ($self, $payment, $batch_id) = @_;
+    my ($self, $args) = @_;
     __PACKAGE__->call_procedure(procname => 'payment__reverse_overpayment',
-                                     args => [] );
+                                     args => [$args->{id},
+                                              $args->{post_date},
+                                              $args->{batch_id},
+                                              $args->{account_class},
+                                              $args->{exchangerate},
+                                              $args->{curr}] );
 }
 
 =item init

Modified: trunk/LedgerSMB/Scripts/reports.pm
===================================================================
--- trunk/LedgerSMB/Scripts/reports.pm	2014-02-10 08:36:11 UTC (rev 6821)
+++ trunk/LedgerSMB/Scripts/reports.pm	2014-02-10 08:52:19 UTC (rev 6822)
@@ -188,7 +188,8 @@
 sub search_overpayments {
     my ($request) = @_;
     my $hiddens = {};
-    $hiddens->{$_} = $request->{$_} for qw(batch_id currency exchangerate);
+    $hiddens->{$_} = $request->{$_} for qw(batch_id currency exchangerate
+                                        post_date batch_class account_class);
     $request->{hiddens} = $hiddens;
     LedgerSMB::Report::Listings::Overpayments->new(%$request)->render($request);
 }
@@ -197,9 +198,10 @@
     my ($request) = @_;
     for my $rc (1 .. $request->{rowcount_}){
         next unless $request->{"select_$rc"};
-        LedgerSMB::DBObject::Payment->overpayment_reverse(
-             $request->{"select_$rc"}, $request->{batch_id}
-        );
+        my $args = {id => $request->{"select_$rc"}};
+        $args->{$_} = $request->{$_} for qw(post_date batch_id account_class
+                                            exchangerate, curr);
+        LedgerSMB::DBObject::Payment->overpayment_reverse($args);
     }
     $request->{report_name} = 'overpayments';
     start_report($request);

Modified: trunk/UI/Reports/filters/overpayments.html
===================================================================
--- trunk/UI/Reports/filters/overpayments.html	2014-02-10 08:36:11 UTC (rev 6821)
+++ trunk/UI/Reports/filters/overpayments.html	2014-02-10 08:52:19 UTC (rev 6822)
@@ -61,6 +61,12 @@
       text = text('Search')
 };
  PROCESS input element_data = {
+      name = "post_date"
+     value = post_date
+      type = 'hidden'
+      
+};
+ PROCESS input element_data = {
       name = "account_class"
      value = account_class
       type = 'hidden'

Modified: trunk/UI/create_batch.html
===================================================================
--- trunk/UI/create_batch.html	2014-02-10 08:36:11 UTC (rev 6821)
+++ trunk/UI/create_batch.html	2014-02-10 08:52:19 UTC (rev 6822)
@@ -52,7 +52,7 @@
 <?lsmb 
 
 FOREACH row IN search_results;
-     row.row_id = row.id;
+     row.row_id = row.id _ "&post_date=" _ row.default_date;
 END;
 
 PROCESS dynatable 

Modified: trunk/sql/modules/Payment.sql
===================================================================
--- trunk/sql/modules/Payment.sql	2014-02-10 08:36:11 UTC (rev 6821)
+++ trunk/sql/modules/Payment.sql	2014-02-10 08:52:19 UTC (rev 6822)
@@ -1550,12 +1550,16 @@
        ($5 IS NULL OR e.name @@ plainto_tsquery($5));
 $$;
 
+DROP FUNCTION IF EXISTS overpayment__reverse
+(in_id int, in_transdate date, in_batch_id int, in_account_class int,
+in_cash_accno text, in_exchangerate numeric, in_curr char(3));
+
 CREATE OR REPLACE FUNCTION overpayment__reverse 
-(in_id int, in_transdate date, in_batch_id int, in_account_class int,
-in_cash_accno text, in_exchangerate numeric, in_curr char(3))
+(in_id int, in_transdate date, in_batch_id int, in_account_class int, in_exchangerate numeric, in_curr char(3))
 returns bool LANGUAGE PLPGSQL AS
 $$
 declare t_id int;
+        in_cash_accno text;
 BEGIN
 
 -- reverse overpayment gl
@@ -1575,10 +1579,12 @@
  WHERE trans_id = in_id;
 
 -- reverse overpayment usage
-SELECT payment__reverse(ac.source, ac.transdate, eca.id, in_cash_accno,
+SELECT payment__reverse(ac.source, ac.transdate, eca.id, accno,
         in_transdate, eca.entity_class, in_batch_id, null, 
         in_exchangerate, in_currency)
   FROM acc_trans ac
+  JOIN account a ON ac.chart_id = a.id
+  JOIN account_link al ON a.id = al.account_id AND description like 'A%paid'
   JOIN (select id, entity_credit_account FROM ar UNION
         select id, entity_credit_account from ap) a ON a.id = ac.trans_id
   JOIN entity_credit_account eca ON a.entity_credit_account = eca.id
@@ -1586,7 +1592,8 @@
   JOIN overpayment op ON op.id = pl.payment_id
   JOIN payment p ON p.id = o.payment_id
  WHERE p.gl_id = in_id
-GROUP BY ac.source, ac.transdate, eca.id, eca.entity_class;
+GROUP BY ac.source, ac.transdate, eca.id, eca.entity_class,
+         a.accno, al.description;
 
 UPDATE overpayment set available = 0 
  WHERE payment_id = (select id from payment where gl_id = in_id);

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


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits