From: Moritz Bunkus Date: Tue, 21 May 2013 11:19:50 +0000 (+0200) Subject: Anpassung Rose-Funktionen auf Umstellung currencies X-Git-Tag: release-3.1.0beta1~401^2~21^2~1 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=e770cd180600810fecd3554e104546236a9c9597;p=kivitendo-erp.git Anpassung Rose-Funktionen auf Umstellung currencies --- diff --git a/SL/DB/Default.pm b/SL/DB/Default.pm index b71b0f474..4ea7be63f 100644 --- a/SL/DB/Default.pm +++ b/SL/DB/Default.pm @@ -9,8 +9,8 @@ __PACKAGE__->meta->make_manager_class; sub get_default_currency { my $self = shift->get; - my @currencies = grep { $_ } split(/:/, $self->curr || ''); - return $currencies[0] || ''; + return $self->currency->name || '' if $self->currency_id; + return ''; } sub get { diff --git a/SL/DB/Helper/FlattenToForm.pm b/SL/DB/Helper/FlattenToForm.pm index d5805b0c0..c2d8a5fe9 100644 --- a/SL/DB/Helper/FlattenToForm.pm +++ b/SL/DB/Helper/FlattenToForm.pm @@ -14,11 +14,11 @@ sub flatten_to_form { my $vc = $self->can('customer_id') && $self->customer_id ? 'customer' : 'vendor'; - _copy($self, $form, '', '', 0, qw(id type taxzone_id ordnumber quonumber invnumber donumber cusordnumber taxincluded shippingpoint shipvia notes intnotes curr cp_id + _copy($self, $form, '', '', 0, qw(id type taxzone_id ordnumber quonumber invnumber donumber cusordnumber taxincluded shippingpoint shipvia notes intnotes cp_id employee_id salesman_id closed department_id language_id payment_id delivery_customer_id delivery_vendor_id shipto_id proforma globalproject_id delivered transaction_description container_type accepted_by_customer invoice terms storno storno_id dunning_config_id orddate quodate reqdate gldate duedate deliverydate datepaid transdate)); - $form->{currency} = $form->{curr}; # curr is called currency in almost all forms + $form->{currency} = $form->{curr} = $self->currency_id ? $self->currency->name || '' : ''; if (_has($self, 'transdate')) { my $transdate_idx = ref($self) eq 'SL::DB::Order' ? ($self->quotation ? 'quodate' : 'orddate') diff --git a/SL/DB/Helper/PriceTaxCalculator.pm b/SL/DB/Helper/PriceTaxCalculator.pm index 0801299fb..73613f89d 100644 --- a/SL/DB/Helper/PriceTaxCalculator.pm +++ b/SL/DB/Helper/PriceTaxCalculator.pm @@ -53,8 +53,9 @@ sub calculate_prices_and_taxes { sub _get_exchangerate { my ($self, $data, %params) = @_; - if (($self->curr || '') ne SL::DB::Default->get_default_currency) { - $data->{exchangerate} = $::form->check_exchangerate(\%::myconfig, $self->curr, $self->transdate, $data->{is_sales} ? 'buy' : 'sell'); + my $currency = $self->currency_id ? $self->currency->name || '' : ''; + if ($currency ne SL::DB::Default->get_default_currency) { + $data->{exchangerate} = $::form->check_exchangerate(\%::myconfig, $currency, $self->transdate, $data->{is_sales} ? 'buy' : 'sell'); $data->{exchangerate} ||= $params{exchangerate}; } $data->{exchangerate} ||= 1; diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index 09c7f86e7..d93de711a 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -98,9 +98,9 @@ sub new_from { my $terms = $source->can('payment_id') && $source->payment_id ? $source->payment_terms->terms_netto : 0; - my %args = ( map({ ( $_ => $source->$_ ) } qw(customer_id taxincluded shippingpoint shipvia notes intnotes curr salesman_id cusordnumber ordnumber quonumber + my %args = ( map({ ( $_ => $source->$_ ) } qw(customer_id taxincluded shippingpoint shipvia notes intnotes salesman_id cusordnumber ordnumber quonumber department_id cp_id language_id payment_id delivery_customer_id delivery_vendor_id taxzone_id shipto_id - globalproject_id transaction_description)), + globalproject_id transaction_description currency_id)), transdate => DateTime->today_local, gldate => DateTime->today_local, duedate => DateTime->today_local->add(days => $terms * 1), diff --git a/SL/DB/VC.pm b/SL/DB/VC.pm index 44b2dbb09..c41f28788 100644 --- a/SL/DB/VC.pm +++ b/SL/DB/VC.pm @@ -26,7 +26,7 @@ SQL $query = <