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

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



Revision: 5506
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5506&view=rev
Author:   einhverfr
Date:     2013-01-07 11:02:09 +0000 (Mon, 07 Jan 2013)
Log Message:
-----------
Fully functional Perl code now for inventory activity report and drilldown

Modified Paths:
--------------
    trunk/LedgerSMB/Report/Invoices/Transactions.pm
    trunk/sql/modules/Goods.sql
    trunk/sql/modules/Report.sql

Added Paths:
-----------
    trunk/LedgerSMB/Report/Inventory/Activity.pm

Added: trunk/LedgerSMB/Report/Inventory/Activity.pm
===================================================================
--- trunk/LedgerSMB/Report/Inventory/Activity.pm	                        (rev 0)
+++ trunk/LedgerSMB/Report/Inventory/Activity.pm	2013-01-07 11:02:09 UTC (rev 5506)
@@ -0,0 +1,154 @@
+=head1 NAME
+
+LedgerSMB::Report::Inventory::Activity - Inventory Activity reports for 
+LedgerSMB
+
+=head1 SYNOPSIS
+
+ my $report = LedgerSMB::Report::Inventory::Activity->new(%$request);
+ $report->render($request);
+
+=cut
+
+package LedgerSMB::Report::Inventory::Activity;
+use Moose;
+extends 'LedgerSMB::Report';
+with 'LedgerSMB::Report::Dates';
+
+=head1 CRITERIA PROPERTIES
+
+Standard dates plus:
+
+=over
+
+=item partnumber
+
+Prefix search on partnumber
+
+=cut
+
+has partnumber => (is => 'ro', isa => 'Str', required => 0);
+
+=item description
+
+Full text search on description
+
+=cut
+
+has description  => (is => 'ro', isa => 'Str', required => 0);
+
+=back;
+
+=head1 INTERNALS
+
+=head2 columns
+
+=over
+
+=item partnumber 
+
+=item description
+
+=item sold
+
+=item receivable
+
+=item purchased
+
+=item payable
+
+=back
+
+=cut
+
+sub columns {
+    my $self = shift;
+    return [
+     {col_id => 'partnumber',
+        type => 'text',
+        name => LedgerSMB::Report::text('Partnumber'), }
+
+     {col_id => 'description',
+        type => 'text',
+        name => LedgerSMB::Report::text('Description'), }
+
+     {col_id => 'sold',
+        type => 'href',
+        name => LedgerSMB::Report::text('Sold'), 
+   href_base => "invoice.pl&date_from=$self->date_from&date_to=$self->date_to"
+                . "&open=1&closed=1&"
+                . 'col_invnumber=1&col_transdate=1&col_entity_name=1&'
+                . 'col_netamount=1&entity_class=2&parts_id=',
+     }
+
+     {col_id => 'receivable',
+        type => 'text',
+        name => LedgerSMB::Report::text('Receivable'), }
+
+     {col_id => 'purchased',
+        type => 'href',
+        name => LedgerSMB::Report::text('Purchased'), 
+   href_base => "invoice.pl&date_from=$self->date_from&date_to=$self->date_to"
+                . "&open=1&closed=1&"
+                . 'col_invnumber=1&col_transdate=1&col_entity_name=1&'
+                . 'col_netamount=1&entity_class=1&parts_id=',
+     }
+
+     {col_id => 'payable',
+        type => 'text',
+        name => LedgerSMB::Report::text('Payable'), }
+    ];
+}
+
+=head2 header_lines
+
+=over
+
+=item partnumber
+
+=item description
+
+=item date_from
+
+=item date_to
+
+=cut
+
+sub header_lines {
+    return [
+      { name => 'partnumber',  text => LedgerSMB::Report::text('Partnumber') },
+      { name => 'description', text => LedgerSMB::Report::text('Description') },
+      { name => 'date_from',   text => LedgerSMB::Report::text('From Date') },
+      { name => 'date_to',     text => LedgerSMB::Report::text('To Date') },
+    ];
+}
+
+=head2 name
+
+Inventory Activity Report
+
+=cut
+
+sub name {
+    return LedgerSMB::Report::text('Inventory Activity Report');
+}
+
+=head1 METHODS
+
+=head2 run_report
+
+=cut
+
+sub run_report {
+    my ($self) = @_;
+    my @rows = $self->exec_method({funcname => 'inventory__activity'});
+    for my $r (@rows) {
+       $r->{row_id} = $r->{parts_id};
+    }
+}
+
+=head1 COPYRIGHT
+
+=cut
+
+__PACKAGE__->meta->make_immutable;

Modified: trunk/LedgerSMB/Report/Invoices/Transactions.pm
===================================================================
--- trunk/LedgerSMB/Report/Invoices/Transactions.pm	2013-01-07 10:33:34 UTC (rev 5505)
+++ trunk/LedgerSMB/Report/Invoices/Transactions.pm	2013-01-07 11:02:09 UTC (rev 5506)
@@ -98,12 +98,20 @@
 
 =item partnumber string
 
-If set only include invoices including the relevant part number
+If set only include invoices including the relevant part number (prefix search)
 
 =cut
 
 has partnumber => (is => 'ro', isa => 'Str', required => 0);
 
+=item parts_id int
+
+If set only include invoices including the specified part (exact match_
+
+=cut
+
+has parts_id => (is => 'ro', isa => 'Int', required => 0);
+
 =item source string
 
 Prefix string on source number

Modified: trunk/sql/modules/Goods.sql
===================================================================
--- trunk/sql/modules/Goods.sql	2013-01-07 10:33:34 UTC (rev 5505)
+++ trunk/sql/modules/Goods.sql	2013-01-07 11:02:09 UTC (rev 5506)
@@ -146,7 +146,7 @@
 );
    
 CREATE OR REPLACE FUNCTION inventory__activity
-(in_date_from date, in_date_to date, in_partnumber text, in_descripiton text)
+(in_date_from date, in_date_to date, in_partnumber text, in_description text)
 RETURNS SETOF inv_activity_line LANGUAGE SQL AS
 $$
     SELECT p.id, p.description, p.partnumber,  

Modified: trunk/sql/modules/Report.sql
===================================================================
--- trunk/sql/modules/Report.sql	2013-01-07 10:33:34 UTC (rev 5505)
+++ trunk/sql/modules/Report.sql	2013-01-07 11:02:09 UTC (rev 5506)
@@ -372,7 +372,7 @@
 (in_entity_class int, in_account_id int, in_entity_name text, 
  in_meta_number text,
  in_employee_id int, in_business_units int[], in_ship_via text, in_on_hold bool,
- in_date_from date, in_date_to date, in_partnumber text)
+ in_date_from date, in_date_to date, in_partnumber text, in_parts_id int)
 RETURNS SETOF aa_transactions_line LANGUAGE PLPGSQL AS $$
 DECLARE retval aa_transactions_line;
 
@@ -427,6 +427,9 @@
           OR EXISTS(SELECT 1 FROM invoice inv 
                       JOIN parts ON inv.parts_id = parts.id
                      WHERE inv.trans_id = a.id))
+       AND (in_parts_id IS NULL 
+          OR EXISTS (select 1 FROM invoice 
+                      WHERE parts_id = in_parts_id AND trans_id = a.id))
            
 LOOP
    RETURN NEXT retval;

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