[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[6266] addons/1.3/wxPOS/WXPOS/UI



Revision: 6266
          http://sourceforge.net/p/ledger-smb/code/6266
Author:   einhverfr
Date:     2013-11-08 12:50:56 +0000 (Fri, 08 Nov 2013)
Log Message:
-----------
Fixing rounding issues

Modified Paths:
--------------
    addons/1.3/wxPOS/WXPOS/UI/AR/Pay.pm
    addons/1.3/wxPOS/WXPOS/UI/AR.pm

Modified: addons/1.3/wxPOS/WXPOS/UI/AR/Pay.pm
===================================================================
--- addons/1.3/wxPOS/WXPOS/UI/AR/Pay.pm	2013-11-08 11:36:50 UTC (rev 6265)
+++ addons/1.3/wxPOS/WXPOS/UI/AR/Pay.pm	2013-11-08 12:50:56 UTC (rev 6266)
@@ -108,7 +108,7 @@
    $paid ||= 0;
    $paid += $amount;
    $self->{total_paid}->SetLabel($paid);
-   $owing = $total - $paid;
+   $owing = $self->{parent_window}->format_money($total - $paid);
    if ($owing < 0) {
        $self->{oweing_label}->SetLabel('Change');
        $self->{oweing}->SetLabel($owing * -1);

Modified: addons/1.3/wxPOS/WXPOS/UI/AR.pm
===================================================================
--- addons/1.3/wxPOS/WXPOS/UI/AR.pm	2013-11-08 11:36:50 UTC (rev 6265)
+++ addons/1.3/wxPOS/WXPOS/UI/AR.pm	2013-11-08 12:50:56 UTC (rev 6266)
@@ -8,6 +8,7 @@
 use WXPOS::Counterparty;
 use lib 'scripts';
 use WXPOS::UI::AR::Pay;
+use Math::BigFloat; # for rounding
 
 # TODO:
 # Need payment/posting screen
@@ -198,9 +199,7 @@
  my $format;
  if ($disc){
     $sell = $sell * (100 - $disc)/100;
-    $format = "%." .$WXPOS::Sysconfig::money_places . "f";
     
-    $sell = sprintf($format, $sell);
  }
  my $qty = $self->{part_qty}->GetValue();
  my $total_tax = 0;
@@ -214,16 +213,16 @@
  my $total = $st * $qty;
  my $pp = $self->{list}->InsertStringItem($self->{sesion}->{tk}->{items}, $numb);
  $self->{list}->SetItem($pp, 1, $desc, -1);
- $self->{list}->SetItem($pp, 2, $sell, -1);
- $self->{list}->SetItem($pp, 3, $total_tax, -1);
+ $self->{list}->SetItem($pp, 2, $self->format_money($sell), -1);
+ $self->{list}->SetItem($pp, 3, $self->format_money($total_tax), -1);
  $self->{list}->SetItem($pp, 4, $total_tax_ratio, -1);
- $self->{list}->SetItem($pp, 5, $st, -1);
+ $self->{list}->SetItem($pp, 5, $self->format_money($st), -1);
  $self->{list}->SetItem($pp, 6, $qty, -1);
- $self->{list}->SetItem($pp, 7, $total, -1);
+ $self->{list}->SetItem($pp, 7, $self->format_money($total), -1);
 
- $self->{sesion}->{tk}->{tnet} += $sell;
- $self->{sesion}->{tk}->{ttax} += $total_tax;
- $self->{sesion}->{tk}->{total} += $total;
+ $self->{sesion}->{tk}->{tnet} += $self->format_money($sell);
+ $self->{sesion}->{tk}->{ttax} += $self->format_money($total_tax);
+ $self->{sesion}->{tk}->{total} += $self->format_money($total);
  $self->{net_total}->SetLabel($self->{sesion}->{tk}->{tnet});
  $self->{tax_total}->SetLabel($self->{sesion}->{tk}->{ttax});
  $self->{total}->SetLabel($self->{sesion}->{tk}->{total});
@@ -275,4 +274,13 @@
  return undef unless $total ne '' and defined $total; # Can't pay without anything here.
  WXPOS::UI::AR::Pay->new($self);
 }
+
+sub format_money {
+    my ($self, $string) = @_;
+    $string = $string * 1;
+    $num = Math::BigFloat->new($string);
+    $num->precision($WXPOS::Sysconfig::money_places  * -1);
+    return sprintf("%.0" . ($WXPOS::Sysconfig::money_places) . "f", $num->bstr());
+}
+
 1;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits