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

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



Revision: 6160
          http://sourceforge.net/p/ledger-smb/code/6160
Author:   einhverfr
Date:     2013-10-23 11:24:45 +0000 (Wed, 23 Oct 2013)
Log Message:
-----------
Invoice series code working ifor AR/AP transactions.

Modified Paths:
--------------
    trunk/LedgerSMB/AA.pm
    trunk/LedgerSMB/Form.pm
    trunk/bin/aa.pl

Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm	2013-10-23 11:19:14 UTC (rev 6159)
+++ trunk/LedgerSMB/AA.pm	2013-10-23 11:24:45 UTC (rev 6160)
@@ -103,7 +103,7 @@
         $invnumber = "vinumber";
     }
     $form->{invnumber} = $form->update_defaults( $myconfig, $invnumber )
-      unless $form->{invnumber};
+      if $form->should_update_defaults('invnumber');
 
     if ( $form->{currency} eq $form->{defaultcurrency} ) {
         $form->{exchangerate} = 1;

Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm	2013-10-23 11:19:14 UTC (rev 6159)
+++ trunk/LedgerSMB/Form.pm	2013-10-23 11:24:45 UTC (rev 6160)
@@ -67,6 +67,7 @@
 use LedgerSMB::PGNumber;
 use Log::Log4perl;
 use LedgerSMB::App_State;
+use LedgerSMB::Setting::Sequence;
 
 use charnames qw(:full);
 use open ':utf8';
@@ -3321,6 +3322,10 @@
 sub update_defaults {
 
     my ( $self, $myconfig, $fld,$dbh_parm,$nocommit) = @_;
+    if ($self->{setting_sequence}){
+        return LedgerSMB::Setting::Sequence->increment(
+              $self->{setting_sequence}, $self);
+    }
 
     if ( !$self->{dbh} && $self ) {
         $self->db_init($myconfig);
@@ -3464,6 +3469,26 @@
     return $var;
 }
 
+=item should_update_defaults(fldname)
+
+This should be used instead of direct tests, and checks for a sequence selected.
+
+=cut
+
+sub should_update_defaults {
+    my ($self, $fldname) = @_;
+    if (!$self->{$fldname}){
+       return 1;
+    }
+    if (!$self->{setting_sequence}){
+        return 0;
+    }
+
+    my $sequence = LedgerSMB::Setting::Sequence->get($self->{setting_sequence});
+    return 1 unless $sequence->accept_input;
+    return 0;
+}
+
 =item $form->db_prepare_vars(var1, var2, ..., varI<n>)
 
 Undefines $form->{varI<m>}, 1 <= I<m> <= I<n>, iff $form-<{varI<m> is both
@@ -3753,6 +3778,32 @@
 
 }
 
+=item sequence_dropdown(setting_key)
+
+This function returns the HTML code for a dropdown box for a given setting
+key.  It is not generally to be used with code on new templates.
+
+=cut
+
+sub sequence_dropdown{
+    my ($self, $setting_key) = @_;
+    my @sequences = LedgerSMB::Setting::Sequence->list($setting_key);
+    my $retval = qq|<select name='setting_sequence' class='sequence'>\n|;
+    $retval .= qq|<option></option>|;
+    for my $seq (@sequences){
+        my $selected = '';
+        my $label = $seq->label;
+        $selected = "SELECTED='SELECTED'"
+            if $self->{setting_sequence} eq $label;
+        $retval .= qq|<option value='$label' $selected>$label</option>\n|;
+    }
+    $retval .= "</select>";
+    if (@sequences){
+        return $retval;
+    } else {
+        return undef
+    }
+}
 #end decrysiption
 
 1;

Modified: trunk/bin/aa.pl
===================================================================
--- trunk/bin/aa.pl	2013-10-23 11:19:14 UTC (rev 6159)
+++ trunk/bin/aa.pl	2013-10-23 11:24:45 UTC (rev 6160)
@@ -161,6 +161,12 @@
 }
 
 sub display_form {
+    my $invnumber = "sinumber";
+    if ( $form->{vc} eq 'vendor' ) {
+        $invnumber = "vinumber";
+    }
+    $form->{sequence_select} = $form->sequence_dropdown($invnumber)
+        unless $form->{id};
     $form->{format} = $form->get_setting('format') unless $form->{format};
     $form->close_form;
     $form->open_form;
@@ -662,7 +668,8 @@
 	      $employee
 	      <tr>
 		<th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
-		<td><input name=invnumber size=20 value="$form->{invnumber}"></td>
+		<td><input name=invnumber size=20 value="$form->{invnumber}">
+                      $form->{sequence_select}</td>
 	      </tr>
 	      <tr>
 		<th align=right nowrap>| . $locale->text('Order Number') . qq|</th>

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


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits