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

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



Revision: 4797
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4797&view=rev
Author:   einhverfr
Date:     2012-05-28 15:47:00 +0000 (Mon, 28 May 2012)
Log Message:
-----------
Entity Credit Account base functionality now works on new, modular codebase

Modified Paths:
--------------
    trunk/LedgerSMB/ScriptLib/Company.pm
    trunk/LedgerSMB/Scripts/contact.pm
    trunk/UI/Contact/contact.css
    trunk/UI/Contact/divs/credit.html

Modified: trunk/LedgerSMB/ScriptLib/Company.pm
===================================================================
--- trunk/LedgerSMB/ScriptLib/Company.pm	2012-05-28 11:29:38 UTC (rev 4796)
+++ trunk/LedgerSMB/ScriptLib/Company.pm	2012-05-28 15:47:00 UTC (rev 4797)
@@ -398,66 +398,11 @@
 
 =pod
 
-=over
 
-=item save_credit($request)
-
-This inserts or updates a credit account of the sort listed here.
-
-=back
-
-=cut
-
-sub save_credit {
-    
-    my ($request) = @_;
-    my $company;
-    my @taxes;
-
-    if (!$request->{ar_ap_account_id}){
-          $request->error(
-              $request->{_locale}->text('No AR or AP Account Selected')
-          );
-    }
-
-    $request->{tax_ids} = [];
-    for my $key(keys %$request){
-        if ($key =~ /^taxact_(\d+)$/){
-           my $tax = $1;
-           push @{$request->{tax_ids}}, $tax;
-        }  
-    }
-    if (_close_form($request)){
-        LedgerSMB::DBObject::Entity::Credit_Account->prepare_input($request);
-        $credit = LedgerSMB::DBObject::Entity::Credit_Account->new(%$request);
-        $credit->save();
-    }
-    get($request);
-}
-
 =pod
 
 =over
 
-=item save_credit_new($request)
-
-This inserts a new credit account.
-
-=back
-
-=cut
-
-
-sub save_credit_new {
-    my ($request) = @_;
-    $request->{credit_id} = undef;
-    save_credit($request);
-}
-
-=pod
-
-=over
-
 =item edit($request)
 
 Displays a company for editing.  Needs the following to be set:

Modified: trunk/LedgerSMB/Scripts/contact.pm
===================================================================
--- trunk/LedgerSMB/Scripts/contact.pm	2012-05-28 11:29:38 UTC (rev 4796)
+++ trunk/LedgerSMB/Scripts/contact.pm	2012-05-28 15:47:00 UTC (rev 4797)
@@ -23,6 +23,8 @@
 use LedgerSMB::DBObject::Entity::Bank;
 use LedgerSMB::DBObject::Entity::Note;
 use LedgerSMB::App_State;
+use strict;
+use warnings;
 
 my $locale = $LedgerSMB::App_State::Locale;
 
@@ -70,8 +72,7 @@
     my ($request) = @_;
     $request->{entity_class} ||= $request->{account_class};
     $request->{legal_name} ||= 'test';
-    my $company = LedgerSMB::DBObject::Entity::Company->new(%$request);
-    $company = $company->get($request->{entity_id});
+    my $company = LedgerSMB::DBObject::Entity::Company->get($request->{entity_id});
     _main_screen($request, $company);
 }
 
@@ -82,6 +83,7 @@
 
 sub _main_screen {
     my ($request, $company) = @_;
+
     # DIVS logic
     my @DIVS;
     if ($company->{entity_id}){
@@ -90,7 +92,7 @@
        @DIVS = qw(company);
     }
 
-    %DIV_LABEL = (
+    my %DIV_LABEL = (
              company => $locale->text('Company'),
               credit => $locale->text('Credit Accounts'),
              address => $locale->text('Addresses'),
@@ -112,6 +114,10 @@
                 or ($request->{meta_number} eq $ref->{meta_number});
     }
 
+    my $entity_class = $credit_act->{entity_class};
+    $entity_class ||= $company->{entity_class};
+    $entity_class ||= $request->{entity_class};
+    $entity_class ||= $request->{account_class};
     my @locations = LedgerSMB::DBObject::Entity::Location->get_active(
                        {entity_id => $request->{entity_id},
                         credit_id => $credit_act->{id}}
@@ -129,13 +135,68 @@
     my @notes =
          LedgerSMB::DBObject::Entity::Note->list($request->{entity_id},
                                                  $credit_act->{id});
-    $attach_level_options = [
+
+    # Globals for the template
+    my @all_taxes = $request->call_procedure(procname => 'account__get_taxes');
+
+    my @ar_ap_acc_list = $request->call_procedure(procname => 'chart_get_ar_ap',
+                                           args => [$entity_class]);
+
+    my @cash_acc_list = $request->call_procedure(procname => 'chart_list_cash',
+                                           args => [$entity_class]);
+
+    my @discount_acc_list =
+         $request->call_procedure(procname => 'chart_list_discount',
+                                     args => [$entity_class]);
+
+    for my $var (..hidden.., ..hidden.., ..hidden..){
+        for my $ref (@$var){
+            $ref->{text} = "$ref->{accno}--$ref->{description}";
+        }
+    }
+
+#
+    my @language_code_list = 
+             $request->call_procedure(procname=> 'person__list_languages');
+
+    for my $ref (@language_code_list){
+        $ref->{text} = "$ref->{code}--$ref->{description}";
+    }
+    
+    my @location_class_list = 
+            $request->call_procedure(procname => 'location_list_class');
+
+    my @business_types =
+               $request->call_procedure(procname => 'business_type__list');
+
+    my ($curr_list) =
+          $request->call_procedure(procname => 'setting__get_currencies');
+
+    my @all_currencies;
+    for my $curr (@{$curr_list->{'setting__get_currencies'}}){
+        push @all_currencies, { text => $curr};
+    }
+
+    my ($default_country) = $request->call_procedure(
+              procname => 'setting_get',
+                  args => ['default_country']);
+    $default_country = $default_country->{value};
+
+    my ($default_language) = $request->call_procedure(
+              procname => 'setting_get',
+                  args => ['default_language']);
+    $default_language = $default_language->{value};
+
+    my $attach_level_options = [
         {label => $locale->text('Entity'), value => 1} ];
     ..hidden..,
         {label => $locale->text('Credit Account'),
          value => 3} if $credit_act->{id};
     ;
 
+    $request->close_form();
+    $request->open_form();
+
     # Template info and rendering 
     my $template = LedgerSMB::Template->new(
         user => $request->{_user},
@@ -145,14 +206,16 @@
         format => 'HTML'
     );
 
-    #use Data::Dumper;
-    #$Data::Dumper::Sortkeys = 1;
-    @country_list = $request->call_procedure(
+    use Data::Dumper;
+    $Data::Dumper::Sortkeys = 1;
+    #die '<pre>' . Dumper($request) . '</pre>';
+    my @country_list = $request->call_procedure(
                      procname => 'location_list_country'
       );
-    @entity_classes = $request->call_procedure(
+    my @entity_classes = $request->call_procedure(
                       procname => 'entity__list_classes'
     );
+    my $entity_id = $company->{entity_id};
 
     $template->render({
                      DIVS => ..hidden..,
@@ -167,7 +230,16 @@
                  contacts => ..hidden..,
              bank_account => ..hidden..,
                     notes => ..hidden..,
-     attach_level_options => $attach_level_options
+          # globals
+                  form_id => $request->{form_id},
+           ar_ap_acc_list => ..hidden..,
+            cash_acc_list => ..hidden..,
+        discount_acc_list => ..hidden..,
+       language_code_list => ..hidden..,
+           all_currencies => ..hidden..,
+     attach_level_options => $attach_level_options, 
+                entity_id => $entity_id,
+             entity_class => $entity_class,
     });
 }
 
@@ -201,25 +273,28 @@
 sub dispatch_legacy {
     our ($request) = shift @_;
     use LedgerSMB::Form;
+    no strict;
+    use Data::Dumper;
     my $aa;
     my $inv;
     my $otype;
     my $qtype;
     my $cv;
+    $request->{account_class} ||= $request->{entity_class};
     if ($request->{account_class} == 1){
        $aa = 'ap';
        $inv = 'ir';
-       $otypr = 'purchase_order';
+       $otype = 'purchase_order';
        $qtype = 'request_quotation';
        $cv = 'vendor';
     } elsif ($request->{account_class} == 2){
        $aa = 'ar';
        $inv = 'is';
-       $otypr = 'sales_order';
+       $otype = 'sales_order';
        $qtype = 'sales_quotation';
        $cv = 'customer';
     } else {
-       $request->error($request->{_locale}->text('Unsupport account type'));
+       $request->error($request->{_locale}->text('Unsupported account type'));
     }
     our $dispatch = 
     {
@@ -336,4 +411,51 @@
     _main_screen($request, $company);
 }
 
+=item save_credit($request)
+
+This inserts or updates a credit account of the sort listed here.
+
+=cut
+
+sub save_credit {
+    
+    my ($request) = @_;
+    my $company;
+    my @taxes;
+
+    if (!$request->{ar_ap_account_id}){
+          $request->error(
+              $request->{_locale}->text('No AR or AP Account Selected')
+          );
+    }
+
+    $request->{tax_ids} = [];
+    for my $key(keys %$request){
+        if ($key =~ /^taxact_(\d+)$/){
+           my $tax = $1;
+           push @{$request->{tax_ids}}, $tax;
+        }  
+    }
+    if ($request->close_form){
+        LedgerSMB::DBObject::Entity::Credit_Account->prepare_input($request);
+        my $credit = LedgerSMB::DBObject::Entity::Credit_Account->new(%$request);
+        $credit = $credit->save();
+        $request->{meta_number} = $credit->{meta_number};
+    }
+    get($request);
+}
+
+=item save_credit_new($request)
+
+This inserts a new credit account.
+
+=cut
+
+
+sub save_credit_new {
+    my ($request) = @_;
+    $request->{credit_id} = undef;
+    save_credit($request);
+}
+
 1;

Modified: trunk/UI/Contact/contact.css
===================================================================
--- trunk/UI/Contact/contact.css	2012-05-28 11:29:38 UTC (rev 4796)
+++ trunk/UI/Contact/contact.css	2012-05-28 15:47:00 UTC (rev 4797)
@@ -86,7 +86,7 @@
 	width: 10em;
 }
 
-#location_div label {
+#address_div label {
 	width: 6em;
 }
 

Modified: trunk/UI/Contact/divs/credit.html
===================================================================
--- trunk/UI/Contact/divs/credit.html	2012-05-28 11:29:38 UTC (rev 4796)
+++ trunk/UI/Contact/divs/credit.html	2012-05-28 15:47:00 UTC (rev 4797)
@@ -3,10 +3,10 @@
 <?lsmb 
 
 FOREACH cl IN credit_list;
-   IF cl.entity_class == 1;
-        cl.account_class_label = text('Vendor');
-   ELSIF  cl.entity_class == 2;
-        cl.account_class_label = text('Customer');
+   IF entity_class == 1;
+        account_class_label = text('Vendor');
+   ELSIF  entity_class == 2;
+        account_class_label = text('Customer');
    END;
    cl.meta_number_href_suffix = 'account_class=' _ cl.entity_class _ 
       '&entity_id=' _ cl.entity_id _ '&meta_number=' _ cl.meta_number;
@@ -44,6 +44,9 @@
 	<?lsmb ec = credit_act.entity_class;
               IF !ec;
                  ec=account_class;
+                 IF !ec;
+                    ec=entity_class;
+                 END;
               END;
               PROCESS input element_data = {
 		type = "hidden"
@@ -54,7 +57,7 @@
 	<tr class="eca_row">
 	<td>
  	<?lsmb PROCESS input element_data = {
-		label = text("$entity_classname Number"),
+		label = text("$entity_classname Number"), #fixme for i18n
 		type= "text",
 		name = "meta_number",
 		value = credit_act.meta_number,
@@ -257,7 +260,7 @@
          </div>
 		<?lsmb IF credit_act.id;
 		INCLUDE button element_data = {
-			text = text('Save Changes'),
+			text = text('Save Changes'), #'
 			class="submit" 
 			type="submit" 
 			name="action" 
@@ -265,16 +268,17 @@
 			accesskey="C" 
 			title="Save Credit Account[Alt-C]"
 		};
-		END ?>
-		<?lsmb INCLUDE button element_data = {
-			text = text('Save New'),
+		END;
+		INCLUDE button element_data = {
+			text = text('Save New'), #'
 			class="submit" 
 			type="submit" 
 			name="action" 
 			value="save_credit_new"  
-			title="Save Credit Account as New" #'
-		} ?>
-		<?lsmb INCLUDE button element_data = {
+			title="Save Credit Account as New" 
+		};
+                IF credit_act.id;
+		    INCLUDE button element_data = {
                         class="submit" 
                         type="submit" 
                         name="action" 
@@ -282,8 +286,8 @@
                         accesskey="A" 
                         title="Transaction [Alt-A]"
 			text = (entity_class == 1) ? text('AP Transaction') : text('AR Transaction')
-		} ?>
-		<?lsmb INCLUDE button element_data = {
+		    }; 
+		    INCLUDE button element_data = {
                         class="submit" 
                         type="submit" 
                         name="action" 
@@ -291,8 +295,8 @@
                         accesskey="I" 
                         title="Invoice [Alt-I]"
 			text = (entity_class == 1) ? text('Vendor Invoice')  : text('Customer Invoice') 
-		} ?>
-		<?lsmb INCLUDE button element_data = {
+		    };
+		    INCLUDE button element_data = {
                         class="submit" 
                         type="submit" 
                         name="action" 
@@ -300,8 +304,8 @@
                         accesskey="O" 
                         title="Order [Alt-O]"
 			text = (entity_class == 1) ? text('Purchase Order') : text('Sales Order')
-		} ?>
-		<?lsmb INCLUDE button element_data = {
+		    };
+		    INCLUDE button element_data = {
                         class="submit" 
                         type="submit" 
                         name="action" 
@@ -309,8 +313,8 @@
                         accesskey="Q" 
                         title="Quotation [Alt-Q]"
 			text = (entity_class == 1) ? text('RFQ') : text('Quotation')
-		} ?>
-		<?lsmb INCLUDE button element_data = {
+		    };
+		    INCLUDE button element_data = {
                         class="submit" 
                         type="submit" 
                         name="action" 
@@ -318,7 +322,8 @@
                         accesskey="P" 
                         title="Pricelist [Alt-P]"
 			text = text('Pricelist') 
-		} ?>
+		    };
+                END ?>
 	
     </form>
 </div>

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