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

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



Revision: 5370
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5370&view=rev
Author:   einhverfr
Date:     2012-12-17 08:39:46 +0000 (Mon, 17 Dec 2012)
Log Message:
-----------
Payment Reversal and Receipt Reversal moved to New Reporting Framework Successfully

Modified Paths:
--------------
    trunk/LedgerSMB/Report/Invoices/Payments.pm
    trunk/LedgerSMB/Scripts/payment.pm
    trunk/UI/Reports/filters/payments.html
    trunk/sql/modules/Payment.sql

Modified: trunk/LedgerSMB/Report/Invoices/Payments.pm
===================================================================
--- trunk/LedgerSMB/Report/Invoices/Payments.pm	2012-12-17 06:36:54 UTC (rev 5369)
+++ trunk/LedgerSMB/Report/Invoices/Payments.pm	2012-12-17 08:39:46 UTC (rev 5370)
@@ -39,13 +39,13 @@
 
 has meta_number => (is => 'ro', isa => 'Str', required => '0');
 
-=item cash_account_id
+=item cash_accno
 
-Account id, exact match
+Cash account number, exact match
 
 =cut
 
-has cash_account_id => (is => 'ro', isa => 'Int', required => 1);
+has cash_accno => (is => 'ro', isa => 'Str', required => 1);
 
 =item source
 
@@ -121,15 +121,14 @@
            type => 'checkbox'},
         {col_id => 'credit_id',
            type => 'hidden', },
+        {col_id => 'entity_class',
+           type => 'hidden', },
         {col_id => 'voucher_id',
            type => 'hidden', },
         {col_id => 'source',
            type => 'hidden', },
         {col_id => 'date_paid',
-           type => 'hidden', }
-        {col_id => 'meta_number', 
-           name => $meta_number,
-           type => 'text', },
+           type => 'hidden', },
         {col_id => 'date_paid',
            type => 'text',
            name => LedgerSMB::Report::text('Date Paid'), },
@@ -139,6 +138,9 @@
         {col_id => 'source',
            type => 'text',
            name => LedgerSMB::Report::text('Source'), },
+        {col_id => 'meta_number', 
+           name => $meta_number,
+           type => 'text', },
         {col_id => 'company_paid',
            type => 'text',
            name => LedgerSMB::Report::text('Company Name'), },
@@ -182,12 +184,13 @@
         die 'Invalid entity class';
     }
     return [{name => 'meta_number', text => $meta_number },
+            {name => 'cash_accno',  
+             text => LedgerSMB::Report::text('Account Number') },
             {name => 'date_from',   
              text => LedgerSMB::Report::text('From Date')},
             {name => 'date_to',
              text => LedgerSMB::Report::text('To Date')}
            ];
-];
 }
 
 =head2 name
@@ -219,9 +222,17 @@
     my $count = 1;
     for my $r(@rows){
         $r->{row_id} = $count;
+        $r->{entity_class} = $self->entity_class;
         ++$count;
     }
     $self->rows(..hidden..);
+    $self->buttons([{
+        text => LedgerSMB::Report::text('Reverse Payments'),
+        name => 'action',
+        type => 'submit',
+       class => 'submit',
+       value => 'reverse_payments',
+    }]);
 }
 
 =back

Modified: trunk/LedgerSMB/Scripts/payment.pm
===================================================================
--- trunk/LedgerSMB/Scripts/payment.pm	2012-12-17 06:36:54 UTC (rev 5369)
+++ trunk/LedgerSMB/Scripts/payment.pm	2012-12-17 08:39:46 UTC (rev 5370)
@@ -51,6 +51,7 @@
 use LedgerSMB::DBObject::Payment;
 use LedgerSMB::DBObject::Date;
 use LedgerSMB::Scripts::reports;
+use LedgerSMB::Report::Invoices::Payments;
 use Error::Simple;
 use Error;
 use strict; 
@@ -274,123 +275,23 @@
 
 sub get_search_results {
     my ($request) = @_;
-    my $rows = [];
-    my $payment =  LedgerSMB::DBObject::Payment->new({'base' => $request});
-    my @search_results = $payment->search;
-    $payment->close_form;
-    $payment->open_form;
-    my $template = LedgerSMB::Template->new(
-        user     => $request->{_user},
-        locale   => $request->{_locale},
-        path     => 'UI',
-        template => 'form-dynatable',
-        format   => ($payment->{format}) ? $payment->{format} : 'HTML',
-    ); 
-
-    my $base_url = "payment.pl?";
-    my $search_url = "$base_url";
-    for my $key (keys %{$request->take_top_level}){
-        if ($base_url =~ /\?$/){
-            if ( defined $key && defined $request->{key} )
-            {
-               $base_url .= "$key=$request->{key}";
-            }
-        } else {
-            if ( defined $key && defined $request->{key} )
-            {
-               $base_url .= "&$key=$request->{key}";
-            }
-        }
-    }
-
-    my @columns = qw(selected meta_number date_paid amount source 
-		company_paid batch_description batch_control);
-    my $contact_type = ($payment->{account_class} == 1) ? 'Vendor' : 'Customer';
-
-    # CT:  Locale strings for gettext:
-    #  $request->{_locale}->text("Vendor Number");
-    #  $request->{_locale}->text("Customer Number");
-
-    my $column_names = {
-        selected => 'Selected',
-        company_paid => 'Company Name',
-        meta_number => "$contact_type Number",
-        date_paid => 'Date Paid',
-        amount => 'Total Paid',
-        source => 'Source',
-        batch_control => 'Batch',
-        batch_description => 'Batch Description'
-    };
-    my $sort_href = "$search_url&orderby";
-    my @sort_columns = qw(meta_number date_paid amount source 
-		company_paid batch_description batch_control);
-
-	my $column_heading = $template->column_heading($column_names, 
-	    {href => $sort_href, columns => ..hidden..
-	);	
-
-    my $classcount;
-    $classcount = 0;
-    my $rowcount;
-    $rowcount = 1;
-    for my $line (@search_results){
-        $classcount ||= 0;
-        $rowcount += 1;
-        push(@$rows, {
-          company_paid => $line->{company_paid},
-          amount       => $request->format_amount(amount => $line->{amount}),
-          i            => "$classcount",
-          date_paid    => $line->{date_paid},
-          source       => $line->{source},
-          meta_number  => $line->{meta_number},
-          batch_control => $line->{batch_control},
-          batch_description => $line->{batch_description},
-          selected     => {
-                          input => {
-                                    type  => "checkbox",
-                                    name  => "payment_$rowcount",
-                                    value => "1",
-                          },
-           }
-        });
-        $payment->{"credit_id_$rowcount"} = $line->{credit_id};
-        $payment->{"date_paid_$rowcount"} = $line->{date_paid};
-        $payment->{"source_$rowcount"} = $line->{source};
-        $payment->{"voucher_id_$rowcount"} = $line->{voucher_id};
-        $classcount = ($classcount + 1) % 2;
-        ++$rowcount;
-    }
-    $payment->{rowcount} = $rowcount;
-    $payment->{script} = 'payment.pl';
-    $payment->{title} = $request->{_locale}->text("Payment Results");
-    my $hiddens = $payment->take_top_level;
-    $template->render({
-        form    => $payment,
-        columns => ..hidden..,
-        heading => $column_heading,
-        hiddens => $payment->take_top_level,
-        rows    => $rows,
-        buttons => [{
-                    value => 'reverse_payments',
-                    name  => 'action',
-                    class => 'submit',
-                    type  => 'submit',
-                    text  => $request->{_locale}->text('Reverse Payments'),
-                   }]
-    }); 
+    my $report = LedgerSMB::Report::Invoices::Payments->new(%$request);
+    $report->render;
 }
 
-=item get_search_results_reverse_payments
+=item reverse_payments
 
 This reverses payments selected in the search results.
 
 =cut
 
-sub get_search_results_reverse_payments {
+sub reverse_payments {
     my ($request) = @_;
+    $request->{account_class} = 1;
     my $payment = LedgerSMB::DBObject::Payment->new({base => $request});
     for my $count (1 .. $payment->{rowcount}){
         if ($payment->{"payment_$count"}){
+           $payment->{account_class} = $payment->{"account_class_$count"};
            $payment->{credit_id} = $payment->{"credit_id_$count"};
            $payment->{date_paid} = $payment->{"date_paid_$count"};
            $payment->{source} = $payment->{"source_$count"};

Modified: trunk/UI/Reports/filters/payments.html
===================================================================
--- trunk/UI/Reports/filters/payments.html	2012-12-17 06:36:54 UTC (rev 5369)
+++ trunk/UI/Reports/filters/payments.html	2012-12-17 08:39:46 UTC (rev 5370)
@@ -5,7 +5,8 @@
 			'UI/payments/payments.css'
 		]
 		titlebar = text('Search Payments') # '
-?><?lsmb PROCESS 'elements.html' ?>
+?><?lsmb PROCESS 'elements.html';
+         IF ! entity_class.defined; entity_class = account_class; END ?>
 <body>
 <?lsmb IF    account_class == 2 ?><?lsmb contact_type = "Customer" -?>
 <?lsmb ELSIF account_class == 1 ?><?lsmb contact_type = "Vendor" -?>
@@ -25,8 +26,8 @@
 	} ?>
 	<?lsmb INCLUDE input element_data = {
 		type  = "hidden"
-		name  = "account_class"
-		value = account_class
+		name  = "entity_class"
+		value = entity_class
 	} ?>
 <div class="listtop" id="page_title"><?lsmb text('Search Payments') ?></div>
 <div class="input" id="vendor_input_div">

Modified: trunk/sql/modules/Payment.sql
===================================================================
--- trunk/sql/modules/Payment.sql	2012-12-17 06:36:54 UTC (rev 5369)
+++ trunk/sql/modules/Payment.sql	2012-12-17 08:39:46 UTC (rev 5370)
@@ -1040,13 +1040,9 @@
         date_paid date
 );
 
-DROP FUNCTION IF EXISTS payment__search 
-(in_source text, in_date_from date, in_date_to date, in_credit_id int,
-        in_cash_accno text, in_account_class int);
-
 CREATE OR REPLACE FUNCTION payment__search 
 (in_source text, in_date_from date, in_date_to date, in_credit_id int, 
-	in_cash_accno text, in_account_class int, in_currency char(3))
+	in_cash_accno text, in_entity_class int, in_currency char(3))
 RETURNS SETOF payment_record AS
 $$
 DECLARE 
@@ -1061,10 +1057,10 @@
 			b.control_code, b.description, a.voucher_id, a.transdate
 		FROM entity_credit_account c
 		JOIN ( select entity_credit_account, id, curr
-			FROM ar WHERE in_account_class = 2
+			FROM ar WHERE in_entity_class = 2
 			UNION
 			SELECT entity_credit_account, id, curr
-			FROM ap WHERE in_account_class = 1
+			FROM ap WHERE in_entity_class = 1
 			) arap ON (arap.entity_credit_account = c.id)
 		JOIN acc_trans a ON (arap.id = a.trans_id)
 		JOIN chart ch ON (ch.id = a.chart_id)
@@ -1090,7 +1086,7 @@
 
 COMMENT ON FUNCTION payment__search
 (in_source text, in_date_from date, in_date_to date, in_credit_id int,
-        in_cash_accno text, in_account_class int, char(3)) IS
+        in_cash_accno text, in_entity_class int, char(3)) IS
 $$This searches for payments.  in_date_to and _date_from specify the acceptable
 date range.  All other matches are exact except that null matches all values.
 

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