Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4b1666b7

Von Felix Eichler vor mehr als 4 Jahren hinzugefügt

  • ID 4b1666b74b0fa70077c64144a57526a1d64b4e64
  • Vorgänger 59626ee2
  • Nachfolger 82098575

Auftragsschnellerfassung: Währung und Wechselkurs definierbar

impl. #9491

(cherry picked from commit 6cdc5a4a33df4530ce4e141151e83138320e27a2)
(cherry pick von odyn)

Unterschiede anzeigen:

SL/DB/Order.pm
10 10

  
11 11
use SL::DB::MetaSetup::Order;
12 12
use SL::DB::Manager::Order;
13
use SL::DB::Helper::Attr;
13 14
use SL::DB::Helper::AttrHTML;
14 15
use SL::DB::Helper::AttrSorted;
15 16
use SL::DB::Helper::FlattenToForm;
......
40 41
    column_map             => { id => 'trans_id' },
41 42
    query_args             => [ module => 'OE' ],
42 43
  },
44
  exchangerate_obj         => {
45
    type                   => 'one to one',
46
    class                  => 'SL::DB::Exchangerate',
47
    column_map             => { currency_id => 'currency_id', transdate => 'transdate' },
48
  },
43 49
);
44 50

  
51
SL::DB::Helper::Attr::make(__PACKAGE__, exchangerate => 'numeric');
52

  
45 53
__PACKAGE__->meta->initialize;
46 54

  
47 55
__PACKAGE__->attr_html('notes');
......
111 119
  return !!shift->customer_id;
112 120
}
113 121

  
122
sub exchangerate {
123
  my ($self, $val) = @_;
124

  
125
  return 1 if $self->currency_id == $::instance_conf->get_currency_id;
126

  
127
  my $rate = $self->is_sales ? 'buy' : 'sell';
128

  
129
  if (defined $val) {
130
    croak 'exchange rate has to be positive' if $val <= 0;
131
    if (!$self->exchangerate_obj) {
132
      $self->exchangerate_obj(SL::DB::Exchangerate->new(
133
        currency_id => $self->currency_id,
134
        transdate   => $self->transdate,
135
        $rate       => $val,
136
      ));
137
    } elsif (!defined $self->exchangerate_obj->$rate) {
138
      $self->exchangerate_obj->$rate($val);
139
    } else {
140
      croak 'exchange rate already exists, no update allowed';
141
    }
142
  }
143
  return $self->exchangerate_obj->$rate if $self->exchangerate_obj;
144
}
145

  
114 146
sub invoices {
115 147
  my $self   = shift;
116 148
  my %params = @_;

Auch abrufbar als: Unified diff