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

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



Revision: 6841
          http://sourceforge.net/p/ledger-smb/code/6841
Author:   einhverfr
Date:     2014-02-11 08:28:10 +0000 (Tue, 11 Feb 2014)
Log Message:
-----------
1.3-specific changelog message to merge

Modified Paths:
--------------
    trunk/Changelog
    trunk/LedgerSMB/Template.pm
    trunk/sql/modules/trial_balance.sql
    trunk/templates/demo/invoice.tex

Modified: trunk/Changelog
===================================================================
--- trunk/Changelog	2014-02-11 08:25:48 UTC (rev 6840)
+++ trunk/Changelog	2014-02-11 08:28:10 UTC (rev 6841)
@@ -124,6 +124,7 @@
 * Fixed contact description not preserved on edit (Chris T, 981)
 * Fixed useless buttons on credit div when no account active (Chris T, 1001)
 * Backported requires() and requires_series() APIs from 1.4 (Chris T)
+* Updated INSTALL to reflect better instructions for Apache 2.4 (Chris T)
 
 Changelog for 1.3.37
 * 1.3-1.2 downgrade now drops extensions (Chris T, 943)

Modified: trunk/LedgerSMB/Template.pm
===================================================================
--- trunk/LedgerSMB/Template.pm	2014-02-11 08:25:48 UTC (rev 6840)
+++ trunk/LedgerSMB/Template.pm	2014-02-11 08:28:10 UTC (rev 6841)
@@ -292,6 +292,7 @@
         $vars->{USER} ||= {dateformat => 'yyyy-mm-dd'};
         $vars->{CSSDIR} = $LedgerSMB::Sysconfig::cssdir;
         $vars->{DBNAME} = $LedgerSMB::App_State::DBName;
+        $vars->{LETTERHEAD} = sub { $self->_include('letterhead', $vars) };
         my @stdformats = ();
         for (qw(HTML PDF PS)){
            if (scalar(grep {/^$_$/} $self->available_formats)){
@@ -350,7 +351,7 @@
            
 	$format->can('process')->($self, $cleanvars);
 	#return $format->can('postprocess')->($self);
-	my $post = $format->can('postprocess')->($self);
+	my $post = $format->can('postprocess')->($self) unless $self->{_no_postprocess};
         #$logger->debug("\$format=$format \$self->{'noauto'}=$self->{'noauto'} \$self->{rendered}=$self->{rendered}");
 	if (!$self->{'noauto'}) {
 		# Clean up
@@ -581,4 +582,38 @@
 	return $names;
 }
 
+# $self->_include($templatename, $vars)
+#
+# This is a private method used to handle things like including files that are
+# db templates.  It is not performance-optimal for frequently used operations
+# like user-interface templates.  It returns processed but not post-processed 
+# content.
+
+sub _include {
+    my ($self, $templatename, $vars) = @_;
+    die 'No Template Name in _include' unless $templatename;
+    my $template = LedgerSMB::Template->new(
+                  user => $self->{myconfig}, 
+              template => $templatename,
+                locale => $self->{locale},
+        no_auto_output => 1,
+                format => $self->{format},
+                  path => $self->{include_path}
+    );
+    my $data;
+    $template->{outputfile} = \$data;
+    $template->{_no_postprocess} = 1;
+    $template->render($vars);
+    if (!defined $data and defined $self->{rendered}){
+       	$data = "";
+        open (DATA, '<', $self->{rendered});
+        binmode DATA, $self->{binmode};
+        while (my $line = <DATA>){
+            $data .= $line;
+        }
+        unlink($self->{rendered}) or die 'Unable to delete output file';
+    }
+    return $data;
+}
+
 1;

Modified: trunk/sql/modules/trial_balance.sql
===================================================================
--- trunk/sql/modules/trial_balance.sql	2014-02-11 08:25:48 UTC (rev 6840)
+++ trunk/sql/modules/trial_balance.sql	2014-02-11 08:28:10 UTC (rev 6841)
@@ -21,10 +21,13 @@
    ending_balance numeric
 );
 
+DROP FUNCTION IF EXISTS trial_balance__generate
+(in_date_from DATE, in_date_to DATE, in_heading INT, in_accounts INT[],
+ in_ignore_yearend TEXT, in_business_units int[]);
 
 CREATE OR REPLACE FUNCTION trial_balance__generate 
 (in_date_from DATE, in_date_to DATE, in_heading INT, in_accounts INT[],
- in_ignore_yearend TEXT, in_business_units int[]) 
+ in_ignore_yearend TEXT, in_business_units int[], in_balance_sign int) 
 returns setof tb_row AS
 $$
 DECLARE
@@ -34,7 +37,15 @@
         ignore_trans    int[];
         t_start_date    date; 
         t_end_date      date;
+        t_balance_sign  int;
 BEGIN
+    IF in_balance_sign IS NULL OR in_balance_sign = 0 THEN
+       t_balance_sign = null;
+    ELSIF in_balance_sign = -1 OR in_balance_sign = 1 THEN
+       t_balance_sign = in_balance_sign;
+    ELSE 
+       RAISE EXCEPTION 'Invalid Balance Type';
+    END IF;
 
     IF in_date_from IS NULL AND in_ignore_yearend = 'none' THEN
        SELECT max(end_date) INTO t_roll_forward 
@@ -111,7 +122,8 @@
        )
        SELECT a.id, a.accno, a.description, a.gifi_accno,
          case when in_date_from is null then 0 else
-              CASE WHEN a.category IN ('A', 'E') THEN -1 ELSE 1 END 
+              COALESCE(t_balance_sign, 
+                      CASE WHEN a.category IN ('A', 'E') THEN -1 ELSE 1 END )
               * (coalesce(cp.amount, 0) 
               + sum(CASE WHEN ac.transdate < coalesce(in_date_from, 
                                                       t_roll_forward)
@@ -128,7 +140,8 @@
                                                          ac.transdate)
                              AND ac.amount > 0 THEN ac.amount ELSE 0 END) + 
               case when in_date_from is null then coalesce(cp.credits, 0) else 0 end, 
-              CASE WHEN a.category IN ('A', 'E') THEN -1 ELSE 1 END 
+              COALESCE(t_balance_sign, 
+                       CASE WHEN a.category IN ('A', 'E') THEN -1 ELSE 1 END)
               * (coalesce(cp.amount, 0) + sum(coalesce(ac.amount, 0)))
          FROM account a
     LEFT JOIN ac ON ac.chart_id = a.id

Modified: trunk/templates/demo/invoice.tex
===================================================================
--- trunk/templates/demo/invoice.tex	2014-02-11 08:25:48 UTC (rev 6840)
+++ trunk/templates/demo/invoice.tex	2014-02-11 08:28:10 UTC (rev 6841)
@@ -33,7 +33,7 @@
   }
 }
 
-<?lsmb INCLUDE letterhead.tex ?>
+<?lsmb LETTERHEAD ?>
 
 \markboth{<?lsmb company ?>\hfill <?lsmb invnumber ?>}{<?lsmb company ?>\hfill <?lsmb invnumber ?>}
 

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


------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits