Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 73a78da6

Von Rolf Fluehmann vor fast 9 Jahren hinzugefügt

  • ID 73a78da630ce363f70062447dd82a8a0ece8cd89
  • Vorgänger e358c9af
  • Nachfolger e3f82371

Form: round_amount precision support

Unterschiede anzeigen:

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

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

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

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

  
954 959
  # We use Perl's knowledge of string representation for
955 960
  # rounding. First, convert the floating point number to a string
956 961
  # 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