From e6d9f3706a42003ac003820c0532db20d5d50ff8 Mon Sep 17 00:00:00 2001 From: Maxime Bourget Date: Thu, 2 May 2013 22:24:10 +0100 Subject: [PATCH] Changed supplier payment to accept amount in foreign currency instead of exchange rate. --- js/payalloc.js | 18 +++++++++++++----- purchasing/supplier_payment.php | 6 +++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/js/payalloc.js b/js/payalloc.js index a1cbc09e..1bd818c1 100644 --- a/js/payalloc.js +++ b/js/payalloc.js @@ -56,12 +56,20 @@ function allocate_none(doc) { var allocations = { '.amount': function(e) { - e.onblur = function() { - blur_alloc(this); + if(e.name == 'allocated_amount') + { + e.onblur = function() { + var dec = this.getAttribute("dec"); + price_format(this.name, get_amount(this.name), dec); }; - e.onfocus = function() { - focus_alloc(this); - }; + } else { + e.onblur = function() { + blur_alloc(this); + }; + e.onfocus = function() { + focus_alloc(this); + }; + } } } diff --git a/purchasing/supplier_payment.php b/purchasing/supplier_payment.php index 9bd3559f..dd2a09d4 100644 --- a/purchasing/supplier_payment.php +++ b/purchasing/supplier_payment.php @@ -226,7 +226,11 @@ function handle_add_payment() if ($comp_currency != $bank_currency && $bank_currency != $supp_currency) $rate = 0; else + { $rate = input_num('_ex_rate'); + $supplier_amount = input_num('allocated_amount'); + if($supplier_amount) $rate = input_num('amount')/$supplier_amount; + } $payment_id = add_supp_payment($_POST['supplier_id'], $_POST['DatePaid'], $_POST['bank_account'], input_num('amount'), input_num('discount'), @@ -297,7 +301,7 @@ start_form(); $bank_currency = get_bank_account_currency($_POST['bank_account']); if ($bank_currency != $supplier_currency) { - exchange_rate_display($bank_currency, $supplier_currency, $_POST['DatePaid'], true); + amount_row("Supplier Amount:", 'allocated_amount', null, '', $supplier_currency, 2); } amount_row(_("Bank Charge:"), 'charge'); -- 2.30.2