Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a2bab345

Von Sven Schöling vor mehr als 8 Jahren hinzugefügt

  • ID a2bab345aedcfbb03bdf0e0aa1f28a5c57a5d02b
  • Vorgänger 061f4d6d
  • Nachfolger a0b8d78b

Reapply "Form: round_amount precision support"

Und mit neuer Autorschaft neu.

Unterschiede anzeigen:

SL/DB/MetaSetup/Default.pm
78 78
  payments_changeable                       => { type => 'integer', default => '0', not_null => 1 },
79 79
  pdonumber                                 => { type => 'text' },
80 80
  ponumber                                  => { type => 'text' },
81
  precision                                 => { type => 'numeric', default => '0.01', not_null => 1, precision => 15, scale => 5 },
81 82
  profit_determination                      => { type => 'text' },
82 83
  project_status_id                         => { type => 'integer' },
83 84
  project_type_id                           => { type => 'integer' },
SL/Form.pm
948 948
}
949 949

  
950 950
sub round_amount {
951
  my ($self, $amount, $places) = @_;
951
  my ($self, $amount, $places, $adjust) = @_;
952 952

  
953 953
  return 0 if !defined $amount;
954 954

  
955 955
  $places //= 0;
956 956

  
957
  if ($adjust) {
958
    my $precision = $::instance_conf->get_precision || 0.01;
959
    return $self->round_amount( $self->round_amount($amount / $precision, 0) * $precision, $places);
960
  }
961

  
957 962
  # We use Perl's knowledge of string representation for
958 963
  # rounding. First, convert the floating point number to a string
959 964
  # with a high number of places. Then split the string on the decimal
sql/Pg-upgrade2/defaults_add_precision.sql
1
-- @tag: defaults_add_precision
2
-- @description: adds new column 'precision' in table defaults, used to round amounts
3
-- @depends: release_3_0_0
4
ALTER TABLE defaults ADD COLUMN precision NUMERIC(15,5) NOT NULL DEFAULT(0.01);
5

  

Auch abrufbar als: Unified diff