summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-07-10 19:32:46 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-07-10 19:32:46 +0000
commit9263554936de0058ff5cef43dfbf2d5829a03ca6 (patch)
treefb5c0fbb26151dfc81f248aa104194a187103804 /scripts
parent0befab1e5e83dd62b039df033a53b86fc96d2a0c (diff)
Committing David Mora's rounding fix. May require new lines in ledgersmb.conf for those testing.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2207 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'scripts')
-rw-r--r--scripts/payment.pl25
1 files changed, 12 insertions, 13 deletions
diff --git a/scripts/payment.pl b/scripts/payment.pl
index dd3a309d..52142119 100644
--- a/scripts/payment.pl
+++ b/scripts/payment.pl
@@ -654,9 +654,9 @@ for my $ref (0 .. $#array_options) {
# LETS SET THE EXCHANGERATE VALUES
my $due_fx; my $topay_fx_value;
if ("$exchangerate") {
- $topay_fx_value = $due_fx = "$array_options[$ref]->{due}"/"$exchangerate" - "$array_options[$ref]->{discount}"/"$exchangerate";
+ $topay_fx_value = $due_fx = $request->round_amount("$array_options[$ref]->{due}"/"$exchangerate");
if ($request->{"optional_discount_$array_options[$ref]->{invoice_id}"}) {
- $topay_fx_value = $due_fx = $due_fx - "$array_options[$ref]->{discount}"/"$exchangerate";
+ $topay_fx_value = $due_fx = $request->round_amount($due_fx - "$array_options[$ref]->{discount}"/"$exchangerate");
}
} else {
$topay_fx_value = $due_fx = "N/A";
@@ -664,16 +664,15 @@ for my $ref (0 .. $#array_options) {
# We need to check for unhandled overpayment, see the post function for details
# First we will see if the discount should apply?
my $temporary_discount = 0;
- if (($request->{"optional_discount_$array_options[$ref]->{invoice_id}"})&&($due_fx <= $request->{"topay_fx_$array_options[$ref]->{invoice_id}"} + $array_options[$ref]->{discount}/"$exchangerate")) {
- $temporary_discount = "$array_options[$ref]->{discount}"/"$exchangerate";
-
- }
+ if (($request->{"optional_discount_$array_options[$ref]->{invoice_id}"})&&($due_fx <= $request->{"topay_fx_$array_options[$ref]->{invoice_id}"} + $request->round_amount($array_options[$ref]->{discount}/"$exchangerate"))) {
+ $temporary_discount = $request->round_amount("$array_options[$ref]->{discount}"/"$exchangerate");
+ }
# We need to compute the unhandled_overpayment, notice that all the values inside the if already have
# the exchangerate applied
if ( $due_fx < $request->{"topay_fx_$array_options[$ref]->{invoice_id}"}) {
# We need to store all the overpayments so we can use it on the screen
- $unhandled_overpayment = $unhandled_overpayment + $request->{"topay_fx_$array_options[$ref]->{invoice_id}"} - $due_fx ;
- $request->{"topay_fx_$array_options[$ref]->{invoice_id}"} = $due_fx;
+ $unhandled_overpayment = $request->round_amount($unhandled_overpayment + $request->{"topay_fx_$array_options[$ref]->{invoice_id}"} - $due_fx );
+ $request->{"topay_fx_$array_options[$ref]->{invoice_id}"} = "$due_fx";
}
push @invoice_data, { invoice => { number => $array_options[$ref]->{invnumber},
id => $array_options[$ref]->{invoice_id},
@@ -686,7 +685,7 @@ for my $ref (0 .. $#array_options) {
discount => $request->{"optional_discount_$array_options[$ref]->{invoice_id}"} ? "$array_options[$ref]->{discount}" : 0 ,
optional_discount => $request->{"optional_discount_$array_options[$ref]->{invoice_id}"},
exchange_rate => "$exchangerate",
- due_fx => $due_fx, # This was set at the begining of the for statement
+ due_fx => "$due_fx", # This was set at the begining of the for statement
topay => "$array_options[$ref]->{due}" - "$array_options[$ref]->{discount}",
source_text => $request->{"source_text_$array_options[$ref]->{invoice_id}"},
optional => $request->{"optional_pay_$array_options[$ref]->{invoice_id}"},
@@ -695,9 +694,9 @@ for my $ref (0 .. $#array_options) {
topay_fx => { name => "topay_fx_$array_options[$ref]->{invoice_id}",
value => $request->{"topay_fx_$array_options[$ref]->{invoice_id}"} ?
$request->{"topay_fx_$array_options[$ref]->{invoice_id}"} eq 'N/A' ?
- $topay_fx_value :
+ "$topay_fx_value" :
$request->{"topay_fx_$array_options[$ref]->{invoice_id}"} :
- $topay_fx_value
+ "$topay_fx_value"
# Ugly hack, but works ;) ...
}#END HASH
};# END PUSH
@@ -799,7 +798,7 @@ my $select = {
vendorcustomer => { name => 'vendor-customer',
value => $request->{'vendor-customer'}
},
- unhandled_overpayment => { name => 'unhandledoverpayment', value => $unhandled_overpayment } ,
+ unhandled_overpayment => { name => 'unhandledoverpayment', value => "$unhandled_overpayment" } ,
vc => { name => $Payment->{company_name}, # We will assume that the first Billing Information as default
address => [ {text => $vc_options[0]->{'line_one'}},
{text => $vc_options[0]->{'line_two'}},
@@ -912,7 +911,7 @@ for my $ref (0 .. $#array_options) {
#
if ( "$array_options[$ref]->{due}"/"$request->{exrate}" < $request->{"topay_fx_$array_options[$ref]->{invoice_id}"} + $temporary_discount ) {
# We need to store all the overpayments so we can use it on a new payment2 screen
- $unhandled_overpayment = $unhandled_overpayment + $request->{"topay_fx_$array_options[$ref]->{invoice_id}"} + $temporary_discount - $array_options[$ref]->{amount} ;
+ $unhandled_overpayment = $request->round_amount($unhandled_overpayment + $request->{"topay_fx_$array_options[$ref]->{invoice_id}"} + $temporary_discount - $array_options[$ref]->{amount}) ;
}
if ($request->{"optional_discount_$array_options[$ref]->{invoice_id}"}) {