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

SF.net SVN: ledger-smb:[3872] addons/1.3/budgetting/trunk



Revision: 3872
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3872&view=rev
Author:   einhverfr
Date:     2011-10-16 03:45:33 +0000 (Sun, 16 Oct 2011)
Log Message:
-----------
Can now save a budget, some UI glitches remain

Modified Paths:
--------------
    addons/1.3/budgetting/trunk/LedgerSMB/DBObject/Budget.pm
    addons/1.3/budgetting/trunk/UI/budgetting/budget_entry.html
    addons/1.3/budgetting/trunk/scripts/budgets.pl
    addons/1.3/budgetting/trunk/sql/modules/Budgetting.sql

Modified: addons/1.3/budgetting/trunk/LedgerSMB/DBObject/Budget.pm
===================================================================
--- addons/1.3/budgetting/trunk/LedgerSMB/DBObject/Budget.pm	2011-10-16 00:36:44 UTC (rev 3871)
+++ addons/1.3/budgetting/trunk/LedgerSMB/DBObject/Budget.pm	2011-10-16 03:45:33 UTC (rev 3872)
@@ -142,7 +142,8 @@
 
 sub save {
     my ($self) = @_;
-    $self->exec_method({funcname => 'budget__save_info'});
+    my ($ref) = $self->exec_method({funcname => 'budget__save_info'});
+    $self->merge($ref); # sets defaults
     $self->{details} = [];
     for my $line (@{$self->{lines}}){
        my $l_info = [$line->{account_id}, 
@@ -217,7 +218,7 @@
 sub get {
    my ($self, $id) = @_;
    my ($info) = $self->call_procedure(
-          {procname => 'budget__get_info', args => [$id]}
+          procname => 'budget__get_info', args => [$id]
    );
    $self->merge($info);
    @{$self->{lines}} = $self->exec_method({funcname => 'budget__get_details'});

Modified: addons/1.3/budgetting/trunk/UI/budgetting/budget_entry.html
===================================================================
--- addons/1.3/budgetting/trunk/UI/budgetting/budget_entry.html	2011-10-16 00:36:44 UTC (rev 3871)
+++ addons/1.3/budgetting/trunk/UI/budgetting/budget_entry.html	2011-10-16 03:45:33 UTC (rev 3872)
@@ -61,9 +61,9 @@
 	    <?lsmb INCLUDE select element_data = {
 			text_attr = "description"
 			value_attr = "id"
-			default_values = [department]
+			default_values = [department_id]
 			options = departments
-			name = "department"
+			name = "department_id"
                         label = text('Department')
 	    } ?>
 
@@ -72,9 +72,9 @@
 	    <?lsmb INCLUDE select element_data = {
 			text_attr = "description"
 			value_attr = "id"
-			default_values = [project]
+			default_values = [project_id]
 			options = projects
-			name = "project"
+			name = "project_id"
                         label = text('Project')
 	    } ?>
 

Modified: addons/1.3/budgetting/trunk/scripts/budgets.pl
===================================================================
--- addons/1.3/budgetting/trunk/scripts/budgets.pl	2011-10-16 00:36:44 UTC (rev 3871)
+++ addons/1.3/budgetting/trunk/scripts/budgets.pl	2011-10-16 03:45:33 UTC (rev 3872)
@@ -172,14 +172,29 @@
 
 =cut
 
-sub save_budget {
+sub save {
     my ($request) = @_;
     my $budget = LedgerSMB::DBObject::Budget->new({base => $request});
     for my $rownum (1 .. $request->{rowcount}){
          my $line = {};
-         for (qw(debits credits account_id description)){
-             $line->{$_} = $request->{"${_}_$rownum"};
+         if ($request->{"debit_$rownum"} and $request->{"credit_$rownum"}){
+             $request->error($request->{_locale}->text(
+                 'Cannot specify both debits and credits for budget line [_1]',
+                 $rownum
+             )); 
+         } elsif(!$request->{"debit_$rownum"} and !$request->{"credit_$rownum"}){
+             next;
+         } else {
+             $line->{amount} = $request->{"credit_$rownum"} 
+                             - $request->{"debit_$rownum"};
          }
+         my ($accno) = split /--/, $request->{"account_id_$rownum"};
+         my ($ref) = $request->call_procedure(
+                       procname => 'account__get_from_accno',
+                           args => [$accno]
+          );
+         $line->{description} = $request->{"description_$rownum"};
+         $line->{account_id} = $ref->{id};
          push @{$budget->{lines}}, $line;
     }
     $budget->save();

Modified: addons/1.3/budgetting/trunk/sql/modules/Budgetting.sql
===================================================================
--- addons/1.3/budgetting/trunk/sql/modules/Budgetting.sql	2011-10-16 00:36:44 UTC (rev 3871)
+++ addons/1.3/budgetting/trunk/sql/modules/Budgetting.sql	2011-10-16 03:45:33 UTC (rev 3872)
@@ -118,11 +118,11 @@
          end_date = in_end_date,
          reference = in_reference,
          description = in_description
-   WHERE id = in_id and approved is not true;
+   WHERE id = in_id and approved_by is null;
   IF FOUND THEN
       t_id := in_id;
   ELSE
-       PERFORM * FROM budget_info WHERE id = in_id and approved is true;
+       PERFORM * FROM budget_info WHERE id = in_id and approved_by is not null;
        IF FOUND THEN
            RAISE EXCEPTION 'report approved';
        END IF;
@@ -150,8 +150,8 @@
              VALUES (t_id, in_department_id);
      END IF;
   END IF;
-  SELECT bi.*, in_department_id, in_project_id FROM budget_info
-   WHERE id = t_id;
+  retval := budget__get_info(t_id);
+  return retval;
 END;
 $$ language plpgsql;
 
@@ -169,8 +169,8 @@
    retval budget_info_ext;
 BEGIN
     FOR loop_count in   
-        array_lower(in_transactions, 1) ..
-        array_upper(in_transactions, 1)
+        array_lower(in_details, 1) ..
+        array_upper(in_details, 1)
     LOOP
         INSERT INTO budget_line 
                     (budget_id, 

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