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

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



Revision: 4347
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4347&view=rev
Author:   einhverfr
Date:     2012-02-23 02:20:21 +0000 (Thu, 23 Feb 2012)
Log Message:
-----------
Undef date handling added for 1.4 code
Return value added for business_unit__save sql function

Modified Paths:
--------------
    trunk/LedgerSMB/PGDate.pm
    trunk/sql/modules/Business_Unit.sql

Modified: trunk/LedgerSMB/PGDate.pm
===================================================================
--- trunk/LedgerSMB/PGDate.pm	2012-02-23 02:05:30 UTC (rev 4346)
+++ trunk/LedgerSMB/PGDate.pm	2012-02-23 02:20:21 UTC (rev 4347)
@@ -124,6 +124,7 @@
 
 sub _parse_string {
     my ($self, $string, $format, $has_time) = @_;
+    return undef if !defined $string;
     if (!defined $LedgerSMB::App_State::Locale->{datetime}){
         $LedgerSMB::App_State::Locale->{datetime} = 'en_US';
     }
@@ -165,6 +166,7 @@
 =cut
 sub to_output {
     my ($self) = @_;
+    return undef if !defined $self->date;
     my $fmt = $formats->{$LedgerSMB::App_State::User->dateformat}->[0];
     my $formatter = new DateTime::Format::Strptime(
              pattern => $fmt,
@@ -204,6 +206,7 @@
 
 sub to_db {
     my ($self) = @_;
+    return undef if !defined $self->date;
     my $fmt = $formats->{'YYYY-MM-DD'}->[0];
     $fmt .= ' %T' if ($self->date->hour);
     my $formatter = new DateTime::Format::Strptime(

Modified: trunk/sql/modules/Business_Unit.sql
===================================================================
--- trunk/sql/modules/Business_Unit.sql	2012-02-23 02:05:30 UTC (rev 4346)
+++ trunk/sql/modules/Business_Unit.sql	2012-02-23 02:20:21 UTC (rev 4347)
@@ -47,7 +47,7 @@
 With the exception of in_business_unit_class_id, the null matches all records.
 $$;
 
-DROP TYPE IF EXISTS business_unit_short;
+DROP TYPE IF EXISTS business_unit_short CASCADE;
 
 CREATE TYPE business_unit_short AS (
 id int,
@@ -121,6 +121,7 @@
 RETURNS business_unit AS
 $$
 DECLARE retval business_unit;
+        t_id int;
 
 BEGIN
 
@@ -134,7 +135,10 @@
        credit_id = in_credit_id
  WHERE id = in_id;
 
-IF NOT FOUND THEN
+
+IF FOUND THEN
+   t_id = in_id;
+ELSE
    INSERT INTO business_unit 
           (class_id, control_code, description, start_date, end_date, parent_id,
            credit_id)
@@ -142,6 +146,7 @@
            in_end_date, in_parent_id, in_credit_id);
 END IF;
 
+SELECT * INTO retval FROM business_unit WHERE id = in_id;
 
 RETURN retval;
 END;

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