diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-11-22 06:19:05 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-11-22 06:19:05 +0000 |
commit | 08e1b04d20e4f328638fbde9f7a2ae54a3dca966 (patch) | |
tree | 1191bd1b7d8bad8873a95b864e108e8358ae2345 /LedgerSMB | |
parent | a7badcbfb8db7f379590d66031137efb9f65717c (diff) |
First (unsuccessful) attempt to automatically handle number formatting in the template engine..
Customer screen enhancements as well.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1890 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB')
-rw-r--r-- | LedgerSMB/DBObject/Customer.pm | 23 | ||||
-rwxr-xr-x | LedgerSMB/Template.pm | 33 |
2 files changed, 47 insertions, 9 deletions
diff --git a/LedgerSMB/DBObject/Customer.pm b/LedgerSMB/DBObject/Customer.pm index 7bae0a9c..3805762f 100644 --- a/LedgerSMB/DBObject/Customer.pm +++ b/LedgerSMB/DBObject/Customer.pm @@ -3,6 +3,7 @@ package LedgerSMB::DBObject::Customer; use base qw(LedgerSMB::DBObject); use LedgerSMB::DBObject; use LedgerSMB::Entity; +use strict; my $CUSTOMER_ENTITY_CLASS = 2; @@ -12,7 +13,7 @@ sub save { # This saves both the entity and the credit account. -- CT $self->{entity_class} = $CUSTOMER_ENTITY_CLASS; - ($ref) = $self->exec_method(funcname => 'entity_credit_save'); + my ($ref) = $self->exec_method(funcname => 'entity_credit_save'); $self->{entity_id} = $ref->{entity_credit_save}; $self->{dbh}->commit; } @@ -20,18 +21,18 @@ sub save { sub get_metadata { my $self = shift @_; - @{$self->{location_class}} = + @{$self->{location_class_list}} = $self->exec_method(funcname => 'location_list_class'); - @{$self->{country}} = + @{$self->{country_list}} = $self->exec_method(funcname => 'location_list_country'); - @{$self->{contact_class}} = + @{$self->{contact_class_list}} = $self->exec_method(funcname => 'entity_list_contact_class'); } sub save_location { - $self = shift @_; + my $self = shift @_; $self->{entity_class} = $CUSTOMER_ENTITY_CLASS; $self->{country_id} = $self->{country}; $self->exec_method(funcname => 'customer_location_save'); @@ -40,14 +41,20 @@ sub save_location { } sub save_contact { + my ($self) = @_; + $self->exec_method(funcname => 'company__save_contact'); + $self->{dbh}->commit; } -sub save_bank_acct { +sub save_bank_account { + my $self = shift @_; + $self->exec_method(funcname => 'entity__save_bank_account'); + $self->{dbh}->commit; } sub get { my $self = shift @_; - ($ref) = $self->exec_method(funcname => 'customer__retrieve'); + my ($ref) = $self->exec_method(funcname => 'customer__retrieve'); $self->merge($ref); $self->{name} = $self->{legal_name}; @@ -58,7 +65,7 @@ sub get { @{$self->{contacts}} = $self->exec_method( funcname => 'company__list_contacts'); - @{$self->{contacts}} = $self->exec_method( + @{$self->{bank_account}} = $self->exec_method( funcname => 'company__list_bank_account'); @{$self->{notes}} = $self->exec_method( diff --git a/LedgerSMB/Template.pm b/LedgerSMB/Template.pm index 28c1f40e..aff967a0 100755 --- a/LedgerSMB/Template.pm +++ b/LedgerSMB/Template.pm @@ -198,6 +198,35 @@ sub _valid_language { return 1; } +sub _preprocess { + my ($self, $vars) = @_; + return unless $self->{myconfig}; + use LedgerSMB; + if (UNIVERSAL::isa($vars, 'Math::BigFloat')){ + $vars = + LedgerSMB::format_amount('LedgerSMB', + {amount => $vars. + user => $self->{myconfig} }); + } + my $type = ref($vars); + + if ($type eq 'SCALAR' || !$type){ + return; + } + if ($type eq 'ARRAY'){ + for (@$vars){ + if (ref($_)){ + $self->_preprocess($_); + } + } + } + else { + for my $key (keys %$vars){ + $self->_preprocess($vars->{$key}); + } + } +} + sub render { my $self = shift; my $vars = shift; @@ -205,7 +234,9 @@ sub render { throw Error::Simple "Invalid format"; } my $format = "LedgerSMB::Template::$self->{format}"; - +# if ($self->{myconfig}){ +# $self->_preprocess($vars); +# } eval "require $format"; if ($@) { throw Error::Simple $@; |